mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Working on "Check for updates..."
This commit is contained in:
parent
919322a8cd
commit
a9108975f7
118
src/Forms/CheckForUpdates.Designer.cs
generated
Normal file
118
src/Forms/CheckForUpdates.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
partial class CheckForUpdates
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.textBoxChangeLog = new System.Windows.Forms.TextBox();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonDownloadAndInstall = new System.Windows.Forms.Button();
|
||||
this.timerCheckForUpdates = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelStatus
|
||||
//
|
||||
this.labelStatus.AutoSize = true;
|
||||
this.labelStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.labelStatus.Location = new System.Drawing.Point(12, 22);
|
||||
this.labelStatus.Name = "labelStatus";
|
||||
this.labelStatus.Size = new System.Drawing.Size(41, 13);
|
||||
this.labelStatus.TabIndex = 0;
|
||||
this.labelStatus.Text = "label1";
|
||||
//
|
||||
// textBoxChangeLog
|
||||
//
|
||||
this.textBoxChangeLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBoxChangeLog.Location = new System.Drawing.Point(13, 38);
|
||||
this.textBoxChangeLog.Multiline = true;
|
||||
this.textBoxChangeLog.Name = "textBoxChangeLog";
|
||||
this.textBoxChangeLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxChangeLog.Size = new System.Drawing.Size(618, 46);
|
||||
this.textBoxChangeLog.TabIndex = 1;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(556, 90);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonDownloadAndInstall
|
||||
//
|
||||
this.buttonDownloadAndInstall.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDownloadAndInstall.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonDownloadAndInstall.Location = new System.Drawing.Point(390, 90);
|
||||
this.buttonDownloadAndInstall.Name = "buttonDownloadAndInstall";
|
||||
this.buttonDownloadAndInstall.Size = new System.Drawing.Size(160, 21);
|
||||
this.buttonDownloadAndInstall.TabIndex = 4;
|
||||
this.buttonDownloadAndInstall.Text = "&OK";
|
||||
this.buttonDownloadAndInstall.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// timerCheckForUpdates
|
||||
//
|
||||
this.timerCheckForUpdates.Tick += new System.EventHandler(this.timerCheckForUpdates_Tick);
|
||||
//
|
||||
// CheckForUpdates
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(643, 123);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonDownloadAndInstall);
|
||||
this.Controls.Add(this.textBoxChangeLog);
|
||||
this.Controls.Add(this.labelStatus);
|
||||
this.KeyPreview = true;
|
||||
this.Name = "CheckForUpdates";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "CheckForUpdates";
|
||||
this.Shown += new System.EventHandler(this.CheckForUpdates_Shown);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CheckForUpdates_KeyDown);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label labelStatus;
|
||||
private System.Windows.Forms.TextBox textBoxChangeLog;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonDownloadAndInstall;
|
||||
private System.Windows.Forms.Timer timerCheckForUpdates;
|
||||
}
|
||||
}
|
66
src/Forms/CheckForUpdates.cs
Normal file
66
src/Forms/CheckForUpdates.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using Nikse.SubtitleEdit.Logic.Forms;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public partial class CheckForUpdates : Form
|
||||
{
|
||||
private CheckForUpdatesHelper _updatesHelper;
|
||||
private double _seconds = 0;
|
||||
|
||||
public CheckForUpdates()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Text = Configuration.Settings.Language.CheckForUpdates.Title;
|
||||
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdates;
|
||||
buttonDownloadAndInstall.Text = Configuration.Settings.Language.CheckForUpdates.InstallUpdate;
|
||||
buttonDownloadAndInstall.Visible = false;
|
||||
textBoxChangeLog.Visible = false;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.OK;
|
||||
}
|
||||
|
||||
private void CheckForUpdates_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Escape)
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
private void CheckForUpdates_Shown(object sender, EventArgs e)
|
||||
{
|
||||
_updatesHelper = new CheckForUpdatesHelper();
|
||||
Application.DoEvents();
|
||||
Refresh();
|
||||
_updatesHelper.CheckForUpdates();
|
||||
timerCheckForUpdates.Start();
|
||||
}
|
||||
|
||||
private void timerCheckForUpdates_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (_seconds > 10)
|
||||
{
|
||||
timerCheckForUpdates.Stop();
|
||||
labelStatus.Text = string.Format(Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesFailedX, "Time out");
|
||||
}
|
||||
else if (_updatesHelper.Error != null)
|
||||
{
|
||||
timerCheckForUpdates.Stop();
|
||||
labelStatus.Text = string.Format(Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesFailedX, _updatesHelper.Error);
|
||||
}
|
||||
else if (_updatesHelper.Done)
|
||||
{
|
||||
timerCheckForUpdates.Stop();
|
||||
Height = 600;
|
||||
textBoxChangeLog.Text = _updatesHelper.LatestChangeLog;
|
||||
textBoxChangeLog.Visible = true;
|
||||
labelStatus.Text = Configuration.Settings.Language.CheckForUpdates.CheckingForUpdatesNewVersion;
|
||||
buttonDownloadAndInstall.Visible = true;
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
}
|
||||
_seconds += timerCheckForUpdates.Interval / 1000.0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
123
src/Forms/CheckForUpdates.resx
Normal file
123
src/Forms/CheckForUpdates.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="timerCheckForUpdates.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
34
src/Forms/Main.Designer.cs
generated
34
src/Forms/Main.Designer.cs
generated
@ -154,6 +154,7 @@
|
||||
this.ChangeCasingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemAutoMergeShortLines = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemMergeDuplicateText = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemAutoSplitLongLines = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -446,7 +447,8 @@
|
||||
this.imageListPlayRate = new System.Windows.Forms.ImageList(this.components);
|
||||
this.timerTextUndo = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerAlternateTextUndo = new System.Windows.Forms.Timer(this.components);
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
@ -1590,6 +1592,13 @@
|
||||
this.toolStripMenuItemMergeDuplicateText.Text = "Merge lines with same text...";
|
||||
this.toolStripMenuItemMergeDuplicateText.Click += new System.EventHandler(this.toolStripMenuItemMergeDuplicateText_Click);
|
||||
//
|
||||
// toolStripMenuItemMergeLinesWithSameTimeCodes
|
||||
//
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Name = "toolStripMenuItemMergeLinesWithSameTimeCodes";
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Size = new System.Drawing.Size(346, 22);
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Text = "Merge lines with same time codes...";
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemMergeLinesWithSameTimeCodes_Click);
|
||||
//
|
||||
// toolStripMenuItemAutoSplitLongLines
|
||||
//
|
||||
this.toolStripMenuItemAutoSplitLongLines.Name = "toolStripMenuItemAutoSplitLongLines";
|
||||
@ -2119,6 +2128,8 @@
|
||||
// helpToolStripMenuItem
|
||||
//
|
||||
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.checkForUpdatesToolStripMenuItem,
|
||||
this.toolStripMenuItem3,
|
||||
this.helpToolStripMenuItem1,
|
||||
this.aboutToolStripMenuItem});
|
||||
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
|
||||
@ -2129,14 +2140,14 @@
|
||||
//
|
||||
this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1";
|
||||
this.helpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1;
|
||||
this.helpToolStripMenuItem1.Size = new System.Drawing.Size(118, 22);
|
||||
this.helpToolStripMenuItem1.Size = new System.Drawing.Size(186, 22);
|
||||
this.helpToolStripMenuItem1.Text = "Help";
|
||||
this.helpToolStripMenuItem1.Click += new System.EventHandler(this.HelpToolStripMenuItem1Click);
|
||||
//
|
||||
// aboutToolStripMenuItem
|
||||
//
|
||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(118, 22);
|
||||
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.aboutToolStripMenuItem.Text = "About";
|
||||
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItemClick);
|
||||
//
|
||||
@ -4389,12 +4400,17 @@
|
||||
this.timerAlternateTextUndo.Interval = 700;
|
||||
this.timerAlternateTextUndo.Tick += new System.EventHandler(this.TimerAlternateTextUndoTick);
|
||||
//
|
||||
// toolStripMenuItemMergeLinesWithSameTimeCodes
|
||||
// toolStripMenuItem3
|
||||
//
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Name = "toolStripMenuItemMergeLinesWithSameTimeCodes";
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Size = new System.Drawing.Size(346, 22);
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Text = "Merge lines with same time codes...";
|
||||
this.toolStripMenuItemMergeLinesWithSameTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemMergeLinesWithSameTimeCodes_Click);
|
||||
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||
this.toolStripMenuItem3.Size = new System.Drawing.Size(183, 6);
|
||||
//
|
||||
// checkForUpdatesToolStripMenuItem
|
||||
//
|
||||
this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem";
|
||||
this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.checkForUpdatesToolStripMenuItem.Text = "Check for updates...";
|
||||
this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);
|
||||
//
|
||||
// Main
|
||||
//
|
||||
@ -4896,6 +4912,8 @@
|
||||
private System.Windows.Forms.ToolStripButton toolStripButtonFixCommonErrors;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportDcinemaInterop;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeLinesWithSameTimeCodes;
|
||||
private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19421,5 +19421,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return _subtitle;
|
||||
}
|
||||
|
||||
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new CheckForUpdates();
|
||||
_formPositionsAndSizes.SetPositionAndSize(form);
|
||||
form.ShowDialog(this);
|
||||
_formPositionsAndSizes.SavePositionAndSize(form);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -607,9 +607,6 @@
|
||||
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>208, 56</value>
|
||||
</metadata>
|
||||
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>208, 56</value>
|
||||
</metadata>
|
||||
<data name="toolStripButtonWaveFormZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
@ -725,7 +722,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
|
||||
CAAAAk1TRnQBSQFMAgEBAgEAARABIQEQASEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
CAAAAk1TRnQBSQFMAgEBAgEAARgBIQEYASEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
|
117
src/Logic/Forms/CheckForUpdatesHelper.cs
Normal file
117
src/Logic/Forms/CheckForUpdatesHelper.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic.Forms
|
||||
{
|
||||
public class CheckForUpdatesHelper
|
||||
{
|
||||
private const string ReleasesUrl = "https://api.github.com/repos/SubtitleEdit/subtitleedit/releases";
|
||||
private const string ChangeLogUrl = "https://raw.githubusercontent.com/SubtitleEdit/subtitleedit/master/src/Changelog.txt";
|
||||
|
||||
private string _jsonReleases;
|
||||
private string _changeLog;
|
||||
private int _successCount;
|
||||
|
||||
public string Error { get; set; }
|
||||
public bool Done
|
||||
{
|
||||
get
|
||||
{
|
||||
return _successCount == 2;
|
||||
}
|
||||
private set
|
||||
{
|
||||
Done = value;
|
||||
}
|
||||
}
|
||||
public string LatestVersionNumber { get; set; }
|
||||
public string LatestChangeLog { get; set; }
|
||||
|
||||
private void StartDownloadString(string url, string contentType, AsyncCallback callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
request.UserAgent = "SubtitleEdit";
|
||||
request.ContentType = contentType;
|
||||
request.Timeout = Timeout.Infinite;
|
||||
request.Method = "GET";
|
||||
request.AllowAutoRedirect = true;
|
||||
request.Accept = contentType;
|
||||
request.BeginGetResponse(callback, request);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (Error == null)
|
||||
{
|
||||
Error = exception.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FinishWebRequestReleases(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
_jsonReleases = GetStringFromResponse(result);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (Error == null)
|
||||
{
|
||||
Error = exception.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FinishWebRequestChangeLog(IAsyncResult result)
|
||||
{
|
||||
try
|
||||
{
|
||||
_changeLog = GetStringFromResponse(result);
|
||||
LatestChangeLog = _changeLog;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (Error == null)
|
||||
{
|
||||
Error = exception.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetStringFromResponse(IAsyncResult result)
|
||||
{
|
||||
HttpWebResponse response = (result.AsyncState as HttpWebRequest).EndGetResponse(result) as HttpWebResponse;
|
||||
System.IO.Stream responseStream = response.GetResponseStream();
|
||||
byte[] buffer = new byte[5000000];
|
||||
int count = 1;
|
||||
int index = 0;
|
||||
while (count > 0)
|
||||
{
|
||||
count = responseStream.Read(buffer, index, 2048);
|
||||
index += count;
|
||||
}
|
||||
if (index > 0)
|
||||
_successCount++;
|
||||
return System.Text.Encoding.UTF8.GetString(buffer, 0, index);
|
||||
}
|
||||
|
||||
public CheckForUpdatesHelper()
|
||||
{
|
||||
Error = null;
|
||||
_successCount = 0;
|
||||
}
|
||||
|
||||
public void CheckForUpdates()
|
||||
{
|
||||
// load github release json
|
||||
StartDownloadString(ReleasesUrl, "application/json", new AsyncCallback(FinishWebRequestReleases));
|
||||
|
||||
// load change log
|
||||
StartDownloadString(ChangeLogUrl, null, new AsyncCallback(FinishWebRequestChangeLog));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public LanguageStructure.ChangeCasingNames ChangeCasingNames;
|
||||
public LanguageStructure.ChangeFrameRate ChangeFrameRate;
|
||||
public LanguageStructure.ChangeSpeedInPercent ChangeSpeedInPercent;
|
||||
public LanguageStructure.CheckForUpdates CheckForUpdates;
|
||||
public LanguageStructure.ChooseAudioTrack ChooseAudioTrack;
|
||||
public LanguageStructure.ChooseEncoding ChooseEncoding;
|
||||
public LanguageStructure.ChooseLanguage ChooseLanguage;
|
||||
@ -329,6 +330,16 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
Info = "Change speed of subtitle in percent",
|
||||
};
|
||||
|
||||
CheckForUpdates = new LanguageStructure.CheckForUpdates
|
||||
{
|
||||
Title = "Check for updates",
|
||||
CheckingForUpdates = "Checking for updates...",
|
||||
CheckingForUpdatesFailedX = "Checking for updates failed: {0}",
|
||||
CheckingForUpdatesNoneAvailable = "You're using the latest version of Subtitle Edit :)",
|
||||
CheckingForUpdatesNewVersion = "New version available!",
|
||||
InstallUpdate = "Download and install",
|
||||
};
|
||||
|
||||
ChooseAudioTrack = new LanguageStructure.ChooseAudioTrack
|
||||
{
|
||||
Title = "Choose audio track",
|
||||
|
@ -217,6 +217,16 @@
|
||||
public string Info { get; set; }
|
||||
}
|
||||
|
||||
public class CheckForUpdates
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string CheckingForUpdates { get; set; }
|
||||
public string CheckingForUpdatesFailedX { get; set; }
|
||||
public string CheckingForUpdatesNoneAvailable { get; set; }
|
||||
public string CheckingForUpdatesNewVersion { get; set; }
|
||||
public string InstallUpdate { get; set; }
|
||||
}
|
||||
|
||||
public class ChooseAudioTrack
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
@ -75,6 +75,12 @@
|
||||
<Compile Include="Controls\AudioVisualizer.Designer.cs">
|
||||
<DependentUpon>AudioVisualizer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CheckForUpdates.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\CheckForUpdates.Designer.cs">
|
||||
<DependentUpon>CheckForUpdates.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\ColorChooser.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -753,6 +759,7 @@
|
||||
<Compile Include="Logic\ColorChooser\ColorChangedEventArgs.cs" />
|
||||
<Compile Include="Logic\ColorChooser\ColorHandler.cs" />
|
||||
<Compile Include="Logic\ColorChooser\ColorWheel.cs" />
|
||||
<Compile Include="Logic\Forms\CheckForUpdatesHelper.cs" />
|
||||
<Compile Include="Logic\Forms\RemoveTextForHISettings.cs" />
|
||||
<Compile Include="Logic\Forms\RemoveTextForHI.cs" />
|
||||
<Compile Include="Logic\Forms\SplitLongLinesHelper.cs" />
|
||||
@ -1170,6 +1177,9 @@
|
||||
<EmbeddedResource Include="Controls\AudioVisualizer.resx">
|
||||
<DependentUpon>AudioVisualizer.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\CheckForUpdates.resx">
|
||||
<DependentUpon>CheckForUpdates.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\ColorChooser.resx">
|
||||
<DependentUpon>ColorChooser.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
Loading…
Reference in New Issue
Block a user