diff --git a/Updater/App.config b/Updater/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Updater/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Updater/Form1.Designer.cs b/Updater/Form1.Designer.cs new file mode 100644 index 0000000..c423a94 --- /dev/null +++ b/Updater/Form1.Designer.cs @@ -0,0 +1,106 @@ +namespace Updater +{ + partial class UpdateForm + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button1 = new System.Windows.Forms.Button(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Location = new System.Drawing.Point(76, 29); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(215, 35); + this.label1.TabIndex = 2; + this.label1.Text = "Application will be updated and reopened."; + // + // panel1 + // + this.panel1.BackColor = System.Drawing.SystemColors.Window; + this.panel1.Controls.Add(this.pictureBox1); + this.panel1.Controls.Add(this.label1); + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(294, 83); + this.panel1.TabIndex = 4; + // + // pictureBox1 + // + this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pictureBox1.Image = global::Updater.Properties.Resources.inbox_download; + this.pictureBox1.Location = new System.Drawing.Point(10, 10); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(60, 60); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(212, 92); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 5; + this.button1.Text = "OK"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // UpdateForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(294, 121); + this.Controls.Add(this.button1); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "UpdateForm"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Crypto Notepad Updater"; + this.Load += new System.EventHandler(this.Form1_Load); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Panel panel1; + } +} + diff --git a/Updater/Form1.cs b/Updater/Form1.cs new file mode 100644 index 0000000..784f2d3 --- /dev/null +++ b/Updater/Form1.cs @@ -0,0 +1,88 @@ +using System; +using Ionic.Zip; +using System.Windows.Forms; +using System.IO; +using System.Diagnostics; +using System.ComponentModel; +using System.Net; +using System.Reflection; + +namespace Updater +{ + public partial class UpdateForm : Form + { + string[] arg; + string exePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\"; + bool okButton = false; + + public UpdateForm(string[] args) + { + arg = args; + InitializeComponent(); + } + + #region ExtractZip + public void ExtractFileToDirectory(string zipFileName, string outputDirectory) + { + ZipFile zip = ZipFile.Read(zipFileName); + Directory.CreateDirectory(outputDirectory); + zip.ExtractAll(outputDirectory, ExtractExistingFileAction.OverwriteSilently); + } + #endregion + + void downloader_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) + { + if (e.Error != null) + { + System.Media.SystemSounds.Beep.Play(); + okButton = true; + button1.Enabled = true; + label1.Text = "There was some errors during the update, please try again later."; + } + + if (e.Error == null) + { + var pr = new Process(); + ExtractFileToDirectory(exePath + "Crypto-Notepad-Update.zip", exePath); + pr.StartInfo.FileName = exePath + "Crypto Notepad.exe"; + pr.Start(); + Application.Exit(); + } + } + + private void Form1_Load(object sender, EventArgs e) + { + if (arg.Length == 0) + { + this.Close(); + } + + else if (arg[0] == "/u") + { + return; + } + } + + private void button1_Click(object sender, EventArgs e) + { + if (okButton == false) + { + var pr = new Process(); + button1.Enabled = false; + WebClient webClient = new WebClient(); + webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(downloader_DownloadFileCompleted); + webClient.DownloadFileAsync(new Uri("https://raw.githubusercontent.com/Sigmanor/Crypto-Notepad/master/Crypto-Notepad-Update.zip"), exePath + "Crypto-Notepad-Update.zip"); + } + + if (okButton == true) + { + var pr = new Process(); + pr.StartInfo.FileName = exePath + "Crypto Notepad.exe"; + pr.Start(); + Application.Exit(); + } + } + + + } +} diff --git a/Updater/Form1.resx b/Updater/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Updater/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Updater/Ionic.Zip.dll b/Updater/Ionic.Zip.dll new file mode 100644 index 0000000..95fa928 Binary files /dev/null and b/Updater/Ionic.Zip.dll differ diff --git a/Updater/Program.cs b/Updater/Program.cs new file mode 100644 index 0000000..372be53 --- /dev/null +++ b/Updater/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Updater +{ + static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new UpdateForm(args)); + } + } +} diff --git a/Updater/Properties/AssemblyInfo.cs b/Updater/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2752a04 --- /dev/null +++ b/Updater/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Управление общими сведениями о сборке осуществляется с помощью +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("Updater")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Updater")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Параметр ComVisible со значением FALSE делает типы в сборке невидимыми +// для COM-компонентов. Если требуется обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("7b347593-6f3c-4308-bb94-51d35677c0c4")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Updater/Properties/Resources.Designer.cs b/Updater/Properties/Resources.Designer.cs new file mode 100644 index 0000000..081ca54 --- /dev/null +++ b/Updater/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Updater.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Updater.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap inbox_download { + get { + object obj = ResourceManager.GetObject("inbox_download", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Updater/Properties/Resources.resx b/Updater/Properties/Resources.resx new file mode 100644 index 0000000..726d6c6 --- /dev/null +++ b/Updater/Properties/Resources.resx @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m + dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAVTSURBVFhHvZV7TJV1GMddWP8019wEuthf1dqSmk0S + 3ThgIClIYB5M8JKCaYBIOhVQUK6K5oWroiQcRAkU4yoHDne8NATKzHXjOLG01GRobbX117fn+77nvHbg + QBLob/vs/Hie7/P9PnvhvEwYxXnKOcWIrJ77mLT3R0zJ6IVjpgrvrLFHDbXqyPieyTRP77wHx6xevJBj + xou5Kryzxp5lgcnqyPgep2fFPOn8PSX0pUNX8XKeCu+ssUcNterI+B5lgfiOAbySdw2vHbmGafkqvLPG + 3iNfYHNbP1yO9mF6YR/etMA7a+w98gWiW/rxluE63I5dxywLvLPG3nguMHFqqtH4fFoDnkutV4ynJNYi + wnQXuhM/w7PEFtbYo4ZaznCWHvRSLUd3Jk3dacLHrb8jsmkA4aZ+4S5Cqm/Bu/QGfMpsYY09aqjlDGfp + QS/V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ZwcLIXYIRkemHmfrSnDxm15c/PoHW6TGHjUjeTCDWczUFsiJkAUaDuBCbgguHFomLLfD + MnQeXIKSqlaUVjagtMJoi9TYo2YkD2Ywi5naAtnh7uitTUPX4RXoOrJyWL7M/wB5G+YgJ8oduYNgjT1q + 7M1qSAazmKktkLVWh6uV8bhUGDoCYbhsCEO3BDQfCEZLRogNrLFHDbX2PVSYxcx/LeCBn6o2wVwajt4R + YN9cFoGrJ+3D3sN4MIuZ1gUc01bMPp+5RoeMD90fnjWDsKcZBmYxk9lcgK/DaYKn4P2YYBYzlVcx/yHw + wm34SB4HzJLMCRP/ARSfaL/X5EbIAAAAAElFTkSuQmCC + + + \ No newline at end of file diff --git a/Updater/Properties/Settings.Designer.cs b/Updater/Properties/Settings.Designer.cs new file mode 100644 index 0000000..a73b3cf --- /dev/null +++ b/Updater/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Updater.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Updater/Properties/Settings.settings b/Updater/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Updater/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Updater/Resources/inbox_download.png b/Updater/Resources/inbox_download.png new file mode 100644 index 0000000..af90840 Binary files /dev/null and b/Updater/Resources/inbox_download.png differ diff --git a/Updater/Updater.csproj b/Updater/Updater.csproj new file mode 100644 index 0000000..08118fd --- /dev/null +++ b/Updater/Updater.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {7B347593-6F3C-4308-BB94-51D35677C0C4} + WinExe + Properties + Updater + Updater + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + inbox_download.ico + + + + .\Ionic.Zip.dll + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Updater/inbox_download.ico b/Updater/inbox_download.ico new file mode 100644 index 0000000..c8fdd1d Binary files /dev/null and b/Updater/inbox_download.ico differ