First upgrade warning logic entered into DM

This provides the steps to the users from the remote site so that I can update them if they are wrong. Seems to work correctly.
This commit is contained in:
Terry MacDonald 2021-09-30 21:30:06 +13:00
parent 09c1fcf452
commit d298c00199
4 changed files with 65 additions and 25 deletions

View File

@ -17,10 +17,6 @@ using DesktopNotifications;
using System.Runtime.Serialization;
using NLog.Config;
using System.Collections.Generic;
using System.Collections;
using DisplayMagicianShared.AMD;
using DisplayMagicianShared.NVIDIA;
using DisplayMagicianShared.Windows;
using AutoUpdaterDotNET;
using Newtonsoft.Json;
@ -645,6 +641,15 @@ namespace DisplayMagician {
// Check if it's an upgrade from DisplayMagician v1 to v2
// and if it is then explain what the user needs to do.
// e.g. DisplayProfiles_1.0.json exists, but DisplayProfiles_2.0.json doesn't
if (File.Exists(Path.Combine(AppProfilePath, "DisplayProfiles_1.0.json")) && !File.Exists(Path.Combine(AppProfilePath, "DisplayProfiles_2.0.json")))
{
StartMessageForm myMessageWindow = new StartMessageForm();
myMessageWindow.URL = "https://displaymagician.littlebitbig.com/messages/DisplayMagician1to2.rtf";
myMessageWindow.HeadingText = "DisplayMagician v2.0.0 Upgrade Warning";
myMessageWindow.ButtonText = "&Close";
myMessageWindow.Show();
}
// Run the program with normal startup
AppMainForm = new MainForm();

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.0.0.1")]
[assembly: AssemblyFileVersion("2.0.0.1")]
[assembly: AssemblyVersion("2.0.0.7")]
[assembly: AssemblyFileVersion("2.0.0.7")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -29,30 +29,35 @@ namespace DisplayMagician.UIForms
/// </summary>
private void InitializeComponent()
{
this.lbl_profile_shown = new System.Windows.Forms.Label();
this.lbl_heading_text = new System.Windows.Forms.Label();
this.rtb_message = new System.Windows.Forms.RichTextBox();
this.btn_back = new System.Windows.Forms.Button();
this.pnl_richtextbox = new System.Windows.Forms.Panel();
this.pnl_richtextbox.SuspendLayout();
this.SuspendLayout();
//
// lbl_profile_shown
// lbl_heading_text
//
this.lbl_profile_shown.AutoSize = true;
this.lbl_profile_shown.BackColor = System.Drawing.Color.Black;
this.lbl_profile_shown.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_profile_shown.ForeColor = System.Drawing.Color.White;
this.lbl_profile_shown.Location = new System.Drawing.Point(437, 19);
this.lbl_profile_shown.Name = "lbl_profile_shown";
this.lbl_profile_shown.Size = new System.Drawing.Size(400, 29);
this.lbl_profile_shown.TabIndex = 20;
this.lbl_profile_shown.Text = "Important DisplayMagician Message";
this.lbl_profile_shown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lbl_heading_text.AutoSize = true;
this.lbl_heading_text.BackColor = System.Drawing.Color.Black;
this.lbl_heading_text.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_heading_text.ForeColor = System.Drawing.Color.White;
this.lbl_heading_text.Location = new System.Drawing.Point(437, 19);
this.lbl_heading_text.Name = "lbl_heading_text";
this.lbl_heading_text.Size = new System.Drawing.Size(400, 29);
this.lbl_heading_text.TabIndex = 20;
this.lbl_heading_text.Text = "Important DisplayMagician Message";
this.lbl_heading_text.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// rtb_message
//
this.rtb_message.Location = new System.Drawing.Point(0, 62);
this.rtb_message.BackColor = System.Drawing.Color.White;
this.rtb_message.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.rtb_message.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtb_message.Location = new System.Drawing.Point(20, 20);
this.rtb_message.Name = "rtb_message";
this.rtb_message.ReadOnly = true;
this.rtb_message.Size = new System.Drawing.Size(1275, 732);
this.rtb_message.Size = new System.Drawing.Size(1209, 687);
this.rtb_message.TabIndex = 21;
this.rtb_message.Text = "";
//
@ -68,24 +73,37 @@ namespace DisplayMagician.UIForms
this.btn_back.Name = "btn_back";
this.btn_back.Size = new System.Drawing.Size(75, 23);
this.btn_back.TabIndex = 22;
this.btn_back.Text = "&Back";
this.btn_back.Text = "&Close";
this.btn_back.UseVisualStyleBackColor = true;
this.btn_back.Click += new System.EventHandler(this.btn_back_Click);
//
// pnl_richtextbox
//
this.pnl_richtextbox.BackColor = System.Drawing.Color.White;
this.pnl_richtextbox.Controls.Add(this.rtb_message);
this.pnl_richtextbox.Location = new System.Drawing.Point(13, 63);
this.pnl_richtextbox.Name = "pnl_richtextbox";
this.pnl_richtextbox.Padding = new System.Windows.Forms.Padding(20);
this.pnl_richtextbox.Size = new System.Drawing.Size(1249, 727);
this.pnl_richtextbox.TabIndex = 23;
//
// StartMessageForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(1274, 844);
this.Controls.Add(this.pnl_richtextbox);
this.Controls.Add(this.btn_back);
this.Controls.Add(this.rtb_message);
this.Controls.Add(this.lbl_profile_shown);
this.Controls.Add(this.lbl_heading_text);
this.Name = "StartMessageForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "DisplayMagician - Message";
this.TopMost = true;
this.Load += new System.EventHandler(this.StartMessageForm_Load);
this.pnl_richtextbox.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -93,8 +111,9 @@ namespace DisplayMagician.UIForms
#endregion
private System.Windows.Forms.Label lbl_profile_shown;
private System.Windows.Forms.Label lbl_heading_text;
private System.Windows.Forms.RichTextBox rtb_message;
private System.Windows.Forms.Button btn_back;
private System.Windows.Forms.Panel pnl_richtextbox;
}
}

View File

@ -18,7 +18,8 @@ namespace DisplayMagician.UIForms
public string Filename;
public string URL;
public string Heading;
public string HeadingText;
public string ButtonText;
public StartMessageForm()
{
@ -34,6 +35,18 @@ namespace DisplayMagician.UIForms
{
string FullPath;
// Set the heading text if supplied
if (!String.IsNullOrWhiteSpace(HeadingText))
{
lbl_heading_text.Text = HeadingText;
}
// Set the button text if supplied
if (!String.IsNullOrWhiteSpace(ButtonText))
{
btn_back.Text = ButtonText;
}
// check if we're in Filename mode or URL mode
if (!String.IsNullOrWhiteSpace(Filename))
{
@ -74,6 +87,7 @@ namespace DisplayMagician.UIForms
if (!IsURLValid(URL))
{
logger.Error($"StartMessageForm/StartMessageForm_Load: URL {URL} pointing to the RTF file is invalid!");
this.Close();
return;
}
// If we get here, then the URL is good. See if we can access the URL supplied
@ -83,11 +97,13 @@ namespace DisplayMagician.UIForms
byte[] byteArray = client.DownloadData(URL);
MemoryStream theMemStream = new MemoryStream();
theMemStream.Write(byteArray, 0, byteArray.Length);
theMemStream.Position = 0;
rtb_message.LoadFile(theMemStream, RichTextBoxStreamType.RichText);
}
catch (Exception ex)
{
logger.Error(ex, $"StartMessageForm/StartMessageForm_Load: Exception while trying to load the URL supplied (\"{Filename}\") into the RichTextBox message object");
this.Close();
return;
}