WIP: Added the loader start component

This commit is contained in:
Thorsten Sommer 2022-06-06 22:06:41 +02:00
parent d1f6b3af13
commit 6df7b70499
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
4 changed files with 316 additions and 4 deletions

View File

@ -0,0 +1,168 @@
namespace UI_WinForms.Components
{
partial class LoaderStart
{
/// <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 Component 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();
this.tableLayout = new System.Windows.Forms.TableLayoutPanel();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.labelTitle = new System.Windows.Forms.Label();
this.flowLayoutButtons = new System.Windows.Forms.FlowLayoutPanel();
this.buttonNew = new System.Windows.Forms.Button();
this.buttonOpen = new System.Windows.Forms.Button();
this.contextMenuRecentProjects = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayout.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.flowLayoutButtons.SuspendLayout();
this.contextMenuRecentProjects.SuspendLayout();
this.SuspendLayout();
//
// tableLayout
//
this.tableLayout.ColumnCount = 4;
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 128F));
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 360F));
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayout.Controls.Add(this.pictureBox, 1, 1);
this.tableLayout.Controls.Add(this.labelTitle, 2, 1);
this.tableLayout.Controls.Add(this.flowLayoutButtons, 1, 2);
this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayout.Location = new System.Drawing.Point(0, 0);
this.tableLayout.Name = "tableLayout";
this.tableLayout.RowCount = 4;
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 128F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 66F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayout.Size = new System.Drawing.Size(937, 465);
this.tableLayout.TabIndex = 0;
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Image = global::UI_WinForms.Resources.Icons.icons8_language_512;
this.pictureBox.Location = new System.Drawing.Point(227, 138);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(122, 122);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// labelTitle
//
this.labelTitle.Dock = System.Windows.Forms.DockStyle.Fill;
this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 28F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.labelTitle.Location = new System.Drawing.Point(355, 135);
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(354, 128);
this.labelTitle.TabIndex = 1;
this.labelTitle.Text = "I18N Commander";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// flowLayoutButtons
//
this.tableLayout.SetColumnSpan(this.flowLayoutButtons, 2);
this.flowLayoutButtons.Controls.Add(this.buttonNew);
this.flowLayoutButtons.Controls.Add(this.buttonOpen);
this.flowLayoutButtons.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutButtons.Location = new System.Drawing.Point(224, 263);
this.flowLayoutButtons.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutButtons.Name = "flowLayoutButtons";
this.flowLayoutButtons.Size = new System.Drawing.Size(488, 66);
this.flowLayoutButtons.TabIndex = 2;
//
// buttonNew
//
this.buttonNew.Image = global::UI_WinForms.Resources.Icons.icons8_new_window_512;
this.buttonNew.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.buttonNew.Location = new System.Drawing.Point(3, 3);
this.buttonNew.Name = "buttonNew";
this.buttonNew.Size = new System.Drawing.Size(200, 60);
this.buttonNew.TabIndex = 0;
this.buttonNew.Text = "New Project";
this.buttonNew.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
this.buttonNew.UseVisualStyleBackColor = true;
//
// buttonOpen
//
this.buttonOpen.Image = global::UI_WinForms.Resources.Icons.icons8_open_file_under_cursor_512;
this.buttonOpen.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.buttonOpen.Location = new System.Drawing.Point(209, 3);
this.buttonOpen.Name = "buttonOpen";
this.buttonOpen.Size = new System.Drawing.Size(259, 60);
this.buttonOpen.TabIndex = 1;
this.buttonOpen.Text = "Open Recent Project";
this.buttonOpen.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
this.buttonOpen.UseVisualStyleBackColor = true;
this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
//
// contextMenuRecentProjects
//
this.contextMenuRecentProjects.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.contextMenuRecentProjects.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuRecentProjects.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.contextMenuRecentProjects.Name = "contextMenuRecentProjects";
this.contextMenuRecentProjects.Size = new System.Drawing.Size(181, 48);
this.contextMenuRecentProjects.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.contextMenuRecentProjects_Closing);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
//
// LoaderStart
//
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.tableLayout);
this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.Name = "LoaderStart";
this.Size = new System.Drawing.Size(937, 465);
this.tableLayout.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.flowLayoutButtons.ResumeLayout(false);
this.contextMenuRecentProjects.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private TableLayoutPanel tableLayout;
private PictureBox pictureBox;
private Label labelTitle;
private FlowLayoutPanel flowLayoutButtons;
private Button buttonNew;
private Button buttonOpen;
private ContextMenuStrip contextMenuRecentProjects;
private ToolStripMenuItem toolStripMenuItem1;
}
}

View File

@ -0,0 +1,85 @@
using Microsoft.Win32;
namespace UI_WinForms.Components;
public partial class LoaderStart : UserControl
{
private bool areRecentProjectsVisible = false;
public LoaderStart()
{
this.InitializeComponent();
}
private RegistryKey I18NCommanderKey => Registry.CurrentUser.OpenSubKey("Software", RegistryKeyPermissionCheck.ReadWriteSubTree)!.CreateSubKey("I18N Commander", RegistryKeyPermissionCheck.ReadWriteSubTree);
private List<string> RecentProjects
{
get
{
using var regKey = this.I18NCommanderKey;
var recentProjectsValue = regKey.GetValue("recentProjects");
return recentProjectsValue switch
{
string[] list => new List<string>(list),
_ => new List<string>(),
};
}
set
{
using var regKey = this.I18NCommanderKey;
regKey.SetValue("recentProjects", value, RegistryValueKind.MultiString);
}
}
private void buttonOpen_Click(object sender, EventArgs e)
{
if(this.areRecentProjectsVisible)
{
this.areRecentProjectsVisible = false;
this.contextMenuRecentProjects.Close();
return;
}
var recentProjects = this.RecentProjects;
this.contextMenuRecentProjects.Items.Clear();
this.contextMenuRecentProjects.Items.Add("Browse for project...", Resources.Icons.icons8_browse_folder_512, (innerSender, args) => this.browseForProject());
foreach (var recentProject in recentProjects)
{
var fileInfo = new FileInfo(recentProject);
var item = this.contextMenuRecentProjects.Items.Add($"{fileInfo.Directory.GetDirectories().Last()}/{fileInfo.Name}", Resources.Icons.icons8_document_512, (innerSender, args) => this.openRecentProject(innerSender));
item.Tag = recentProject;
}
var button = (sender as Button)!;
this.contextMenuRecentProjects.Show(button, 0, button.Height);
this.areRecentProjectsVisible = true;
}
private void browseForProject()
{
// TODO: Browse for project
// TODO: Open the project
// TODO: Handle cancel event
// TODO: Add the project to the recent projects
// TODO: Prune the recent project list
}
private void openRecentProject(object? sender)
{
if(sender is null)
return;
if (sender is ToolStripItem item)
{
var path = (item.Tag as string)!;
// TODO: Open the project
}
}
private void contextMenuRecentProjects_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
this.areRecentProjectsVisible = false;
}
}

View File

@ -0,0 +1,63 @@
<root>
<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>
<metadata name="contextMenuRecentProjects.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -13,10 +13,6 @@
<ProjectReference Include="..\Processor\Processor.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Components\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Resources\Icons.Designer.cs">
<DesignTime>True</DesignTime>