Changed: correct blank product names from shortcut

This commit is contained in:
Ray 2020-05-17 16:48:04 +01:00
parent 557395b941
commit 3a2ee532c7
9 changed files with 369 additions and 76 deletions

86
MainForm.Designer.cs generated
View File

@ -32,6 +32,12 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
@ -39,6 +45,7 @@
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.imageBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.imageBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.imageBox1)).BeginInit();
@ -49,19 +56,19 @@
//
this.imageBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.imageBox3.Image = ((System.Drawing.Image)(resources.GetObject("imageBox3.Image")));
this.imageBox3.Location = new System.Drawing.Point(384, 18);
this.imageBox3.Location = new System.Drawing.Point(-71, 18);
//
// imageBox2
//
this.imageBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.imageBox2.Image = ((System.Drawing.Image)(resources.GetObject("imageBox2.Image")));
this.imageBox2.Location = new System.Drawing.Point(356, 18);
this.imageBox2.Location = new System.Drawing.Point(-99, 18);
//
// imageBox1
//
this.imageBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.imageBox1.Image = ((System.Drawing.Image)(resources.GetObject("imageBox1.Image")));
this.imageBox1.Location = new System.Drawing.Point(328, 18);
this.imageBox1.Location = new System.Drawing.Point(-127, 18);
//
// contextMenuStrip1
//
@ -71,22 +78,66 @@
this.toolStripSeparator1,
this.exitToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 98);
this.contextMenuStrip1.Size = new System.Drawing.Size(100, 76);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem5,
this.toolStripMenuItem7,
this.toolStripSeparator2,
this.toolStripMenuItem8,
this.toolStripSeparator3,
this.toolStripMenuItem6,
this.toolStripMenuItem2});
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem4.Size = new System.Drawing.Size(99, 22);
this.toolStripMenuItem4.Text = "&File";
//
// toolStripMenuItem5
//
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
this.toolStripMenuItem5.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem5.Text = "&New";
this.toolStripMenuItem5.Click += new System.EventHandler(this.toolStripMenuItem5_Click);
//
// toolStripMenuItem7
//
this.toolStripMenuItem7.Name = "toolStripMenuItem7";
this.toolStripMenuItem7.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem7.Text = "&Open";
this.toolStripMenuItem7.Click += new System.EventHandler(this.toolStripMenuItem7_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(120, 6);
//
// toolStripMenuItem8
//
this.toolStripMenuItem8.Name = "toolStripMenuItem8";
this.toolStripMenuItem8.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem8.Text = "&Close";
this.toolStripMenuItem8.Click += new System.EventHandler(this.toolStripMenuItem8_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(120, 6);
//
// toolStripMenuItem6
//
this.toolStripMenuItem6.Name = "toolStripMenuItem6";
this.toolStripMenuItem6.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem6.Text = "&Save";
this.toolStripMenuItem6.Click += new System.EventHandler(this.toolStripMenuItem6_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItem2.Text = "&Save As...";
this.toolStripMenuItem2.Text = "Save &As...";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
// toolStripMenuItem3
@ -94,7 +145,7 @@
this.toolStripMenuItem3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem3.Size = new System.Drawing.Size(99, 22);
this.toolStripMenuItem3.Text = "&View";
//
// toolStripMenuItem1
@ -107,12 +158,12 @@
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(96, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
@ -127,7 +178,7 @@
this.flowLayoutPanel1.Location = new System.Drawing.Point(12, 58);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(0, 0, 10, 0);
this.flowLayoutPanel1.Size = new System.Drawing.Size(1075, 341);
this.flowLayoutPanel1.Size = new System.Drawing.Size(620, 341);
this.flowLayoutPanel1.TabIndex = 27;
this.flowLayoutPanel1.WrapContents = false;
//
@ -136,13 +187,19 @@
this.saveFileDialog1.Filter = "Session files|*.jsonfig";
this.saveFileDialog1.Title = "Choose file to save the session";
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
this.openFileDialog1.Filter = "Session files|*.jsonfig";
this.openFileDialog1.Title = "Choose session file";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(254)))), ((int)(((byte)(254)))));
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(1088, 400);
this.ClientSize = new System.Drawing.Size(633, 400);
this.Controls.Add(this.flowLayoutPanel1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "MainForm";
@ -170,6 +227,13 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem6;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem8;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
}
}

View File

@ -15,7 +15,8 @@ namespace AppLauncher
{
protected int collapsedWidth = 40;
protected int expandedWidth = 800;
protected bool isBusy = false;
protected string sessionFilename = null;
public MainForm() : base()
{
@ -24,13 +25,6 @@ namespace AppLauncher
//this.Visible = false;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//this.Visible = false;
}
protected override void OnShown(EventArgs e)
{
this.Visible = false;
@ -40,7 +34,7 @@ namespace AppLauncher
string jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig");
if (File.Exists(jsonfigFilename))
{
loadSession(jsonfigFilename);
loadFile(jsonfigFilename);
}
this.Location = this.DefaultLocation;
@ -63,61 +57,159 @@ namespace AppLauncher
}
}
/// <summary>
/// New
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(sessionFilename))
{
newSession();
}
else
{
DialogResult dr = MessageBox.Show("Save existing session?", "New session", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
bool rv = saveFile(sessionFilename, false);
if (rv)
{
newSession();
sessionFilename = null;
}
}
else if (dr == DialogResult.No)
{
newSession();
sessionFilename = null;
}
else if (dr == DialogResult.Cancel)
{
return;
}
}
}
/// <summary>
/// Open
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem7_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(sessionFilename))
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
loadFile(openFileDialog1.FileName);
}
}
else
{
DialogResult dr = MessageBox.Show("Save existing session?", "Open session", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
bool rv = saveFile(sessionFilename, false);
if (rv)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
loadFile(openFileDialog1.FileName);
}
}
}
else if (dr == DialogResult.No)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
loadFile(openFileDialog1.FileName);
}
}
else if (dr == DialogResult.Cancel)
{
return;
}
}
}
/// <summary>
/// Close
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem8_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(sessionFilename))
{
flowLayoutPanel1.Controls.Clear();
}
else
{
DialogResult dr = MessageBox.Show("Save existing session?", "Close session", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
bool rv = saveFile(sessionFilename, false);
if (rv)
{
flowLayoutPanel1.Controls.Clear();
sessionFilename = null;
}
}
else if (dr == DialogResult.No)
{
flowLayoutPanel1.Controls.Clear();
sessionFilename = null;
}
else if (dr == DialogResult.Cancel)
{
return;
}
}
}
/// <summary>
/// Save
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem6_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(sessionFilename))
{
saveAsFile();
}
else
{
saveFile(sessionFilename, true);
}
}
/// <summary>
/// Save As
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
if (isBusy)
{
return;
}
if (flowLayoutPanel1.Controls.Count <= 0)
{
return;
}
if (saveFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
isBusy = true;
List<TileGroupModel> rs = new List<TileGroupModel>();
for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
{
if (flowLayoutPanel1.Controls[i].GetType() != typeof(TTilePanelLayout))
{
continue;
}
TTilePanelLayout container = flowLayoutPanel1.Controls[i] as TTilePanelLayout;
rs.Add(container.Model);
}
try
{
File.WriteAllText(saveFileDialog1.FileName, JsonConvert.SerializeObject(rs));
MessageBox.Show("Session saved!", "Save session", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Save session");
}
isBusy = false;
}
private void toolStripMenuItem2_Click(object sender, EventArgs e) => saveAsFile();
/// <summary>
/// Always On Top
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem1_Click(object sender, EventArgs e) => this.TopMost = !this.TopMost;
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// Exit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitToolStripMenuItem_Click(object sender, EventArgs e) => this.Close();
protected async Task collapseWindow(int width, int increment = 6)
{
@ -149,9 +241,37 @@ namespace AppLauncher
});
}
protected void loadSession(string filename)
protected void loadFile(string filename)
{
string sourceCode = File.ReadAllText(filename);
if (isBusy)
{
return;
}
if (string.IsNullOrWhiteSpace(filename))
{
return;
}
if (!File.Exists(filename))
{
return;
}
string sourceCode = null;
try
{
sessionFilename = filename;
sourceCode = File.ReadAllText(sessionFilename);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Load session");
return;
}
if (string.IsNullOrWhiteSpace(sourceCode))
{
return;
@ -174,18 +294,105 @@ namespace AppLauncher
flowLayoutPanel1.Controls.Add(panel);
}
//flowLayoutPanel1.Width = maxWidth + SystemInformation.VerticalScrollBarWidth + 20;
//flowLayoutPanel1.Width = maxWidth + SystemInformation.VerticalScrollBarWidth + 20;
//this.Width = flowLayoutPanel1.Width + (flowLayoutPanel1.Left * 2);
//this.Width = flowLayoutPanel1.Width + flowLayoutPanel1.Left;
this.Width = maxWidth + SystemInformation.VerticalScrollBarWidth + 20 + flowLayoutPanel1.Left;
}
protected void newSession()
{
int maxWidth = 0;
flowLayoutPanel1.Controls.Clear();
TTilePanelLayout panel = new TTilePanelLayout(new TileGroupModel()
{
Title = "New Group",
IsExpanded = true,
GridSize = new Size(8, 1)
});
maxWidth = Math.Max(maxWidth, panel.Width);
flowLayoutPanel1.Controls.Add(panel);
this.Width = maxWidth + SystemInformation.VerticalScrollBarWidth + 20 + flowLayoutPanel1.Left;
}
protected bool saveFile(string filename, bool showNotices = true)
{
if (isBusy)
{
return false;
}
if (string.IsNullOrWhiteSpace(filename))
{
return false;
}
if (flowLayoutPanel1.Controls.Count <= 0)
{
return true;
}
isBusy = true;
List<TileGroupModel> rs = new List<TileGroupModel>();
for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
{
if (flowLayoutPanel1.Controls[i].GetType() != typeof(TTilePanelLayout))
{
continue;
}
TTilePanelLayout container = flowLayoutPanel1.Controls[i] as TTilePanelLayout;
rs.Add(container.Model);
}
try
{
File.WriteAllText(filename, JsonConvert.SerializeObject(rs));
if (showNotices)
{
MessageBox.Show("Session saved!", "Save session", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Save session");
return false;
}
isBusy = false;
return true;
}
protected bool saveAsFile()
{
if (isBusy)
{
return false;
}
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
bool rv = saveFile(saveFileDialog1.FileName);
if (rv)
{
sessionFilename = saveFileDialog1.FileName;
}
return rv;
}
return false;
}
private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
toolStripMenuItem1.Checked = this.TopMost;
toolStripMenuItem6.Enabled = !string.IsNullOrWhiteSpace(sessionFilename);
}
}

View File

@ -153,6 +153,9 @@
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>308, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAQAMDAAAAEAIACoJQAARgAAACAgAAABACAAqBAAAO4lAAAYGAAAAQAgAIgJAACWNgAAEBAAAAEA

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

View File

@ -13,12 +13,15 @@ namespace AppLauncher.Windows.Forms
protected readonly int titleBarHeight = 56;
private bool isDragging = false;
private Point startPosition = new Point();
protected bool isBusy = false;
protected internal RyzStudio.Windows.Forms.TImageBox imageBox3;
protected internal RyzStudio.Windows.Forms.TImageBox imageBox2;
protected internal RyzStudio.Windows.Forms.TImageBox imageBox1;
private NotifyIcon notifyIcon1;
private IContainer components;
private Point startPosition = new Point();
public AForm() : base()
{

View File

@ -267,6 +267,12 @@ namespace AppLauncher.Windows.Forms
// do nothing
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(fileList[0]);
}
}
listBox1.ListBox.Items.Add(model);

View File

@ -288,6 +288,11 @@ namespace AppLauncher.Windows.Forms
// do nothing
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(fileList[0]);
}
}
listBox1.ListBox.Items.Add(model);

View File

@ -89,6 +89,11 @@ namespace AppLauncher.Windows.Forms
// do nothing
}
}
if (string.IsNullOrWhiteSpace(model.Title))
{
model.Title = Path.GetFileNameWithoutExtension(fileList[0]);
}
}
this.AddTile(model);