mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-06 00:13:33 +00:00
Compare commits
2 Commits
ed66fabbd0
...
3324af7364
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3324af7364 | ||
|
|
ab3dd1b0c7 |
@@ -131,6 +131,12 @@
|
||||
<Compile Include="src\ConnectionSettings.Designer.cs">
|
||||
<DependentUpon>ConnectionSettings.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="src\UninstallForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\UninstallForm.Designer.cs">
|
||||
<DependentUpon>UninstallForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="src\ListViewExtended.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -321,6 +327,10 @@
|
||||
<EmbeddedResource Include="src\ConnectionSettings.resx">
|
||||
<DependentUpon>ConnectionSettings.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="src\UninstallForm.resx">
|
||||
<DependentUpon>UninstallForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="src\KVMViewerExtra.resx">
|
||||
<DependentUpon>KVMViewerExtra.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -119,23 +119,37 @@ namespace MeshCentralRouter
|
||||
try { Registry.ClassesRoot.DeleteSubKeyTree("mcrouter"); } catch (Exception) { }
|
||||
}
|
||||
|
||||
private void unHookRouterEx()
|
||||
{
|
||||
if (IsAdministrator() == false)
|
||||
{
|
||||
// Restart program and run as admin
|
||||
var exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo(exeName, "-uninstall");
|
||||
startInfo.Verb = "runas";
|
||||
try { installProcess = System.Diagnostics.Process.Start(startInfo); } catch (Exception) { return; }
|
||||
installTimer.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
unHookRouter();
|
||||
}
|
||||
}
|
||||
|
||||
private void hookRouterEx()
|
||||
{
|
||||
if (IsAdministrator() == false)
|
||||
{
|
||||
|
||||
// Restart program and run as admin
|
||||
var exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo(exeName, "-install");
|
||||
startInfo.Verb = "runas";
|
||||
try { installProcess = System.Diagnostics.Process.Start(startInfo); } catch (Exception) { return; }
|
||||
installTimer.Enabled = true;
|
||||
installButton.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
hookRouter();
|
||||
installButton.Visible = !isRouterHooked();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +158,15 @@ namespace MeshCentralRouter
|
||||
if ((installProcess == null) || (installProcess.HasExited == true))
|
||||
{
|
||||
installTimer.Enabled = false;
|
||||
installButton.Visible = !isRouterHooked();
|
||||
installButton.Visible = true;
|
||||
if (isRouterHooked())
|
||||
{
|
||||
installButton.Text = "Uninstall";
|
||||
}
|
||||
else
|
||||
{
|
||||
installButton.Text = "Install";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +364,16 @@ namespace MeshCentralRouter
|
||||
}
|
||||
|
||||
// Check MeshCentral .mcrouter hook
|
||||
installButton.Visible = !isRouterHooked();
|
||||
installButton.Visible = true;
|
||||
if (isRouterHooked())
|
||||
{
|
||||
installButton.Text = "Uninstall";
|
||||
}
|
||||
else
|
||||
{
|
||||
installButton.Text = "Install";
|
||||
}
|
||||
|
||||
|
||||
// Right click action
|
||||
deviceDoubleClickAction = int.Parse(Settings.GetRegValue("DevDoubleClickClickAction", "0"));
|
||||
@@ -1888,8 +1919,15 @@ namespace MeshCentralRouter
|
||||
|
||||
private void installButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
InstallForm form = new InstallForm();
|
||||
if (form.ShowDialog(this) == DialogResult.OK) { hookRouterEx(); }
|
||||
if (isRouterHooked())
|
||||
{
|
||||
UninstallForm form = new UninstallForm();
|
||||
if (form.ShowDialog(this) == DialogResult.OK) { unHookRouterEx(); }
|
||||
} else
|
||||
{
|
||||
InstallForm form = new InstallForm();
|
||||
if (form.ShowDialog(this) == DialogResult.OK) { hookRouterEx(); }
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeLanguage(string lang)
|
||||
|
||||
102
src/UninstallForm.Designer.cs
generated
Normal file
102
src/UninstallForm.Designer.cs
generated
Normal file
@@ -0,0 +1,102 @@
|
||||
namespace MeshCentralRouter
|
||||
{
|
||||
partial class UninstallForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UninstallForm));
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = global::MeshCentralRouter.Properties.Resources.xinstall;
|
||||
resources.ApplyResources(this.pictureBox1, "pictureBox1");
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.UseVisualStyleBackColor = true;
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
resources.ApplyResources(this.groupBox1, "groupBox1");
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.pictureBox1);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
resources.ApplyResources(this.label1, "label1");
|
||||
this.label1.Name = "label1";
|
||||
//
|
||||
// UninstallForm
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.okButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "UninstallForm";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
52
src/UninstallForm.cs
Normal file
52
src/UninstallForm.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2009-2022 Intel Corporation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MeshCentralRouter
|
||||
{
|
||||
public partial class UninstallForm : Form
|
||||
{
|
||||
public UninstallForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
Translate.TranslateControl(this);
|
||||
|
||||
// Load customizations
|
||||
FileInfo selfExe = new FileInfo(Assembly.GetExecutingAssembly().Location);
|
||||
try { pictureBox1.Image = (Bitmap)Image.FromFile(Path.Combine(selfExe.Directory.FullName, @"customization\install.png")); } catch (Exception) { }
|
||||
try {
|
||||
string[] lines = File.ReadAllLines(Path.Combine(selfExe.Directory.FullName, @"customization\customize.txt"));
|
||||
if (lines[2] != "") { groupBox1.Text = lines[2]; }
|
||||
if (lines[3] != "") { label1.Text = lines[3]; }
|
||||
} catch (Exception) { }
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void cancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
1967
src/UninstallForm.resx
Normal file
1967
src/UninstallForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user