Skip to content

Commit 61243e6

Browse files
committed
Merge pull request #1013 from wise0704/ImageManager
All Images Update Properly
2 parents b766737 + af33c44 commit 61243e6

File tree

34 files changed

+1136
-387
lines changed

34 files changed

+1136
-387
lines changed

External/Plugins/ASCompletion/ASCompletion.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@
8484
<Compile Include="Completion\ASDocumentation.cs" />
8585
<Compile Include="Completion\ContextFeatures.cs" />
8686
<Compile Include="Context\IASContext.cs" />
87-
<Compile Include="CustomControls\StateSavingTreeView.cs">
88-
<SubType>Component</SubType>
89-
</Compile>
87+
<Compile Include="CustomControls\StateSavingTreeView.cs" />
9088
<Compile Include="CustomControls\ModelsExplorer.cs">
9189
<SubType>UserControl</SubType>
9290
</Compile>

External/Plugins/ASCompletion/PluginUI.cs

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
*/
77

88
using System;
9-
using System.Windows.Forms;
10-
using System.Text;
119
using System.Collections.Generic;
12-
using PluginCore;
13-
using PluginCore.Managers;
14-
using ASCompletion.Model;
15-
using ASCompletion.Context;
16-
using ASCompletion.Settings;
17-
using PluginCore.Localization;
1810
using System.Drawing;
1911
using System.Reflection;
12+
using System.Text;
13+
using System.Windows.Forms;
14+
using ASCompletion.Context;
15+
using ASCompletion.Model;
16+
using ASCompletion.Settings;
17+
using PluginCore;
2018
using PluginCore.Helpers;
19+
using PluginCore.Localization;
20+
using PluginCore.Managers;
2121

2222
namespace ASCompletion
2323
{
@@ -77,7 +77,7 @@ public ImageList TreeIcons
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,44 +113,7 @@ 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[]
117-
{
118-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("FilePlain.png"))),
119-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("FolderClosed.png"))),
120-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("FolderOpen.png"))),
121-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("CheckAS.png"))),
122-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("QuickBuild.png"))),
123-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Package.png"))),
124-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Interface.png"))),
125-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Intrinsic.png"))),
126-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Class.png"))),
127-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Variable.png"))),
128-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("VariableProtected.png"))),
129-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("VariablePrivate.png"))),
130-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("VariableStatic.png"))),
131-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("VariableStaticProtected.png"))),
132-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("VariableStaticPrivate.png"))),
133-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Const.png"))),
134-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("ConstProtected.png"))),
135-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("ConstPrivate.png"))),
136-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Const.png"))),
137-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("ConstProtected.png"))),
138-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("ConstPrivate.png"))),
139-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Method.png"))),
140-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("MethodProtected.png"))),
141-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("MethodPrivate.png"))),
142-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("MethodStatic.png"))),
143-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("MethodStaticProtected.png"))),
144-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("MethodStaticPrivate.png"))),
145-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Property.png"))),
146-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("PropertyProtected.png"))),
147-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("PropertyPrivate.png"))),
148-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("PropertyStatic.png"))),
149-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("PropertyStaticProtected.png"))),
150-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("PropertyStaticPrivate.png"))),
151-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Template.png"))),
152-
PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream("Declaration.png")))
153-
});
116+
treeIcons.Initialize(TreeIcons_Populate);
154117

155118
toolStrip.Renderer = new DockPanelStripRenderer();
156119
toolStrip.ImageScalingSize = ScaleHelper.Scale(new Size(16, 16));
@@ -177,6 +140,53 @@ private void InitializeControls()
177140
outlineTree.BringToFront();
178141
}
179142

143+
private void TreeIcons_Populate(object sender, EventArgs e)
144+
{
145+
treeIcons.Images.AddRange(new Image[]
146+
{
147+
GetImage("FilePlain.png"),
148+
GetImage("FolderClosed.png"),
149+
GetImage("FolderOpen.png"),
150+
GetImage("CheckAS.png"),
151+
GetImage("QuickBuild.png"),
152+
GetImage("Package.png"),
153+
GetImage("Interface.png"),
154+
GetImage("Intrinsic.png"),
155+
GetImage("Class.png"),
156+
GetImage("Variable.png"),
157+
GetImage("VariableProtected.png"),
158+
GetImage("VariablePrivate.png"),
159+
GetImage("VariableStatic.png"),
160+
GetImage("VariableStaticProtected.png"),
161+
GetImage("VariableStaticPrivate.png"),
162+
GetImage("Const.png"),
163+
GetImage("ConstProtected.png"),
164+
GetImage("ConstPrivate.png"),
165+
GetImage("Const.png"),
166+
GetImage("ConstProtected.png"),
167+
GetImage("ConstPrivate.png"),
168+
GetImage("Method.png"),
169+
GetImage("MethodProtected.png"),
170+
GetImage("MethodPrivate.png"),
171+
GetImage("MethodStatic.png"),
172+
GetImage("MethodStaticProtected.png"),
173+
GetImage("MethodStaticPrivate.png"),
174+
GetImage("Property.png"),
175+
GetImage("PropertyProtected.png"),
176+
GetImage("PropertyPrivate.png"),
177+
GetImage("PropertyStatic.png"),
178+
GetImage("PropertyStaticProtected.png"),
179+
GetImage("PropertyStaticPrivate.png"),
180+
GetImage("Template.png"),
181+
GetImage("Declaration.png")
182+
});
183+
}
184+
185+
public static Image GetImage(String name)
186+
{
187+
return PluginBase.MainForm.ImageSetAdjust(Image.FromStream(GetStream(name)));
188+
}
189+
180190
public static System.IO.Stream GetStream(String name)
181191
{
182192
String prefix = "ASCompletion.Icons.";
@@ -270,7 +280,7 @@ private void InitializeComponent()
270280
{
271281
this.components = new System.ComponentModel.Container();
272282
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PluginUI));
273-
this.treeIcons = new System.Windows.Forms.ImageList(this.components);
283+
this.treeIcons = new ImageListManager(this.components);
274284
this.toolStrip = new PluginCore.Controls.ToolStripEx();
275285
this.sortDropDown = new System.Windows.Forms.ToolStripDropDownButton();
276286
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.GetStringWithoutMnemonicsOrEllipsis("Label.ProjectMenuItem");
197198
this.pmMenuButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
198199
this.pmMenuButton.Click += new EventHandler(this.OpenWizard);

External/Plugins/BookmarkPanel/PluginUI.cs

Lines changed: 10 additions & 8 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");
234+
this.imageList.Initialize(ImageList_Populate);
240235
this.listView.SmallImageList = this.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_Populate(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 & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
using System;
2+
using System.Collections.Specialized;
3+
using System.Drawing;
24
using System.IO;
35
using System.Text;
4-
using System.Drawing;
5-
using System.Security;
6-
using System.Diagnostics;
7-
using System.Collections;
86
using System.Windows.Forms;
9-
using System.ComponentModel;
10-
using System.Collections.Specialized;
11-
using PluginCore.Localization;
12-
using PluginCore.Utilities;
13-
using PluginCore.Managers;
7+
using PluginCore;
148
using PluginCore.Controls;
159
using PluginCore.Helpers;
16-
using PluginCore;
10+
using PluginCore.Localization;
11+
using PluginCore.Managers;
12+
using PluginCore.Utilities;
1713

1814
namespace FileExplorer
1915
{
@@ -39,7 +35,7 @@ public class PluginUI : DockPanelControl
3935
private System.Windows.Forms.ColumnHeader modifiedHeader;
4036
private Ookii.Dialogs.VistaFolderBrowserDialog folderBrowserDialog;
4137
private System.Windows.Forms.ListViewItem highlightedItem;
42-
private System.Windows.Forms.ImageList imageList;
38+
private ImageListManager imageList;
4339
private System.Boolean updateInProgress;
4440
private System.String previousItemLabel;
4541
private System.String autoSelectItem;
@@ -293,9 +289,11 @@ private void InitializeContextMenu()
293289
/// </summary>
294290
private void InitializeGraphics()
295291
{
296-
this.imageList = new ImageList();
292+
this.imageList = new ImageListManager();
297293
this.imageList.ImageSize = ScaleHelper.Scale(new Size(16, 16));
298294
this.imageList.ColorDepth = ColorDepth.Depth32Bit;
295+
this.imageList.Populate += RefreshFileView;
296+
this.AddNonWin32Images();
299297
this.syncronizeButton.Image = PluginBase.MainForm.FindImage("203|9|-3|-3");
300298
this.browseButton.Image = PluginBase.MainForm.FindImage("203");
301299
this.fileView.SmallImageList = this.imageList;
@@ -424,7 +422,7 @@ private void UpdateUI(string path, DirectoryInfo directory, FileSystemInfo[] inf
424422
ListViewItem item;
425423
if (directory.Parent != null)
426424
{
427-
item = new ListViewItem("[..]", ExtractIconIfNecessary("/Folder/"));
425+
item = new ListViewItem("[..]", ExtractIconIfNecessary("/Folder/", false));
428426
item.Tag = directory.Parent.FullName;
429427
item.SubItems.Add("-");
430428
item.SubItems.Add("-");
@@ -436,7 +434,7 @@ private void UpdateUI(string path, DirectoryInfo directory, FileSystemInfo[] inf
436434
DirectoryInfo subDir = info as DirectoryInfo;
437435
if (subDir != null && (subDir.Attributes & FileAttributes.Hidden) == 0)
438436
{
439-
item = new ListViewItem(subDir.Name, ExtractIconIfNecessary(subDir.FullName));
437+
item = new ListViewItem(subDir.Name, ExtractIconIfNecessary(subDir.FullName, false));
440438
item.Tag = subDir.FullName;
441439
item.SubItems.Add("-");
442440
item.SubItems.Add("-");
@@ -450,7 +448,7 @@ private void UpdateUI(string path, DirectoryInfo directory, FileSystemInfo[] inf
450448
if (file != null && (file.Attributes & FileAttributes.Hidden) == 0)
451449
{
452450
String kbs = TextHelper.GetString("Info.Kilobytes");
453-
item = new ListViewItem(file.Name, ExtractIconIfNecessary(file.FullName));
451+
item = new ListViewItem(file.Name, ExtractIconIfNecessary(file.FullName, true));
454452
item.Tag = file.FullName;
455453
if (file.Length / 1024 < 1) item.SubItems.Add("1 " + kbs);
456454
else item.SubItems.Add((file.Length / 1024) + " " + kbs);
@@ -1128,25 +1126,22 @@ private void WatcherRenamed(Object sender, RenamedEventArgs e)
11281126
/// Ask the shell to feed us the appropriate icon for the given file, but
11291127
/// first try looking in our cache to see if we've already loaded it.
11301128
/// </summary>
1131-
private int ExtractIconIfNecessary(String path)
1129+
private int ExtractIconIfNecessary(String path, bool isFile)
11321130
{
11331131
Icon icon; Image image;
11341132
Size size = ScaleHelper.Scale(new Size(16, 16));
11351133
if (Win32.ShouldUseWin32())
11361134
{
1137-
if (File.Exists(path)) icon = IconExtractor.GetFileIcon(path, false, true);
1135+
if (isFile) icon = IconExtractor.GetFileIcon(path, false, true);
11381136
else icon = IconExtractor.GetFolderIcon(path, false, true);
11391137
image = ImageKonverter.ImageResize(icon.ToBitmap(), size.Width, size.Height);
11401138
image = PluginBase.MainForm.ImageSetAdjust(image);
11411139
icon.Dispose();
1140+
this.imageList.Images.Add(image);
1141+
return this.imageList.Images.Count - 1;
11421142
}
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;
1143+
1144+
return isFile ? 0 : 1;
11501145
}
11511146

11521147
/// <summary>
@@ -1155,11 +1150,14 @@ private int ExtractIconIfNecessary(String path)
11551150
private void ClearImageList()
11561151
{
11571152
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;
1153+
AddNonWin32Images();
1154+
}
1155+
1156+
private void AddNonWin32Images()
1157+
{
1158+
if (Win32.ShouldUseWin32()) return;
1159+
this.imageList.Images.Add(PluginBase.MainForm.FindImageAndSetAdjust("526"));
1160+
this.imageList.Images.Add(PluginBase.MainForm.FindImageAndSetAdjust("203"));
11631161
}
11641162

11651163
#endregion

0 commit comments

Comments
 (0)