Removing old ApplyingChangesForm

This commit is contained in:
Terry MacDonald 2020-10-06 20:08:36 +13:00
parent 267dfbe9f3
commit 0b5937d25c
4 changed files with 0 additions and 2455 deletions

View File

@ -122,12 +122,6 @@
<Compile Include="UIForms\ShortcutForm.Designer.cs">
<DependentUpon>ShortcutForm.cs</DependentUpon>
</Compile>
<Compile Include="UIForms\ApplyingChangesForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UIForms\ApplyingChangesForm.Designer.cs">
<DependentUpon>ApplyingChangesForm.cs</DependentUpon>
</Compile>
<Compile Include="UIForms\DisplayProfileForm.cs">
<SubType>Form</SubType>
</Compile>
@ -165,9 +159,6 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="UIForms\ApplyingChangesForm.resx">
<DependentUpon>ApplyingChangesForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UIForms\ShortcutLibraryForm.resx">
<DependentUpon>ShortcutLibraryForm.cs</DependentUpon>
<SubType>Designer</SubType>

View File

@ -1,157 +0,0 @@
using System.Windows.Forms;
using HeliosPlus.Resources;
namespace HeliosPlus.UIForms
{
sealed partial class ApplyingChangesForm
{
/// <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();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ApplyingChangesForm));
this.progressPanel = new System.Windows.Forms.Panel();
this.lbl_sub_message = new System.Windows.Forms.Label();
this.lbl_message = new System.Windows.Forms.Label();
this.progressBar = new CircularProgressBar.CircularProgressBar();
this.t_cancellation = new System.Windows.Forms.Timer(this.components);
this.t_countdown = new System.Windows.Forms.Timer(this.components);
this.progressPanel.SuspendLayout();
this.SuspendLayout();
//
// progressPanel
//
this.progressPanel.Anchor = System.Windows.Forms.AnchorStyles.None;
this.progressPanel.Controls.Add(this.lbl_sub_message);
this.progressPanel.Controls.Add(this.lbl_message);
this.progressPanel.Controls.Add(this.progressBar);
this.progressPanel.Location = new System.Drawing.Point(12, 54);
this.progressPanel.Name = "progressPanel";
this.progressPanel.Size = new System.Drawing.Size(621, 270);
this.progressPanel.TabIndex = 0;
//
// lbl_sub_message
//
this.lbl_sub_message.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_sub_message.ForeColor = System.Drawing.Color.White;
this.lbl_sub_message.Location = new System.Drawing.Point(160, 85);
this.lbl_sub_message.Name = "lbl_sub_message";
this.lbl_sub_message.Size = new System.Drawing.Size(300, 16);
this.lbl_sub_message.TabIndex = 2;
this.lbl_sub_message.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lbl_message
//
this.lbl_message.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
this.lbl_message.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.lbl_message.Location = new System.Drawing.Point(3, 27);
this.lbl_message.Name = "lbl_message";
this.lbl_message.Size = new System.Drawing.Size(615, 61);
this.lbl_message.TabIndex = 1;
this.lbl_message.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// progressBar
//
this.progressBar.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner;
this.progressBar.AnimationSpeed = 1000;
this.progressBar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.progressBar.Font = new System.Drawing.Font("Microsoft Sans Serif", 39.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.progressBar.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.progressBar.InnerColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
this.progressBar.InnerMargin = 0;
this.progressBar.InnerWidth = 0;
this.progressBar.Location = new System.Drawing.Point(243, 125);
this.progressBar.MarqueeAnimationSpeed = 2000;
this.progressBar.Name = "progressBar";
this.progressBar.OuterColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.progressBar.OuterMargin = -8;
this.progressBar.OuterWidth = 6;
this.progressBar.ProgressColor = System.Drawing.Color.DodgerBlue;
this.progressBar.ProgressWidth = 10;
this.progressBar.SecondaryFont = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.progressBar.Size = new System.Drawing.Size(135, 135);
this.progressBar.StartAngle = 270;
this.progressBar.SubscriptColor = System.Drawing.Color.FromArgb(((int)(((byte)(166)))), ((int)(((byte)(166)))), ((int)(((byte)(166)))));
this.progressBar.SubscriptMargin = new System.Windows.Forms.Padding(10, -35, 0, 0);
this.progressBar.SubscriptText = "";
this.progressBar.SuperscriptColor = System.Drawing.Color.Gray;
this.progressBar.SuperscriptMargin = new System.Windows.Forms.Padding(0, 30, 0, 0);
this.progressBar.SuperscriptText = "";
this.progressBar.TabIndex = 0;
this.progressBar.TextMargin = new System.Windows.Forms.Padding(2, 5, 0, 0);
this.progressBar.Value = 68;
//
// t_start
//
this.t_cancellation.Interval = 1000;
this.t_cancellation.Tick += new System.EventHandler(this.t_cancellation_Tick);
//
// t_countdown
//
this.t_countdown.Interval = 1000;
this.t_countdown.Tick += new System.EventHandler(this.t_countdown_Tick);
//
// ApplyingChangesForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.ClientSize = new System.Drawing.Size(645, 418);
this.ControlBox = false;
this.Controls.Add(this.progressPanel);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ApplyingChangesForm";
this.Opacity = 0D;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "HeliosPlus - Please Wait";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SplashForm_FormClosing);
this.Load += new System.EventHandler(this.SplashForm_Reposition);
this.Shown += new System.EventHandler(this.SplashForm_Shown);
this.LocationChanged += new System.EventHandler(this.SplashForm_Reposition);
this.Leave += new System.EventHandler(this.SplashForm_Reposition);
this.Move += new System.EventHandler(this.SplashForm_Reposition);
this.progressPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Panel progressPanel;
private CircularProgressBar.CircularProgressBar progressBar;
private System.Windows.Forms.Label lbl_message;
private System.Windows.Forms.Timer t_cancellation;
private System.Windows.Forms.Timer t_countdown;
private Label lbl_sub_message;
}
}

View File

@ -1,305 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using HeliosPlus.Resources;
using WinFormAnimation;
namespace HeliosPlus.UIForms
{
public sealed partial class ApplyingChangesForm : Form
{
private readonly Action _job;
private readonly Bitmap _progressImage;
private readonly List<Point> _progressPositions = new List<Point>();
private int _countdownCounter;
private readonly int _displayChangeMaxDelta = -1;
private int _displayChangeDelta;
private int _lastCount;
private bool _isClosing;
private int _startCounter;
public ApplyingChangesForm()
{
InitializeComponent();
_progressImage = new Bitmap(progressPanel.Width, progressPanel.Height);
Controls.Remove(progressPanel);
progressPanel.BackColor = BackColor;
progressBar.Invalidated += (sender, args) => Invalidate();
progressPanel.Invalidated += (sender, args) => Invalidate();
Reposition();
}
public ApplyingChangesForm(Action job, int cancellationTimeout = 0, int countdown = 0) : this()
{
_job = job;
_startCounter = cancellationTimeout;
_countdownCounter = countdown; _lastCount = _countdownCounter;
}
public ApplyingChangesForm(Action job, int cancellationTimeout = 0, int countdown = 0, int displayChangeMaxDelta = 5, string state = null) : this(job, cancellationTimeout, countdown)
{
_displayChangeMaxDelta = displayChangeMaxDelta;
if (!string.IsNullOrEmpty(state)) CountdownMessage = state;
}
public string CancellationMessage { get; set; } = Language.Starting_in;
public string CancellationSubMessage { get; set; } = Language.Press_ESC_to_cancel;
public string CountdownMessage { get; set; } = Language.Please_wait;
public string CountdownSubMessage { get; set; } = Language.It_wont_be_long_now;
protected override void OnKeyDown(KeyEventArgs e)
{
e.Handled = true;
}
protected override void OnPaint(PaintEventArgs e)
{
lock (_progressPositions)
{
progressPanel.DrawToBitmap(_progressImage, new Rectangle(Point.Empty, progressPanel.Size));
foreach (var position in _progressPositions)
{
e.Graphics.DrawImage(_progressImage, new Rectangle(position, progressPanel.Size));
}
}
base.OnPaint(e);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData != Keys.Escape)
{
return base.ProcessCmdKey(ref msg, keyData);
}
if (t_cancellation.Enabled)
{
t_cancellation.Stop();
t_countdown.Stop();
DialogResult = DialogResult.Cancel;
Close();
return true;
}
return true;
}
private void HandleDisplayChangeDelta()
{
if (_displayChangeMaxDelta <= -1) return;
_displayChangeDelta = _lastCount - _countdownCounter;
if (_displayChangeDelta > _displayChangeMaxDelta)
{
Debug.Print("_displayChangeDelta > _displayChangeMaxDelta! " + _displayChangeDelta + " > " + _displayChangeMaxDelta);
DialogResult = DialogResult.OK;
Close();
}
}
private void DoJob()
{
lbl_message.Text = CountdownMessage;
lbl_sub_message.Text = CountdownSubMessage;
progressBar.ProgressColor = Color.OrangeRed;
if (_countdownCounter > 0)
{
progressBar.Text = (progressBar.Value = progressBar.Maximum = _countdownCounter).ToString();
t_countdown.Start();
_job?.Invoke();
}
else
{
progressBar.Style = ProgressBarStyle.Marquee;
progressBar.Text = "";
progressBar.Maximum = 100;
progressBar.Value = 50;
progressBar.Style = ProgressBarStyle.Marquee;
_job?.Invoke();
DialogResult = DialogResult.OK;
Close();
}
HandleDisplayChangeDelta();
}
private void DoTimeout()
{
if (_startCounter > 0)
{
lbl_message.Text = CancellationMessage;
lbl_sub_message.Text = CancellationSubMessage;
progressBar.ProgressColor = Color.DodgerBlue;
progressBar.Text = (progressBar.Value = progressBar.Maximum = _startCounter).ToString();
t_cancellation.Start();
}
else
{
DoJob();
}
HandleDisplayChangeDelta();
}
private void Reposition()
{
lock (_progressPositions)
{
Screen[] screens = Screen.AllScreens;
Size = screens.Select(screen => screen.Bounds)
.Aggregate(Rectangle.Union)
.Size;
_progressPositions.Clear();
_progressPositions.AddRange(
screens.Select(
screen =>
new Point(screen.Bounds.X + ((screen.Bounds.Width - progressPanel.Width) / 2),
screen.Bounds.Y + ((screen.Bounds.Height - progressPanel.Height) / 2))
)
);
}
Invalidate();
}
private void SplashForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (_isClosing)
{
return;
}
_isClosing = true;
e.Cancel = true;
var dialogResult = DialogResult;
new Animator(new Path((float) Opacity, 0, 200))
.Play(new SafeInvoker<float>(f =>
{
try
{
Opacity = f;
}
catch (Exception ex)
{
Console.WriteLine($"ApplyingChangesForm/SplashForm_FormClosing exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
// ignored
}
}, this), new SafeInvoker(() =>
{
DialogResult = dialogResult;
Close();
}, this));
}
private void SplashForm_Reposition(object sender, EventArgs e)
{
Reposition();
}
private void SplashForm_Shown(object sender, EventArgs e)
{
new Animator(new Path((float) Opacity, 0.97f, 200))
.Play(new SafeInvoker<float>(f =>
{
try
{
Opacity = f;
}
catch (Exception ex)
{
Console.WriteLine($"ApplyingChangesForm/SplashForm_Shown exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}");
// ignored
}
}, this), new SafeInvoker(DoTimeout, this));
}
private void t_countdown_Tick(object sender, EventArgs e)
{
if (_countdownCounter < 0)
{
t_countdown.Stop();
DialogResult = DialogResult.OK;
Close();
return;
}
HandleDisplayChangeDelta();
progressBar.Value = _countdownCounter;
progressBar.Text = progressBar.Value.ToString();
_countdownCounter--;
Reposition();
}
private void t_cancellation_Tick(object sender, EventArgs e)
{
if (_startCounter < 0)
{
t_cancellation.Stop();
DoJob();
return;
}
progressBar.Value = _startCounter;
progressBar.Text = progressBar.Value.ToString();
_startCounter--;
Reposition();
}
protected override void WndProc(ref Message m)
{
const int WM_SETTINGCHANGE = 0x001A;
const int SPI_SETWORKAREA = 0x02F;
const int WM_DISPLAYCHANGE = 0x007E;
const int x_bitshift = 0;
const int y_bitshift = 16;
const int xy_mask = 0xFFFF;
bool displayChange = false;
switch (m.Msg)
{
case WM_SETTINGCHANGE:
Debug.Print("Message: " + m.ToString());
Debug.Print("WM_SETTINGCHANGE");
switch ((int)m.WParam)
{
case SPI_SETWORKAREA:
Debug.Print("SPI_SETWORKAREA");
displayChange = true;
break;
}
break;
case WM_DISPLAYCHANGE:
int cxScreen = (xy_mask & ((int)m.LParam) >> x_bitshift);
int cyScreen = (xy_mask & ((int)m.LParam) >> y_bitshift);
Debug.Print("Message: " + m.ToString());
Debug.Print("WM_DISPLAYCHANGE");
Debug.Print("cxScreen: " + cxScreen + " cyScreen: " + cyScreen);
displayChange = true;
break;
}
if (displayChange)
{
_displayChangeDelta = _lastCount - _countdownCounter;
_lastCount = _countdownCounter;
Debug.Print("Display Change Detected at t " + _lastCount + " difference between changes is " + _displayChangeDelta);
}
base.WndProc(ref m);
}
}
}

File diff suppressed because it is too large Load Diff