mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Added overlay to inform user UI is locked
This informs the user that the user UI is locked until they close the game/application that is started.
This commit is contained in:
parent
e9a821e594
commit
ccefa80642
@ -100,6 +100,12 @@
|
||||
<Compile Include="UIForms\ApplyingProfileForm.Designer.cs">
|
||||
<DependentUpon>ApplyingProfileForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UIForms\MaskedForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UIForms\MaskedDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UIForms\WaitingForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -160,6 +166,9 @@
|
||||
<EmbeddedResource Include="UIForms\ApplyingProfileForm.resx">
|
||||
<DependentUpon>ApplyingProfileForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UIForms\MaskedForm.resx">
|
||||
<DependentUpon>MaskedForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UIForms\WaitingForm.resx">
|
||||
<DependentUpon>WaitingForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -618,7 +618,10 @@ namespace HeliosPlus
|
||||
IPCService.GetInstance().HoldProcessId = processesToMonitor.FirstOrDefault()?.Id ?? 0;
|
||||
IPCService.GetInstance().Status = InstanceStatus.OnHold;
|
||||
|
||||
notifyIcon.Text = $"HeliosPlus: Waiting for the Application {processesToMonitor[0].ProcessName} to exit...";
|
||||
int substringStart = shortcutToUse.ExecutableNameAndPath.Length - 42;
|
||||
if (substringStart < 0)
|
||||
substringStart = 0;
|
||||
notifyIcon.Text = $"HeliosPlus: Running {shortcutToUse.ExecutableNameAndPath.Substring(substringStart)}...";
|
||||
Application.DoEvents();
|
||||
|
||||
// Wait for the monitored process to exit
|
||||
@ -682,7 +685,7 @@ namespace HeliosPlus
|
||||
IPCService.GetInstance().Status = InstanceStatus.OnHold;
|
||||
|
||||
// Add a status notification icon in the status area
|
||||
notifyIcon.Text = $"HeliosPlus: Waiting for the Game {steamGameToRun.Name} to exit...";
|
||||
notifyIcon.Text = $"HeliosPlus: Running {steamGameToRun.Name.Substring(0, 41)}...";
|
||||
Application.DoEvents();
|
||||
|
||||
// Wait 300ms for the game process to spawn
|
||||
@ -754,7 +757,7 @@ namespace HeliosPlus
|
||||
IPCService.GetInstance().Status = InstanceStatus.OnHold;
|
||||
|
||||
// Add a status notification icon in the status area
|
||||
notifyIcon.Text = $"HeliosPlus: Waiting for the Game {uplayGameToRun.Name} to exit...";
|
||||
notifyIcon.Text = $"HeliosPlus: Running {uplayGameToRun.Name.Substring(0,41)}...";
|
||||
Application.DoEvents();
|
||||
|
||||
// Wait 300ms for the game process to spawn
|
||||
|
116
HeliosPlus/UIForms/MaskedDialog.cs
Normal file
116
HeliosPlus/UIForms/MaskedDialog.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HeliosPlus.UIForms
|
||||
{
|
||||
public partial class MaskedDialog : Form
|
||||
{
|
||||
// from https://stackoverflow.com/questions/21530699/how-to-draw-overlay-window-winform-apps-c-sharp
|
||||
|
||||
static MaskedDialog mask;
|
||||
static Form frmContainer;
|
||||
|
||||
private Form dialog;
|
||||
private UserControl ucDialog;
|
||||
|
||||
private MaskedDialog(Form parent, Form dialog)
|
||||
{
|
||||
this.dialog = dialog;
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.Opacity = 0.50;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = parent.ClientSize;
|
||||
this.Location = parent.PointToScreen(System.Drawing.Point.Empty);
|
||||
parent.Move += AdjustPosition;
|
||||
parent.SizeChanged += AdjustPosition;
|
||||
}
|
||||
|
||||
private MaskedDialog(Form parent, UserControl ucDialog)
|
||||
{
|
||||
this.ucDialog = ucDialog;
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.Opacity = 0.50;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = parent.ClientSize;
|
||||
this.Location = parent.PointToScreen(System.Drawing.Point.Empty);
|
||||
parent.Move += AdjustPosition;
|
||||
parent.SizeChanged += AdjustPosition;
|
||||
}
|
||||
|
||||
private void AdjustPosition(object sender, EventArgs e)
|
||||
{
|
||||
Form parent = sender as Form;
|
||||
this.Location = parent.PointToScreen(System.Drawing.Point.Empty);
|
||||
this.ClientSize = parent.ClientSize;
|
||||
}
|
||||
|
||||
//
|
||||
public static DialogResult ShowDialog(Form parent, Form dialog)
|
||||
{
|
||||
mask = new MaskedDialog(parent, dialog);
|
||||
dialog.StartPosition = FormStartPosition.CenterParent;
|
||||
mask.MdiParent = parent.MdiParent;
|
||||
//mask.Show();
|
||||
DialogResult result = dialog.ShowDialog(mask);
|
||||
//mask.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static DialogResult ShowDialog(Form parent, UserControl dialog)
|
||||
{
|
||||
mask = new MaskedDialog(parent, dialog);
|
||||
frmContainer = new Form();
|
||||
frmContainer.ShowInTaskbar = false;
|
||||
frmContainer.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
frmContainer.StartPosition = FormStartPosition.CenterParent;
|
||||
frmContainer.Height = dialog.Height;
|
||||
frmContainer.Width = dialog.Width;
|
||||
|
||||
frmContainer.Controls.Add(dialog);
|
||||
mask.MdiParent = parent.MdiParent;
|
||||
//mask.ShowDialog();
|
||||
DialogResult result = frmContainer.ShowDialog(mask);
|
||||
frmContainer.Close();
|
||||
//mask.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void CloseDialog()
|
||||
{
|
||||
if (frmContainer != null)
|
||||
{
|
||||
frmContainer.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// MaskedDialog
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(284, 262);
|
||||
this.Name = "MaskedDialog";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MaskedDialog_FormClosing);
|
||||
this.Load += new System.EventHandler(this.MaskedDialog_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
private void MaskedDialog_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void MaskedDialog_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
115
HeliosPlus/UIForms/MaskedForm.cs
Normal file
115
HeliosPlus/UIForms/MaskedForm.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HeliosPlus.UIForms
|
||||
{
|
||||
public partial class MaskedForm : Form
|
||||
{
|
||||
private Label lbl_message;
|
||||
|
||||
// from https://stackoverflow.com/questions/21530699/how-to-draw-overlay-window-winform-apps-c-sharp
|
||||
|
||||
public static MaskedForm mask;
|
||||
|
||||
|
||||
|
||||
private MaskedForm(Form parent, string message)
|
||||
{
|
||||
this.SuspendLayout();
|
||||
InitializeComponent();
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
//this.BackColor = System.Drawing.Color.Black;
|
||||
this.Opacity = 0.50;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = parent.ClientSize;
|
||||
this.Location = parent.PointToScreen(System.Drawing.Point.Empty);
|
||||
//this.lbl_message.BackColor = System.Drawing.Color.Black;
|
||||
this.lbl_message.Text = message;
|
||||
this.MdiParent = parent.MdiParent;
|
||||
this.TopLevel = true;
|
||||
parent.Move += AdjustPosition;
|
||||
parent.SizeChanged += AdjustPosition;
|
||||
this.ResumeLayout();
|
||||
}
|
||||
|
||||
private void AdjustPosition(object sender, EventArgs e)
|
||||
{
|
||||
Form parent = sender as Form;
|
||||
this.Location = parent.PointToScreen(System.Drawing.Point.Empty);
|
||||
this.ClientSize = parent.ClientSize;
|
||||
}
|
||||
|
||||
//
|
||||
public static MaskedForm Show(Form parent, string message)
|
||||
{
|
||||
mask = new MaskedForm(parent, message);
|
||||
mask.Show();
|
||||
mask.Activate();
|
||||
Application.DoEvents();
|
||||
return mask;
|
||||
}
|
||||
|
||||
public static MaskedForm ShowDialog(Form parent, string message)
|
||||
{
|
||||
mask = new MaskedForm(parent, message);
|
||||
mask.ShowDialog();
|
||||
mask.Activate();
|
||||
Application.DoEvents();
|
||||
return mask;
|
||||
}
|
||||
|
||||
/*public static void Close()
|
||||
{
|
||||
MaskedForm.mask.Close();
|
||||
}*/
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lbl_message = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lbl_message
|
||||
//
|
||||
this.lbl_message.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.lbl_message.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lbl_message.Location = new System.Drawing.Point(161, 93);
|
||||
this.lbl_message.Name = "lbl_message";
|
||||
this.lbl_message.Size = new System.Drawing.Size(415, 104);
|
||||
this.lbl_message.TabIndex = 0;
|
||||
this.lbl_message.Text = "label1";
|
||||
this.lbl_message.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// MaskedForm
|
||||
//
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(714, 310);
|
||||
this.Controls.Add(this.lbl_message);
|
||||
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "MaskedForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MaskedForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.MaskedForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
private void MaskedForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void MaskedForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
120
HeliosPlus/UIForms/MaskedForm.resx
Normal file
120
HeliosPlus/UIForms/MaskedForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
@ -234,10 +234,25 @@ namespace HeliosPlus.UIForms
|
||||
if (_selectedShortcut == null)
|
||||
return;
|
||||
|
||||
MainForm mf = (MainForm)this.Owner;
|
||||
// Figure out the string we're going to use as the MaskedForm message
|
||||
string message = "";
|
||||
if (_selectedShortcut.Category.Equals(ShortcutCategory.Application))
|
||||
message = $"Starting the {_selectedShortcut.ExecutableNameAndPath} application and waiting until you close it.";
|
||||
else if (_selectedShortcut.Category.Equals(ShortcutCategory.Game))
|
||||
message = $"Starting the {_selectedShortcut.GameName} game and waiting until you close it.";
|
||||
|
||||
// Create a MaskForm that will cover the ShortcutLibrary Window to lock
|
||||
// the controls and inform the user that the game is running....
|
||||
MaskedForm maskedForm = MaskedForm.Show(this, message);
|
||||
|
||||
// Get the MainForm so we can access the NotifyIcon on it.
|
||||
MainForm mainForm = (MainForm)this.Owner;
|
||||
|
||||
|
||||
// Run the shortcut
|
||||
ShortcutRepository.RunShortcut(_selectedShortcut, mf.notifyIcon);
|
||||
ShortcutRepository.RunShortcut(_selectedShortcut, mainForm.notifyIcon);
|
||||
|
||||
maskedForm.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user