Skip to content

Commit f70a1bd

Browse files
committed
ImageListManager
All images are now refreshed when the theme changes.
1 parent 7f11acf commit f70a1bd

File tree

35 files changed

+824
-246
lines changed

35 files changed

+824
-246
lines changed

External/Plugins/ASCompletion/PluginUI.cs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public FixedTreeView OutlineTree
7272
}
7373
public ImageList TreeIcons
7474
{
75-
get { return treeIcons; }
75+
get { return treeIcons.ImageList; }
7676
}
7777

7878
public ToolStripMenuItem LookupMenuItem;
7979
private System.ComponentModel.IContainer components;
80-
public System.Windows.Forms.ImageList treeIcons;
80+
public ImageListManager treeIcons;
8181
private FixedTreeView outlineTree;
8282
private System.Timers.Timer tempoClick;
8383

@@ -113,7 +113,36 @@ private void InitializeControls()
113113
InitializeComponent();
114114
treeIcons.ColorDepth = ColorDepth.Depth32Bit;
115115
treeIcons.ImageSize = ScaleHelper.Scale(new Size(16, 16));
116-
treeIcons.Images.AddRange( new Image[]
116+
treeIcons.Initialize(TreeIcons_OnInitialize);
117+
118+
toolStrip.Renderer = new DockPanelStripRenderer();
119+
toolStrip.ImageScalingSize = ScaleHelper.Scale(new Size(16, 16));
120+
toolStrip.Padding = new Padding(2, 1, 2, 2);
121+
sortDropDown.Font = PluginBase.Settings.DefaultFont;
122+
sortDropDown.Image = PluginBase.MainForm.FindImage("444");
123+
clearButton.Image = PluginBase.MainForm.FindImage("153");
124+
clearButton.Alignment = ToolStripItemAlignment.Right;
125+
clearButton.CheckOnClick = false;
126+
127+
outlineTree = new FixedTreeView();
128+
outlineTree.BorderStyle = BorderStyle.None;
129+
outlineTree.ShowRootLines = false;
130+
outlineTree.Location = new System.Drawing.Point(0, toolStrip.Bottom);
131+
outlineTree.Size = new System.Drawing.Size(198, 300);
132+
outlineTree.Dock = DockStyle.Fill;
133+
outlineTree.ImageList = treeIcons.ImageList;
134+
outlineTree.HotTracking = true;
135+
outlineTree.TabIndex = 1;
136+
outlineTree.NodeClicked += new FixedTreeView.NodeClickedHandler(ClassTreeSelect);
137+
outlineTree.AfterSelect += new TreeViewEventHandler(outlineTree_AfterSelect);
138+
outlineTree.ShowNodeToolTips = true;
139+
Controls.Add(outlineTree);
140+
outlineTree.BringToFront();
141+
}
142+
143+
private void TreeIcons_OnInitialize(object sender, EventArgs e)
144+
{
145+
treeIcons.Images.AddRange(new Image[]
117146
{
118147
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("FilePlain.png"))),
119148
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("FolderClosed.png"))),
@@ -151,30 +180,6 @@ private void InitializeControls()
151180
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Template.png"))),
152181
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Declaration.png")))
153182
});
154-
155-
toolStrip.Renderer = new DockPanelStripRenderer();
156-
toolStrip.ImageScalingSize = ScaleHelper.Scale(new Size(16, 16));
157-
toolStrip.Padding = new Padding(2, 1, 2, 2);
158-
sortDropDown.Font = PluginBase.Settings.DefaultFont;
159-
sortDropDown.Image = PluginBase.MainForm.FindImage("444");
160-
clearButton.Image = PluginBase.MainForm.FindImage("153");
161-
clearButton.Alignment = ToolStripItemAlignment.Right;
162-
clearButton.CheckOnClick = false;
163-
164-
outlineTree = new FixedTreeView();
165-
outlineTree.BorderStyle = BorderStyle.None;
166-
outlineTree.ShowRootLines = false;
167-
outlineTree.Location = new System.Drawing.Point(0, toolStrip.Bottom);
168-
outlineTree.Size = new System.Drawing.Size(198, 300);
169-
outlineTree.Dock = DockStyle.Fill;
170-
outlineTree.ImageList = treeIcons;
171-
outlineTree.HotTracking = true;
172-
outlineTree.TabIndex = 1;
173-
outlineTree.NodeClicked += new FixedTreeView.NodeClickedHandler(ClassTreeSelect);
174-
outlineTree.AfterSelect += new TreeViewEventHandler(outlineTree_AfterSelect);
175-
outlineTree.ShowNodeToolTips = true;
176-
Controls.Add(outlineTree);
177-
outlineTree.BringToFront();
178183
}
179184

180185
public static System.IO.Stream GetStream(String name)
@@ -270,7 +275,7 @@ private void InitializeComponent()
270275
{
271276
this.components = new System.ComponentModel.Container();
272277
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PluginUI));
273-
this.treeIcons = new System.Windows.Forms.ImageList(this.components);
278+
this.treeIcons = new ImageListManager(this.components);
274279
this.toolStrip = new PluginCore.Controls.ToolStripEx();
275280
this.sortDropDown = new System.Windows.Forms.ToolStripDropDownButton();
276281
this.noneItem = new System.Windows.Forms.ToolStripMenuItem();

External/Plugins/AirProperties/PluginMain.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ public void AddEventHandlers()
173173
/// </summary>
174174
private void CreateMenuItems()
175175
{
176-
this.pluginMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ProjectMenuItem"), GetImage("blockdevice_small.png"), new EventHandler(this.OpenWizard), null);
176+
Image image = PluginBase.MainForm.GetAutoAdjustedImage(GetImage("blockdevice_small.png"));
177+
this.pluginMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ProjectMenuItem"), image, new EventHandler(this.OpenWizard), null);
177178
PluginBase.MainForm.RegisterShortcutItem("ProjectMenu.AirApplicationProperties", this.pluginMenuItem);
178179
this.pluginMenuItem.Enabled = false;
179180
}
@@ -192,7 +193,7 @@ private void AddMenuItems(ToolStripMenuItem projectMenu)
192193
private void AddToolBarItems(ToolStrip toolStrip)
193194
{
194195
this.pmMenuButton = new ToolStripButton();
195-
this.pmMenuButton.Image = GetImage("blockdevice_small.png");
196+
this.pmMenuButton.Image = this.pluginMenuItem.Image;
196197
this.pmMenuButton.Text = TextHelper.GetString("Label.ProjectMenuItem").Replace("&", "").Replace("...", "");
197198
this.pmMenuButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
198199
this.pmMenuButton.Click += new EventHandler(this.OpenWizard);

External/Plugins/BookmarkPanel/PluginUI.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class PluginUI : DockPanelControl
3030
private System.Windows.Forms.ToolStripStatusLabel statusLabel;
3131
private System.Windows.Forms.ToolStripMenuItem removeBookmarksItem;
3232
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
33-
private System.Windows.Forms.ImageList imageList;
33+
private ImageListManager imageList;
3434
private System.Windows.Forms.Timer updateTimer;
3535
private TimeoutManager timeoutManager;
3636
private PluginMain pluginMain;
@@ -228,20 +228,22 @@ private void InitializeTexts()
228228
/// </summary>
229229
private void InitializeGraphics()
230230
{
231-
this.imageList = new ImageList();
231+
this.imageList = new ImageListManager();
232232
this.imageList.ImageSize = ScaleHelper.Scale(new Size(16, 16));
233233
this.imageList.ColorDepth = ColorDepth.Depth32Bit;
234-
this.imageList.Images.Add(PluginBase.MainForm.FindImage("559|26|0|1"));
235-
this.imageList.Images.Add(PluginBase.MainForm.FindImage("229"));
236-
this.imageList.Images.Add(PluginBase.MainForm.FindImage("197"));
237-
this.imageList.Images.SetKeyName(0, "Bookmark");
238-
this.imageList.Images.SetKeyName(1, "Info");
239-
this.imageList.Images.SetKeyName(2, "Error");
240-
this.listView.SmallImageList = this.imageList;
234+
this.imageList.Initialize(ImageList_OnInitialize);
235+
this.listView.SmallImageList = this.imageList.ImageList;
241236
this.removeBookmarksItem.Image = PluginBase.MainForm.FindImage("402|4|4|4");
242237
this.searchButton.Image = PluginBase.MainForm.FindImage("484|26|-4|4");
243238
}
244239

240+
private void ImageList_OnInitialize(object sender, EventArgs e)
241+
{
242+
this.imageList.Images.Add("Bookmark", PluginBase.MainForm.FindImageAndSetAdjust("559|26|0|1"));
243+
this.imageList.Images.Add("Info", PluginBase.MainForm.FindImageAndSetAdjust("229"));
244+
this.imageList.Images.Add("Error", PluginBase.MainForm.FindImageAndSetAdjust("197"));
245+
}
246+
245247
/// <summary>
246248
/// Updates the UI with the settings
247249
/// </summary>

External/Plugins/FileExplorer/PluginUI.cs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class PluginUI : DockPanelControl
3939
private System.Windows.Forms.ColumnHeader modifiedHeader;
4040
private Ookii.Dialogs.VistaFolderBrowserDialog folderBrowserDialog;
4141
private System.Windows.Forms.ListViewItem highlightedItem;
42-
private System.Windows.Forms.ImageList imageList;
42+
private ImageListManager imageList;
4343
private System.Boolean updateInProgress;
4444
private System.String previousItemLabel;
4545
private System.String autoSelectItem;
@@ -293,12 +293,19 @@ private void InitializeContextMenu()
293293
/// </summary>
294294
private void InitializeGraphics()
295295
{
296-
this.imageList = new ImageList();
296+
this.imageList = new ImageListManager();
297297
this.imageList.ImageSize = ScaleHelper.Scale(new Size(16, 16));
298298
this.imageList.ColorDepth = ColorDepth.Depth32Bit;
299+
this.imageList.OnInitialize += ImageList_Initialize;
300+
this.AddNonWin32Images();
299301
this.syncronizeButton.Image = PluginBase.MainForm.FindImage("203|9|-3|-3");
300302
this.browseButton.Image = PluginBase.MainForm.FindImage("203");
301-
this.fileView.SmallImageList = this.imageList;
303+
this.fileView.SmallImageList = this.imageList.ImageList;
304+
}
305+
306+
private void ImageList_Initialize(object sender, EventArgs e)
307+
{
308+
RefreshFileView(null, null);
302309
}
303310

304311
/// <summary>
@@ -424,7 +431,7 @@ private void UpdateUI(string path, DirectoryInfo directory, FileSystemInfo[] inf
424431
ListViewItem item;
425432
if (directory.Parent != null)
426433
{
427-
item = new ListViewItem("[..]", ExtractIconIfNecessary("/Folder/"));
434+
item = new ListViewItem("[..]", ExtractIconIfNecessary("/Folder/", false));
428435
item.Tag = directory.Parent.FullName;
429436
item.SubItems.Add("-");
430437
item.SubItems.Add("-");
@@ -436,7 +443,7 @@ private void UpdateUI(string path, DirectoryInfo directory, FileSystemInfo[] inf
436443
DirectoryInfo subDir = info as DirectoryInfo;
437444
if (subDir != null && (subDir.Attributes & FileAttributes.Hidden) == 0)
438445
{
439-
item = new ListViewItem(subDir.Name, ExtractIconIfNecessary(subDir.FullName));
446+
item = new ListViewItem(subDir.Name, ExtractIconIfNecessary(subDir.FullName, false));
440447
item.Tag = subDir.FullName;
441448
item.SubItems.Add("-");
442449
item.SubItems.Add("-");
@@ -450,7 +457,7 @@ private void UpdateUI(string path, DirectoryInfo directory, FileSystemInfo[] inf
450457
if (file != null && (file.Attributes & FileAttributes.Hidden) == 0)
451458
{
452459
String kbs = TextHelper.GetString("Info.Kilobytes");
453-
item = new ListViewItem(file.Name, ExtractIconIfNecessary(file.FullName));
460+
item = new ListViewItem(file.Name, ExtractIconIfNecessary(file.FullName, true));
454461
item.Tag = file.FullName;
455462
if (file.Length / 1024 < 1) item.SubItems.Add("1 " + kbs);
456463
else item.SubItems.Add((file.Length / 1024) + " " + kbs);
@@ -1128,25 +1135,22 @@ private void WatcherRenamed(Object sender, RenamedEventArgs e)
11281135
/// Ask the shell to feed us the appropriate icon for the given file, but
11291136
/// first try looking in our cache to see if we've already loaded it.
11301137
/// </summary>
1131-
private int ExtractIconIfNecessary(String path)
1138+
private int ExtractIconIfNecessary(String path, bool isFile)
11321139
{
11331140
Icon icon; Image image;
11341141
Size size = ScaleHelper.Scale(new Size(16, 16));
11351142
if (Win32.ShouldUseWin32())
11361143
{
1137-
if (File.Exists(path)) icon = IconExtractor.GetFileIcon(path, false, true);
1144+
if (isFile) icon = IconExtractor.GetFileIcon(path, false, true);
11381145
else icon = IconExtractor.GetFolderIcon(path, false, true);
11391146
image = ImageKonverter.ImageResize(icon.ToBitmap(), size.Width, size.Height);
11401147
image = PluginBase.MainForm.ImageSetAdjust(image);
11411148
icon.Dispose();
1149+
this.imageList.Images.Add(image);
1150+
return this.imageList.Images.Count - 1;
11421151
}
1143-
else
1144-
{
1145-
if (File.Exists(path)) image = PluginBase.MainForm.FindImage("526");
1146-
else image = PluginBase.MainForm.FindImage("203");
1147-
}
1148-
this.imageList.Images.Add(image);
1149-
return this.imageList.Images.Count - 1;
1152+
1153+
return isFile ? 0 : 1;
11501154
}
11511155

11521156
/// <summary>
@@ -1155,11 +1159,14 @@ private int ExtractIconIfNecessary(String path)
11551159
private void ClearImageList()
11561160
{
11571161
this.imageList.Images.Clear();
1158-
this.imageList.Dispose();
1159-
this.imageList = new ImageList();
1160-
this.imageList.ImageSize = ScaleHelper.Scale(new Size(16, 16));
1161-
this.imageList.ColorDepth = ColorDepth.Depth32Bit;
1162-
this.fileView.SmallImageList = this.imageList;
1162+
AddNonWin32Images();
1163+
}
1164+
1165+
private void AddNonWin32Images()
1166+
{
1167+
if (Win32.ShouldUseWin32()) return;
1168+
this.imageList.Images.Add(PluginBase.MainForm.FindImageAndSetAdjust("526"));
1169+
this.imageList.Images.Add(PluginBase.MainForm.FindImageAndSetAdjust("203"));
11631170
}
11641171

11651172
#endregion

External/Plugins/FlashDebugger/Controls/BreakPointUI.cs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ namespace FlashDebugger
1717
{
1818
class BreakPointUI : DockPanelControl
1919
{
20-
private static ImageList imageList;
21-
2220
private DataGridView dgv;
2321
private PluginMain pluginMain;
2422
private BreakPointManager breakPointManager;
@@ -65,17 +63,6 @@ void breakPointManager_ChangeBreakPointEvent(object sender, BreakPointArgs e)
6563

6664
private void init()
6765
{
68-
if (imageList == null)
69-
{
70-
imageList = new ImageList();
71-
imageList.ColorDepth = ColorDepth.Depth32Bit;
72-
imageList.ImageSize = ScaleHelper.Scale(new Size(16, 16));
73-
imageList.Images.Add("DeleteBreakpoint", PluginBase.MainForm.FindImage("548|27|5|5"));
74-
imageList.Images.Add("DeleteBreakpoints", PluginBase.MainForm.FindImage("549|27|5|5"));
75-
imageList.Images.Add("ToggleBreakpoints", PluginBase.MainForm.FindImage("136|23|5|5"));
76-
imageList.Images.Add("ExportBreakpoints", PluginBase.MainForm.FindImage("549|22|4|4"));
77-
imageList.Images.Add("ImportBreakpoints", PluginBase.MainForm.FindImage("549|8|4|4"));
78-
}
7966
this.AutoKeyHandling = true;
8067
this.dgv = new DataGridViewEx();
8168
this.dgv.Dock = DockStyle.Fill;
@@ -132,11 +119,11 @@ private void init()
132119
this.dgv.CellDoubleClick += new DataGridViewCellEventHandler(dgv_CellDoubleClick);
133120
this.Controls.Add(this.dgv);
134121
InitializeComponent();
135-
tsbRemoveSelected.Image = imageList.Images["DeleteBreakpoint"];
136-
tsbRemoveFiltered.Image = imageList.Images["DeleteBreakpoints"];
137-
tsbAlternateFiltered.Image = imageList.Images["ToggleBreakpoints"];
138-
tsbExportFiltered.Image = imageList.Images["ExportBreakpoints"];
139-
tsbImport.Image = imageList.Images["ImportBreakpoints"];
122+
tsbRemoveSelected.Image = PluginBase.MainForm.FindImage("548|27|5|5");
123+
tsbRemoveFiltered.Image = PluginBase.MainForm.FindImage("549|27|5|5");
124+
tsbAlternateFiltered.Image = PluginBase.MainForm.FindImage("136|23|5|5");
125+
tsbExportFiltered.Image = PluginBase.MainForm.FindImage("549|22|4|4");
126+
tsbImport.Image = PluginBase.MainForm.FindImage("549|8|4|4");
140127
this.tscbFilterColumns.FlatStyle = PluginBase.Settings.ComboBoxFlatStyle;
141128
this.tsActions.Renderer = new DockPanelStripRenderer(false);
142129
}

0 commit comments

Comments
 (0)