diff --git a/v2rayN/v2rayN/Forms/MainForm.Designer.cs b/v2rayN/v2rayN/Forms/MainForm.Designer.cs
index 914921d4..0a309df6 100644
--- a/v2rayN/v2rayN/Forms/MainForm.Designer.cs
+++ b/v2rayN/v2rayN/Forms/MainForm.Designer.cs
@@ -64,9 +64,9 @@
this.menuExport2ServerConfig = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2ShareUrl = new System.Windows.Forms.ToolStripMenuItem();
this.menuExport2SubContent = new System.Windows.Forms.ToolStripMenuItem();
- this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
this.tabGroup = new System.Windows.Forms.TabControl();
this.qrCodeControl = new v2rayN.Forms.QRCodeControl();
+ this.tsbServer = new System.Windows.Forms.ToolStripDropDownButton();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.gbMsgTitle = new System.Windows.Forms.GroupBox();
@@ -101,7 +101,6 @@
this.menuUpdateSubViaProxy = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.menuExit = new System.Windows.Forms.ToolStripMenuItem();
- this.bgwScan = new System.ComponentModel.BackgroundWorker();
this.panel1 = new System.Windows.Forms.Panel();
this.tsMain = new System.Windows.Forms.ToolStrip();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
@@ -227,7 +226,6 @@
this.menuExport2ShareUrl,
this.menuExport2SubContent});
this.cmsLv.Name = "cmsLv";
- this.cmsLv.OwnerItem = this.tsbServer;
resources.ApplyResources(this.cmsLv, "cmsLv");
//
// menuAddVmessServer
@@ -412,13 +410,6 @@
resources.ApplyResources(this.menuExport2SubContent, "menuExport2SubContent");
this.menuExport2SubContent.Click += new System.EventHandler(this.menuExport2SubContent_Click);
//
- // tsbServer
- //
- this.tsbServer.DropDown = this.cmsLv;
- this.tsbServer.Image = global::v2rayN.Properties.Resources.server;
- resources.ApplyResources(this.tsbServer, "tsbServer");
- this.tsbServer.Name = "tsbServer";
- //
// tabGroup
//
resources.ApplyResources(this.tabGroup, "tabGroup");
@@ -431,6 +422,13 @@
resources.ApplyResources(this.qrCodeControl, "qrCodeControl");
this.qrCodeControl.Name = "qrCodeControl";
//
+ // tsbServer
+ //
+ this.tsbServer.DropDown = this.cmsLv;
+ this.tsbServer.Image = global::v2rayN.Properties.Resources.server;
+ resources.ApplyResources(this.tsbServer, "tsbServer");
+ this.tsbServer.Name = "tsbServer";
+ //
// splitContainer1
//
resources.ApplyResources(this.splitContainer1, "splitContainer1");
@@ -677,12 +675,6 @@
resources.ApplyResources(this.menuExit, "menuExit");
this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
//
- // bgwScan
- //
- this.bgwScan.WorkerReportsProgress = true;
- this.bgwScan.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bgwScan_DoWork);
- this.bgwScan.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bgwScan_ProgressChanged);
- //
// panel1
//
resources.ApplyResources(this.panel1, "panel1");
@@ -1027,7 +1019,6 @@
private System.Windows.Forms.ToolStripDropDownButton tsbHelp;
private System.Windows.Forms.ToolStripMenuItem tsbAbout;
private System.Windows.Forms.ToolStripMenuItem menuAddServers2;
- private System.ComponentModel.BackgroundWorker bgwScan;
private System.Windows.Forms.ToolStripMenuItem menuScanScreen;
private System.Windows.Forms.ToolStripMenuItem menuScanScreen2;
private System.Windows.Forms.ToolStripDropDownButton tsbSub;
diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs
index 820ffae2..c6c7e02c 100644
--- a/v2rayN/v2rayN/Forms/MainForm.cs
+++ b/v2rayN/v2rayN/Forms/MainForm.cs
@@ -1008,9 +1008,34 @@ namespace v2rayN.Forms
}
private void menuScanScreen_Click(object sender, EventArgs e)
+ {
+ _ = ScanScreenTaskAsync();
+ }
+
+ public async Task ScanScreenTaskAsync()
{
HideForm();
- bgwScan.RunWorkerAsync();
+
+ string result = await Task.Run(() =>
+ {
+ return Utils.ScanScreen();
+ });
+
+ ShowForm();
+
+ if (Utils.IsNullOrEmpty(result))
+ {
+ UI.ShowWarning(UIRes.I18N("NoValidQRcodeFound"));
+ }
+ else
+ {
+ int ret = MainFormHandler.Instance.AddBatchServers(config, result, "", groupId);
+ if (ret > 0)
+ {
+ RefreshServers();
+ UI.Show(UIRes.I18N("SuccessfullyImportedServerViaScan"));
+ }
+ }
}
private void menuUpdateSubscriptions_Click(object sender, EventArgs e)
@@ -1422,37 +1447,6 @@ namespace v2rayN.Forms
}
#endregion
- #region ScanScreen
-
-
- private void bgwScan_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
- {
- string ret = Utils.ScanScreen();
- bgwScan.ReportProgress(0, ret);
- }
-
- private void bgwScan_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
- {
- ShowForm();
-
- string result = Convert.ToString(e.UserState);
- if (Utils.IsNullOrEmpty(result))
- {
- UI.ShowWarning(UIRes.I18N("NoValidQRcodeFound"));
- }
- else
- {
- int ret = MainFormHandler.Instance.AddBatchServers(config, result, "", groupId);
- if (ret > 0)
- {
- RefreshServers();
- UI.Show(UIRes.I18N("SuccessfullyImportedServerViaScan"));
- }
- }
- }
-
- #endregion
-
#region 订阅
private void tsbSubSetting_Click(object sender, EventArgs e)
{
diff --git a/v2rayN/v2rayN/Forms/MainForm.resx b/v2rayN/v2rayN/Forms/MainForm.resx
index b7d19fed..7a643648 100644
--- a/v2rayN/v2rayN/Forms/MainForm.resx
+++ b/v2rayN/v2rayN/Forms/MainForm.resx
@@ -302,18 +302,6 @@
Export subscription (base64) share to clipboard
-
- Magenta
-
-
- 64, 53
-
-
- Servers
-
-
- ImageAboveText
-
356, 622
@@ -464,6 +452,18 @@
0
+
+ Magenta
+
+
+ 64, 53
+
+
+ Servers
+
+
+ ImageAboveText
+
Fill
@@ -510,7 +510,7 @@
0
- 603, 17
+ 493, 20
227, 22
@@ -549,7 +549,7 @@
Set message filters
- 228, 136
+ 228, 158
cmsMsgBox
@@ -824,9 +824,6 @@
True
-
- 498, 17
-
Top
@@ -1478,12 +1475,6 @@
System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- bgwScan
-
-
- System.ComponentModel.BackgroundWorker, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
toolStripSeparator4