From e81e6f412532a657efbe8b2df643f2a0ac68b2af Mon Sep 17 00:00:00 2001 From: YonghoAhn Date: Tue, 22 Sep 2020 03:56:00 +0900 Subject: [PATCH 1/3] [Add] Created ElectronicObserver Automatic Updater project. This project will get files from github releases and automatically replace EO files. --- ElectronicObserver.sln | 10 +- ElectronicObserverUpdater/App.config | 6 + .../ElectronicObserverUpdater.csproj | 83 ++++++++++++ ElectronicObserverUpdater/Form1.Designer.cs | 47 +++++++ ElectronicObserverUpdater/Form1.cs | 20 +++ ElectronicObserverUpdater/Form1.resx | 120 ++++++++++++++++++ ElectronicObserverUpdater/Program.cs | 22 ++++ .../Properties/AssemblyInfo.cs | 36 ++++++ .../Properties/Resources.Designer.cs | 71 +++++++++++ .../Properties/Resources.resx | 117 +++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Properties/Settings.settings | 7 + 12 files changed, 567 insertions(+), 2 deletions(-) create mode 100644 ElectronicObserverUpdater/App.config create mode 100644 ElectronicObserverUpdater/ElectronicObserverUpdater.csproj create mode 100644 ElectronicObserverUpdater/Form1.Designer.cs create mode 100644 ElectronicObserverUpdater/Form1.cs create mode 100644 ElectronicObserverUpdater/Form1.resx create mode 100644 ElectronicObserverUpdater/Program.cs create mode 100644 ElectronicObserverUpdater/Properties/AssemblyInfo.cs create mode 100644 ElectronicObserverUpdater/Properties/Resources.Designer.cs create mode 100644 ElectronicObserverUpdater/Properties/Resources.resx create mode 100644 ElectronicObserverUpdater/Properties/Settings.Designer.cs create mode 100644 ElectronicObserverUpdater/Properties/Settings.settings diff --git a/ElectronicObserver.sln b/ElectronicObserver.sln index 92f5df99a..5a7f2e955 100644 --- a/ElectronicObserver.sln +++ b/ElectronicObserver.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2003 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30503.244 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicObserver", "ElectronicObserver\ElectronicObserver.csproj", "{A9ABEC50-1BFC-4C69-87AE-C68DB6004F68}" EndProject @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicObserverUpdater", "ElectronicObserverUpdater\ElectronicObserverUpdater.csproj", "{83DF5838-CF4B-430F-A1A7-0FE38C28CF00}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +40,10 @@ Global {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.Build.0 = Debug|Any CPU {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.Build.0 = Release|Any CPU + {83DF5838-CF4B-430F-A1A7-0FE38C28CF00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83DF5838-CF4B-430F-A1A7-0FE38C28CF00}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83DF5838-CF4B-430F-A1A7-0FE38C28CF00}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83DF5838-CF4B-430F-A1A7-0FE38C28CF00}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ElectronicObserverUpdater/App.config b/ElectronicObserverUpdater/App.config new file mode 100644 index 000000000..88fa4027b --- /dev/null +++ b/ElectronicObserverUpdater/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ElectronicObserverUpdater/ElectronicObserverUpdater.csproj b/ElectronicObserverUpdater/ElectronicObserverUpdater.csproj new file mode 100644 index 000000000..33a8ae896 --- /dev/null +++ b/ElectronicObserverUpdater/ElectronicObserverUpdater.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {83DF5838-CF4B-430F-A1A7-0FE38C28CF00} + WinExe + ElectronicObserverUpdater + ElectronicObserverUpdater + v4.5.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/ElectronicObserverUpdater/Form1.Designer.cs b/ElectronicObserverUpdater/Form1.Designer.cs new file mode 100644 index 000000000..260806e80 --- /dev/null +++ b/ElectronicObserverUpdater/Form1.Designer.cs @@ -0,0 +1,47 @@ +namespace ElectronicObserverUpdater +{ + partial class Form1 + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(421, 140); + this.Name = "Form1"; + this.Text = "Form1"; + this.ResumeLayout(false); + + } + + #endregion + } +} + diff --git a/ElectronicObserverUpdater/Form1.cs b/ElectronicObserverUpdater/Form1.cs new file mode 100644 index 000000000..9e1c42b18 --- /dev/null +++ b/ElectronicObserverUpdater/Form1.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ElectronicObserverUpdater +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} diff --git a/ElectronicObserverUpdater/Form1.resx b/ElectronicObserverUpdater/Form1.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/ElectronicObserverUpdater/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/ElectronicObserverUpdater/Program.cs b/ElectronicObserverUpdater/Program.cs new file mode 100644 index 000000000..f3ae2d7cd --- /dev/null +++ b/ElectronicObserverUpdater/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ElectronicObserverUpdater +{ + static class Program + { + /// + /// 해당 애플리케이션의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/ElectronicObserverUpdater/Properties/AssemblyInfo.cs b/ElectronicObserverUpdater/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..d5a26bc4b --- /dev/null +++ b/ElectronicObserverUpdater/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("ElectronicObserverUpdater")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ElectronicObserverUpdater")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("83df5838-cf4b-430f-a1a7-0fe38c28cf00")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ElectronicObserverUpdater/Properties/Resources.Designer.cs b/ElectronicObserverUpdater/Properties/Resources.Designer.cs new file mode 100644 index 000000000..62351f429 --- /dev/null +++ b/ElectronicObserverUpdater/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace ElectronicObserverUpdater.Properties +{ + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 + // ResGen을 다시 실행하거나 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 ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ElectronicObserverUpdater.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; + } + } + } +} diff --git a/ElectronicObserverUpdater/Properties/Resources.resx b/ElectronicObserverUpdater/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/ElectronicObserverUpdater/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ElectronicObserverUpdater/Properties/Settings.Designer.cs b/ElectronicObserverUpdater/Properties/Settings.Designer.cs new file mode 100644 index 000000000..11b20e117 --- /dev/null +++ b/ElectronicObserverUpdater/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 ElectronicObserverUpdater.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/ElectronicObserverUpdater/Properties/Settings.settings b/ElectronicObserverUpdater/Properties/Settings.settings new file mode 100644 index 000000000..39645652a --- /dev/null +++ b/ElectronicObserverUpdater/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + From 0114ce6a359f6e4cb9f7c5f82ba99024c78c15c8 Mon Sep 17 00:00:00 2001 From: YonghoAhn Date: Tue, 22 Sep 2020 19:58:59 +0900 Subject: [PATCH 2/3] [Add] Automatic Updater -ElectronicObserver/Utility/SoftwareInformation.cs: Modified DownloadStringCompleted Method now starting updater process instead of URL -ElectronicObserverUpdater/Utility/ Zip Extracting Utility class -ElectronicObserverUpdater/Window/ FormUpdater(Main WinForm) --- ElectronicObserver.sln | 3 + .../Utility/SoftwareInformation.cs | 8 +- ElectronicObserverUpdater/74eo.ico | Bin 0 -> 32038 bytes .../ElectronicObserverUpdater.csproj | 25 ++- ElectronicObserverUpdater/Form1.Designer.cs | 47 ----- ElectronicObserverUpdater/Form1.cs | 20 -- ElectronicObserverUpdater/Program.cs | 6 +- .../Properties/AssemblyInfo.cs | 2 +- .../Utillity/ZipFileExtensions.cs | 72 ++++++++ .../Utillity/ZipProgress.cs | 34 ++++ .../Window/FormUpdater.Designer.cs | 88 +++++++++ .../Window/FormUpdater.cs | 172 ++++++++++++++++++ .../{Form1.resx => Window/FormUpdater.resx} | 0 13 files changed, 398 insertions(+), 79 deletions(-) create mode 100644 ElectronicObserverUpdater/74eo.ico delete mode 100644 ElectronicObserverUpdater/Form1.Designer.cs delete mode 100644 ElectronicObserverUpdater/Form1.cs create mode 100644 ElectronicObserverUpdater/Utillity/ZipFileExtensions.cs create mode 100644 ElectronicObserverUpdater/Utillity/ZipProgress.cs create mode 100644 ElectronicObserverUpdater/Window/FormUpdater.Designer.cs create mode 100644 ElectronicObserverUpdater/Window/FormUpdater.cs rename ElectronicObserverUpdater/{Form1.resx => Window/FormUpdater.resx} (100%) diff --git a/ElectronicObserver.sln b/ElectronicObserver.sln index 5a7f2e955..e2427899b 100644 --- a/ElectronicObserver.sln +++ b/ElectronicObserver.sln @@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 16.0.30503.244 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElectronicObserver", "ElectronicObserver\ElectronicObserver.csproj", "{A9ABEC50-1BFC-4C69-87AE-C68DB6004F68}" + ProjectSection(ProjectDependencies) = postProject + {83DF5838-CF4B-430F-A1A7-0FE38C28CF00} = {83DF5838-CF4B-430F-A1A7-0FE38C28CF00} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Browser", "Browser\Browser.csproj", "{87A2B596-57D0-48BB-B522-895782D7A6FC}" EndProject diff --git a/ElectronicObserver/Utility/SoftwareInformation.cs b/ElectronicObserver/Utility/SoftwareInformation.cs index e96ed4545..14be24c3c 100644 --- a/ElectronicObserver/Utility/SoftwareInformation.cs +++ b/ElectronicObserver/Utility/SoftwareInformation.cs @@ -42,7 +42,7 @@ public static class SoftwareInformation /// /// 更新日時 /// - public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2020/09/21 02:30:00"); + public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2020/07/21 02:30:00"); @@ -114,7 +114,11 @@ private static void DownloadStringCompleted(object sender, System.Net.DownloadSt if (result == System.Windows.Forms.DialogResult.Yes) { - System.Diagnostics.Process.Start("http://electronicobserver.blog.fc2.com/"); + //System.Diagnostics.Process.Start("http://electronicobserver.blog.fc2.com/"); + var p = new System.Diagnostics.Process(); + p.StartInfo.FileName = "ElectronicObserverUpdater.exe"; + p.StartInfo.Arguments = version; + p.Start(); } else if (result == System.Windows.Forms.DialogResult.Cancel) diff --git a/ElectronicObserverUpdater/74eo.ico b/ElectronicObserverUpdater/74eo.ico new file mode 100644 index 0000000000000000000000000000000000000000..23ccb1204543028514e842d3ab34948ecc85a688 GIT binary patch literal 32038 zcmeHQ36xgFm3|~1JbSIzyI~$dpD4r{O45P zT5jE?UTybQz1Km|BRC~E^UMG+E4c2IAUHP&f~+h}Z$|!8$SW!F=}|%O*?~b&TdV23 zX+iMegdoU69iW1O<^#0tmuRdE5{(TAuOJ)==D&C(SiI|%V8v?nC!-W@dnrb>)&y~+P7Ws(7}eZG!l)^^uF`^fnWMh; z=Z6k8uuqr_twHuR;T`RSn~y$28YV|N8szKiruJW>!#=s@ZP)*<@5u8dKHHgXCHkt& z>Bo=JXn3Pi#_A%B+4WQ-fg3M}wfghlWUTO4Q1U%Q~#f zc_s^?7J>8C-^4G`I1_EPsz;*n`JM~6?>}wvi%0t}f9dGiD}VlOX2Y(=oVCALm%HxO zOS@FpMB{1Tc@M(AQ|{U72H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7Y09cn)*sQhaw5_#sZ@jL6QA;$^AlH+GKWApMHGigyGgs69 zL_t04)$`$LvGe4KpO`LZxW4bV?b%yf@NOZ_j(LVG=lwie=ehrMo_!PQdAof#`b6k2 z-?o;!2r8GH|MMOI1LWh~Jg*yu8!B8uyc1qd9QNApK-r#kK^5a z$9EIDyB+wB1>Z5@I~UNIf$Mwc*0`4RY^jWUqzAE2eDDu)$E@edSMiR@e8+cHy1E@W zw^MJvW8?KE(=!Bw{v9Q#&_iS zt{mT)gO2gQyLl&{-to5LyNdLs-3Nc7-nYRw0A922OWGN<|6bq@JClm*YH2>}xd4yvijbA2kdsq$%TL@91 zo>2Z*4I^3|P^yE2eD?tVXU3qA!_5kETy;4sOwM{vRCvIt}*-nc&ps zU|c>+n;r&DPlMJD(yWp83EOQ;fFIgX7^7WElectronicObserverUpdater v4.5.2 512 - true + false true @@ -18,7 +18,7 @@ true full false - bin\Debug\ + ..\ElectronicObserver\bin\Debug\ DEBUG;TRACE prompt 4 @@ -32,9 +32,15 @@ prompt 4 + + 74eo.ico + + + + @@ -46,16 +52,18 @@ - + + Form - - Form1.cs + + FormUpdater.cs - - Form1.cs + + + FormUpdater.cs ResXFileCodeGenerator @@ -79,5 +87,8 @@ + + + \ No newline at end of file diff --git a/ElectronicObserverUpdater/Form1.Designer.cs b/ElectronicObserverUpdater/Form1.Designer.cs deleted file mode 100644 index 260806e80..000000000 --- a/ElectronicObserverUpdater/Form1.Designer.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace ElectronicObserverUpdater -{ - partial class Form1 - { - /// - /// 필수 디자이너 변수입니다. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// 사용 중인 모든 리소스를 정리합니다. - /// - /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form 디자이너에서 생성한 코드 - - /// - /// 디자이너 지원에 필요한 메서드입니다. - /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(421, 140); - this.Name = "Form1"; - this.Text = "Form1"; - this.ResumeLayout(false); - - } - - #endregion - } -} - diff --git a/ElectronicObserverUpdater/Form1.cs b/ElectronicObserverUpdater/Form1.cs deleted file mode 100644 index 9e1c42b18..000000000 --- a/ElectronicObserverUpdater/Form1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ElectronicObserverUpdater -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ElectronicObserverUpdater/Program.cs b/ElectronicObserverUpdater/Program.cs index f3ae2d7cd..a1136451f 100644 --- a/ElectronicObserverUpdater/Program.cs +++ b/ElectronicObserverUpdater/Program.cs @@ -12,11 +12,13 @@ static class Program /// 해당 애플리케이션의 주 진입점입니다. /// [STAThread] - static void Main() + static void Main(string[] args) { + if (args[0] == "") + throw new ArgumentException("Argument was null"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + Application.Run(new FormUpdater(args[0])); } } } diff --git a/ElectronicObserverUpdater/Properties/AssemblyInfo.cs b/ElectronicObserverUpdater/Properties/AssemblyInfo.cs index d5a26bc4b..fd32f3bb4 100644 --- a/ElectronicObserverUpdater/Properties/AssemblyInfo.cs +++ b/ElectronicObserverUpdater/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ElectronicObserverUpdater")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyCopyright("Copyright © 2020 MisakaMOE")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/ElectronicObserverUpdater/Utillity/ZipFileExtensions.cs b/ElectronicObserverUpdater/Utillity/ZipFileExtensions.cs new file mode 100644 index 000000000..fbbf757fb --- /dev/null +++ b/ElectronicObserverUpdater/Utillity/ZipFileExtensions.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ElectronicObserverUpdater.Utillity +{ + public static class ZipFileExtensions + { + /// + /// Extract zip file to directory. + /// this method doesn't generate root directory of zip file. + /// + /// Zip file + /// Destination Direcctory path + /// Progress receiver + /// overwrite? + public static void ExtractToDirectory(this ZipArchive source, string destinationDirectoryName, IProgress progress, bool overwrite) + { + if (source == null) + throw new ArgumentNullException(nameof(source)); + + if (destinationDirectoryName == null) + throw new ArgumentNullException(nameof(destinationDirectoryName)); + + // Rely on Directory.CreateDirectory for validation of destinationDirectoryName. + // Note that this will give us a good DirectoryInfo even if destinationDirectoryName exists: + DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName); + string destinationDirectoryFullPath = di.FullName; + + int count = 0; + var root = source.Entries[0]?.FullName; + foreach (ZipArchiveEntry entry in source.Entries) + { + count++; + //Remove zip file Root directory from path. + var newName = entry.FullName.Substring(root.Length); + string fileDestinationPath = Path.Combine(destinationDirectoryFullPath, newName); + + if (!fileDestinationPath.StartsWith(destinationDirectoryFullPath, StringComparison.OrdinalIgnoreCase)) + throw new IOException("File is extracting to outside of the folder specified."); + + //Report extracting progress. + var zipProgress = new ZipProgress(source.Entries.Count, count, entry.FullName); + progress.Report(zipProgress); + + if (Path.GetFileName(fileDestinationPath).Length == 0) + { + // If it is a directory: + if (entry.Length != 0) + throw new IOException("Directory entry with data."); + + Directory.CreateDirectory(fileDestinationPath); + } + else + { + // If it is a file: + // Create containing directory: + //Check if entry is root directory + if (!(fileDestinationPath == destinationDirectoryName)) + { + Directory.CreateDirectory(Path.GetDirectoryName(fileDestinationPath)); + entry.ExtractToFile(fileDestinationPath, overwrite: overwrite); + } + } + } + } + } +} diff --git a/ElectronicObserverUpdater/Utillity/ZipProgress.cs b/ElectronicObserverUpdater/Utillity/ZipProgress.cs new file mode 100644 index 000000000..8851e6d73 --- /dev/null +++ b/ElectronicObserverUpdater/Utillity/ZipProgress.cs @@ -0,0 +1,34 @@ +namespace ElectronicObserverUpdater +{ + /// + /// This indicates extracting progress of zip file. + /// + public class ZipProgress + { + /// + /// Init ZipProgress object + /// + /// default total value + /// default progress value + /// currently working item + public ZipProgress(int total, int processed, string currentItem) + { + Total = total; + Processed = processed; + CurrentItem = currentItem; + } + /// + /// Total item count of zip file. + /// + public int Total { get; } + /// + /// Extracted item count of zip file. + /// + public int Processed { get; } + /// + /// The filename of currently extracting. + /// + public string CurrentItem { get; } + } + +} \ No newline at end of file diff --git a/ElectronicObserverUpdater/Window/FormUpdater.Designer.cs b/ElectronicObserverUpdater/Window/FormUpdater.Designer.cs new file mode 100644 index 000000000..ad8bff8e8 --- /dev/null +++ b/ElectronicObserverUpdater/Window/FormUpdater.Designer.cs @@ -0,0 +1,88 @@ +namespace ElectronicObserverUpdater +{ + partial class FormUpdater + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.labelStatus = new System.Windows.Forms.Label(); + this.labelDescription = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(12, 29); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(397, 23); + this.progressBar.TabIndex = 0; + // + // labelStatus + // + this.labelStatus.AutoSize = true; + this.labelStatus.Location = new System.Drawing.Point(12, 9); + this.labelStatus.Name = "labelStatus"; + this.labelStatus.Size = new System.Drawing.Size(90, 12); + this.labelStatus.TabIndex = 1; + this.labelStatus.Text = "Downloading..."; + // + // labelDescription + // + this.labelDescription.AutoSize = true; + this.labelDescription.Location = new System.Drawing.Point(10, 64); + this.labelDescription.Name = "labelDescription"; + this.labelDescription.Size = new System.Drawing.Size(148, 12); + this.labelDescription.TabIndex = 2; + this.labelDescription.Text = "0.0 Byte / 10000000 Bytes"; + // + // FormUpdater + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(421, 87); + this.Controls.Add(this.labelDescription); + this.Controls.Add(this.labelStatus); + this.Controls.Add(this.progressBar); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "FormUpdater"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ElectronicObserver Updater"; + this.Load += new System.EventHandler(this.FormUpdater_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ProgressBar progressBar; + private System.Windows.Forms.Label labelStatus; + private System.Windows.Forms.Label labelDescription; + } +} + diff --git a/ElectronicObserverUpdater/Window/FormUpdater.cs b/ElectronicObserverUpdater/Window/FormUpdater.cs new file mode 100644 index 000000000..0610bb663 --- /dev/null +++ b/ElectronicObserverUpdater/Window/FormUpdater.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO.Compression; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ElectronicObserverUpdater +{ + public partial class FormUpdater : Form + { + #region Variables/Fields + /// + /// Base Url of update file. + /// Two parameters should be replaced when download file. + /// + private static string BASE_URL = "https://github.com/andanteyk/ElectronicObserver/releases/download/v{0}/ElectronicObserver{1}.zip"; + public string Version { get; set; } = ""; + public bool IsSetBaseSize { get; private set; } + + private string FileName { get; set; } = ""; + + public Progress _progress; + + private delegate void CSafeSetText(string text); + private delegate void CSafeSetMaximum(int value); + private delegate void CSafeSetValue(int value); + private readonly CSafeSetText csst; + private readonly CSafeSetMaximum cssm; + private readonly WebClient wc; + #endregion + + #region Invoke Methods + void CrossSafeSetTextMethod(string text) + { + if (labelDescription.InvokeRequired) + labelDescription.Invoke(csst, text); + else + labelDescription.Text = text; + } + + void CrossSafeSetValueMethod(int value) + { + if (progressBar.InvokeRequired) + progressBar.Invoke(cssm, value); + else + progressBar.Value = value; + } + void CrossSafeSetMaximumMethod(int value) + { + if (progressBar.InvokeRequired) + progressBar.Invoke(cssm, value); + else + progressBar.Maximum = value; + } + #endregion + + /// + /// Initializer of FormUpdater class + /// + /// current version. this should be {n}.{n}.{n}.{n} template. (ElectronicObserver.Utility.SoftwareInformation.VersionEnglish) + public FormUpdater(string v) + { + wc = new WebClient(); + InitializeComponent(); + Version = v; + + _progress = new Progress(); + _progress.ProgressChanged += Report; + } + + + private void FormUpdater_Load(object sender, EventArgs e) + { + KillEOProcess(); + + //turn on TLS/SSL Options + ServicePointManager.Expect100Continue = true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; + ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; + + FileName = Version.Replace(".", string.Empty); + //If minor version exists + if(FileName.Length > 3) + { + FileName = FileName.Insert(3, "_"); + } + string url = string.Format(BASE_URL, Version, FileName); + FileName = string.Format(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\{0}", System.IO.Path.GetFileName(url)); + try + { + wc.DownloadFileCompleted += new AsyncCompletedEventHandler(FileDownloadCompleted); + wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(FileDownloadProgressChanged); + wc.DownloadFileAsync(new Uri(url), FileName); + + progressBar.Value = 0; + labelStatus.Text = "Downloading..."; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + + /// + /// Kill ElectronicObserver process before update. + /// + private void KillEOProcess() + { + Process[] processes = Process.GetProcessesByName("ElectronicObserver"); + foreach(var p in processes) + { + p.Kill(); + } + } + + private void Report(object sender, ZipProgress zipProgress) + { + //Update value asynchronously + CrossSafeSetMaximumMethod(zipProgress.Total); + CrossSafeSetValueMethod(zipProgress.Processed); + CrossSafeSetTextMethod(zipProgress.CurrentItem); + + if(zipProgress.Total == zipProgress.Processed) + { + var eo = "ElectronicObserver.exe"; + var eoFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\ElectronicObserver.exe"; + var result = MessageBox.Show("アップデートが完了しました。", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); + //When update completed, automatically start EO again. + if(result == DialogResult.OK) + { + if (System.IO.File.Exists(eo)) + Process.Start(eo); + else + Process.Start(eoFile); + Application.Exit(); + } + } + } + + void FileDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) + { + if (!IsSetBaseSize) + { + CrossSafeSetMaximumMethod((int)e.TotalBytesToReceive); + IsSetBaseSize = true; + } + + CrossSafeSetValueMethod((int)e.BytesReceived); + + CrossSafeSetTextMethod(String.Format("{0:N0} Bytes / {1:N0} Bytes ({2:P})", e.BytesReceived, e.TotalBytesToReceive, (Double)e.BytesReceived / (Double)e.TotalBytesToReceive)); + } + + void FileDownloadCompleted(object sender, AsyncCompletedEventArgs e) + { + //Extract File + labelStatus.Text = "Unzipping Files..."; + ZipArchive zip = ZipFile.OpenRead(FileName); + //Extract zip asynchronously + Task.Run(() => + { + Utillity.ZipFileExtensions.ExtractToDirectory(zip, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), _progress, true); + }); + } + } +} diff --git a/ElectronicObserverUpdater/Form1.resx b/ElectronicObserverUpdater/Window/FormUpdater.resx similarity index 100% rename from ElectronicObserverUpdater/Form1.resx rename to ElectronicObserverUpdater/Window/FormUpdater.resx From ab9794f5388c78a4b78857b1033785d95d9cedfd Mon Sep 17 00:00:00 2001 From: YonghoAhn Date: Tue, 22 Sep 2020 20:13:13 +0900 Subject: [PATCH 3/3] [Edit] Changed updateTime Roll backed to original --- ElectronicObserver/Utility/SoftwareInformation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElectronicObserver/Utility/SoftwareInformation.cs b/ElectronicObserver/Utility/SoftwareInformation.cs index 14be24c3c..29351635b 100644 --- a/ElectronicObserver/Utility/SoftwareInformation.cs +++ b/ElectronicObserver/Utility/SoftwareInformation.cs @@ -42,7 +42,7 @@ public static class SoftwareInformation /// /// 更新日時 /// - public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2020/07/21 02:30:00"); + public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2020/09/21 02:30:00");