mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-10-31 04:22:51 +00:00 
			
		
		
		
	Merge pull request #2415 from EdiWang/master
C# language usage improvements
This commit is contained in:
		
						commit
						28b2e1a405
					
				
					 30 changed files with 247 additions and 341 deletions
				
			
		|  | @ -16,37 +16,37 @@ namespace v2rayN.Base | |||
|             UpdateStyles(); | ||||
|         } | ||||
| 
 | ||||
|         public void RegisterDragEvent(Action<int, int> _update) | ||||
|         public void RegisterDragEvent(Action<int, int> update) | ||||
|         { | ||||
|             _updateFunc = _update; | ||||
|             this.AllowDrop = true; | ||||
|             _updateFunc = update; | ||||
|             AllowDrop = true; | ||||
| 
 | ||||
|             this.ItemDrag += new ItemDragEventHandler(this.lv_ItemDrag); | ||||
|             this.DragDrop += new DragEventHandler(this.lv_DragDrop); | ||||
|             this.DragEnter += new DragEventHandler(this.lv_DragEnter); | ||||
|             this.DragOver += new DragEventHandler(this.lv_DragOver); | ||||
|             this.DragLeave += new EventHandler(this.lv_DragLeave); | ||||
|             ItemDrag += lv_ItemDrag; | ||||
|             DragDrop += lv_DragDrop; | ||||
|             DragEnter += lv_DragEnter; | ||||
|             DragOver += lv_DragOver; | ||||
|             DragLeave += lv_DragLeave; | ||||
|         } | ||||
| 
 | ||||
|         private void lv_DragDrop(object sender, DragEventArgs e) | ||||
|         { | ||||
|             int targetIndex = this.InsertionMark.Index; | ||||
|             int targetIndex = InsertionMark.Index; | ||||
|             if (targetIndex == -1) | ||||
|             { | ||||
|                 return; | ||||
|             } | ||||
|             if (this.InsertionMark.AppearsAfterItem) | ||||
|             if (InsertionMark.AppearsAfterItem) | ||||
|             { | ||||
|                 targetIndex++; | ||||
|             } | ||||
| 
 | ||||
| 
 | ||||
|             if (this.SelectedIndices.Count <= 0) | ||||
|             if (SelectedIndices.Count <= 0) | ||||
|             { | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             _updateFunc(this.SelectedIndices[0], targetIndex); | ||||
|             _updateFunc(SelectedIndices[0], targetIndex); | ||||
| 
 | ||||
|             //ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem)); | ||||
|             //this.BeginUpdate(); | ||||
|  | @ -63,35 +63,35 @@ namespace v2rayN.Base | |||
| 
 | ||||
|         private void lv_DragLeave(object sender, EventArgs e) | ||||
|         { | ||||
|             this.InsertionMark.Index = -1; | ||||
|             InsertionMark.Index = -1; | ||||
|         } | ||||
| 
 | ||||
|         private void lv_DragOver(object sender, DragEventArgs e) | ||||
|         { | ||||
|             Point targetPoint = this.PointToClient(new Point(e.X, e.Y)); | ||||
|             int targetIndex = this.InsertionMark.NearestIndex(targetPoint); | ||||
|             Point targetPoint = PointToClient(new Point(e.X, e.Y)); | ||||
|             int targetIndex = InsertionMark.NearestIndex(targetPoint); | ||||
| 
 | ||||
|             if (targetIndex > -1) | ||||
|             { | ||||
|                 Rectangle itemBounds = this.GetItemRect(targetIndex); | ||||
|                 this.EnsureVisible(targetIndex); | ||||
|                 Rectangle itemBounds = GetItemRect(targetIndex); | ||||
|                 EnsureVisible(targetIndex); | ||||
| 
 | ||||
|                 if (targetPoint.Y > itemBounds.Top + (itemBounds.Height / 2)) | ||||
|                 { | ||||
|                     this.InsertionMark.AppearsAfterItem = true; | ||||
|                     InsertionMark.AppearsAfterItem = true; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     this.InsertionMark.AppearsAfterItem = false; | ||||
|                     InsertionMark.AppearsAfterItem = false; | ||||
|                 } | ||||
|             } | ||||
|             this.InsertionMark.Index = targetIndex; | ||||
|             InsertionMark.Index = targetIndex; | ||||
|         } | ||||
| 
 | ||||
|         private void lv_ItemDrag(object sender, ItemDragEventArgs e) | ||||
|         { | ||||
|             this.DoDragDrop(e.Item, DragDropEffects.Move); | ||||
|             this.InsertionMark.Index = -1; | ||||
|             DoDragDrop(e.Item, DragDropEffects.Move); | ||||
|             InsertionMark.Index = -1; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -32,8 +32,10 @@ namespace v2rayN.Forms | |||
|             } | ||||
|             else | ||||
|             { | ||||
|                 vmessItem = new VmessItem(); | ||||
|                 vmessItem.groupId = groupId; | ||||
|                 vmessItem = new VmessItem | ||||
|                 { | ||||
|                     groupId = groupId | ||||
|                 }; | ||||
|                 ClearServer(); | ||||
|             } | ||||
|         } | ||||
|  | @ -46,14 +48,7 @@ namespace v2rayN.Forms | |||
|             txtRemarks.Text = vmessItem.remarks; | ||||
|             txtAddress.Text = vmessItem.address; | ||||
| 
 | ||||
|             if (vmessItem.coreType == null) | ||||
|             { | ||||
|                 cmbCoreType.Text = string.Empty; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 cmbCoreType.Text = vmessItem.coreType.ToString(); | ||||
|             } | ||||
|             cmbCoreType.Text = vmessItem.coreType == null ? string.Empty : vmessItem.coreType.ToString(); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -90,7 +85,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (ConfigHandler.EditCustomServer(ref config, vmessItem) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -100,14 +95,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             if (Utils.IsNullOrEmpty(vmessItem.indexId)) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.Cancel; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             DialogResult = Utils.IsNullOrEmpty(vmessItem.indexId) ? DialogResult.Cancel : DialogResult.OK; | ||||
|         } | ||||
| 
 | ||||
|         private void btnBrowse_Click(object sender, EventArgs e) | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void AddServerForm_Load(object sender, EventArgs e) | ||||
|         { | ||||
|             this.Text = (eConfigType).ToString(); | ||||
|             Text = (eConfigType).ToString(); | ||||
|              | ||||
|             cmbCoreType.Items.AddRange(Global.coreTypes.ToArray()); | ||||
|             cmbCoreType.Items.Add(string.Empty); | ||||
|  | @ -41,7 +41,7 @@ namespace v2rayN.Forms | |||
|                     panSocks.Dock = DockStyle.Fill; | ||||
|                     panSocks.Visible = true; | ||||
|                     panTran.Visible = false; | ||||
|                     this.Height = this.Height - panTran.Height; | ||||
|                     Height = Height - panTran.Height; | ||||
|                     break; | ||||
|                 case EConfigType.VLESS: | ||||
|                     panVless.Dock = DockStyle.Fill; | ||||
|  | @ -65,8 +65,10 @@ namespace v2rayN.Forms | |||
|             } | ||||
|             else | ||||
|             { | ||||
|                 vmessItem = new VmessItem(); | ||||
|                 vmessItem.groupId = groupId; | ||||
|                 vmessItem = new VmessItem | ||||
|                 { | ||||
|                     groupId = groupId | ||||
|                 }; | ||||
|                 ClearServer(); | ||||
|             } | ||||
|         } | ||||
|  | @ -106,14 +108,7 @@ namespace v2rayN.Forms | |||
|                     break; | ||||
|             } | ||||
| 
 | ||||
|             if (vmessItem.coreType == null) | ||||
|             { | ||||
|                 cmbCoreType.Text = string.Empty; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 cmbCoreType.Text = vmessItem.coreType.ToString(); | ||||
|             } | ||||
|             cmbCoreType.Text = vmessItem.coreType == null ? string.Empty : vmessItem.coreType.ToString(); | ||||
| 
 | ||||
|             transportControl.BindingServer(vmessItem); | ||||
|         } | ||||
|  | @ -267,7 +262,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (ret == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -284,7 +279,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -21,11 +21,11 @@ namespace v2rayN.Forms | |||
|                 string file = Utils.GetPath(Global.CustomIconName); | ||||
|                 if (System.IO.File.Exists(file)) | ||||
|                 { | ||||
|                     this.Icon = new System.Drawing.Icon(file); | ||||
|                     Icon = new System.Drawing.Icon(file); | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 this.Icon = Properties.Resources.NotifyIcon1; | ||||
|                 Icon = Properties.Resources.NotifyIcon1; | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|  |  | |||
|  | @ -101,7 +101,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (ConfigHandler.SaveConfig(ref config, false) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -111,7 +111,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
| 
 | ||||
|         private void btnReset_Click(object sender, EventArgs e) | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void GroupSettingControl_Load(object sender, EventArgs e) | ||||
|         { | ||||
|             this.Height = grbMain.Height; | ||||
|             Height = grbMain.Height; | ||||
|             BindingSub(); | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -70,7 +70,7 @@ namespace v2rayN.Forms | |||
|         {             | ||||
|             if (ConfigHandler.SaveGroupItem(ref config) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -80,7 +80,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
| 
 | ||||
|         private void btnAdd_Click(object sender, EventArgs e) | ||||
|  |  | |||
|  | @ -18,8 +18,8 @@ namespace v2rayN.Forms | |||
|     { | ||||
|         private V2rayHandler v2rayHandler; | ||||
|         private List<VmessItem> lstSelecteds = new List<VmessItem>(); | ||||
|         private StatisticsHandler statistics = null; | ||||
|         private List<VmessItem> lstVmess = null; | ||||
|         private StatisticsHandler statistics; | ||||
|         private List<VmessItem> lstVmess; | ||||
|         private string groupId = string.Empty; | ||||
|         private string serverFilter = string.Empty; | ||||
| 
 | ||||
|  | @ -28,10 +28,10 @@ namespace v2rayN.Forms | |||
|         public MainForm() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
|             this.ShowInTaskbar = false; | ||||
|             this.WindowState = FormWindowState.Minimized; | ||||
|             ShowInTaskbar = false; | ||||
|             WindowState = FormWindowState.Minimized; | ||||
|             HideForm(); | ||||
|             this.Text = Utils.GetVersion(); | ||||
|             Text = Utils.GetVersion(); | ||||
|             Global.processJob = new Job(); | ||||
| 
 | ||||
|             Application.ApplicationExit += (sender, args) => | ||||
|  | @ -154,12 +154,12 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (!config.uiItem.mainLocation.IsEmpty) | ||||
|             { | ||||
|                 this.Location = config.uiItem.mainLocation; | ||||
|                 Location = config.uiItem.mainLocation; | ||||
|             } | ||||
|             if (!config.uiItem.mainSize.IsEmpty) | ||||
|             { | ||||
|                 this.Width = config.uiItem.mainSize.Width; | ||||
|                 this.Height = config.uiItem.mainSize.Height; | ||||
|                 Width = config.uiItem.mainSize.Width; | ||||
|                 Height = config.uiItem.mainSize.Height; | ||||
|             } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -172,9 +172,9 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void StorageUI() | ||||
|         { | ||||
|             config.uiItem.mainLocation = this.Location; | ||||
|             config.uiItem.mainLocation = Location; | ||||
| 
 | ||||
|             config.uiItem.mainSize = new Size(this.Width, this.Height); | ||||
|             config.uiItem.mainSize = new Size(Width, Height); | ||||
| 
 | ||||
|             for (int k = 0; k < lvServers.Columns.Count; k++) | ||||
|             { | ||||
|  | @ -187,7 +187,7 @@ namespace v2rayN.Forms | |||
|             switch (Utils.ToInt(e.Name)) | ||||
|             { | ||||
|                 case (int)EGlobalHotkey.ShowForm: | ||||
|                     if (this.ShowInTaskbar) HideForm(); else ShowForm(); | ||||
|                     if (ShowInTaskbar) HideForm(); else ShowForm(); | ||||
|                     break; | ||||
|                 case (int)EGlobalHotkey.SystemProxyClear: | ||||
|                     SetListenerType(ESysProxyType.ForcedClear); | ||||
|  | @ -212,8 +212,8 @@ namespace v2rayN.Forms | |||
|         private void RefreshServers() | ||||
|         { | ||||
|             lstVmess = config.vmess | ||||
|                 .Where(it => Utils.IsNullOrEmpty(groupId) ? true : it.groupId == groupId) | ||||
|                 .Where(it => Utils.IsNullOrEmpty(serverFilter) ? true : it.remarks.Contains(serverFilter)) | ||||
|                 .Where(it => Utils.IsNullOrEmpty(groupId) || it.groupId == groupId) | ||||
|                 .Where(it => Utils.IsNullOrEmpty(serverFilter) || it.remarks.Contains(serverFilter)) | ||||
|                 .OrderBy(it => it.sort) | ||||
|                 .ToList(); | ||||
| 
 | ||||
|  | @ -371,7 +371,7 @@ namespace v2rayN.Forms | |||
|                 { | ||||
|                     ts.Checked = true; | ||||
|                 } | ||||
|                 ts.Click += new EventHandler(ts_Click); | ||||
|                 ts.Click += ts_Click; | ||||
|                 lst.Add(ts); | ||||
|             } | ||||
|             menuServers.DropDownItems.AddRange(lst.ToArray()); | ||||
|  | @ -415,7 +415,7 @@ namespace v2rayN.Forms | |||
|                 } | ||||
| 
 | ||||
|                 var tag = lvServers.Columns[e.Column].Tag?.ToString(); | ||||
|                 bool asc = Utils.IsNullOrEmpty(tag) ? true : !Convert.ToBoolean(tag); | ||||
|                 bool asc = Utils.IsNullOrEmpty(tag) || !Convert.ToBoolean(tag); | ||||
|                 if (ConfigHandler.SortServers(ref config, ref lstVmess, (EServerColName)e.Column, asc) != 0) | ||||
|                 { | ||||
|                     return; | ||||
|  | @ -465,7 +465,7 @@ namespace v2rayN.Forms | |||
|                 { | ||||
|                     Tag = item.id, | ||||
|                 }; | ||||
|                 ts.Click += new EventHandler(ts_Group_Click); | ||||
|                 ts.Click += ts_Group_Click; | ||||
|                 lst.Add(ts); | ||||
|             } | ||||
|             menuMoveToGroup.DropDownItems.AddRange(lst.ToArray()); | ||||
|  | @ -516,7 +516,7 @@ namespace v2rayN.Forms | |||
|         /// </summary> | ||||
|         async Task LoadV2ray() | ||||
|         { | ||||
|             this.BeginInvoke(new Action(() => | ||||
|             BeginInvoke(new Action(() => | ||||
|             { | ||||
|                 tsbReload.Enabled = false; | ||||
|             })); | ||||
|  | @ -536,7 +536,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             ChangePACButtonStatus(config.sysProxyType); | ||||
| 
 | ||||
|             this.BeginInvoke(new Action(() => | ||||
|             BeginInvoke(new Action(() => | ||||
|             { | ||||
|                 tsbReload.Enabled = true; | ||||
|             })); | ||||
|  | @ -1085,8 +1085,8 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void menuExit_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.Visible = false; | ||||
|             this.Close(); | ||||
|             Visible = false; | ||||
|             Close(); | ||||
| 
 | ||||
|             Application.Exit(); | ||||
|         } | ||||
|  | @ -1094,13 +1094,13 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void ShowForm() | ||||
|         { | ||||
|             this.Show(); | ||||
|             if (this.WindowState == FormWindowState.Minimized) | ||||
|             Show(); | ||||
|             if (WindowState == FormWindowState.Minimized) | ||||
|             { | ||||
|                 this.WindowState = FormWindowState.Normal; | ||||
|                 WindowState = FormWindowState.Normal; | ||||
|             } | ||||
|             this.Activate(); | ||||
|             this.ShowInTaskbar = true; | ||||
|             Activate(); | ||||
|             ShowInTaskbar = true; | ||||
|             //this.notifyIcon1.Visible = false; | ||||
|             mainMsgControl.ScrollToCaret(); | ||||
| 
 | ||||
|  | @ -1117,10 +1117,10 @@ namespace v2rayN.Forms | |||
|         private void HideForm() | ||||
|         { | ||||
|             //this.WindowState = FormWindowState.Minimized; | ||||
|             this.Hide(); | ||||
|             Hide(); | ||||
|             //this.notifyMain.Icon = this.Icon; | ||||
|             this.notifyMain.Visible = true; | ||||
|             this.ShowInTaskbar = false; | ||||
|             notifyMain.Visible = true; | ||||
|             ShowInTaskbar = false; | ||||
| 
 | ||||
|             SetVisibleCore(false); | ||||
|         } | ||||
|  | @ -1293,9 +1293,9 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             mainMsgControl.DisplayToolStatus(config); | ||||
| 
 | ||||
|             this.BeginInvoke(new Action(() => | ||||
|             BeginInvoke(new Action(() => | ||||
|             { | ||||
|                 notifyMain.Icon = this.Icon = MainFormHandler.Instance.GetNotifyIcon(config, this.Icon); | ||||
|                 notifyMain.Icon = Icon = MainFormHandler.Instance.GetNotifyIcon(config, Icon); | ||||
|             })); | ||||
|         } | ||||
| 
 | ||||
|  | @ -1487,7 +1487,7 @@ namespace v2rayN.Forms | |||
|                     ts.Checked = true; | ||||
|                     mainMsgControl.SetToolSslInfo("routing", item.remarks); | ||||
|                 } | ||||
|                 ts.Click += new EventHandler(ts_Routing_Click); | ||||
|                 ts.Click += ts_Routing_Click; | ||||
|                 lst.Add(ts); | ||||
|             } | ||||
|             menuRoutings.DropDownItems.AddRange(lst.ToArray()); | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ namespace v2rayN.Forms | |||
| { | ||||
|     public partial class MainMsgControl : UserControl | ||||
|     { | ||||
|         private string MsgFilter = string.Empty; | ||||
|         private string _msgFilter = string.Empty; | ||||
|         delegate void AppendTextDelegate(string text); | ||||
| 
 | ||||
|         public MainMsgControl() | ||||
|  | @ -33,15 +33,15 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         public void AppendText(string text) | ||||
|         { | ||||
|             if (this.txtMsgBox.InvokeRequired) | ||||
|             if (txtMsgBox.InvokeRequired) | ||||
|             { | ||||
|                 Invoke(new AppendTextDelegate(AppendText), new object[] { text }); | ||||
|                 Invoke(new AppendTextDelegate(AppendText), text); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 if (!Utils.IsNullOrEmpty(MsgFilter)) | ||||
|                 if (!Utils.IsNullOrEmpty(_msgFilter)) | ||||
|                 { | ||||
|                     if (!Regex.IsMatch(text, MsgFilter)) | ||||
|                     if (!Regex.IsMatch(text, _msgFilter)) | ||||
|                     { | ||||
|                         return; | ||||
|                     } | ||||
|  | @ -61,10 +61,10 @@ namespace v2rayN.Forms | |||
|             { | ||||
|                 ClearMsg(); | ||||
|             } | ||||
|             this.txtMsgBox.AppendText(msg); | ||||
|             txtMsgBox.AppendText(msg); | ||||
|             if (!msg.EndsWith(Environment.NewLine)) | ||||
|             { | ||||
|                 this.txtMsgBox.AppendText(Environment.NewLine); | ||||
|                 txtMsgBox.AppendText(Environment.NewLine); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -124,7 +124,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         public void ScrollToCaret() | ||||
|         { | ||||
|             this.txtMsgBox.ScrollToCaret(); | ||||
|             txtMsgBox.ScrollToCaret(); | ||||
|         } | ||||
|         #endregion | ||||
| 
 | ||||
|  | @ -132,24 +132,24 @@ namespace v2rayN.Forms | |||
|         #region MsgBoxMenu | ||||
|         private void menuMsgBoxSelectAll_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.txtMsgBox.Focus(); | ||||
|             this.txtMsgBox.SelectAll(); | ||||
|             txtMsgBox.Focus(); | ||||
|             txtMsgBox.SelectAll(); | ||||
|         } | ||||
| 
 | ||||
|         private void menuMsgBoxCopy_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             var data = this.txtMsgBox.SelectedText.TrimEx(); | ||||
|             var data = txtMsgBox.SelectedText.TrimEx(); | ||||
|             Utils.SetClipboardData(data); | ||||
|         } | ||||
| 
 | ||||
|         private void menuMsgBoxCopyAll_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             var data = this.txtMsgBox.Text; | ||||
|             var data = txtMsgBox.Text; | ||||
|             Utils.SetClipboardData(data); | ||||
|         } | ||||
|         private void menuMsgBoxClear_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.txtMsgBox.Clear(); | ||||
|             txtMsgBox.Clear(); | ||||
|         } | ||||
|         private void menuMsgBoxAddRoutingRule_Click(object sender, EventArgs e) | ||||
|         { | ||||
|  | @ -182,12 +182,12 @@ namespace v2rayN.Forms | |||
|         private void menuMsgBoxFilter_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             var fm = new MsgFilterSetForm(); | ||||
|             fm.MsgFilter = MsgFilter; | ||||
|             fm.MsgFilter = _msgFilter; | ||||
|             fm.ShowDefFilter = true; | ||||
|             if (fm.ShowDialog() == DialogResult.OK) | ||||
|             { | ||||
|                 MsgFilter = fm.MsgFilter; | ||||
|                 gbMsgTitle.Text = string.Format(ResUI.MsgInformationTitle, MsgFilter); | ||||
|                 _msgFilter = fm.MsgFilter; | ||||
|                 gbMsgTitle.Text = string.Format(ResUI.MsgInformationTitle, _msgFilter); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,12 +30,12 @@ namespace v2rayN.Forms | |||
|         private void btnOK_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             MsgFilter = txtMsgFilter.Text; | ||||
|             this.DialogResult = DialogResult.OK; | ||||
|             DialogResult = DialogResult.OK; | ||||
|         } | ||||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
| 
 | ||||
|         private void btnFilderProxy_Click(object sender, EventArgs e) | ||||
|  | @ -51,7 +51,7 @@ namespace v2rayN.Forms | |||
|         private void btnClear_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             MsgFilter = string.Empty; | ||||
|             this.DialogResult = DialogResult.OK; | ||||
|             DialogResult = DialogResult.OK; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -177,7 +177,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (ConfigHandler.SaveConfig(ref config) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -335,7 +335,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -115,34 +115,28 @@ namespace v2rayN.Forms | |||
|         private void btnOK_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             EndBindingData(); | ||||
|             var hasRule = false; | ||||
|             if (rulesItem.domain != null && rulesItem.domain.Count > 0) | ||||
|             { | ||||
|                 hasRule = true; | ||||
|             } | ||||
|             if (rulesItem.ip != null && rulesItem.ip.Count > 0) | ||||
|             { | ||||
|                 hasRule = true; | ||||
|             } | ||||
|             if (rulesItem.protocol != null && rulesItem.protocol.Count > 0) | ||||
|             { | ||||
|                 hasRule = true; | ||||
|             } | ||||
|             if (!Utils.IsNullOrEmpty(rulesItem.port)) | ||||
|             { | ||||
|                 hasRule = true; | ||||
|             } | ||||
| 
 | ||||
|             bool hasRule =  | ||||
|                 rulesItem.domain != null  | ||||
|                 && rulesItem.domain.Count > 0  | ||||
|                 || rulesItem.ip != null  | ||||
|                 && rulesItem.ip.Count > 0  | ||||
|                 || rulesItem.protocol != null  | ||||
|                 && rulesItem.protocol.Count > 0  | ||||
|                 || !Utils.IsNullOrEmpty(rulesItem.port); | ||||
| 
 | ||||
|             if (!hasRule) | ||||
|             { | ||||
|                 UI.ShowWarning(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP")); | ||||
|                 return; | ||||
|             } | ||||
|             this.DialogResult = DialogResult.OK; | ||||
| 
 | ||||
|             DialogResult = DialogResult.OK; | ||||
|         } | ||||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -15,9 +15,9 @@ namespace v2rayN.Forms | |||
|         { | ||||
|             get; set; | ||||
|         } | ||||
|         protected RoutingItem routingItem = null; | ||||
|         protected RoutingItem routingItem; | ||||
| 
 | ||||
|         private List<int> lvSelecteds = new List<int>(); | ||||
|         private readonly List<int> lvSelecteds = new List<int>(); | ||||
|         public RoutingRuleSettingForm() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
|  | @ -25,14 +25,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void RoutingRuleSettingForm_Load(object sender, EventArgs e) | ||||
|         { | ||||
|             if (EditIndex >= 0) | ||||
|             { | ||||
|                 routingItem = config.routings[EditIndex]; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 routingItem = new RoutingItem(); | ||||
|             } | ||||
|             routingItem = EditIndex >= 0 ? config.routings[EditIndex] : new RoutingItem(); | ||||
|             if (routingItem.rules == null) | ||||
|             { | ||||
|                 routingItem.rules = new List<RulesItem>(); | ||||
|  | @ -86,10 +79,8 @@ namespace v2rayN.Forms | |||
|             lvRoutings.BeginUpdate(); | ||||
|             lvRoutings.Items.Clear(); | ||||
| 
 | ||||
|             for (int k = 0; k < routingItem.rules.Count; k++) | ||||
|             foreach (var item in routingItem.rules) | ||||
|             { | ||||
|                 var item = routingItem.rules[k]; | ||||
| 
 | ||||
|                 ListViewItem lvItem = new ListViewItem(""); | ||||
|                 Utils.AddSubItem(lvItem, "outboundTag", item.outboundTag); | ||||
|                 Utils.AddSubItem(lvItem, "port", item.port); | ||||
|  | @ -112,7 +103,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (ConfigHandler.AddRoutingItem(ref config, routingItem, EditIndex) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -122,7 +113,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
|         private void btnBrowse_Click(object sender, EventArgs e) | ||||
|         { | ||||
|  |  | |||
|  | @ -10,8 +10,8 @@ namespace v2rayN.Forms | |||
| { | ||||
|     public partial class RoutingSettingForm : BaseForm | ||||
|     { | ||||
|         private List<int> lvSelecteds = new List<int>(); | ||||
|         private RoutingItem lockedItem; | ||||
|         private readonly List<int> _lvSelecteds = new List<int>(); | ||||
|         private RoutingItem _lockedItem; | ||||
|         public RoutingSettingForm() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
|  | @ -58,7 +58,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|             if (ConfigHandler.SaveRouting(ref config) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -68,7 +68,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
|         private void chkenableRoutingAdvanced_CheckedChanged_1(object sender, EventArgs e) | ||||
|         { | ||||
|  | @ -78,20 +78,20 @@ namespace v2rayN.Forms | |||
|         { | ||||
|             if (chkenableRoutingAdvanced.Checked) | ||||
|             { | ||||
|                 this.tabPageProxy.Parent = null; | ||||
|                 this.tabPageDirect.Parent = null; | ||||
|                 this.tabPageBlock.Parent = null; | ||||
|                 this.tabPageRuleList.Parent = tabNormal; | ||||
|                 tabPageProxy.Parent = null; | ||||
|                 tabPageDirect.Parent = null; | ||||
|                 tabPageBlock.Parent = null; | ||||
|                 tabPageRuleList.Parent = tabNormal; | ||||
|                 MenuItemBasic.Enabled = false; | ||||
|                 MenuItemAdvanced.Enabled = true; | ||||
| 
 | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 this.tabPageProxy.Parent = tabNormal; | ||||
|                 this.tabPageDirect.Parent = tabNormal; | ||||
|                 this.tabPageBlock.Parent = tabNormal; | ||||
|                 this.tabPageRuleList.Parent = null; | ||||
|                 tabPageProxy.Parent = tabNormal; | ||||
|                 tabPageDirect.Parent = tabNormal; | ||||
|                 tabPageBlock.Parent = tabNormal; | ||||
|                 tabPageRuleList.Parent = null; | ||||
|                 MenuItemBasic.Enabled = true; | ||||
|                 MenuItemAdvanced.Enabled = false; | ||||
|             } | ||||
|  | @ -102,31 +102,31 @@ namespace v2rayN.Forms | |||
|         #region locked | ||||
|         private void BindingLockedData() | ||||
|         { | ||||
|             lockedItem = ConfigHandler.GetLockedRoutingItem(ref config); | ||||
|             if (lockedItem != null) | ||||
|             _lockedItem = ConfigHandler.GetLockedRoutingItem(ref config); | ||||
|             if (_lockedItem != null) | ||||
|             { | ||||
|                 txtProxyDomain.Text = Utils.List2String(lockedItem.rules[0].domain, true); | ||||
|                 txtProxyIp.Text = Utils.List2String(lockedItem.rules[0].ip, true); | ||||
|                 txtProxyDomain.Text = Utils.List2String(_lockedItem.rules[0].domain, true); | ||||
|                 txtProxyIp.Text = Utils.List2String(_lockedItem.rules[0].ip, true); | ||||
| 
 | ||||
|                 txtDirectDomain.Text = Utils.List2String(lockedItem.rules[1].domain, true); | ||||
|                 txtDirectIp.Text = Utils.List2String(lockedItem.rules[1].ip, true); | ||||
|                 txtDirectDomain.Text = Utils.List2String(_lockedItem.rules[1].domain, true); | ||||
|                 txtDirectIp.Text = Utils.List2String(_lockedItem.rules[1].ip, true); | ||||
| 
 | ||||
|                 txtBlockDomain.Text = Utils.List2String(lockedItem.rules[2].domain, true); | ||||
|                 txtBlockIp.Text = Utils.List2String(lockedItem.rules[2].ip, true); | ||||
|                 txtBlockDomain.Text = Utils.List2String(_lockedItem.rules[2].domain, true); | ||||
|                 txtBlockIp.Text = Utils.List2String(_lockedItem.rules[2].ip, true); | ||||
|             } | ||||
|         } | ||||
|         private void EndBindingLockedData() | ||||
|         { | ||||
|             if (lockedItem != null) | ||||
|             if (_lockedItem != null) | ||||
|             { | ||||
|                 lockedItem.rules[0].domain = Utils.String2List(txtProxyDomain.Text.TrimEx()); | ||||
|                 lockedItem.rules[0].ip = Utils.String2List(txtProxyIp.Text.TrimEx()); | ||||
|                 _lockedItem.rules[0].domain = Utils.String2List(txtProxyDomain.Text.TrimEx()); | ||||
|                 _lockedItem.rules[0].ip = Utils.String2List(txtProxyIp.Text.TrimEx()); | ||||
| 
 | ||||
|                 lockedItem.rules[1].domain = Utils.String2List(txtDirectDomain.Text.TrimEx()); | ||||
|                 lockedItem.rules[1].ip = Utils.String2List(txtDirectIp.Text.TrimEx()); | ||||
|                 _lockedItem.rules[1].domain = Utils.String2List(txtDirectDomain.Text.TrimEx()); | ||||
|                 _lockedItem.rules[1].ip = Utils.String2List(txtDirectIp.Text.TrimEx()); | ||||
| 
 | ||||
|                 lockedItem.rules[2].domain = Utils.String2List(txtBlockDomain.Text.TrimEx()); | ||||
|                 lockedItem.rules[2].ip = Utils.String2List(txtBlockIp.Text.TrimEx()); | ||||
|                 _lockedItem.rules[2].domain = Utils.String2List(txtBlockDomain.Text.TrimEx()); | ||||
|                 _lockedItem.rules[2].ip = Utils.String2List(txtBlockIp.Text.TrimEx()); | ||||
| 
 | ||||
|             } | ||||
|         } | ||||
|  | @ -207,7 +207,7 @@ namespace v2rayN.Forms | |||
|         private int GetLvSelectedIndex() | ||||
|         { | ||||
|             int index = -1; | ||||
|             lvSelecteds.Clear(); | ||||
|             _lvSelecteds.Clear(); | ||||
|             try | ||||
|             { | ||||
|                 if (lvRoutings.SelectedIndices.Count <= 0) | ||||
|  | @ -219,7 +219,7 @@ namespace v2rayN.Forms | |||
|                 index = lvRoutings.SelectedIndices[0]; | ||||
|                 foreach (int i in lvRoutings.SelectedIndices) | ||||
|                 { | ||||
|                     lvSelecteds.Add(i); | ||||
|                     _lvSelecteds.Add(i); | ||||
|                 } | ||||
|                 return index; | ||||
|             } | ||||
|  | @ -264,7 +264,7 @@ namespace v2rayN.Forms | |||
|             { | ||||
|                 return; | ||||
|             } | ||||
|             for (int k = lvSelecteds.Count - 1; k >= 0; k--) | ||||
|             for (int k = _lvSelecteds.Count - 1; k >= 0; k--) | ||||
|             { | ||||
|                 config.routings.RemoveAt(index); | ||||
|             } | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ namespace v2rayN.Forms | |||
|     public partial class ServerTransportControl : UserControl | ||||
|     { | ||||
|         public bool AllowXtls { get; set; } | ||||
|         private VmessItem vmessItem = null; | ||||
|         private VmessItem vmessItem; | ||||
| 
 | ||||
|         public ServerTransportControl() | ||||
|         { | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void SubSettingControl_Load(object sender, EventArgs e) | ||||
|         { | ||||
|             this.Height = grbMain.Height; | ||||
|             Height = grbMain.Height; | ||||
| 
 | ||||
|             groupItem = LazyConfig.Instance.GetConfig().groupItem; | ||||
| 
 | ||||
|  | @ -90,7 +90,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnShare_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             if (this.Height <= grbMain.Height) | ||||
|             if (Height <= grbMain.Height) | ||||
|             { | ||||
|                 if (Utils.IsNullOrEmpty(subItem.url)) | ||||
|                 { | ||||
|  | @ -98,11 +98,11 @@ namespace v2rayN.Forms | |||
|                     return; | ||||
|                 } | ||||
|                 picQRCode.Image = QRCodeHelper.GetQRCode(subItem.url); | ||||
|                 this.Height = grbMain.Height + 200; | ||||
|                 Height = grbMain.Height + 200; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 this.Height = grbMain.Height; | ||||
|                 Height = grbMain.Height; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -71,7 +71,7 @@ namespace v2rayN.Forms | |||
|         { | ||||
|             if (ConfigHandler.SaveSubItem(ref config) == 0) | ||||
|             { | ||||
|                 this.DialogResult = DialogResult.OK; | ||||
|                 DialogResult = DialogResult.OK; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|  | @ -81,7 +81,7 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void btnClose_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             this.DialogResult = DialogResult.Cancel; | ||||
|             DialogResult = DialogResult.Cancel; | ||||
|         } | ||||
| 
 | ||||
|         private void btnAdd_Click(object sender, EventArgs e) | ||||
|  |  | |||
|  | @ -304,7 +304,7 @@ namespace v2rayN.Handler | |||
|             { | ||||
|                 VmessItem vmessItem = Utils.DeepCopy(item); | ||||
|                 vmessItem.indexId = string.Empty; | ||||
|                 vmessItem.remarks = string.Format("{0}-clone", item.remarks); | ||||
|                 vmessItem.remarks = $"{item.remarks}-clone"; | ||||
| 
 | ||||
|                 if (vmessItem.configType == EConfigType.Custom) | ||||
|                 { | ||||
|  | @ -469,7 +469,7 @@ namespace v2rayN.Handler | |||
|                 return -1; | ||||
|             } | ||||
|             var ext = Path.GetExtension(fileName); | ||||
|             string newFileName = string.Format("{0}{1}", Utils.GetGUID(), ext); | ||||
|             string newFileName = $"{Utils.GetGUID()}{ext}"; | ||||
|             //newFileName = Path.Combine(Utils.GetTempPath(), newFileName); | ||||
| 
 | ||||
|             try | ||||
|  | @ -489,7 +489,7 @@ namespace v2rayN.Handler | |||
|             vmessItem.configType = EConfigType.Custom; | ||||
|             if (Utils.IsNullOrEmpty(vmessItem.remarks)) | ||||
|             { | ||||
|                 vmessItem.remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString()); | ||||
|                 vmessItem.remarks = $"import custom@{DateTime.Now.ToShortDateString()}"; | ||||
|             } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -814,7 +814,7 @@ namespace v2rayN.Handler | |||
|                 && o.path == n.path | ||||
|                 && o.streamSecurity == n.streamSecurity | ||||
|                 && o.flow == n.flow | ||||
|                 && (remarks ? o.remarks == n.remarks : true); | ||||
|                 && (!remarks || o.remarks == n.remarks); | ||||
|         } | ||||
| 
 | ||||
|         private static int RemoveVmessItem(Config config, int index) | ||||
|  | @ -1051,7 +1051,7 @@ namespace v2rayN.Handler | |||
|             if (lstSsServer == null || lstSsServer.Count <= 0) | ||||
|             { | ||||
|                 var ssSIP008 = Utils.FromJson<SsSIP008>(clipboardData); | ||||
|                 if (ssSIP008 != null && ssSIP008.servers != null && ssSIP008.servers.Count > 0) | ||||
|                 if (ssSIP008?.servers != null && ssSIP008.servers.Count > 0) | ||||
|                 { | ||||
|                     lstSsServer = ssSIP008.servers; | ||||
|                 } | ||||
|  | @ -1154,12 +1154,9 @@ namespace v2rayN.Handler | |||
|                 return -1; | ||||
|             } | ||||
| 
 | ||||
|             foreach (SubItem item in config.subItem) | ||||
|             foreach (var item in config.subItem.Where(item => Utils.IsNullOrEmpty(item.id))) | ||||
|             { | ||||
|                 if (Utils.IsNullOrEmpty(item.id)) | ||||
|                 { | ||||
|                     item.id = Utils.GetGUID(false); | ||||
|                 } | ||||
|                 item.id = Utils.GetGUID(false); | ||||
|             } | ||||
| 
 | ||||
|             ToJsonFile(config); | ||||
|  | @ -1203,12 +1200,9 @@ namespace v2rayN.Handler | |||
|                 return -1; | ||||
|             } | ||||
| 
 | ||||
|             foreach (GroupItem item in config.groupItem) | ||||
|             foreach (var item in config.groupItem.Where(item => Utils.IsNullOrEmpty(item.id))) | ||||
|             { | ||||
|                 if (Utils.IsNullOrEmpty(item.id)) | ||||
|                 { | ||||
|                     item.id = Utils.GetGUID(false); | ||||
|                 } | ||||
|                 item.id = Utils.GetGUID(false); | ||||
|             } | ||||
| 
 | ||||
|             ToJsonFile(config); | ||||
|  |  | |||
|  | @ -29,8 +29,8 @@ namespace v2rayN.Handler | |||
| 
 | ||||
|             public ResultEventArgs(bool success, string msg) | ||||
|             { | ||||
|                 this.Success = success; | ||||
|                 this.Msg = msg; | ||||
|                 Success = success; | ||||
|                 Msg = msg; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -51,7 +51,7 @@ namespace v2rayN.Handler | |||
|                 { | ||||
|                     if (UpdateCompleted != null) | ||||
|                     { | ||||
|                         string msg = string.Format("{0} M/s", value).PadLeft(9, ' '); | ||||
|                         string msg = $"{value} M/s".PadLeft(9, ' '); | ||||
|                         UpdateCompleted(this, new ResultEventArgs(false, msg)); | ||||
|                     } | ||||
|                 }; | ||||
|  | @ -88,7 +88,7 @@ namespace v2rayN.Handler | |||
|                 { | ||||
|                     if (UpdateCompleted != null) | ||||
|                     { | ||||
|                         string msg = string.Format("...{0}%", value); | ||||
|                         string msg = $"...{value}%"; | ||||
|                         UpdateCompleted(this, new ResultEventArgs(value > 100 ? true : false, msg)); | ||||
|                     } | ||||
|                 }; | ||||
|  |  | |||
|  | @ -11,10 +11,8 @@ namespace v2rayN.Handler | |||
|         private Config _config; | ||||
|         private List<CoreInfo> coreInfos; | ||||
| 
 | ||||
|         public static LazyConfig Instance | ||||
|         { | ||||
|             get { return _instance.Value; } | ||||
|         } | ||||
|         public static LazyConfig Instance => _instance.Value; | ||||
| 
 | ||||
|         public void SetConfig(ref Config config) | ||||
|         { | ||||
|             _config = config; | ||||
|  |  | |||
|  | @ -24,10 +24,8 @@ namespace v2rayN.Handler | |||
|         //private List<int> _selecteds; | ||||
|         //private Thread _workThread; | ||||
|         //Action<int, string> _updateFunc; | ||||
|         public static MainFormHandler Instance | ||||
|         { | ||||
|             get { return instance.Value; } | ||||
|         } | ||||
|         public static MainFormHandler Instance => instance.Value; | ||||
| 
 | ||||
|         public Icon GetNotifyIcon(Config config, Icon def) | ||||
|         { | ||||
|             try | ||||
|  | @ -84,7 +82,7 @@ namespace v2rayN.Handler | |||
|                 int index = (int)config.sysProxyType; | ||||
|                 if (index > 0) | ||||
|                 { | ||||
|                     color = (new Color[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1]; | ||||
|                     color = (new[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1]; | ||||
|                 } | ||||
| 
 | ||||
|                 int width = 128; | ||||
|  |  | |||
|  | @ -81,7 +81,7 @@ namespace v2rayN.Handler | |||
| 
 | ||||
|             url = Utils.ToJson(vmessQRCode); | ||||
|             url = Utils.Base64Encode(url); | ||||
|             url = string.Format("{0}{1}", Global.vmessProtocol, url); | ||||
|             url = $"{Global.vmessProtocol}{url}"; | ||||
| 
 | ||||
|             return url; | ||||
|         } | ||||
|  | @ -104,7 +104,7 @@ namespace v2rayN.Handler | |||
|             //new Sip002 | ||||
|             var pw = Utils.Base64Encode($"{item.security}:{item.id}"); | ||||
|             url = $"{pw}@{GetIpv6(item.address)}:{ item.port}"; | ||||
|             url = string.Format("{0}{1}{2}", Global.ssProtocol, url, remark); | ||||
|             url = $"{Global.ssProtocol}{url}{remark}"; | ||||
|             return url; | ||||
|         } | ||||
| 
 | ||||
|  | @ -125,7 +125,7 @@ namespace v2rayN.Handler | |||
|             //new | ||||
|             var pw = Utils.Base64Encode($"{item.security}:{item.id}"); | ||||
|             url = $"{pw}@{GetIpv6(item.address)}:{ item.port}"; | ||||
|             url = string.Format("{0}{1}{2}", Global.socksProtocol, url, remark); | ||||
|             url = $"{Global.socksProtocol}{url}{remark}"; | ||||
|             return url; | ||||
|         } | ||||
| 
 | ||||
|  | @ -145,7 +145,7 @@ namespace v2rayN.Handler | |||
|             item.id, | ||||
|             GetIpv6(item.address), | ||||
|             item.port); | ||||
|             url = string.Format("{0}{1}{2}{3}", Global.trojanProtocol, url, query, remark); | ||||
|             url = $"{Global.trojanProtocol}{url}{query}{remark}"; | ||||
|             return url; | ||||
|         } | ||||
| 
 | ||||
|  | @ -173,7 +173,7 @@ namespace v2rayN.Handler | |||
|             item.id, | ||||
|             GetIpv6(item.address), | ||||
|             item.port); | ||||
|             url = string.Format("{0}{1}{2}{3}", Global.vlessProtocol, url, query, remark); | ||||
|             url = $"{Global.vlessProtocol}{url}{query}{remark}"; | ||||
|             return url; | ||||
|         } | ||||
|         private static string GetIpv6(string address) | ||||
|  | @ -207,40 +207,20 @@ namespace v2rayN.Handler | |||
|             { | ||||
|                 dicQuery.Add("alpn", Utils.UrlEncode(Utils.List2String(item.alpn))); | ||||
|             } | ||||
|             if (!Utils.IsNullOrEmpty(item.network)) | ||||
|             { | ||||
|                 dicQuery.Add("type", item.network); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 dicQuery.Add("type", "tcp"); | ||||
|             } | ||||
| 
 | ||||
|             dicQuery.Add("type", !Utils.IsNullOrEmpty(item.network) ? item.network : "tcp"); | ||||
| 
 | ||||
|             switch (item.network) | ||||
|             { | ||||
|                 case "tcp": | ||||
|                     if (!Utils.IsNullOrEmpty(item.headerType)) | ||||
|                     { | ||||
|                         dicQuery.Add("headerType", item.headerType); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         dicQuery.Add("headerType", "none"); | ||||
|                     } | ||||
|                     dicQuery.Add("headerType", !Utils.IsNullOrEmpty(item.headerType) ? item.headerType : "none"); | ||||
|                     if (!Utils.IsNullOrEmpty(item.requestHost)) | ||||
|                     { | ||||
|                         dicQuery.Add("host", Utils.UrlEncode(item.requestHost)); | ||||
|                     } | ||||
|                     break; | ||||
|                 case "kcp": | ||||
|                     if (!Utils.IsNullOrEmpty(item.headerType)) | ||||
|                     { | ||||
|                         dicQuery.Add("headerType", item.headerType); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         dicQuery.Add("headerType", "none"); | ||||
|                     } | ||||
|                     dicQuery.Add("headerType", !Utils.IsNullOrEmpty(item.headerType) ? item.headerType : "none"); | ||||
|                     if (!Utils.IsNullOrEmpty(item.path)) | ||||
|                     { | ||||
|                         dicQuery.Add("seed", Utils.UrlEncode(item.path)); | ||||
|  | @ -272,14 +252,7 @@ namespace v2rayN.Handler | |||
|                     break; | ||||
| 
 | ||||
|                 case "quic": | ||||
|                     if (!Utils.IsNullOrEmpty(item.headerType)) | ||||
|                     { | ||||
|                         dicQuery.Add("headerType", item.headerType); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         dicQuery.Add("headerType", "none"); | ||||
|                     } | ||||
|                     dicQuery.Add("headerType", !Utils.IsNullOrEmpty(item.headerType) ? item.headerType : "none"); | ||||
|                     dicQuery.Add("quicSecurity", Utils.UrlEncode(item.requestHost)); | ||||
|                     dicQuery.Add("key", Utils.UrlEncode(item.path)); | ||||
|                     break; | ||||
|  | @ -341,11 +314,7 @@ namespace v2rayN.Handler | |||
|                 { | ||||
|                     msg = ResUI.ConfigurationFormatIncorrect; | ||||
| 
 | ||||
|                     vmessItem = ResolveSSLegacy(result); | ||||
|                     if (vmessItem == null) | ||||
|                     { | ||||
|                         vmessItem = ResolveSip002(result); | ||||
|                     } | ||||
|                     vmessItem = ResolveSSLegacy(result) ?? ResolveSip002(result); | ||||
|                     if (vmessItem == null) | ||||
|                     { | ||||
|                         return null; | ||||
|  | @ -361,11 +330,7 @@ namespace v2rayN.Handler | |||
|                 { | ||||
|                     msg = ResUI.ConfigurationFormatIncorrect; | ||||
| 
 | ||||
|                     vmessItem = ResolveSocksNew(result); | ||||
|                     if (vmessItem == null) | ||||
|                     { | ||||
|                         vmessItem = ResolveSocks(result); | ||||
|                     } | ||||
|                     vmessItem = ResolveSocksNew(result) ?? ResolveSocks(result); | ||||
|                     if (vmessItem == null) | ||||
|                     { | ||||
|                         return null; | ||||
|  | @ -407,9 +372,11 @@ namespace v2rayN.Handler | |||
|         private static VmessItem ResolveVmess(string result, out string msg) | ||||
|         { | ||||
|             msg = string.Empty; | ||||
|             VmessItem vmessItem = new VmessItem(); | ||||
|             var vmessItem = new VmessItem | ||||
|             { | ||||
|                 configType = EConfigType.Vmess | ||||
|             }; | ||||
| 
 | ||||
|             vmessItem.configType = EConfigType.Vmess; | ||||
|             result = result.Substring(Global.vmessProtocol.Length); | ||||
|             result = Utils.Base64Decode(result); | ||||
| 
 | ||||
|  | @ -432,14 +399,7 @@ namespace v2rayN.Handler | |||
|             vmessItem.alterId = Utils.ToInt(vmessQRCode.aid); | ||||
|             vmessItem.security = Utils.ToString(vmessQRCode.scy); | ||||
| 
 | ||||
|             if (!Utils.IsNullOrEmpty(vmessQRCode.scy)) | ||||
|             { | ||||
|                 vmessItem.security = vmessQRCode.scy; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 vmessItem.security = Global.DefaultSecurity; | ||||
|             } | ||||
|             vmessItem.security = !Utils.IsNullOrEmpty(vmessQRCode.scy) ? vmessQRCode.scy : Global.DefaultSecurity; | ||||
|             if (!Utils.IsNullOrEmpty(vmessQRCode.net)) | ||||
|             { | ||||
|                 vmessItem.network = vmessQRCode.net; | ||||
|  | @ -598,7 +558,7 @@ namespace v2rayN.Handler | |||
|             //2022-blake3 | ||||
|             if (rawUserInfo.Contains(":")) | ||||
|             { | ||||
|                 string[] userInfoParts = rawUserInfo.Split(new char[] { ':' }, 2); | ||||
|                 string[] userInfoParts = rawUserInfo.Split(new[] { ':' }, 2); | ||||
|                 if (userInfoParts.Length != 2) | ||||
|                 { | ||||
|                     return null; | ||||
|  | @ -610,7 +570,7 @@ namespace v2rayN.Handler | |||
|             { | ||||
|                 // parse base64 UserInfo | ||||
|                 string userInfo = Utils.Base64Decode(rawUserInfo); | ||||
|                 string[] userInfoParts = userInfo.Split(new char[] { ':' }, 2); | ||||
|                 string[] userInfoParts = userInfo.Split(new[] { ':' }, 2); | ||||
|                 if (userInfoParts.Length != 2) | ||||
|                 { | ||||
|                     return null; | ||||
|  | @ -668,8 +628,10 @@ namespace v2rayN.Handler | |||
| 
 | ||||
|         private static VmessItem ResolveSocks(string result) | ||||
|         { | ||||
|             VmessItem vmessItem = new VmessItem(); | ||||
|             vmessItem.configType = EConfigType.Socks; | ||||
|             VmessItem vmessItem = new VmessItem | ||||
|             { | ||||
|                 configType = EConfigType.Socks | ||||
|             }; | ||||
|             result = result.Substring(Global.socksProtocol.Length); | ||||
|             //remark | ||||
|             int indexRemark = result.IndexOf("#"); | ||||
|  | @ -733,7 +695,7 @@ namespace v2rayN.Handler | |||
|             // parse base64 UserInfo | ||||
|             string rawUserInfo = parsedUrl.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped); | ||||
|             string userInfo = Utils.Base64Decode(rawUserInfo); | ||||
|             string[] userInfoParts = userInfo.Split(new char[] { ':' }, 2); | ||||
|             string[] userInfoParts = userInfo.Split(new[] { ':' }, 2); | ||||
|             if (userInfoParts.Length == 2) | ||||
|             { | ||||
|                 server.security = userInfoParts[0]; | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Diagnostics; | ||||
| using System.Linq; | ||||
| using System.Net; | ||||
| using System.Net.Sockets; | ||||
| using System.Threading; | ||||
|  | @ -43,19 +44,19 @@ namespace v2rayN.Handler | |||
| 
 | ||||
|             if (actionType == ESpeedActionType.Ping) | ||||
|             { | ||||
|                 Task.Run(() => RunPing()); | ||||
|                 Task.Run(RunPing); | ||||
|             } | ||||
|             else if (actionType == ESpeedActionType.Tcping) | ||||
|             { | ||||
|                 Task.Run(() => RunTcping()); | ||||
|                 Task.Run(RunTcping); | ||||
|             } | ||||
|             else if (actionType == ESpeedActionType.Realping) | ||||
|             { | ||||
|                 Task.Run(() => RunRealPing()); | ||||
|                 Task.Run(RunRealPing); | ||||
|             } | ||||
|             else if (actionType == ESpeedActionType.Speedtest) | ||||
|             { | ||||
|                 Task.Run(() => RunSpeedTestAsync()); | ||||
|                 Task.Run(RunSpeedTestAsync); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -63,12 +64,8 @@ namespace v2rayN.Handler | |||
|         { | ||||
|             try | ||||
|             { | ||||
|                 foreach (var it in _selecteds) | ||||
|                 foreach (var it in _selecteds.Where(it => it.configType != EConfigType.Custom)) | ||||
|                 { | ||||
|                     if (it.configType == EConfigType.Custom) | ||||
|                     { | ||||
|                         continue; | ||||
|                     } | ||||
|                     try | ||||
|                     { | ||||
|                         Task.Run(() => updateFun(it)); | ||||
|  | @ -252,7 +249,7 @@ namespace v2rayN.Handler | |||
|             { | ||||
|                 return "Timeout"; | ||||
|             } | ||||
|             return string.Format("{0}{1}", time, unit).PadLeft(8, ' '); | ||||
|             return $"{time}{unit}".PadLeft(8, ' '); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -31,13 +31,7 @@ namespace v2rayN.Handler | |||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public List<ServerStatItem> Statistic | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return serverStatistics_.server; | ||||
|             } | ||||
|         } | ||||
|         public List<ServerStatItem> Statistic => serverStatistics_.server; | ||||
| 
 | ||||
|         public StatisticsHandler(Mode.Config config, Action<ulong, ulong, List<ServerStatItem>> update) | ||||
|         { | ||||
|  | @ -68,7 +62,7 @@ namespace v2rayN.Handler | |||
| 
 | ||||
|             GrpcInit(); | ||||
| 
 | ||||
|             Task.Run(() => Run()); | ||||
|             Task.Run(Run); | ||||
|         } | ||||
| 
 | ||||
|         private void GrpcInit() | ||||
|  |  | |||
|  | @ -26,8 +26,8 @@ namespace v2rayN.Handler | |||
| 
 | ||||
|             public ResultEventArgs(bool success, string msg) | ||||
|             { | ||||
|                 this.Success = success; | ||||
|                 this.Msg = msg; | ||||
|                 Success = success; | ||||
|                 Msg = msg; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -209,16 +209,12 @@ namespace v2rayN.Handler | |||
|                     else | ||||
|                     { | ||||
|                         int ret = ConfigHandler.AddBatchServers(ref config, result, id, groupId); | ||||
|                         if (ret > 0) | ||||
|                         { | ||||
|                             _updateFunc(false, $"{hashCode}{ResUI.MsgUpdateSubscriptionEnd}"); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             _updateFunc(false, $"{hashCode}{ResUI.MsgFailedImportSubscription}"); | ||||
|                         } | ||||
|                         _updateFunc(false, | ||||
|                             ret > 0 | ||||
|                                 ? $"{hashCode}{ResUI.MsgUpdateSubscriptionEnd}" | ||||
|                                 : $"{hashCode}{ResUI.MsgFailedImportSubscription}"); | ||||
|                     } | ||||
|                     _updateFunc(false, $"-------------------------------------------------------"); | ||||
|                     _updateFunc(false, "-------------------------------------------------------"); | ||||
|                 } | ||||
|                 //restore system proxy | ||||
|                 if (bSysProxyType) | ||||
|  | @ -331,7 +327,7 @@ namespace v2rayN.Handler | |||
|                 string filePath = string.Empty; | ||||
|                 foreach (string name in coreInfo.coreExes) | ||||
|                 { | ||||
|                     string vName = string.Format("{0}.exe", name); | ||||
|                     string vName = $"{name}.exe"; | ||||
|                     vName = Utils.GetPath(vName); | ||||
|                     if (File.Exists(vName)) | ||||
|                     { | ||||
|  |  | |||
|  | @ -427,14 +427,7 @@ namespace v2rayN.Handler | |||
|                     serversItem.address = node.address; | ||||
|                     serversItem.port = node.port; | ||||
|                     serversItem.password = node.id; | ||||
|                     if (LazyConfig.Instance.GetShadowsocksSecuritys().Contains(node.security)) | ||||
|                     { | ||||
|                         serversItem.method = node.security; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         serversItem.method = "none"; | ||||
|                     } | ||||
|                     serversItem.method = LazyConfig.Instance.GetShadowsocksSecuritys().Contains(node.security) ? node.security : "none"; | ||||
| 
 | ||||
| 
 | ||||
|                     serversItem.ota = false; | ||||
|  | @ -761,10 +754,12 @@ namespace v2rayN.Handler | |||
|                         } | ||||
|                         break; | ||||
|                     case "grpc": | ||||
|                         var grpcSettings = new GrpcSettings(); | ||||
|                         var grpcSettings = new GrpcSettings | ||||
|                         { | ||||
|                             serviceName = node.path, | ||||
|                             multiMode = (node.headerType == Global.GrpcmultiMode) | ||||
|                         }; | ||||
| 
 | ||||
|                         grpcSettings.serviceName = node.path; | ||||
|                         grpcSettings.multiMode = (node.headerType == Global.GrpcmultiMode ? true : false); | ||||
|                         streamSettings.grpcSettings = grpcSettings; | ||||
|                         break; | ||||
|                     default: | ||||
|  | @ -785,7 +780,7 @@ namespace v2rayN.Handler | |||
|                                 string request = Utils.GetEmbedText(Global.v2raySampleHttprequestFileName); | ||||
|                                 string[] arrHost = host.Split(','); | ||||
|                                 string host2 = string.Join("\",\"", arrHost); | ||||
|                                 request = request.Replace("$requestHost$", string.Format("\"{0}\"", host2)); | ||||
|                                 request = request.Replace("$requestHost$", $"\"{host2}\""); | ||||
|                                 //request = request.Replace("$requestHost$", string.Format("\"{0}\"", config.requestHost())); | ||||
| 
 | ||||
|                                 //填入自定义Path | ||||
|  | @ -795,7 +790,7 @@ namespace v2rayN.Handler | |||
|                                     string[] arrPath = node.path.Split(','); | ||||
|                                     pathHttp = string.Join("\",\"", arrPath); | ||||
|                                 } | ||||
|                                 request = request.Replace("$requestPath$", string.Format("\"{0}\"", pathHttp)); | ||||
|                                 request = request.Replace("$requestPath$", $"\"{pathHttp}\""); | ||||
|                                 tcpSettings.header.request = Utils.FromJson<object>(request); | ||||
|                             } | ||||
|                             else if (iobound.Equals("in")) | ||||
|  | @ -882,7 +877,7 @@ namespace v2rayN.Handler | |||
|                 policyObj.system = policySystemSetting; | ||||
|                 v2rayConfig.policy = policyObj; | ||||
| 
 | ||||
|                 if (!v2rayConfig.inbounds.Exists(item => { return item.tag == tag; })) | ||||
|                 if (!v2rayConfig.inbounds.Exists(item => item.tag == tag)) | ||||
|                 { | ||||
|                     Inbounds apiInbound = new Inbounds(); | ||||
|                     Inboundsettings apiInboundSettings = new Inboundsettings(); | ||||
|  | @ -895,7 +890,7 @@ namespace v2rayN.Handler | |||
|                     v2rayConfig.inbounds.Add(apiInbound); | ||||
|                 } | ||||
| 
 | ||||
|                 if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; })) | ||||
|                 if (!v2rayConfig.routing.rules.Exists(item => item.outboundTag == tag)) | ||||
|                 { | ||||
|                     RulesItem apiRoutingRule = new RulesItem | ||||
|                     { | ||||
|  | @ -1171,7 +1166,7 @@ namespace v2rayN.Handler | |||
|                 vmessItem.port = outbound.settings.vnext[0].port; | ||||
|                 vmessItem.id = outbound.settings.vnext[0].users[0].id; | ||||
|                 vmessItem.alterId = outbound.settings.vnext[0].users[0].alterId; | ||||
|                 vmessItem.remarks = string.Format("import@{0}", DateTime.Now.ToShortDateString()); | ||||
|                 vmessItem.remarks = $"import@{DateTime.Now.ToShortDateString()}"; | ||||
| 
 | ||||
|                 //tcp or kcp | ||||
|                 if (outbound.streamSettings != null | ||||
|  | @ -1316,7 +1311,7 @@ namespace v2rayN.Handler | |||
|                 vmessItem.id = inbound.settings.clients[0].id; | ||||
|                 vmessItem.alterId = inbound.settings.clients[0].alterId; | ||||
| 
 | ||||
|                 vmessItem.remarks = string.Format("import@{0}", DateTime.Now.ToShortDateString()); | ||||
|                 vmessItem.remarks = $"import@{DateTime.Now.ToShortDateString()}"; | ||||
| 
 | ||||
|                 //tcp or kcp | ||||
|                 if (inbound.streamSettings != null | ||||
|  |  | |||
|  | @ -175,7 +175,7 @@ namespace v2rayN.Handler | |||
|             string fileName = string.Empty; | ||||
|             foreach (string name in lstCoreTemp) | ||||
|             { | ||||
|                 string vName = string.Format("{0}.exe", name); | ||||
|                 string vName = $"{name}.exe"; | ||||
|                 vName = Utils.GetPath(vName); | ||||
|                 if (File.Exists(vName)) | ||||
|                 { | ||||
|  | @ -217,14 +217,14 @@ namespace v2rayN.Handler | |||
|                         StandardOutputEncoding = Encoding.UTF8 | ||||
|                     } | ||||
|                 }; | ||||
|                 p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => | ||||
|                 p.OutputDataReceived += (sender, e) => | ||||
|                 { | ||||
|                     if (!String.IsNullOrEmpty(e.Data)) | ||||
|                     { | ||||
|                         string msg = e.Data + Environment.NewLine; | ||||
|                         ShowMsg(false, msg); | ||||
|                     } | ||||
|                 }); | ||||
|                 }; | ||||
|                 p.Start(); | ||||
|                 p.PriorityClass = ProcessPriorityClass.High; | ||||
|                 p.BeginOutputReadLine(); | ||||
|  | @ -272,14 +272,14 @@ namespace v2rayN.Handler | |||
|                         StandardOutputEncoding = Encoding.UTF8 | ||||
|                     } | ||||
|                 }; | ||||
|                 p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => | ||||
|                 p.OutputDataReceived += (sender, e) => | ||||
|                 { | ||||
|                     if (!String.IsNullOrEmpty(e.Data)) | ||||
|                     { | ||||
|                         string msg = e.Data + Environment.NewLine; | ||||
|                         ShowMsg(false, msg); | ||||
|                     } | ||||
|                 }); | ||||
|                 }; | ||||
|                 p.Start(); | ||||
|                 p.BeginOutputReadLine(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -25,8 +25,8 @@ namespace v2rayN | |||
|             } | ||||
| 
 | ||||
|             Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); | ||||
|             Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); | ||||
|             AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); | ||||
|             Application.ThreadException += Application_ThreadException; | ||||
|             AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | ||||
| 
 | ||||
| 
 | ||||
|             //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; | ||||
|  |  | |||
|  | @ -13,23 +13,27 @@ namespace v2rayN.Tool | |||
|     { | ||||
|         public static void Setup() | ||||
|         { | ||||
|             Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository(); | ||||
|             var hierarchy = (Hierarchy)LogManager.GetRepository(); | ||||
| 
 | ||||
|             PatternLayout patternLayout = new PatternLayout(); | ||||
|             patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline"; | ||||
|             var patternLayout = new PatternLayout | ||||
|             { | ||||
|                 ConversionPattern = "%date [%thread] %-5level %logger - %message%newline" | ||||
|             }; | ||||
|             patternLayout.ActivateOptions(); | ||||
| 
 | ||||
|             RollingFileAppender roller = new RollingFileAppender(); | ||||
|             roller.AppendToFile = true; | ||||
|             roller.RollingStyle = RollingFileAppender.RollingMode.Date; | ||||
|             roller.DatePattern = "yyyy-MM-dd'.txt'"; | ||||
|             roller.File = Utils.GetPath(@"guiLogs\"); | ||||
|             roller.Layout = patternLayout; | ||||
|             roller.StaticLogFileName = false; | ||||
|             var roller = new RollingFileAppender | ||||
|             { | ||||
|                 AppendToFile = true, | ||||
|                 RollingStyle = RollingFileAppender.RollingMode.Date, | ||||
|                 DatePattern = "yyyy-MM-dd'.txt'", | ||||
|                 File = Utils.GetPath(@"guiLogs\"), | ||||
|                 Layout = patternLayout, | ||||
|                 StaticLogFileName = false | ||||
|             }; | ||||
|             roller.ActivateOptions(); | ||||
|             hierarchy.Root.AddAppender(roller); | ||||
| 
 | ||||
|             MemoryAppender memory = new MemoryAppender(); | ||||
|             var memory = new MemoryAppender(); | ||||
|             memory.ActivateOptions(); | ||||
|             hierarchy.Root.AddAppender(memory); | ||||
| 
 | ||||
|  |  | |||
|  | @ -951,7 +951,7 @@ namespace v2rayN | |||
| 
 | ||||
|         public static string GetDownloadFileName(string url) | ||||
|         { | ||||
|             var fileName = System.IO.Path.GetFileName(url); | ||||
|             var fileName = Path.GetFileName(url); | ||||
|             fileName += "_temp"; | ||||
| 
 | ||||
|             return fileName; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 2dust
						2dust