全局模式下系统托盘变为粉色

This commit is contained in:
DengYq 2019-09-13 12:39:50 +08:00
parent 8ddddb66df
commit b20c4ec564
2 changed files with 47 additions and 2 deletions

View file

@ -8,11 +8,13 @@ namespace v2rayN.Forms
{
protected static Config config;
protected static System.Drawing.Icon icon;
protected static System.Drawing.Icon globleAgentIcon;
public BaseForm()
{
InitializeComponent();
LoadCustomIcon();
LoadGlobleAgentCustomIcon();
}
private void LoadCustomIcon()
@ -35,5 +37,37 @@ namespace v2rayN.Forms
Utils.SaveLog($"Loading custom icon failed: {e.Message}");
}
}
//设置托盘图标
private void LoadGlobleAgentCustomIcon()
{
if (this.Icon == null)
{
globleAgentIcon = this.Icon;
}
//原图标进行颜色变化
System.Drawing.Bitmap gImage = this.Icon.ToBitmap();
for (int x = 0; x < gImage.Width; x++)
{
for (int y = 0; y < gImage.Height; y++)
{
System.Drawing.Color pixelColor = gImage.GetPixel(x, y);
if ((0 == pixelColor.R
&& 0 == pixelColor.G
&& 0 == pixelColor.B)
|| (253 == pixelColor.R
&& 253 == pixelColor.G
&& 253 == pixelColor.B))
{
continue;
}
//粉色
gImage.SetPixel(x, y, System.Drawing.Color.FromArgb(255, 174, 210));
}
}
globleAgentIcon = System.Drawing.Icon.FromHandle(gImage.GetHicon());
}
}
}

View file

@ -385,6 +385,17 @@ namespace v2rayN.Forms
toolSslPacPort.Text = $"{HttpProxyHandle.GetPacUrl()}";
}
}
//设置托盘图标
if (config.sysAgentEnabled && 1 == config.listenerType)
{
this.notifyMain.Icon = globleAgentIcon;
}
else
{
this.notifyMain.Icon = this.Icon;
}
}
private void ssMain_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
@ -1010,12 +1021,12 @@ namespace v2rayN.Forms
private void HideForm()
{
//this.WindowState = FormWindowState.Minimized;
this.Hide();
this.notifyMain.Icon = this.Icon;
this.notifyMain.Visible = true;
this.ShowInTaskbar = false;
SetVisibleCore(false);
}