From 7eac3ac83e3cbd089c5cac90eb7cc57536f332b2 Mon Sep 17 00:00:00 2001 From: TheDuffman85 Date: Sun, 1 Mar 2015 09:35:18 +0100 Subject: [PATCH] Version 1.2.0.9 --- Synology Download Station Adapter/Adapter.cs | 68 ++++--------------- .../Properties/AssemblyInfo.cs | 2 +- .../frmAddLinks.Designer.cs | 1 - .../frmDownloadStation.Designer.cs | 1 - .../frmDownloadStation.cs | 11 +-- .../frmSelectHoster.Designer.cs | 1 - .../frmSettings.Designer.cs | 18 +++-- .../frmSettings.cs | 26 +++---- 8 files changed, 39 insertions(+), 89 deletions(-) diff --git a/Synology Download Station Adapter/Adapter.cs b/Synology Download Station Adapter/Adapter.cs index 2840b8e..0c74640 100644 --- a/Synology Download Station Adapter/Adapter.cs +++ b/Synology Download Station Adapter/Adapter.cs @@ -30,8 +30,9 @@ public class Adapter private const string REG_KEY_NAME = "SynologyDownloadStationAdapter"; public static readonly string[] FILE_TYPES_ALL = new string[] { ".dlc", ".ccf", ".rsdf", ".torrent", ".nzb" }; public static readonly string[] FILE_TYPES_NO_DECRYPT = new string[] { ".torrent", ".nzb" }; - - private const string LASTEST_RELEASE_URL = "https://github.com/TheDuffman85/SynologyDownloadStationAdapter/releases/latest"; + + public const string RELEASE_URL = "https://github.com/TheDuffman85/SynologyDownloadStationAdapter/releases"; + public const string LASTEST_RELEASE_URL = "https://github.com/TheDuffman85/SynologyDownloadStationAdapter/releases/latest"; private const int MAX_PORTION_CHAR_SIZE = 1900; private const int MAX_PORTION_LINK_COUNT = 50; @@ -42,7 +43,6 @@ public class Adapter private static HttpListener _httpListener; private static Dictionary _fileDownloads; - //private static WebRequest _checkNewReleaseRequest; private static System.Timers.Timer _checkNewReleaseTimer; #endregion @@ -68,34 +68,6 @@ public static string AssemblyDirectory } } - public static Form VisibleForm - { - get - { - - return (Form)frmSettings.Instance.Invoke(new Func
( - delegate - { - if (frmDownloadStation.Instance.Visible) - { - return frmDownloadStation.Instance; - } - else if (frmSelectHoster.Instance.Visible) - { - return frmSelectHoster.Instance; - } - else if (frmAddLinks.Instance.Visible) - { - return frmAddLinks.Instance; - } - else - { - return frmSettings.Instance; - } - })); - } - } - #endregion #region Static Methods @@ -299,18 +271,12 @@ private static void WebRequestCallback(IAsyncResult result) if (Properties.Settings.Default.ShowDecryptedLinks) { - if (Adapter.VisibleForm.InvokeRequired) - { - Adapter.VisibleForm.Invoke((MethodInvoker)(() => - { - frmAddLinks.ShowInstance(decrypter.Links); - } - )); - } - else + frmSettings.Instance.Invoke((MethodInvoker)(() => { + // Run on UI thread frmAddLinks.ShowInstance(decrypter.Links); } + )); } else { @@ -547,19 +513,13 @@ public static bool AddLinksToDownloadStation(List links) } if (validHostLinks.Keys.Count > 1) - { - if (Adapter.VisibleForm.InvokeRequired) - { - Adapter.VisibleForm.Invoke((MethodInvoker)(() => - { - frmSelectHoster.Instance.SelectHoster(validHostLinks); - } - )); - } - else + { + frmSettings.Instance.Invoke((MethodInvoker)(() => { + // Run on UI thread frmSelectHoster.Instance.SelectHoster(validHostLinks); } + )); } // Get total link count @@ -597,11 +557,11 @@ public static bool AddLinksToDownloadStation(List links) { if (result.Error.Code == 406) { - throw new Exception("Couldn't add link. You have to choose a download folder for your Download Station."); + throw new Exception("Couldn't add link(s). You have to choose a download folder for your Download Station."); } else { - throw new Exception("While adding links the error code " + result.Error.Code + " occurred"); + throw new Exception("While adding link(s) the error code " + result.Error.Code + " occurred"); } } } @@ -681,7 +641,7 @@ public static bool AddFileToDownloadStation(string path) { if (result.Error.Code == 406) { - throw new Exception("Couldn't add link. You have to choose a download folder for your Download Station."); + throw new Exception("Couldn't add link(s). You have to choose a download folder for your Download Station."); } else { @@ -795,7 +755,7 @@ private static void CheckUpdate() try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(LASTEST_RELEASE_URL); - request.Referer = "http://SynologyDownloadStationAdapte.update"; + request.Referer = "UpdateCheck"; WebResponse response = request.GetResponse(); diff --git a/Synology Download Station Adapter/Properties/AssemblyInfo.cs b/Synology Download Station Adapter/Properties/AssemblyInfo.cs index 3d43840..3b60fdc 100644 --- a/Synology Download Station Adapter/Properties/AssemblyInfo.cs +++ b/Synology Download Station Adapter/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.2.0.8")] +[assembly: AssemblyFileVersion("1.2.0.9")] diff --git a/Synology Download Station Adapter/frmAddLinks.Designer.cs b/Synology Download Station Adapter/frmAddLinks.Designer.cs index 1b87cb6..a3c0d81 100644 --- a/Synology Download Station Adapter/frmAddLinks.Designer.cs +++ b/Synology Download Station Adapter/frmAddLinks.Designer.cs @@ -110,7 +110,6 @@ private void InitializeComponent() this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(350, 220); this.Name = "frmAddLinks"; - this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Add Links"; this.Load += new System.EventHandler(this.frmAddLinks_Load); diff --git a/Synology Download Station Adapter/frmDownloadStation.Designer.cs b/Synology Download Station Adapter/frmDownloadStation.Designer.cs index 0165fc8..91a4128 100644 --- a/Synology Download Station Adapter/frmDownloadStation.Designer.cs +++ b/Synology Download Station Adapter/frmDownloadStation.Designer.cs @@ -72,7 +72,6 @@ private void InitializeComponent() this.Name = "frmDownloadStation"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Download Station"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmDownloadStation_FormClosing); this.Load += new System.EventHandler(this.frmDownloadStation_Load); this.ResizeEnd += new System.EventHandler(this.frmDownloadStation_ResizeEnd); ((System.ComponentModel.ISupportInitialize)(this.pbLoadingIndicator)).EndInit(); diff --git a/Synology Download Station Adapter/frmDownloadStation.cs b/Synology Download Station Adapter/frmDownloadStation.cs index 49a6d5c..59e31e1 100644 --- a/Synology Download Station Adapter/frmDownloadStation.cs +++ b/Synology Download Station Adapter/frmDownloadStation.cs @@ -126,16 +126,7 @@ private void Awesomium_Windows_Forms_WebControl_CertificateError(object sender, e.Handled = Awesomium.Core.EventHandling.Modal; e.Ignore = true; } - - private void frmDownloadStation_FormClosing(object sender, FormClosingEventArgs e) - { - if (e.CloseReason == CloseReason.UserClosing) - { - e.Cancel = true; - this.Visible = false; - } - } - + private void webControl_DocumentReady(object sender, DocumentReadyEventArgs e) { if (e.Url.Segments.Length == 3 && diff --git a/Synology Download Station Adapter/frmSelectHoster.Designer.cs b/Synology Download Station Adapter/frmSelectHoster.Designer.cs index 740631a..8ff0f06 100644 --- a/Synology Download Station Adapter/frmSelectHoster.Designer.cs +++ b/Synology Download Station Adapter/frmSelectHoster.Designer.cs @@ -88,7 +88,6 @@ private void InitializeComponent() this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "frmSelectHoster"; - this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Select Hoster"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmSelectHoster_FormClosing); diff --git a/Synology Download Station Adapter/frmSettings.Designer.cs b/Synology Download Station Adapter/frmSettings.Designer.cs index ca5854d..9b749d3 100644 --- a/Synology Download Station Adapter/frmSettings.Designer.cs +++ b/Synology Download Station Adapter/frmSettings.Designer.cs @@ -51,14 +51,12 @@ private void InitializeComponent() this.txtApplicationUrl = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.cbShowDecryptedLinks = new System.Windows.Forms.CheckBox(); + this.lblVersion = new System.Windows.Forms.LinkLabel(); this.contextMenuStrip.SuspendLayout(); this.SuspendLayout(); // // notifyIcon // - this.notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; - this.notifyIcon.BalloonTipText = "Test Text"; - this.notifyIcon.BalloonTipTitle = "Test Titel"; this.notifyIcon.ContextMenuStrip = this.contextMenuStrip; this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon"))); this.notifyIcon.Text = "Synology Download Station Adapter"; @@ -243,11 +241,23 @@ private void InitializeComponent() this.cbShowDecryptedLinks.Text = "Show decrypted links before adding"; this.cbShowDecryptedLinks.UseVisualStyleBackColor = true; // + // lblVersion + // + this.lblVersion.AutoSize = true; + this.lblVersion.Location = new System.Drawing.Point(13, 211); + this.lblVersion.Name = "lblVersion"; + this.lblVersion.Size = new System.Drawing.Size(59, 13); + this.lblVersion.TabIndex = 92; + this.lblVersion.TabStop = true; + this.lblVersion.Text = "Version {0}"; + this.lblVersion.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lblVersion_LinkClicked); + // // frmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(335, 237); + this.Controls.Add(this.lblVersion); this.Controls.Add(this.cbShowDecryptedLinks); this.Controls.Add(this.label4); this.Controls.Add(this.txtApplicationUrl); @@ -267,7 +277,6 @@ private void InitializeComponent() this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "frmSettings"; - this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Settings"; @@ -303,5 +312,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox txtApplicationUrl; private System.Windows.Forms.Label label4; private System.Windows.Forms.CheckBox cbShowDecryptedLinks; + private System.Windows.Forms.LinkLabel lblVersion; } } \ No newline at end of file diff --git a/Synology Download Station Adapter/frmSettings.cs b/Synology Download Station Adapter/frmSettings.cs index 72b3eba..0bbce35 100644 --- a/Synology Download Station Adapter/frmSettings.cs +++ b/Synology Download Station Adapter/frmSettings.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; @@ -93,6 +94,7 @@ private frmSettings() AddClipboardFormatListener(this.Handle); this.btnFileAssociation.Text = string.Format(this.btnFileAssociation.Text, string.Join(",", Adapter.FILE_TYPES_ALL) ); + this.lblVersion.Text = string.Format(this.lblVersion.Text, FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion); } #endregion @@ -138,10 +140,7 @@ protected override void WndProc(ref Message m) { frmAddLinks.ShowInstance(); } - } - - - + } } } } @@ -322,21 +321,14 @@ private void contextMenuStrip_Opening(object sender, CancelEventArgs e) private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e) { - if (Adapter.VisibleForm.InvokeRequired) - { - Adapter.VisibleForm.Invoke((MethodInvoker)(() => - { - Adapter.OpenDownloadStation(); - } - )); - } - else - { - Adapter.OpenDownloadStation(); - } + Adapter.OpenDownloadStation(); } - #endregion + private void lblVersion_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start(Adapter.RELEASE_URL); + } + #endregion } }