[WIP] Adding wallpaper manipulation

This commit is contained in:
Terry MacDonald 2021-08-27 22:26:12 +12:00
parent cf0a15acdd
commit 93c85d7d87
7 changed files with 403 additions and 0 deletions

View File

@ -148,6 +148,12 @@
<DependentUpon>HotkeyForm.cs</DependentUpon> <DependentUpon>HotkeyForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UIForms\ImageListViewRenderers.cs" /> <Compile Include="UIForms\ImageListViewRenderers.cs" />
<Compile Include="UIForms\ProfileSettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UIForms\ProfileSettingsForm.Designer.cs">
<DependentUpon>ProfileSettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="UIForms\SettingsForm.cs"> <Compile Include="UIForms\SettingsForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@ -216,6 +222,9 @@
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UIForms\ProfileSettingsForm.resx">
<DependentUpon>ProfileSettingsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UIForms\SettingsForm.resx"> <EmbeddedResource Include="UIForms\SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon> <DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -59,6 +59,7 @@ namespace DisplayMagician.UIForms
this.dialog_save = new System.Windows.Forms.SaveFileDialog(); this.dialog_save = new System.Windows.Forms.SaveFileDialog();
this.btn_hotkey = new System.Windows.Forms.Button(); this.btn_hotkey = new System.Windows.Forms.Button();
this.lbl_hotkey_assigned = new System.Windows.Forms.Label(); this.lbl_hotkey_assigned = new System.Windows.Forms.Label();
this.btn_profile_settings = new System.Windows.Forms.Button();
this.menu_profiles.SuspendLayout(); this.menu_profiles.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
@ -360,6 +361,22 @@ namespace DisplayMagician.UIForms
this.lbl_hotkey_assigned.Visible = false; this.lbl_hotkey_assigned.Visible = false;
this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click);
// //
// btn_profile_settings
//
this.btn_profile_settings.Anchor = System.Windows.Forms.AnchorStyles.None;
this.btn_profile_settings.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_profile_settings.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_profile_settings.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_profile_settings.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_profile_settings.ForeColor = System.Drawing.Color.White;
this.btn_profile_settings.Location = new System.Drawing.Point(810, 520);
this.btn_profile_settings.Name = "btn_profile_settings";
this.btn_profile_settings.Size = new System.Drawing.Size(120, 33);
this.btn_profile_settings.TabIndex = 37;
this.btn_profile_settings.Text = "Profile Settings";
this.btn_profile_settings.UseVisualStyleBackColor = true;
this.btn_profile_settings.Click += new System.EventHandler(this.btn_profile_settings_Click);
//
// DisplayProfileForm // DisplayProfileForm
// //
this.AcceptButton = this.btn_apply; this.AcceptButton = this.btn_apply;
@ -369,6 +386,7 @@ namespace DisplayMagician.UIForms
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.CancelButton = this.btn_back; this.CancelButton = this.btn_back;
this.ClientSize = new System.Drawing.Size(976, 829); this.ClientSize = new System.Drawing.Size(976, 829);
this.Controls.Add(this.btn_profile_settings);
this.Controls.Add(this.lbl_hotkey_assigned); this.Controls.Add(this.lbl_hotkey_assigned);
this.Controls.Add(this.btn_hotkey); this.Controls.Add(this.btn_hotkey);
this.Controls.Add(this.btn_save); this.Controls.Add(this.btn_save);
@ -429,6 +447,7 @@ namespace DisplayMagician.UIForms
private System.Windows.Forms.SaveFileDialog dialog_save; private System.Windows.Forms.SaveFileDialog dialog_save;
private System.Windows.Forms.Button btn_hotkey; private System.Windows.Forms.Button btn_hotkey;
private System.Windows.Forms.Label lbl_hotkey_assigned; private System.Windows.Forms.Label lbl_hotkey_assigned;
private System.Windows.Forms.Button btn_profile_settings;
} }
} }

View File

@ -534,5 +534,12 @@ namespace DisplayMagician.UIForms
} }
private void btn_profile_settings_Click(object sender, EventArgs e)
{
ProfileSettingsForm profileSettingsForm = new ProfileSettingsForm();
profileSettingsForm.Profile = _selectedProfile;
profileSettingsForm.ShowDialog(this);
//_selectedProfile = profileSettingsForm.Profile;
}
} }
} }

View File

@ -0,0 +1,170 @@

namespace DisplayMagician.UIForms
{
partial class ProfileSettingsForm
{
/// <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.btn_back = new System.Windows.Forms.Button();
this.gb_general = new System.Windows.Forms.GroupBox();
this.btn_select_wallpaper = new System.Windows.Forms.Button();
this.txt_wallpaper_filename = new System.Windows.Forms.TextBox();
this.cb_set_wallpaper = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.cmb_wallpaper_display_mode = new System.Windows.Forms.ComboBox();
this.gb_general.SuspendLayout();
this.SuspendLayout();
//
// btn_back
//
this.btn_back.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btn_back.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btn_back.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_back.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_back.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_back.ForeColor = System.Drawing.Color.White;
this.btn_back.Location = new System.Drawing.Point(476, 202);
this.btn_back.Name = "btn_back";
this.btn_back.Size = new System.Drawing.Size(75, 23);
this.btn_back.TabIndex = 9;
this.btn_back.Text = "&Back";
this.btn_back.UseVisualStyleBackColor = true;
this.btn_back.Click += new System.EventHandler(this.btn_back_Click);
//
// gb_general
//
this.gb_general.Controls.Add(this.btn_select_wallpaper);
this.gb_general.Controls.Add(this.txt_wallpaper_filename);
this.gb_general.Controls.Add(this.cb_set_wallpaper);
this.gb_general.Controls.Add(this.label1);
this.gb_general.Controls.Add(this.cmb_wallpaper_display_mode);
this.gb_general.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.gb_general.ForeColor = System.Drawing.Color.White;
this.gb_general.Location = new System.Drawing.Point(27, 21);
this.gb_general.Name = "gb_general";
this.gb_general.Size = new System.Drawing.Size(525, 157);
this.gb_general.TabIndex = 11;
this.gb_general.TabStop = false;
this.gb_general.Text = "Wallpaper Settings";
//
// btn_select_wallpaper
//
this.btn_select_wallpaper.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_select_wallpaper.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_select_wallpaper.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_select_wallpaper.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_select_wallpaper.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_select_wallpaper.ForeColor = System.Drawing.Color.White;
this.btn_select_wallpaper.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.btn_select_wallpaper.Location = new System.Drawing.Point(428, 68);
this.btn_select_wallpaper.Name = "btn_select_wallpaper";
this.btn_select_wallpaper.Size = new System.Drawing.Size(75, 23);
this.btn_select_wallpaper.TabIndex = 16;
this.btn_select_wallpaper.Text = "&Select";
this.btn_select_wallpaper.UseVisualStyleBackColor = true;
//
// txt_wallpaper_filename
//
this.txt_wallpaper_filename.Location = new System.Drawing.Point(28, 68);
this.txt_wallpaper_filename.Name = "txt_wallpaper_filename";
this.txt_wallpaper_filename.Size = new System.Drawing.Size(394, 22);
this.txt_wallpaper_filename.TabIndex = 15;
//
// cb_set_wallpaper
//
this.cb_set_wallpaper.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.cb_set_wallpaper.AutoSize = true;
this.cb_set_wallpaper.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F);
this.cb_set_wallpaper.ForeColor = System.Drawing.Color.White;
this.cb_set_wallpaper.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.cb_set_wallpaper.Location = new System.Drawing.Point(28, 36);
this.cb_set_wallpaper.Name = "cb_set_wallpaper";
this.cb_set_wallpaper.Size = new System.Drawing.Size(261, 20);
this.cb_set_wallpaper.TabIndex = 14;
this.cb_set_wallpaper.Text = "Set wallpaper when applying this profile";
this.cb_set_wallpaper.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(42, 111);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(155, 16);
this.label1.TabIndex = 13;
this.label1.Text = "Wallpaper display style: ";
//
// cmb_wallpaper_display_mode
//
this.cmb_wallpaper_display_mode.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmb_wallpaper_display_mode.FormattingEnabled = true;
this.cmb_wallpaper_display_mode.Items.AddRange(new object[] {
"Centered",
"Stretched",
"Tiled"});
this.cmb_wallpaper_display_mode.Location = new System.Drawing.Point(203, 108);
this.cmb_wallpaper_display_mode.Name = "cmb_wallpaper_display_mode";
this.cmb_wallpaper_display_mode.Size = new System.Drawing.Size(219, 24);
this.cmb_wallpaper_display_mode.TabIndex = 12;
this.cmb_wallpaper_display_mode.SelectedIndexChanged += new System.EventHandler(this.cmb_wallpaper_display_mode_SelectedIndexChanged);
//
// ProfileSettingsForm
//
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(580, 249);
this.Controls.Add(this.gb_general);
this.Controls.Add(this.btn_back);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ProfileSettingsForm";
this.ShowIcon = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Profile Settings";
this.TopMost = true;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProfileSettingsForm_FormClosing);
this.Load += new System.EventHandler(this.ProfileSettingsForm_Load);
this.gb_general.ResumeLayout(false);
this.gb_general.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btn_back;
private System.Windows.Forms.GroupBox gb_general;
private System.Windows.Forms.CheckBox cb_set_wallpaper;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cmb_wallpaper_display_mode;
private System.Windows.Forms.TextBox txt_wallpaper_filename;
private System.Windows.Forms.Button btn_select_wallpaper;
}
}

View File

@ -0,0 +1,75 @@
using DisplayMagicianShared;
using NHotkey;
using NHotkey.WindowsForms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using WK.Libraries.BootMeUpNS;
namespace DisplayMagician.UIForms
{
public partial class ProfileSettingsForm : Form
{
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private Dictionary<Wallpaper.Style, string> wallpaperStyleText = new Dictionary<Wallpaper.Style, string>();
public ProfileSettingsForm()
{
logger.Info($"ProfileSettingsForm/ProfileSettingsForm: Creating a ProfileSettingsForm UI Form");
InitializeComponent();
// Populate the Style dictionary
wallpaperStyleText.Add(Wallpaper.Style.Centered, "Center the Wallpaper");
wallpaperStyleText.Add(Wallpaper.Style.Stretched, "Stretch the Wallpaper");
wallpaperStyleText.Add(Wallpaper.Style.Tiled, "Tile the Wallpaper");
// Now use it to populate the Style Dropdown
cmb_wallpaper_display_mode.Items.Clear();
cmb_wallpaper_display_mode.Items.AddRange(wallpaperStyleText.Values.ToArray());
cmb_wallpaper_display_mode.SelectedIndex = 0;
}
public ProfileItem Profile
{
get;
set;
}
private void ProfileSettingsForm_Load(object sender, EventArgs e)
{
if (Profile.SetWallpaper)
{
logger.Info($"ProfileSettingsForm/ProfileSettingsForm_Load: Profile {Profile.Name} has loaded with Set Wallpaper enabled and Wallpaper Style {Profile.WallpaperStyle.ToString("G")} and Wallpaper Filename of {Profile.WallpaperBitmapFilename}.");
cmb_wallpaper_display_mode.SelectedIndex = cmb_wallpaper_display_mode.FindStringExact(wallpaperStyleText[Profile.WallpaperStyle]);
if (Profile.WallpaperBitmapFilename != "")
{
txt_wallpaper_filename.Text = Profile.WallpaperBitmapFilename;
}
}
}
private void ProfileSettingsForm_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void btn_back_Click(object sender, EventArgs e)
{
Profile.SetWallpaper = cb_set_wallpaper.Checked;
Profile.WallpaperStyle = (Wallpaper.Style)cmb_wallpaper_display_mode.SelectedValue;
Profile.WallpaperBitmapFilename = txt_wallpaper_filename.Text;
this.Close();
}
private void cmb_wallpaper_display_mode_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}

View 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>

View File

@ -182,6 +182,8 @@ namespace DisplayMagicianShared
public bool SetWallpaper { get; set; } public bool SetWallpaper { get; set; }
public Wallpaper.Style WallpaperStyle { get; set; }
public string WallpaperBitmapFilename{ public string WallpaperBitmapFilename{
get get
{ {
@ -314,6 +316,7 @@ namespace DisplayMagicianShared
profile.ProfileDisplayIdentifiers = ProfileDisplayIdentifiers; profile.ProfileDisplayIdentifiers = ProfileDisplayIdentifiers;
profile.SetWallpaper = SetWallpaper; profile.SetWallpaper = SetWallpaper;
profile.WallpaperBitmapFilename = WallpaperBitmapFilename; profile.WallpaperBitmapFilename = WallpaperBitmapFilename;
profile.WallpaperStyle = WallpaperStyle;
return true; return true;
} }