mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
Added automatic check and install updates
This commit is contained in:
parent
ea5cd631a7
commit
4d3f757a99
3 changed files with 6103 additions and 1499 deletions
10
Crypto Notepad/Form1.Designer.cs
generated
10
Crypto Notepad/Form1.Designer.cs
generated
|
|
@ -357,14 +357,14 @@ public void InitializeComponent()
|
|||
// changeKeyToolStripMenuItem
|
||||
//
|
||||
this.changeKeyToolStripMenuItem.Name = "changeKeyToolStripMenuItem";
|
||||
this.changeKeyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.changeKeyToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
|
||||
this.changeKeyToolStripMenuItem.Text = "Change Key";
|
||||
this.changeKeyToolStripMenuItem.Click += new System.EventHandler(this.changeKeyToolStripMenuItem_Click);
|
||||
//
|
||||
// settingsToolStripMenuItem
|
||||
//
|
||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
|
||||
this.settingsToolStripMenuItem.Text = "Settings";
|
||||
this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click);
|
||||
//
|
||||
|
|
@ -388,10 +388,10 @@ public void InitializeComponent()
|
|||
//
|
||||
// сheckForUpdatesToolStripMenuItem
|
||||
//
|
||||
this.сheckForUpdatesToolStripMenuItem.Enabled = false;
|
||||
this.сheckForUpdatesToolStripMenuItem.Name = "сheckForUpdatesToolStripMenuItem";
|
||||
this.сheckForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||
this.сheckForUpdatesToolStripMenuItem.Text = "Сheck for Updates...";
|
||||
this.сheckForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.сheckForUpdatesToolStripMenuItem_Click);
|
||||
//
|
||||
// оПрограммеToolStripMenuItem
|
||||
//
|
||||
|
|
@ -493,11 +493,11 @@ public void InitializeComponent()
|
|||
//
|
||||
// OpenFile
|
||||
//
|
||||
this.OpenFile.Filter = "Encryption files (*.enp)|*.enp";
|
||||
this.OpenFile.Filter = "Crypto Notepad (*.enp)|*.enp|All files (*.*)|*.*";
|
||||
//
|
||||
// SaveFile
|
||||
//
|
||||
this.SaveFile.Filter = "Encryption files (*.enp)|*.enp";
|
||||
this.SaveFile.Filter = "Crypto Notepad (*.enp)|*.enp";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
|
@ -70,7 +74,16 @@ void SaltMAC()
|
|||
if (OpenFile.ShowDialog() != DialogResult.OK) return;
|
||||
{
|
||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||
|
||||
if (OpenFile.FileName.Contains(".txt"))
|
||||
{
|
||||
customRTB.Text = opnfile;
|
||||
toolStripStatusLabel1.Text = NameWithotPath;
|
||||
toolStripStatusLabel1.ToolTipText = (OpenFile.FileName);
|
||||
return;
|
||||
}
|
||||
|
||||
f2.ShowDialog();
|
||||
if (Form2.OkPressed == false)
|
||||
{
|
||||
|
|
@ -383,20 +396,47 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
if (ps.ShowToolbar == true)
|
||||
{
|
||||
panel2.Visible = true;
|
||||
//int h = customRTB.Height;
|
||||
//h -= 23;
|
||||
//customRTB.Height = h;
|
||||
//customRTB.Location = new Point(0, 48);
|
||||
}
|
||||
|
||||
if (ps.AutoCheckUpdate == true)
|
||||
{
|
||||
Thread up = new Thread(() => сheckForUpdates(false));
|
||||
up.Start();
|
||||
}
|
||||
|
||||
LineAndColumn();
|
||||
|
||||
SaltMAC();
|
||||
|
||||
DeleteUpdateFiles();
|
||||
|
||||
if (args.Length > 1)
|
||||
{
|
||||
openAsotiations();
|
||||
openAsotiations();
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteUpdateFiles()
|
||||
{
|
||||
string exePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\";
|
||||
string UpdaterExe = exePath + "Updater.exe";
|
||||
string UpdateZip = exePath + "Crypto-Notepad-Update.zip";
|
||||
string ZipDll = exePath + "Ionic.Zip.dll";
|
||||
|
||||
if (File.Exists(UpdaterExe))
|
||||
{
|
||||
File.Delete(UpdaterExe);
|
||||
}
|
||||
|
||||
SaltMAC();
|
||||
if (File.Exists(UpdateZip))
|
||||
{
|
||||
File.Delete(UpdateZip);
|
||||
}
|
||||
|
||||
if (File.Exists(ZipDll))
|
||||
{
|
||||
File.Delete(ZipDll);
|
||||
}
|
||||
}
|
||||
|
||||
private void очиститьToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
@ -418,6 +458,7 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Form2.OkPressed = false;
|
||||
}
|
||||
|
||||
|
|
@ -486,7 +527,7 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
|
||||
}
|
||||
|
||||
private void УдалитьФайлToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
private async void УдалитьФайлToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
if (filename != "Unnamed.enp")
|
||||
{
|
||||
|
|
@ -497,6 +538,12 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
File.Delete(filename);
|
||||
toolStripStatusLabel1.Text = filename + " deleted";
|
||||
customRTB.Clear();
|
||||
key = "";
|
||||
pictureBox11.Enabled = false;
|
||||
filename = "Unnamed.enp";
|
||||
await Task.Delay(4000);
|
||||
toolStripStatusLabel1.Text = "Ready";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -513,7 +560,7 @@ private void MainWindow_Load(object sender, EventArgs e)
|
|||
{
|
||||
if (filename != "Unnamed.enp")
|
||||
{
|
||||
System.Diagnostics.Process.Start("explorer.exe", @"/select, " + filename);
|
||||
Process.Start("explorer.exe", @"/select, " + filename);
|
||||
}
|
||||
if (filename == "Unnamed.enp")
|
||||
{
|
||||
|
|
@ -722,7 +769,6 @@ private async void MainWindow_Activated(object sender, EventArgs e)
|
|||
toolStripStatusLabel1.Text = "Ready";
|
||||
}
|
||||
|
||||
|
||||
if (key == "")
|
||||
{
|
||||
pictureBox11.Enabled = false;
|
||||
|
|
@ -891,6 +937,58 @@ private void pictureBox1_MouseLeave(object sender, EventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void сheckForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Thread up = new Thread(() => сheckForUpdates(true));
|
||||
up.Start();
|
||||
}
|
||||
|
||||
public void сheckForUpdates(bool autoCheck)
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
Stream stream = client.OpenRead("https://raw.githubusercontent.com/Sigmanor/Crypto-Notepad/master/version.txt");
|
||||
StreamReader reader = new StreamReader(stream);
|
||||
string content = reader.ReadToEnd();
|
||||
string version = Application.ProductVersion;
|
||||
string exePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\";
|
||||
|
||||
int ver = Convert.ToInt32(version.Replace(".", "")), con = Convert.ToInt32(content.Replace(".", ""));
|
||||
|
||||
if (con != ver)
|
||||
{
|
||||
MainMenu.Invoke((Action)delegate
|
||||
{
|
||||
using (new CenterWinDialog(this))
|
||||
{
|
||||
DialogResult res = new DialogResult();
|
||||
|
||||
res = MessageBox.Show("New version is avaliable. Install it now?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
|
||||
|
||||
if (res == DialogResult.Yes)
|
||||
{
|
||||
File.WriteAllBytes(exePath + "Ionic.Zip.dll", Properties.Resources.Ionic_Zip);
|
||||
File.WriteAllBytes(exePath + "Updater.exe", Properties.Resources.Updater);
|
||||
|
||||
var pr = new Process();
|
||||
pr.StartInfo.FileName = exePath + "Updater.exe";
|
||||
pr.StartInfo.Arguments = "/u";
|
||||
pr.Start();
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (con == ver && autoCheck == true)
|
||||
{
|
||||
MainMenu.Invoke((Action)delegate
|
||||
{
|
||||
using (new CenterWinDialog(this))
|
||||
{
|
||||
MessageBox.Show("No update avaliable.", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue