mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-19 08:04:40 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea1a471c42 | |||
| 6043d74bd0 | |||
| 1bd2944074 |
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
|
|
||||||
@@ -35,5 +36,52 @@ namespace v2rayN.Forms
|
|||||||
Utils.SaveLog($"Loading custom icon failed: {e.Message}");
|
Utils.SaveLog($"Loading custom icon failed: {e.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Icon GetNotifyIcon()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var index = config.sysAgentEnabled ? config.listenerType : 0;
|
||||||
|
if (index <= 0)
|
||||||
|
{
|
||||||
|
return this.Icon;
|
||||||
|
}
|
||||||
|
var color = (new Color[] { Color.Red, Color.Orange, Color.Yellow, Color.Green })[index - 1];
|
||||||
|
var text = index.ToString();
|
||||||
|
|
||||||
|
var width = 128;
|
||||||
|
var height = 128;
|
||||||
|
//Create bitmap, kind of canvas
|
||||||
|
Bitmap bitmap = new Bitmap(width, height);
|
||||||
|
|
||||||
|
//var drawFont = new Font(FontFamily.Families[0], 64f, FontStyle.Bold);
|
||||||
|
//var drawBrush = new SolidBrush(color);
|
||||||
|
var pen = new Pen(color, 24);
|
||||||
|
|
||||||
|
var graphics = Graphics.FromImage(bitmap);
|
||||||
|
//graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
|
||||||
|
graphics.DrawIcon(this.Icon, 0, 0);
|
||||||
|
graphics.DrawEllipse(pen, new Rectangle(0, 0, width, height));
|
||||||
|
//graphics.DrawString(text, drawFont, drawBrush, width / 4, height / 8);
|
||||||
|
|
||||||
|
//To Save icon to disk
|
||||||
|
bitmap.Save(Utils.GetPath("temp_icon.ico"), System.Drawing.Imaging.ImageFormat.Icon);
|
||||||
|
|
||||||
|
Icon createdIcon = Icon.FromHandle(bitmap.GetHicon());
|
||||||
|
|
||||||
|
//drawFont.Dispose();
|
||||||
|
//drawBrush.Dispose();
|
||||||
|
pen.Dispose();
|
||||||
|
graphics.Dispose();
|
||||||
|
bitmap.Dispose();
|
||||||
|
|
||||||
|
return createdIcon;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.SaveLog(ex.Message, ex);
|
||||||
|
return this.Icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,6 +392,8 @@ namespace v2rayN.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notifyMain.Icon = GetNotifyIcon();
|
||||||
|
|
||||||
}
|
}
|
||||||
private void ssMain_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
private void ssMain_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -1019,7 +1021,7 @@ namespace v2rayN.Forms
|
|||||||
{
|
{
|
||||||
//this.WindowState = FormWindowState.Minimized;
|
//this.WindowState = FormWindowState.Minimized;
|
||||||
this.Hide();
|
this.Hide();
|
||||||
this.notifyMain.Icon = this.Icon;
|
//this.notifyMain.Icon = this.Icon;
|
||||||
this.notifyMain.Visible = true;
|
this.notifyMain.Visible = true;
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
|
|||||||
// 方法是按如下所示使用“*”:
|
// 方法是按如下所示使用“*”:
|
||||||
//[assembly: AssemblyVersion("1.0.*")]
|
//[assembly: AssemblyVersion("1.0.*")]
|
||||||
//[assembly: AssemblyVersion("1.0.0")]
|
//[assembly: AssemblyVersion("1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2.41")]
|
[assembly: AssemblyFileVersion("2.42")]
|
||||||
|
|||||||
Reference in New Issue
Block a user