From 5ade1943d9e0fd13eff901e68c79ebf6db2a78d9 Mon Sep 17 00:00:00 2001 From: huiyadanli Date: Sun, 19 Nov 2017 23:15:32 +0800 Subject: [PATCH] [#] Update info --- PasteEx/FormSetting.Designer.cs | 31 +++++++--- PasteEx/FormSetting.cs | 75 ++++++++++++++++++++--- PasteEx/FormSetting.resx | 74 ++++++++++++++++------ PasteEx/PasteEx.csproj | 1 + PasteEx/Properties/Resources.Designer.cs | 10 +++ PasteEx/Properties/Resources.resx | 3 + PasteEx/Resources/Image/loading.gif | Bin 0 -> 729 bytes README.md | 4 +- 8 files changed, 163 insertions(+), 35 deletions(-) create mode 100644 PasteEx/Resources/Image/loading.gif diff --git a/PasteEx/FormSetting.Designer.cs b/PasteEx/FormSetting.Designer.cs index 7a876cc..38c7610 100644 --- a/PasteEx/FormSetting.Designer.cs +++ b/PasteEx/FormSetting.Designer.cs @@ -44,16 +44,18 @@ private void InitializeComponent() this.txtAutoExtRule = new System.Windows.Forms.TextBox(); this.chkAutoExtSwitch = new System.Windows.Forms.CheckBox(); this.tabPageAbout = new System.Windows.Forms.TabPage(); + this.picLoading = new System.Windows.Forms.PictureBox(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.label2 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.btnGetUpdateInfo = new System.Windows.Forms.Button(); + this.labelUpdateinfo = new System.Windows.Forms.LinkLabel(); this.tabControl1.SuspendLayout(); this.tabPageNomal.SuspendLayout(); this.groupBox1.SuspendLayout(); this.tabPageCustom.SuspendLayout(); this.groupBox2.SuspendLayout(); this.tabPageAbout.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picLoading)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -75,6 +77,7 @@ private void InitializeComponent() this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; + this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); // // tabPageNomal // @@ -159,7 +162,8 @@ private void InitializeComponent() // // tabPageAbout // - this.tabPageAbout.Controls.Add(this.btnGetUpdateInfo); + this.tabPageAbout.Controls.Add(this.labelUpdateinfo); + this.tabPageAbout.Controls.Add(this.picLoading); this.tabPageAbout.Controls.Add(this.linkLabel1); this.tabPageAbout.Controls.Add(this.label2); this.tabPageAbout.Controls.Add(this.pictureBox1); @@ -167,6 +171,13 @@ private void InitializeComponent() this.tabPageAbout.Name = "tabPageAbout"; this.tabPageAbout.UseVisualStyleBackColor = true; // + // picLoading + // + this.picLoading.Image = global::PasteEx.Properties.Resources.loading; + resources.ApplyResources(this.picLoading, "picLoading"); + this.picLoading.Name = "picLoading"; + this.picLoading.TabStop = false; + // // linkLabel1 // resources.ApplyResources(this.linkLabel1, "linkLabel1"); @@ -186,12 +197,13 @@ private void InitializeComponent() this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.TabStop = false; // - // btnGetUpdateInfo + // labelUpdateinfo // - resources.ApplyResources(this.btnGetUpdateInfo, "btnGetUpdateInfo"); - this.btnGetUpdateInfo.Name = "btnGetUpdateInfo"; - this.btnGetUpdateInfo.UseVisualStyleBackColor = true; - this.btnGetUpdateInfo.Click += new System.EventHandler(this.btnGetUpdateInfo_Click); + this.labelUpdateinfo.ForeColor = System.Drawing.Color.Green; + resources.ApplyResources(this.labelUpdateinfo, "labelUpdateinfo"); + this.labelUpdateinfo.LinkColor = System.Drawing.Color.Green; + this.labelUpdateinfo.Name = "labelUpdateinfo"; + this.labelUpdateinfo.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabels_LinkClicked); // // FormSetting // @@ -209,6 +221,8 @@ private void InitializeComponent() this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.tabPageAbout.ResumeLayout(false); + this.tabPageAbout.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picLoading)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); @@ -232,6 +246,7 @@ private void InitializeComponent() private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.LinkLabel linkLabel1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button btnGetUpdateInfo; + private System.Windows.Forms.PictureBox picLoading; + private System.Windows.Forms.LinkLabel labelUpdateinfo; } } \ No newline at end of file diff --git a/PasteEx/FormSetting.cs b/PasteEx/FormSetting.cs index 8d7ddbf..3559d4c 100644 --- a/PasteEx/FormSetting.cs +++ b/PasteEx/FormSetting.cs @@ -1,4 +1,5 @@ -using System; +using PasteEx.Util; +using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -139,14 +140,74 @@ private void linkLabels_LinkClicked(object sender, LinkLabelLinkClickedEventArgs System.Diagnostics.Process.Start(e.Link.LinkData as string); } - private async void btnGetUpdateInfo_Click(object sender, EventArgs e) + private int VersionToNumber(string version) { - Task> t = new Task>(Client.GetUpdateInfo); - t.Start(); - var dic = await t; - if (dic != null) + int res = 0; + try { - MessageBox.Show(dic["version"]); + string[] nums = version.Split('.'); + if (nums.Length == 4) + { + int rate = 1000; + for (int i = nums.Length - 1; i >= 0; i--) + { + res += Convert.ToInt32(nums[i]) * rate; + rate *= 10; + } + } + } + catch (Exception ex) + { + Logger.Error(ex); + } + return res; + } + + private async void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + { + if (tabControl1.SelectedIndex == 2) + { + Task> t = new Task>(Client.GetUpdateInfo); + t.Start(); + var dic = await t; + if (dic != null) + { + string latestVersion = dic["version"]; + string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + + int latestVersionNum = VersionToNumber(latestVersion); + int currentVersionNum = VersionToNumber(currentVersion); + if (latestVersionNum > 1000000 && currentVersionNum > 1000000) + { + if (latestVersionNum > currentVersionNum) + { + // have new version + labelUpdateinfo.Text = "存在新版本:" + latestVersion; + labelUpdateinfo.ForeColor = System.Drawing.Color.Red; + labelUpdateinfo.LinkColor = System.Drawing.Color.Red; + labelUpdateinfo.Links.Clear(); + labelUpdateinfo.Links.Add(0, labelUpdateinfo.Text.Length, dic["page"].Replace(@"\/",@"/")); + labelUpdateinfo.LinkBehavior = LinkBehavior.AlwaysUnderline; + labelUpdateinfo.Visible = true; + } + else + { + labelUpdateinfo.Text = "已经是最新版本"; + labelUpdateinfo.ForeColor = System.Drawing.Color.Green; + labelUpdateinfo.LinkColor = System.Drawing.Color.Green; + labelUpdateinfo.Links.Clear(); + labelUpdateinfo.LinkBehavior = LinkBehavior.NeverUnderline; + labelUpdateinfo.Visible = true; + } + } + else + { + Logger.Error("错误的版本号:" + latestVersion + "|" + currentVersion); + } + } + + picLoading.Enabled = false; + picLoading.Visible = false; } } } diff --git a/PasteEx/FormSetting.resx b/PasteEx/FormSetting.resx index f5d298c..779aa7d 100644 --- a/PasteEx/FormSetting.resx +++ b/PasteEx/FormSetting.resx @@ -201,39 +201,72 @@ 1 - - 微软雅黑, 9pt + + 0, 0 - - 227, 123 + + 17, 241 - - 20, 24 + + 328, 23 - - 8 + + 11 + + + 已经是最新版本 - - + + TopCenter + + + False - - btnGetUpdateInfo + + labelUpdateinfo - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tabPageAbout - + 0 + + 169, 241 + + + 16, 16 + + + AutoSize + + + 9 + + + picLoading + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tabPageAbout + + + 1 + Top, Left, Right 微软雅黑, 9pt + + NoControl + 23, 0 @@ -268,7 +301,10 @@ tabPageAbout - 1 + 2 + + + NoControl 0, 0 @@ -289,7 +325,7 @@ tabPageAbout - 2 + 3 Top, Left, Right @@ -319,7 +355,7 @@ tabPageAbout - 3 + 4 4, 22 diff --git a/PasteEx/PasteEx.csproj b/PasteEx/PasteEx.csproj index e3978f6..10e616f 100644 --- a/PasteEx/PasteEx.csproj +++ b/PasteEx/PasteEx.csproj @@ -145,6 +145,7 @@ + diff --git a/PasteEx/Properties/Resources.Designer.cs b/PasteEx/Properties/Resources.Designer.cs index b12bf0c..c7f9d47 100644 --- a/PasteEx/Properties/Resources.Designer.cs +++ b/PasteEx/Properties/Resources.Designer.cs @@ -70,6 +70,16 @@ internal static System.Drawing.Bitmap ico { } } + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap loading { + get { + object obj = ResourceManager.GetObject("loading", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// diff --git a/PasteEx/Properties/Resources.resx b/PasteEx/Properties/Resources.resx index bd06260..09c6cad 100644 --- a/PasteEx/Properties/Resources.resx +++ b/PasteEx/Properties/Resources.resx @@ -121,6 +121,9 @@ ..\Resources\Image\ico.ico;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Image\loading.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Image\ico.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/PasteEx/Resources/Image/loading.gif b/PasteEx/Resources/Image/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..6a56815b224f865a176ee02259209bbe734a7c66 GIT binary patch literal 729 zcmZ?wbhEHb6krfw*v!vRRaN!<`}eM{u04D9OrAXX?AfzTO-;|9J-c`B-kLRQjvhVw z?%liDvuAJFvSsn&#sB~RSNzZI=Nc01>=@u`q-Vg)$iTp$_>+Z`gMptx2gn8*D!{ui!K?FQ=} zH?Xd{pt$&AAhW_8|9KxoF0L)FVBuPK^2Fx|Eyj5b!A2T$_)fYrI-Fn;YEaSX(VW82 zk<8BB^ zyg~ZU!^v%pW2>hJf)$GceOB@lW%IqbM+#%`yV*4 zSpoDBFs3Ycm>47vZsmyO|lq3pQPK+9JJ1v_kOAB<7PPOi?B$_+<{i4+h5@D_X*USQo*^ zaDpSuK*RrF;UPy+wgi?0O$Mhka~zylKP%{ViMg8^3Tnt4Ind5xl01vC$yt$sYs%r1 o3nDTyF1RxtpYS1rRbWl(0YARY!rMM@@~&Y>OFO^ag@M5u0Ak7h$N&HU literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 0c5fe8e..07b4e51 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,12 @@ ## ʹ÷ Ҫ .NET Framework 4.5 ֧֡ -Ȱѱƶλã Program Files ļڡ +ȰѱһļڣйлڵǰĿ¼ͷļ ȻֱУʾҼ˵ɣӲ˵ʱ UAC ʾмɣ +жأɫЯֻҪҳƳҼ˵Ȼɾ弴ɡ + ## Thanks [PasteIntoFiles](https://github.com/EslaMx7/PasteIntoFiles)