mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
#287, make icon more harmonic. Load ico/png files in program folder with highest priority to override default icon
This commit is contained in:
parent
785b8fe0c4
commit
4642999ec1
3 changed files with 34 additions and 35 deletions
|
@ -229,6 +229,7 @@ namespace PersistentWindows.SystrayShell
|
||||||
string appDataFolder = redirect_appdata ? "." :
|
string appDataFolder = redirect_appdata ? "." :
|
||||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||||
productName);
|
productName);
|
||||||
|
string iconFolder = appDataFolder;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//avoid db path conflict with release version
|
//avoid db path conflict with release version
|
||||||
//appDataFolder = ".";
|
//appDataFolder = ".";
|
||||||
|
@ -236,44 +237,42 @@ namespace PersistentWindows.SystrayShell
|
||||||
#endif
|
#endif
|
||||||
AppdataFolder = appDataFolder;
|
AppdataFolder = appDataFolder;
|
||||||
|
|
||||||
string icon_path = Path.Combine(appDataFolder, "pwIcon.ico");
|
// default icons
|
||||||
string icon_path2 = Path.Combine(appDataFolder, "pwIcon.png");
|
IdleIcon = Properties.Resources.pwIcon;
|
||||||
if (File.Exists(icon_path2))
|
var iconHandle = Properties.Resources.pwIconBusy.GetHicon();
|
||||||
{
|
BusyIcon = System.Drawing.Icon.FromHandle(iconHandle);
|
||||||
var bitmap = new System.Drawing.Bitmap(icon_path2); // or get it from resource
|
iconHandle = Properties.Resources.pwIconUpdate.GetHicon();
|
||||||
var iconHandle = bitmap.GetHicon();
|
UpdateIcon = System.Drawing.Icon.FromHandle(iconHandle);
|
||||||
IdleIcon = System.Drawing.Icon.FromHandle(iconHandle);
|
|
||||||
}
|
|
||||||
else if (File.Exists(icon_path))
|
|
||||||
{
|
|
||||||
IdleIcon = new System.Drawing.Icon(icon_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IdleIcon = Properties.Resources.pwIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
icon_path = Path.Combine(appDataFolder, "pwIconBusy.ico");
|
// customized icon/png
|
||||||
icon_path2 = Path.Combine(appDataFolder, "pwIconBusy.png");
|
for (int i = 0; i < 2; i++)
|
||||||
if (File.Exists(icon_path2))
|
|
||||||
{
|
{
|
||||||
var bitmap = new System.Drawing.Bitmap(icon_path2);
|
if (i == 1)
|
||||||
var iconHandle = bitmap.GetHicon();
|
iconFolder = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
BusyIcon = System.Drawing.Icon.FromHandle(iconHandle);
|
|
||||||
}
|
|
||||||
else if (File.Exists(icon_path))
|
|
||||||
{
|
|
||||||
BusyIcon = new System.Drawing.Icon(icon_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var iconHandle = Properties.Resources.pwIconBusy.GetHicon();
|
|
||||||
BusyIcon = System.Drawing.Icon.FromHandle(iconHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
string icon_path = Path.Combine(iconFolder, "pwIcon.ico");
|
||||||
var iconHandle = Properties.Resources.pwIconUpdate.GetHicon();
|
string icon_png_path = Path.Combine(iconFolder, "pwIcon.png");
|
||||||
UpdateIcon = System.Drawing.Icon.FromHandle(iconHandle);
|
if (File.Exists(icon_png_path))
|
||||||
|
{
|
||||||
|
var bitmap = new System.Drawing.Bitmap(icon_png_path); // or get it from resource
|
||||||
|
IdleIcon = System.Drawing.Icon.FromHandle(bitmap.GetHicon());
|
||||||
|
}
|
||||||
|
else if (File.Exists(icon_path))
|
||||||
|
{
|
||||||
|
IdleIcon = new System.Drawing.Icon(icon_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
icon_path = Path.Combine(iconFolder, "pwIconBusy.ico");
|
||||||
|
icon_png_path = Path.Combine(iconFolder, "pwIconBusy.png");
|
||||||
|
if (File.Exists(icon_png_path))
|
||||||
|
{
|
||||||
|
var bitmap = new System.Drawing.Bitmap(icon_png_path);
|
||||||
|
BusyIcon = System.Drawing.Icon.FromHandle(bitmap.GetHicon());
|
||||||
|
}
|
||||||
|
else if (File.Exists(icon_path))
|
||||||
|
{
|
||||||
|
BusyIcon = new System.Drawing.Icon(icon_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
systrayForm = new SystrayForm();
|
systrayForm = new SystrayForm();
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 18 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
Loading…
Add table
Add a link
Reference in a new issue