# HG changeset patch # User sl # Date 1421345905 -3600 # Node ID 4f09ae97cdccc0339ac2d741b36e72ff3233147f # Parent 26e884e49594841677ee5e09c1c1bf04fcdf9360 Adding application update button. Adding manifest to run as admin. Disabling ClickOnce security check to run as admin. The whole thing is not tested. diff -r 26e884e49594 -r 4f09ae97cdcc Server/MainForm.Designer.cs --- a/Server/MainForm.Designer.cs Mon Jan 12 08:33:53 2015 +0100 +++ b/Server/MainForm.Designer.cs Thu Jan 15 19:18:25 2015 +0100 @@ -79,6 +79,8 @@ this.labelFontWidth = new System.Windows.Forms.Label(); this.labelFontHeight = new System.Windows.Forms.Label(); this.pictureBoxDemo = new System.Windows.Forms.PictureBox(); + this.tabPageApp = new System.Windows.Forms.TabPage(); + this.buttonUpdate = new System.Windows.Forms.Button(); this.panelDisplay.SuspendLayout(); this.tableLayoutPanel.SuspendLayout(); this.statusStrip.SuspendLayout(); @@ -88,6 +90,7 @@ this.tabControl.SuspendLayout(); this.tabPageDesign.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxDemo)).BeginInit(); + this.tabPageApp.SuspendLayout(); this.SuspendLayout(); // // panelDisplay @@ -485,6 +488,7 @@ this.tabControl.Controls.Add(this.tabPageDisplay); this.tabControl.Controls.Add(this.tabPageClients); this.tabControl.Controls.Add(this.tabPageDesign); + this.tabControl.Controls.Add(this.tabPageApp); this.tabControl.Location = new System.Drawing.Point(12, 139); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; @@ -633,6 +637,27 @@ this.pictureBoxDemo.TabIndex = 21; this.pictureBoxDemo.TabStop = false; // + // tabPageApp + // + this.tabPageApp.Controls.Add(this.buttonUpdate); + this.tabPageApp.Location = new System.Drawing.Point(4, 22); + this.tabPageApp.Name = "tabPageApp"; + this.tabPageApp.Padding = new System.Windows.Forms.Padding(3); + this.tabPageApp.Size = new System.Drawing.Size(592, 242); + this.tabPageApp.TabIndex = 4; + this.tabPageApp.Text = "Application"; + this.tabPageApp.UseVisualStyleBackColor = true; + // + // buttonUpdate + // + this.buttonUpdate.Location = new System.Drawing.Point(6, 213); + this.buttonUpdate.Name = "buttonUpdate"; + this.buttonUpdate.Size = new System.Drawing.Size(75, 23); + this.buttonUpdate.TabIndex = 0; + this.buttonUpdate.Text = "Update"; + this.buttonUpdate.UseVisualStyleBackColor = true; + this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -665,6 +690,7 @@ this.tabPageDesign.ResumeLayout(false); this.tabPageDesign.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxDemo)).EndInit(); + this.tabPageApp.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -721,6 +747,8 @@ private System.Windows.Forms.Label labelFontHeight; private System.Windows.Forms.CheckBox checkBoxInverseColors; private System.Windows.Forms.PictureBox pictureBoxDemo; + private System.Windows.Forms.TabPage tabPageApp; + private System.Windows.Forms.Button buttonUpdate; } } diff -r 26e884e49594 -r 4f09ae97cdcc Server/MainForm.cs --- a/Server/MainForm.cs Mon Jan 12 08:33:53 2015 +0100 +++ b/Server/MainForm.cs Thu Jan 15 19:18:25 2015 +0100 @@ -13,6 +13,7 @@ using System.ServiceModel; using System.Threading; using System.Diagnostics; +using System.Deployment.Application; // using SharpDisplayClient; using SharpDisplay; @@ -1316,6 +1317,81 @@ { iDisplay.HideClock(); } + + private void buttonUpdate_Click(object sender, EventArgs e) + { + InstallUpdateSyncWithInfo(); + } + + + private void InstallUpdateSyncWithInfo() + { + UpdateCheckInfo info = null; + + if (ApplicationDeployment.IsNetworkDeployed) + { + ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment; + + try + { + info = ad.CheckForDetailedUpdate(); + + } + catch (DeploymentDownloadException dde) + { + MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message); + return; + } + catch (InvalidDeploymentException ide) + { + MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message); + return; + } + catch (InvalidOperationException ioe) + { + MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message); + return; + } + + if (info.UpdateAvailable) + { + Boolean doUpdate = true; + + if (!info.IsUpdateRequired) + { + DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel); + if (!(DialogResult.OK == dr)) + { + doUpdate = false; + } + } + else + { + // Display a message that the app MUST reboot. Display the minimum required version. + MessageBox.Show("This application has detected a mandatory update from your current " + + "version to version " + info.MinimumRequiredVersion.ToString() + + ". The application will now install the update and restart.", + "Update Available", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + + if (doUpdate) + { + try + { + ad.Update(); + MessageBox.Show("The application has been upgraded, and will now restart."); + Application.Restart(); + } + catch (DeploymentDownloadException dde) + { + MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde); + return; + } + } + } + } + } } /// diff -r 26e884e49594 -r 4f09ae97cdcc Server/Properties/AssemblyInfo.cs --- a/Server/Properties/AssemblyInfo.cs Mon Jan 12 08:33:53 2015 +0100 +++ b/Server/Properties/AssemblyInfo.cs Thu Jan 15 19:18:25 2015 +0100 @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; using System.Resources; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Sharp Display Manager")] @@ -11,12 +11,12 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Slions")] [assembly: AssemblyProduct("Sharp Display Manager")] -[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyCopyright("Copyright © 2014 Stéphane Lenclud")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -26,11 +26,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff -r 26e884e49594 -r 4f09ae97cdcc Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Mon Jan 12 08:33:53 2015 +0100 +++ b/Server/SharpDisplayManager.csproj Thu Jan 15 19:18:25 2015 +0100 @@ -17,10 +17,10 @@ true Web true - Foreground + Background 7 Days - false + true false true http://publish.slions.net/SharpDisplayManager/ @@ -88,7 +88,7 @@ SharpDisplayManager_TemporaryKey.pfx - true + false vfd.ico @@ -96,6 +96,12 @@ SharpDisplayManager.Program + + app.manifest + + + LocalIntranet + @@ -146,6 +152,7 @@ Resources.resx True + SettingsSingleFileGenerator Settings.Designer.cs diff -r 26e884e49594 -r 4f09ae97cdcc Server/app.manifest --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server/app.manifest Thu Jan 15 19:18:25 2015 +0100 @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file