diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs index dec8f338..6a834343 100644 --- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs +++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs @@ -70,22 +70,7 @@ this.qrCodeControl = new v2rayN.Forms.QRCodeControl(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.gbMsgTitle = new System.Windows.Forms.GroupBox(); - this.txtMsgBox = new System.Windows.Forms.TextBox(); - this.cmsMsgBox = new System.Windows.Forms.ContextMenuStrip(this.components); - this.menuMsgBoxSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.menuMsgBoxCopy = new System.Windows.Forms.ToolStripMenuItem(); - this.menuMsgBoxCopyAll = new System.Windows.Forms.ToolStripMenuItem(); - this.menuMsgBoxClear = new System.Windows.Forms.ToolStripMenuItem(); - this.menuMsgBoxAddRoutingRule = new System.Windows.Forms.ToolStripMenuItem(); - this.menuMsgBoxFilter = new System.Windows.Forms.ToolStripMenuItem(); - this.ssMain = new System.Windows.Forms.StatusStrip(); - this.toolSslInboundInfo = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolSslBlank1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolSslRoutingRule = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolSslBlank2 = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolSslServerSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolSslBlank4 = new System.Windows.Forms.ToolStripStatusLabel(); + this.mainMsgControl = new v2rayN.Forms.MainMsgControl(); this.notifyMain = new System.Windows.Forms.NotifyIcon(this.components); this.cmsMain = new System.Windows.Forms.ContextMenuStrip(this.components); this.menuSysAgentMode = new System.Windows.Forms.ToolStripMenuItem(); @@ -146,9 +131,6 @@ this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.groupBox1.SuspendLayout(); - this.gbMsgTitle.SuspendLayout(); - this.cmsMsgBox.SuspendLayout(); - this.ssMain.SuspendLayout(); this.cmsMain.SuspendLayout(); this.tsMain.SuspendLayout(); this.SuspendLayout(); @@ -226,7 +208,6 @@ this.menuExport2ShareUrl, this.menuExport2SubContent}); this.cmsLv.Name = "cmsLv"; - this.cmsLv.OwnerItem = this.tsbServer; resources.ApplyResources(this.cmsLv, "cmsLv"); // // menuAddVmessServer @@ -447,7 +428,7 @@ // // splitContainer1.Panel2 // - this.splitContainer1.Panel2.Controls.Add(this.gbMsgTitle); + this.splitContainer1.Panel2.Controls.Add(this.mainMsgControl); // // groupBox1 // @@ -456,119 +437,10 @@ this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; // - // gbMsgTitle + // mainMsgControl // - this.gbMsgTitle.Controls.Add(this.txtMsgBox); - this.gbMsgTitle.Controls.Add(this.ssMain); - resources.ApplyResources(this.gbMsgTitle, "gbMsgTitle"); - this.gbMsgTitle.Name = "gbMsgTitle"; - this.gbMsgTitle.TabStop = false; - // - // txtMsgBox - // - this.txtMsgBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(49)))), ((int)(((byte)(52))))); - this.txtMsgBox.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtMsgBox.ContextMenuStrip = this.cmsMsgBox; - resources.ApplyResources(this.txtMsgBox, "txtMsgBox"); - this.txtMsgBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(226)))), ((int)(((byte)(228))))); - this.txtMsgBox.Name = "txtMsgBox"; - this.txtMsgBox.ReadOnly = true; - this.txtMsgBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtMsgBox_KeyDown); - // - // cmsMsgBox - // - this.cmsMsgBox.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.menuMsgBoxSelectAll, - this.menuMsgBoxCopy, - this.menuMsgBoxCopyAll, - this.menuMsgBoxClear, - this.menuMsgBoxAddRoutingRule, - this.menuMsgBoxFilter}); - this.cmsMsgBox.Name = "cmsMsgBox"; - resources.ApplyResources(this.cmsMsgBox, "cmsMsgBox"); - // - // menuMsgBoxSelectAll - // - this.menuMsgBoxSelectAll.Name = "menuMsgBoxSelectAll"; - resources.ApplyResources(this.menuMsgBoxSelectAll, "menuMsgBoxSelectAll"); - this.menuMsgBoxSelectAll.Click += new System.EventHandler(this.menuMsgBoxSelectAll_Click); - // - // menuMsgBoxCopy - // - this.menuMsgBoxCopy.Name = "menuMsgBoxCopy"; - resources.ApplyResources(this.menuMsgBoxCopy, "menuMsgBoxCopy"); - this.menuMsgBoxCopy.Click += new System.EventHandler(this.menuMsgBoxCopy_Click); - // - // menuMsgBoxCopyAll - // - this.menuMsgBoxCopyAll.Name = "menuMsgBoxCopyAll"; - resources.ApplyResources(this.menuMsgBoxCopyAll, "menuMsgBoxCopyAll"); - this.menuMsgBoxCopyAll.Click += new System.EventHandler(this.menuMsgBoxCopyAll_Click); - // - // menuMsgBoxClear - // - this.menuMsgBoxClear.Name = "menuMsgBoxClear"; - resources.ApplyResources(this.menuMsgBoxClear, "menuMsgBoxClear"); - this.menuMsgBoxClear.Click += new System.EventHandler(this.menuMsgBoxClear_Click); - // - // menuMsgBoxAddRoutingRule - // - this.menuMsgBoxAddRoutingRule.Name = "menuMsgBoxAddRoutingRule"; - resources.ApplyResources(this.menuMsgBoxAddRoutingRule, "menuMsgBoxAddRoutingRule"); - this.menuMsgBoxAddRoutingRule.Click += new System.EventHandler(this.menuMsgBoxAddRoutingRule_Click); - // - // menuMsgBoxFilter - // - this.menuMsgBoxFilter.Name = "menuMsgBoxFilter"; - resources.ApplyResources(this.menuMsgBoxFilter, "menuMsgBoxFilter"); - this.menuMsgBoxFilter.Click += new System.EventHandler(this.menuMsgBoxFilter_Click); - // - // ssMain - // - this.ssMain.ImageScalingSize = new System.Drawing.Size(20, 20); - this.ssMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolSslInboundInfo, - this.toolSslBlank1, - this.toolSslRoutingRule, - this.toolSslBlank2, - this.toolSslServerSpeed, - this.toolSslBlank4}); - resources.ApplyResources(this.ssMain, "ssMain"); - this.ssMain.Name = "ssMain"; - this.ssMain.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.ssMain_ItemClicked); - // - // toolSslInboundInfo - // - this.toolSslInboundInfo.Name = "toolSslInboundInfo"; - resources.ApplyResources(this.toolSslInboundInfo, "toolSslInboundInfo"); - // - // toolSslBlank1 - // - resources.ApplyResources(this.toolSslBlank1, "toolSslBlank1"); - this.toolSslBlank1.Name = "toolSslBlank1"; - this.toolSslBlank1.Spring = true; - // - // toolSslRoutingRule - // - this.toolSslRoutingRule.Name = "toolSslRoutingRule"; - resources.ApplyResources(this.toolSslRoutingRule, "toolSslRoutingRule"); - // - // toolSslBlank2 - // - this.toolSslBlank2.Name = "toolSslBlank2"; - resources.ApplyResources(this.toolSslBlank2, "toolSslBlank2"); - this.toolSslBlank2.Spring = true; - // - // toolSslServerSpeed - // - resources.ApplyResources(this.toolSslServerSpeed, "toolSslServerSpeed"); - this.toolSslServerSpeed.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.toolSslServerSpeed.Name = "toolSslServerSpeed"; - // - // toolSslBlank4 - // - this.toolSslBlank4.Name = "toolSslBlank4"; - resources.ApplyResources(this.toolSslBlank4, "toolSslBlank4"); + resources.ApplyResources(this.mainMsgControl, "mainMsgControl"); + this.mainMsgControl.Name = "mainMsgControl"; // // notifyMain // @@ -945,11 +817,6 @@ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); - this.gbMsgTitle.ResumeLayout(false); - this.gbMsgTitle.PerformLayout(); - this.cmsMsgBox.ResumeLayout(false); - this.ssMain.ResumeLayout(false); - this.ssMain.PerformLayout(); this.cmsMain.ResumeLayout(false); this.tsMain.ResumeLayout(false); this.tsMain.PerformLayout(); @@ -961,8 +828,6 @@ #endregion private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.GroupBox gbMsgTitle; - private System.Windows.Forms.TextBox txtMsgBox; private v2rayN.Base.ListViewFlickerFree lvServers; private System.Windows.Forms.NotifyIcon notifyMain; private System.Windows.Forms.ContextMenuStrip cmsMain; @@ -1023,10 +888,6 @@ private System.Windows.Forms.ToolStripMenuItem tsbLanguageZhHans; private System.Windows.Forms.ToolStripButton tsbPromotion; private System.Windows.Forms.ToolStripMenuItem menuAddSocksServer; - private System.Windows.Forms.StatusStrip ssMain; - private System.Windows.Forms.ToolStripStatusLabel toolSslBlank1; - private System.Windows.Forms.ToolStripStatusLabel toolSslServerSpeed; - private System.Windows.Forms.ToolStripStatusLabel toolSslBlank4; private System.Windows.Forms.ToolStripMenuItem menuRemoveDuplicateServer; private System.Windows.Forms.ToolStripMenuItem menuTcpingServer; private System.Windows.Forms.ToolStripMenuItem menuRealPingServer; @@ -1045,27 +906,18 @@ private System.Windows.Forms.ToolStripMenuItem menuClearServerStatistics; private System.Windows.Forms.ToolStripMenuItem menuRoutings; private System.Windows.Forms.ToolStripSeparator toolStripSeparator13; - private System.Windows.Forms.ContextMenuStrip cmsMsgBox; - private System.Windows.Forms.ToolStripMenuItem menuMsgBoxSelectAll; - private System.Windows.Forms.ToolStripMenuItem menuMsgBoxCopy; - private System.Windows.Forms.ToolStripMenuItem menuMsgBoxAddRoutingRule; - private System.Windows.Forms.ToolStripMenuItem menuMsgBoxCopyAll; private System.Windows.Forms.ToolStripSeparator toolStripSeparator14; private System.Windows.Forms.ToolStripMenuItem tsbBackupGuiNConfig; private System.Windows.Forms.ToolStripSeparator toolStripSeparator15; private System.Windows.Forms.ToolStripMenuItem tsbCheckUpdateGeo; private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ToolStripMenuItem menuMsgBoxFilter; - private System.Windows.Forms.ToolStripStatusLabel toolSslInboundInfo; - private System.Windows.Forms.ToolStripStatusLabel toolSslRoutingRule; - private System.Windows.Forms.ToolStripStatusLabel toolSslBlank2; private System.Windows.Forms.ToolStripMenuItem tsbSubUpdateViaProxy; private System.Windows.Forms.ToolStripMenuItem menuUpdateSubViaProxy; - private System.Windows.Forms.ToolStripMenuItem menuMsgBoxClear; private System.Windows.Forms.ToolStripMenuItem tsbGlobalHotkeySetting; private System.Windows.Forms.TabControl tabGroup; private System.Windows.Forms.ToolStripMenuItem tsbGroupSetting; private System.Windows.Forms.ToolStripMenuItem menuMoveToGroup; + private MainMsgControl mainMsgControl; } } diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 0b632ec2..9dcf9ef9 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -3,16 +3,14 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Linq; using System.Text; -using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; -using v2rayN.Base; using v2rayN.Handler; using v2rayN.Mode; -using v2rayN.Tool; -using System.Linq; using v2rayN.Resx; +using v2rayN.Tool; namespace v2rayN.Forms { @@ -21,7 +19,6 @@ namespace v2rayN.Forms private V2rayHandler v2rayHandler; private List lstSelecteds = new List(); private StatisticsHandler statistics = null; - private string MsgFilter = string.Empty; private List lstVmess = null; private string groupId = string.Empty; @@ -527,7 +524,7 @@ namespace v2rayN.Forms if (Global.reloadV2ray) { - ClearMsg(); + mainMsgControl.ClearMsg(); } await Task.Run(() => { @@ -1038,68 +1035,17 @@ namespace v2rayN.Forms AppendText(notify, msg); } - delegate void AppendTextDelegate(string text); void AppendText(bool notify, string msg) { try { - AppendText(msg); + mainMsgControl.AppendText(msg); if (notify) { notifyMsg(msg); } } - catch - { - } - } - - void AppendText(string text) - { - if (this.txtMsgBox.InvokeRequired) - { - Invoke(new AppendTextDelegate(AppendText), new object[] { text }); - } - else - { - if (!Utils.IsNullOrEmpty(MsgFilter)) - { - if (!Regex.IsMatch(text, MsgFilter)) - { - return; - } - } - //this.txtMsgBox.AppendText(text); - ShowMsg(text); - } - } - - /// - /// 提示信息 - /// - /// - private void ShowMsg(string msg) - { - if (txtMsgBox.Lines.Length > 999) - { - ClearMsg(); - } - this.txtMsgBox.AppendText(msg); - if (!msg.EndsWith(Environment.NewLine)) - { - this.txtMsgBox.AppendText(Environment.NewLine); - } - } - - /// - /// 清除信息 - /// - private void ClearMsg() - { - txtMsgBox.Invoke((Action)delegate - { - txtMsgBox.Clear(); - }); + catch { } } /// @@ -1143,7 +1089,7 @@ namespace v2rayN.Forms this.Activate(); this.ShowInTaskbar = true; //this.notifyIcon1.Visible = false; - this.txtMsgBox.ScrollToCaret(); + mainMsgControl.ScrollToCaret(); int index = GetLvSelectedIndex(false); if (index >= 0 && index < lvServers.Items.Count && lvServers.Items.Count > 0) @@ -1211,7 +1157,7 @@ namespace v2rayN.Forms { up /= (ulong)(config.statisticsFreshRate / 1000f); down /= (ulong)(config.statisticsFreshRate / 1000f); - toolSslServerSpeed.Text = string.Format("{0}/s↑ | {1}/s↓", Utils.HumanFy(up), Utils.HumanFy(down)); + mainMsgControl.SetToolSslInfo("speed", string.Format("{0}/s↑ | {1}/s↓", Utils.HumanFy(up), Utils.HumanFy(down))); foreach (var it in statistics) { @@ -1347,7 +1293,7 @@ namespace v2rayN.Forms sb.Append($"{ResUI.SystemProxy} {Global.Loopback}:{config.GetLocalPort(Global.InboundHttp2)}"); } - toolSslInboundInfo.Text = sb.ToString(); + mainMsgControl.SetToolSslInfo("inbound", sb.ToString()); notifyMain.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon); } @@ -1507,10 +1453,6 @@ namespace v2rayN.Forms //Application.Restart(); } - - - - #endregion @@ -1524,7 +1466,7 @@ namespace v2rayN.Forms menuRoutings.Visible = config.enableRoutingAdvanced; if (!config.enableRoutingAdvanced) { - toolSslRoutingRule.Text = string.Empty; + mainMsgControl.SetToolSslInfo("routing", string.Empty); return; } @@ -1547,7 +1489,7 @@ namespace v2rayN.Forms if (config.routingIndex.Equals(k)) { ts.Checked = true; - toolSslRoutingRule.Text = item.remarks; + mainMsgControl.SetToolSslInfo("routing", item.remarks); } ts.Click += new EventHandler(ts_Routing_Click); lst.Add(ts); @@ -1573,66 +1515,5 @@ namespace v2rayN.Forms } } #endregion - - #region MsgBoxMenu - private void menuMsgBoxSelectAll_Click(object sender, EventArgs e) - { - this.txtMsgBox.Focus(); - this.txtMsgBox.SelectAll(); - } - - private void menuMsgBoxCopy_Click(object sender, EventArgs e) - { - var data = this.txtMsgBox.SelectedText.TrimEx(); - Utils.SetClipboardData(data); - } - - private void menuMsgBoxCopyAll_Click(object sender, EventArgs e) - { - var data = this.txtMsgBox.Text; - Utils.SetClipboardData(data); - } - private void menuMsgBoxClear_Click(object sender, EventArgs e) - { - this.txtMsgBox.Clear(); - } - private void menuMsgBoxAddRoutingRule_Click(object sender, EventArgs e) - { - menuMsgBoxCopy_Click(null, null); - tsbRoutingSetting_Click(null, null); - } - - private void txtMsgBox_KeyDown(object sender, KeyEventArgs e) - { - if (e.Control) - { - switch (e.KeyCode) - { - case Keys.A: - menuMsgBoxSelectAll_Click(null, null); - break; - case Keys.C: - menuMsgBoxCopy_Click(null, null); - break; - case Keys.V: - menuMsgBoxAddRoutingRule_Click(null, null); - break; - - } - } - - } - private void menuMsgBoxFilter_Click(object sender, EventArgs e) - { - var fm = new MsgFilterSetForm(); - fm.MsgFilter = MsgFilter; - if (fm.ShowDialog() == DialogResult.OK) - { - MsgFilter = fm.MsgFilter; - gbMsgTitle.Text = string.Format(ResUI.MsgInformationTitle, MsgFilter); - } - } - #endregion - } } diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx index 4e86cc37..afec6ce6 100644 --- a/v2rayN/v2rayN/Forms/MainForm.resx +++ b/v2rayN/v2rayN/Forms/MainForm.resx @@ -126,7 +126,7 @@ 3, 17 - 327, 17 + 226, 19 355, 22 @@ -308,20 +308,8 @@ Export subscription (base64) share to clipboard - - Magenta - - - 64, 53 - - - Servers - - - ImageAboveText - - 356, 644 + 356, 666 cmsLv @@ -470,6 +458,18 @@ 0 + + Magenta + + + 64, 53 + + + Servers + + + ImageAboveText + Fill @@ -515,178 +515,28 @@ 0 - - 493, 20 - - - 227, 22 - - - Select All (Ctrl+A) - - - 227, 22 - - - Copy (Ctrl+C) - - - 227, 22 - - - Copy All - - - 227, 22 - - - Clear All - - - 227, 22 - - - Add Routing Rule (Ctrl+V) - - - 227, 22 - - - Set message filters - - - 228, 136 - - - cmsMsgBox - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + Fill - - 3, 17 - - - 0 - - - True - - - Vertical - - - 946, 177 - - - 3 - - - txtMsgBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbMsgTitle - - - 0 - - - 228, 18 - - - 80, 21 - - - InboundInfo - - - 微软雅黑, 8pt - - - 300, 21 - - - 0, 21 - - - 300, 21 - - - False - - - 微软雅黑, 8pt - - - No - - - 250, 21 - - - SPEED Disabled - - - MiddleRight - - - 0, 21 - - - 3, 194 - - - 946, 26 - - - 0 - - - statusStrip1 - - - ssMain - - - System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gbMsgTitle - - - 1 - - - Fill - - + 0, 0 - + 952, 223 - - 3 + + 0 - - Informations + + mainMsgControl - - gbMsgTitle + + v2rayN.Forms.MainMsgControl, v2rayN, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + splitContainer1.Panel2 - + 0 @@ -720,7 +570,7 @@ $this - 3 + 2 17, 17 @@ -840,10 +690,10 @@ $this - 4 + 3 - 409, 17 + 315, 17 6, 56 @@ -1089,7 +939,7 @@ $this - 5 + 4 True @@ -1307,78 +1157,6 @@ System.Windows.Forms.ToolStripDropDownButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - menuMsgBoxSelectAll - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - menuMsgBoxCopy - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - menuMsgBoxCopyAll - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - menuMsgBoxClear - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - menuMsgBoxAddRoutingRule - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - menuMsgBoxFilter - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslInboundInfo - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslBlank1 - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslRoutingRule - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslBlank2 - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslServerSpeed - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - toolSslBlank4 - - - System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - notifyMain diff --git a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx index 16c98a29..e4efd702 100644 --- a/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/MainForm.zh-Hans.resx @@ -321,48 +321,27 @@ 221, 22 - - 全选 (Ctrl+A) - 221, 22 - - 复制 (Ctrl+C) - 221, 22 - - 复制所有 - 221, 22 - - 清除所有 - 221, 22 - - 快速添加路由规则 (Ctrl+V) - 221, 22 - - 设置信息过滤器 - 222, 136 网速显示未启用 - - 信息 - 172, 22 diff --git a/v2rayN/v2rayN/Forms/MainMsgControl.Designer.cs b/v2rayN/v2rayN/Forms/MainMsgControl.Designer.cs new file mode 100644 index 00000000..9af4bc0f --- /dev/null +++ b/v2rayN/v2rayN/Forms/MainMsgControl.Designer.cs @@ -0,0 +1,202 @@ + +namespace v2rayN.Forms +{ + partial class MainMsgControl + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainMsgControl)); + this.txtMsgBox = new System.Windows.Forms.TextBox(); + this.cmsMsgBox = new System.Windows.Forms.ContextMenuStrip(this.components); + this.menuMsgBoxSelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.menuMsgBoxCopy = new System.Windows.Forms.ToolStripMenuItem(); + this.menuMsgBoxCopyAll = new System.Windows.Forms.ToolStripMenuItem(); + this.menuMsgBoxClear = new System.Windows.Forms.ToolStripMenuItem(); + this.menuMsgBoxAddRoutingRule = new System.Windows.Forms.ToolStripMenuItem(); + this.menuMsgBoxFilter = new System.Windows.Forms.ToolStripMenuItem(); + this.gbMsgTitle = new System.Windows.Forms.GroupBox(); + this.ssMain = new System.Windows.Forms.StatusStrip(); + this.toolSslInboundInfo = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslBlank1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslRoutingRule = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslBlank2 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslServerSpeed = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolSslBlank4 = new System.Windows.Forms.ToolStripStatusLabel(); + this.cmsMsgBox.SuspendLayout(); + this.gbMsgTitle.SuspendLayout(); + this.ssMain.SuspendLayout(); + this.SuspendLayout(); + // + // txtMsgBox + // + resources.ApplyResources(this.txtMsgBox, "txtMsgBox"); + this.txtMsgBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(41)))), ((int)(((byte)(49)))), ((int)(((byte)(52))))); + this.txtMsgBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtMsgBox.ContextMenuStrip = this.cmsMsgBox; + this.txtMsgBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(226)))), ((int)(((byte)(228))))); + this.txtMsgBox.Name = "txtMsgBox"; + this.txtMsgBox.ReadOnly = true; + // + // cmsMsgBox + // + resources.ApplyResources(this.cmsMsgBox, "cmsMsgBox"); + this.cmsMsgBox.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuMsgBoxSelectAll, + this.menuMsgBoxCopy, + this.menuMsgBoxCopyAll, + this.menuMsgBoxClear, + this.menuMsgBoxAddRoutingRule, + this.menuMsgBoxFilter}); + this.cmsMsgBox.Name = "cmsMsgBox"; + // + // menuMsgBoxSelectAll + // + resources.ApplyResources(this.menuMsgBoxSelectAll, "menuMsgBoxSelectAll"); + this.menuMsgBoxSelectAll.Name = "menuMsgBoxSelectAll"; + this.menuMsgBoxSelectAll.Click += new System.EventHandler(this.menuMsgBoxSelectAll_Click); + // + // menuMsgBoxCopy + // + resources.ApplyResources(this.menuMsgBoxCopy, "menuMsgBoxCopy"); + this.menuMsgBoxCopy.Name = "menuMsgBoxCopy"; + this.menuMsgBoxCopy.Click += new System.EventHandler(this.menuMsgBoxCopy_Click); + // + // menuMsgBoxCopyAll + // + resources.ApplyResources(this.menuMsgBoxCopyAll, "menuMsgBoxCopyAll"); + this.menuMsgBoxCopyAll.Name = "menuMsgBoxCopyAll"; + this.menuMsgBoxCopyAll.Click += new System.EventHandler(this.menuMsgBoxCopyAll_Click); + // + // menuMsgBoxClear + // + resources.ApplyResources(this.menuMsgBoxClear, "menuMsgBoxClear"); + this.menuMsgBoxClear.Name = "menuMsgBoxClear"; + this.menuMsgBoxClear.Click += new System.EventHandler(this.menuMsgBoxClear_Click); + // + // menuMsgBoxAddRoutingRule + // + resources.ApplyResources(this.menuMsgBoxAddRoutingRule, "menuMsgBoxAddRoutingRule"); + this.menuMsgBoxAddRoutingRule.Name = "menuMsgBoxAddRoutingRule"; + this.menuMsgBoxAddRoutingRule.Click += new System.EventHandler(this.menuMsgBoxAddRoutingRule_Click); + // + // menuMsgBoxFilter + // + resources.ApplyResources(this.menuMsgBoxFilter, "menuMsgBoxFilter"); + this.menuMsgBoxFilter.Name = "menuMsgBoxFilter"; + this.menuMsgBoxFilter.Click += new System.EventHandler(this.menuMsgBoxFilter_Click); + // + // gbMsgTitle + // + resources.ApplyResources(this.gbMsgTitle, "gbMsgTitle"); + this.gbMsgTitle.Controls.Add(this.txtMsgBox); + this.gbMsgTitle.Controls.Add(this.ssMain); + this.gbMsgTitle.Name = "gbMsgTitle"; + this.gbMsgTitle.TabStop = false; + // + // ssMain + // + resources.ApplyResources(this.ssMain, "ssMain"); + this.ssMain.ImageScalingSize = new System.Drawing.Size(20, 20); + this.ssMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolSslInboundInfo, + this.toolSslBlank1, + this.toolSslRoutingRule, + this.toolSslBlank2, + this.toolSslServerSpeed, + this.toolSslBlank4}); + this.ssMain.Name = "ssMain"; + // + // toolSslInboundInfo + // + resources.ApplyResources(this.toolSslInboundInfo, "toolSslInboundInfo"); + this.toolSslInboundInfo.Name = "toolSslInboundInfo"; + // + // toolSslBlank1 + // + resources.ApplyResources(this.toolSslBlank1, "toolSslBlank1"); + this.toolSslBlank1.Name = "toolSslBlank1"; + this.toolSslBlank1.Spring = true; + // + // toolSslRoutingRule + // + resources.ApplyResources(this.toolSslRoutingRule, "toolSslRoutingRule"); + this.toolSslRoutingRule.Name = "toolSslRoutingRule"; + // + // toolSslBlank2 + // + resources.ApplyResources(this.toolSslBlank2, "toolSslBlank2"); + this.toolSslBlank2.Name = "toolSslBlank2"; + this.toolSslBlank2.Spring = true; + // + // toolSslServerSpeed + // + resources.ApplyResources(this.toolSslServerSpeed, "toolSslServerSpeed"); + this.toolSslServerSpeed.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolSslServerSpeed.Name = "toolSslServerSpeed"; + // + // toolSslBlank4 + // + resources.ApplyResources(this.toolSslBlank4, "toolSslBlank4"); + this.toolSslBlank4.Name = "toolSslBlank4"; + // + // MainMsgControl + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.gbMsgTitle); + this.Name = "MainMsgControl"; + this.Load += new System.EventHandler(this.MainMsgControl_Load); + this.cmsMsgBox.ResumeLayout(false); + this.gbMsgTitle.ResumeLayout(false); + this.gbMsgTitle.PerformLayout(); + this.ssMain.ResumeLayout(false); + this.ssMain.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TextBox txtMsgBox; + private System.Windows.Forms.ContextMenuStrip cmsMsgBox; + private System.Windows.Forms.ToolStripMenuItem menuMsgBoxSelectAll; + private System.Windows.Forms.ToolStripMenuItem menuMsgBoxCopy; + private System.Windows.Forms.ToolStripMenuItem menuMsgBoxCopyAll; + private System.Windows.Forms.ToolStripMenuItem menuMsgBoxClear; + private System.Windows.Forms.ToolStripMenuItem menuMsgBoxAddRoutingRule; + private System.Windows.Forms.ToolStripMenuItem menuMsgBoxFilter; + private System.Windows.Forms.GroupBox gbMsgTitle; + private System.Windows.Forms.StatusStrip ssMain; + private System.Windows.Forms.ToolStripStatusLabel toolSslInboundInfo; + private System.Windows.Forms.ToolStripStatusLabel toolSslBlank1; + private System.Windows.Forms.ToolStripStatusLabel toolSslRoutingRule; + private System.Windows.Forms.ToolStripStatusLabel toolSslBlank2; + private System.Windows.Forms.ToolStripStatusLabel toolSslServerSpeed; + private System.Windows.Forms.ToolStripStatusLabel toolSslBlank4; + } +} diff --git a/v2rayN/v2rayN/Forms/MainMsgControl.cs b/v2rayN/v2rayN/Forms/MainMsgControl.cs new file mode 100644 index 00000000..1f948751 --- /dev/null +++ b/v2rayN/v2rayN/Forms/MainMsgControl.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Forms; +using v2rayN.Base; +using v2rayN.Resx; + +namespace v2rayN.Forms +{ + public partial class MainMsgControl : UserControl + { + private string MsgFilter = string.Empty; + delegate void AppendTextDelegate(string text); + + public MainMsgControl() + { + InitializeComponent(); + } + + private void MainMsgControl_Load(object sender, EventArgs e) + { + + } + + #region 提示信息 + + public void AppendText(string text) + { + if (this.txtMsgBox.InvokeRequired) + { + Invoke(new AppendTextDelegate(AppendText), new object[] { text }); + } + else + { + if (!Utils.IsNullOrEmpty(MsgFilter)) + { + if (!Regex.IsMatch(text, MsgFilter)) + { + return; + } + } + //this.txtMsgBox.AppendText(text); + ShowMsg(text); + } + } + + /// + /// 提示信息 + /// + /// + private void ShowMsg(string msg) + { + if (txtMsgBox.Lines.Length > 999) + { + ClearMsg(); + } + this.txtMsgBox.AppendText(msg); + if (!msg.EndsWith(Environment.NewLine)) + { + this.txtMsgBox.AppendText(Environment.NewLine); + } + } + + /// + /// 清除信息 + /// + public void ClearMsg() + { + txtMsgBox.Invoke((Action)delegate + { + txtMsgBox.Clear(); + }); + } + + public void SetToolSslInfo(string type, string value) + { + switch (type) + { + case "speed": + toolSslServerSpeed.Text = value; + break; + case "inbound": + toolSslInboundInfo.Text = value; + break; + case "routing": + toolSslRoutingRule.Text = value; + break; + } + + } + + public void ScrollToCaret() + { + this.txtMsgBox.ScrollToCaret(); + } + #endregion + + + #region MsgBoxMenu + private void menuMsgBoxSelectAll_Click(object sender, EventArgs e) + { + this.txtMsgBox.Focus(); + this.txtMsgBox.SelectAll(); + } + + private void menuMsgBoxCopy_Click(object sender, EventArgs e) + { + var data = this.txtMsgBox.SelectedText.TrimEx(); + Utils.SetClipboardData(data); + } + + private void menuMsgBoxCopyAll_Click(object sender, EventArgs e) + { + var data = this.txtMsgBox.Text; + Utils.SetClipboardData(data); + } + private void menuMsgBoxClear_Click(object sender, EventArgs e) + { + this.txtMsgBox.Clear(); + } + private void menuMsgBoxAddRoutingRule_Click(object sender, EventArgs e) + { + menuMsgBoxCopy_Click(null, null); + var fm = new RoutingSettingForm(); + fm.ShowDialog(); + + } + + private void txtMsgBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control) + { + switch (e.KeyCode) + { + case Keys.A: + menuMsgBoxSelectAll_Click(null, null); + break; + case Keys.C: + menuMsgBoxCopy_Click(null, null); + break; + case Keys.V: + menuMsgBoxAddRoutingRule_Click(null, null); + break; + + } + } + + } + private void menuMsgBoxFilter_Click(object sender, EventArgs e) + { + var fm = new MsgFilterSetForm(); + fm.MsgFilter = MsgFilter; + if (fm.ShowDialog() == DialogResult.OK) + { + MsgFilter = fm.MsgFilter; + gbMsgTitle.Text = string.Format(ResUI.MsgInformationTitle, MsgFilter); + } + } + #endregion + + + } +} diff --git a/v2rayN/v2rayN/Forms/MainMsgControl.resx b/v2rayN/v2rayN/Forms/MainMsgControl.resx new file mode 100644 index 00000000..8a16d9b2 --- /dev/null +++ b/v2rayN/v2rayN/Forms/MainMsgControl.resx @@ -0,0 +1,387 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolSslRoutingRule + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Select All (Ctrl+A) + + + menuMsgBoxSelectAll + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + False + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolSslServerSpeed + + + + 227, 22 + + + System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + menuMsgBoxCopyAll + + + 0 + + + 1 + + + 3, 221 + + + 227, 22 + + + 227, 22 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 6, 12 + + + 0, 17 + + + 80, 17 + + + toolSslInboundInfo + + + txtMsgBox + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 微软雅黑, 8pt + + + 227, 22 + + + gbMsgTitle + + + 227, 22 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Add Routing Rule (Ctrl+V) + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + MiddleRight + + + 微软雅黑, 8pt + + + 696, 246 + + + InboundInfo + + + 0 + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + menuMsgBoxClear + + + 5 + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 3, 17 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolSslBlank4 + + + gbMsgTitle + + + Informations + + + 0 + + + 172, 17 + + + menuMsgBoxAddRoutingRule + + + True + + + Clear All + + + + Vertical + + + $this + + + 690, 22 + + + cmsMsgBox + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Fill + + + 690, 204 + + + 227, 22 + + + 172, 17 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Copy All + + + 0, 0 + + + 696, 246 + + + toolSslBlank1 + + + No + + + Copy (Ctrl+C) + + + statusStrip1 + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolSslBlank2 + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + SPEED Disabled + + + 4 + + + gbMsgTitle + + + menuMsgBoxFilter + + + 1 + + + MainMsgControl + + + Fill + + + menuMsgBoxCopy + + + 0, 17 + + + ssMain + + + Set message filters + + + 228, 136 + + + 250, 17 + + + 17, 17 + + + zh-Hans + + + True + + + 131, 18 + + \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/MainMsgControl.zh-Hans.resx b/v2rayN/v2rayN/Forms/MainMsgControl.zh-Hans.resx new file mode 100644 index 00000000..d9673dca --- /dev/null +++ b/v2rayN/v2rayN/Forms/MainMsgControl.zh-Hans.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 信息 + + + 快速添加路由规则 (Ctrl+V) + + + 清除所有 + + + 复制 (Ctrl+C) + + + 复制所有 + + + 设置信息过滤器 + + + 全选 (Ctrl+A) + + \ No newline at end of file diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index 7d6cb61b..8b20ff90 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -109,6 +109,12 @@ BaseServerForm.cs + + UserControl + + + MainMsgControl.cs + Form @@ -286,6 +292,12 @@ MainForm.cs Designer + + MainMsgControl.cs + + + MainMsgControl.cs + MsgFilterSetForm.cs