Skip to content

Commit 1838c15

Browse files
unknounkno
unkno
authored and
unkno
committed
Added auto reconnect at app start
1 parent 4aac3ac commit 1838c15

File tree

5 files changed

+84
-7
lines changed

5 files changed

+84
-7
lines changed

WifiAdbHhelper/Form1.cs

+39-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,34 @@ private void buttonKillServer_Click(object sender, EventArgs e)
5757
//notifyBGW("kill-adb");
5858
}
5959
private void metroButton3_Click(object sender, EventArgs e)
60+
{
61+
var r = new Thread(() =>
62+
{
63+
vysorStart();
64+
});
65+
r.IsBackground = true;
66+
r.Start();
67+
}
68+
void vysorStart()
6069
{
6170
try
6271
{
63-
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Vysor\Vysor.exe");
72+
if (InvokeRequired) metroProgressBar1.Invoke(new Action(() => metroProgressBar1.Visible = true));
73+
var procchec1 = Process.GetProcessesByName("Vysor");
74+
if (procchec1.Length !=null)
75+
{
76+
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Vysor\Vysor.exe");
77+
while (true)
78+
{
79+
var proccheck = Process.GetProcessesByName("Vysor");
80+
if (proccheck.Length >= 5)
81+
{
82+
83+
break;
84+
}
85+
}
86+
}
87+
if (InvokeRequired) metroProgressBar1.Invoke(new Action(() => metroProgressBar1.Visible = false));
6488
timerAutoUpdateList.Start();
6589
}
6690
catch (Exception ea)
@@ -175,6 +199,7 @@ private void Form1_Load(object sender, EventArgs e)
175199
ThemeFirst();
176200
mainVars.devicePath();
177201
SetTimerInterval();
202+
AutoreconAtStart();
178203
var r = new Thread(() =>
179204
{
180205
string Ver = checkUpd.MsgUpdateAvailable();
@@ -505,6 +530,19 @@ private void buttontest_Click(object sender, EventArgs e)
505530
{
506531
checkUpd.UpdaterProg(swMsgDwnld);
507532
}
533+
private void AutoreconAtStart()
534+
{
535+
if (INI.KeyExists(consts.allSettings[5], consts.allSettings[0]))
536+
{
537+
bool autorecoStat = bool.Parse(INI.ReadINI(consts.allSettings[0], consts.allSettings[5]));
538+
if (autorecoStat)
539+
{
540+
vysorStart();
541+
AdbOperationCreator(consts.comADB[2] + textboxIP.Text, consts.mesADB[2]);
542+
543+
}
544+
}
545+
}
508546
private void timer1_Tick_1(object sender, EventArgs e)
509547
{
510548
if (labeladbpop.Left > -labeladbpop.Width)

WifiAdbHhelper/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
3333
// используя "*", как показано ниже:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.1.1.7")]
36-
[assembly: AssemblyFileVersion("3.1.1.7")]
35+
[assembly: AssemblyVersion("3.1.1.9")]
36+
[assembly: AssemblyFileVersion("3.1.1.9")]

WifiAdbHhelper/consts.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public static string setFolderPath() {
4242
public static string[] notificationMessagesHeader = new string[] { };
4343

4444
public static readonly string[] setThemeKeys = new string[] { "ThemeStyle", "ThemeColor" };
45-
public static readonly string[] allSettings = new string[] { "Settings","LastIP","AutoUpdate","DevicePath","TimerInterval" };
45+
public static readonly string[] allSettings = new string[] { "Settings","LastIP","AutoUpdate","DevicePath","TimerInterval","AutoConnect" };
4646
}
4747
}

WifiAdbHhelper/settingForm.Designer.cs

+30-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WifiAdbHhelper/settingForm.cs

+12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ private void settingForm_Load(object sender, EventArgs e)
3939
numericUpDown1.ForeColor = consts.listViewColors2[getThemeFromIniId() - 1];
4040
numericUpDown1.Value = SettableVars.DevicesUpdatingTiming/1000;
4141
textBoxDevicePath.Text = SettableVars.DevicePathFile;
42+
if (form1.INI.KeyExists(consts.allSettings[5], consts.allSettings[0]))
43+
metroToggle1.Checked = bool.Parse(form1.INI.ReadINI(consts.allSettings[0], consts.allSettings[5]));
4244
//form1.getThemeFromINI();
4345
}
4446
int getThemeFromIniId()
@@ -146,5 +148,15 @@ private void labelVersion_Click(object sender, EventArgs e)
146148
{
147149

148150
}
151+
152+
private void metroToggle1_CheckedChanged(object sender, EventArgs e)
153+
{
154+
if (!form1.INI.KeyExists("IsFirstEnable", consts.allSettings[0]))
155+
{
156+
form1.INI.Write(consts.allSettings[0], "IsFirstEnable", "true");
157+
MetroMessageBox.Show(this, "By enabling this function, each time you start this program, vysor will automatically start and connect to the last device!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
158+
}
159+
form1.INI.Write(consts.allSettings[0], consts.allSettings[5], metroToggle1.CheckState==CheckState.Checked? "true":"false");
160+
}
149161
}
150162
}

0 commit comments

Comments
 (0)