Added: save session

This commit is contained in:
Ray 2020-05-03 15:53:15 +01:00
parent 4a83971868
commit 92ee5e8eed
13 changed files with 357 additions and 52 deletions

View File

@ -128,10 +128,10 @@
<Compile Include="RyzStudio\Windows\ThemedForms\UserControl.designer.cs"> <Compile Include="RyzStudio\Windows\ThemedForms\UserControl.designer.cs">
<DependentUpon>UserControl.cs</DependentUpon> <DependentUpon>UserControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Windows\Forms\AddTileForm.cs"> <Compile Include="Windows\Forms\Tile\AddTileForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Windows\Forms\EditTileForm.cs"> <Compile Include="Windows\Forms\Tile\EditTileForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Windows\Forms\AForm.cs"> <Compile Include="Windows\Forms\AForm.cs">
@ -195,10 +195,10 @@
<EmbeddedResource Include="RyzStudio\Windows\ThemedForms\TextButtonBox.resx"> <EmbeddedResource Include="RyzStudio\Windows\ThemedForms\TextButtonBox.resx">
<DependentUpon>TextButtonBox.cs</DependentUpon> <DependentUpon>TextButtonBox.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Windows\Forms\AddTileForm.resx"> <EmbeddedResource Include="Windows\Forms\Tile\AddTileForm.resx">
<DependentUpon>AddTileForm.cs</DependentUpon> <DependentUpon>AddTileForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Windows\Forms\EditTileForm.resx"> <EmbeddedResource Include="Windows\Forms\Tile\EditTileForm.resx">
<DependentUpon>EditTileForm.cs</DependentUpon> <DependentUpon>EditTileForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Windows\Forms\Tile\TileGroupLabel.resx"> <EmbeddedResource Include="Windows\Forms\Tile\TileGroupLabel.resx">

63
MainForm.Designer.cs generated
View File

@ -31,10 +31,14 @@
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.titlePanel1 = new AppLauncher.Windows.Forms.TitlePanel(); this.titlePanel1 = new AppLauncher.Windows.Forms.TitlePanel();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -55,28 +59,22 @@
// contextMenuStrip1 // contextMenuStrip1
// //
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1, this.toolStripMenuItem4,
this.toolStripMenuItem3,
this.toolStripSeparator1, this.toolStripSeparator1,
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 54); this.contextMenuStrip1.Size = new System.Drawing.Size(100, 76);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItem1.Text = "Always On &Top";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
// //
// exitToolStripMenuItem // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
// //
@ -89,6 +87,41 @@
this.flowLayoutPanel1.TabIndex = 27; this.flowLayoutPanel1.TabIndex = 27;
this.flowLayoutPanel1.WrapContents = false; this.flowLayoutPanel1.WrapContents = false;
// //
// toolStripMenuItem3
//
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.Text = "&View";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem1.Text = "Always On &Top";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem2});
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem4.Text = "&File";
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem2.Text = "&Save As...";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
// saveFileDialog1
//
this.saveFileDialog1.Filter = "Session files|*.jsonfig";
this.saveFileDialog1.Title = "Choose file to save the session";
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -110,8 +143,12 @@
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
} }
} }

View File

@ -13,6 +13,7 @@ namespace AppLauncher
{ {
protected int collapsedWidth = 40; protected int collapsedWidth = 40;
protected int expandedWidth = 800; protected int expandedWidth = 800;
protected bool isBusy = false;
public MainForm() : base() public MainForm() : base()
{ {
@ -50,6 +51,67 @@ namespace AppLauncher
} }
} }
/// <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(TileContainer))
{
continue;
}
TileContainer container = flowLayoutPanel1.Controls[i] as TileContainer;
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 toolStripMenuItem1_Click(object sender, EventArgs e)
{
this.TopMost = !this.TopMost;
toolStripMenuItem1.Checked = this.TopMost;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
protected async Task collapseWindow(int width, int increment = 6) protected async Task collapseWindow(int width, int increment = 6)
{ {
await Task.Run(() => await Task.Run(() =>
@ -96,18 +158,6 @@ namespace AppLauncher
}); });
} }
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
this.TopMost = !this.TopMost;
toolStripMenuItem1.Checked = this.TopMost;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
protected void loadSession(string filename) protected void loadSession(string filename)
{ {
string sourceCode = File.ReadAllText(filename); string sourceCode = File.ReadAllText(filename);

View File

@ -120,4 +120,7 @@
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
</root> </root>

View File

@ -2,6 +2,7 @@
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -25,7 +26,8 @@ namespace AppLauncher.Windows.Forms
private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1; private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator2; private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator2;
private TextBox textBox1; private TextBox textBox1;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
protected TileLayoutPanel parentPanel = null; protected TileLayoutPanel parentPanel = null;
public AddTileForm() : base() public AddTileForm() : base()
@ -44,7 +46,7 @@ namespace AppLauncher.Windows.Forms
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditTileForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddTileForm));
this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox(); this.textBox1 = new RyzStudio.Windows.ThemedForms.TextBox();
this.label6 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label();
@ -60,6 +62,8 @@ namespace AppLauncher.Windows.Forms
this.pickerBox2 = new RyzStudio.Windows.ThemedForms.PickerBox(); this.pickerBox2 = new RyzStudio.Windows.ThemedForms.PickerBox();
this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator(); this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator();
this.horizontalSeparator2 = new RyzStudio.Windows.Forms.HorizontalSeparator(); this.horizontalSeparator2 = new RyzStudio.Windows.Forms.HorizontalSeparator();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -180,6 +184,7 @@ namespace AppLauncher.Windows.Forms
this.textBox2.SubmitButton = null; this.textBox2.SubmitButton = null;
this.textBox2.TabIndex = 170; this.textBox2.TabIndex = 170;
this.textBox2.UseSystemPasswordChar = false; this.textBox2.UseSystemPasswordChar = false;
this.textBox2.OnButtonClick += new System.EventHandler(this.textBox2_OnButtonClick);
// //
// textBox3 // textBox3
// //
@ -212,6 +217,7 @@ namespace AppLauncher.Windows.Forms
this.textBox4.SubmitButton = null; this.textBox4.SubmitButton = null;
this.textBox4.TabIndex = 172; this.textBox4.TabIndex = 172;
this.textBox4.UseSystemPasswordChar = false; this.textBox4.UseSystemPasswordChar = false;
this.textBox4.OnButtonClick += new System.EventHandler(this.textBox4_OnButtonClick);
// //
// button1 // button1
// //
@ -276,7 +282,16 @@ namespace AppLauncher.Windows.Forms
this.horizontalSeparator2.Size = new System.Drawing.Size(380, 2); this.horizontalSeparator2.Size = new System.Drawing.Size(380, 2);
this.horizontalSeparator2.TabIndex = 177; this.horizontalSeparator2.TabIndex = 177;
// //
// EditTileForm // folderBrowserDialog1
//
this.folderBrowserDialog1.Description = "Choose a directory";
//
// openFileDialog1
//
this.openFileDialog1.Filter = "All files|*";
this.openFileDialog1.Title = "Choose a file";
//
// AddTileForm
// //
this.ClientSize = new System.Drawing.Size(400, 480); this.ClientSize = new System.Drawing.Size(400, 480);
this.Controls.Add(this.horizontalSeparator2); this.Controls.Add(this.horizontalSeparator2);
@ -295,7 +310,7 @@ namespace AppLauncher.Windows.Forms
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1); this.Controls.Add(this.textBox1);
this.Description = "Edit Tile"; this.Description = "Edit Tile";
this.Name = "EditTileForm"; this.Name = "AddTileForm";
this.Controls.SetChildIndex(this.imgbxClose, 0); this.Controls.SetChildIndex(this.imgbxClose, 0);
this.Controls.SetChildIndex(this.lblDescription, 0); this.Controls.SetChildIndex(this.lblDescription, 0);
this.Controls.SetChildIndex(this.panel1, 0); this.Controls.SetChildIndex(this.panel1, 0);
@ -363,5 +378,37 @@ namespace AppLauncher.Windows.Forms
this.Close(); this.Close();
} }
private void textBox2_OnButtonClick(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(textBox2.Text))
{
if (File.Exists(textBox2.Text))
{
openFileDialog1.InitialDirectory = Path.GetDirectoryName(textBox2.Text);
}
}
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox2.Text = openFileDialog1.FileName;
}
}
private void textBox4_OnButtonClick(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(textBox4.Text))
{
if (Directory.Exists(textBox4.Text))
{
folderBrowserDialog1.SelectedPath = textBox4.Text;
}
}
if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox4.Text = folderBrowserDialog1.SelectedPath;
}
}
} }
} }

View File

@ -128,4 +128,10 @@
6dGYH+UCHCTQ9SfV+7pMvJIIaLL0Oudd1x2eUQ8MyeAeq0cAAAAASUVORK5CYII= 6dGYH+UCHCTQ9SfV+7pMvJIIaLL0Oudd1x2eUQ8MyeAeq0cAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>326, 17</value>
</metadata>
</root> </root>

View File

@ -2,6 +2,7 @@
using RyzStudio.Windows.ThemedForms; using RyzStudio.Windows.ThemedForms;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -25,7 +26,8 @@ namespace AppLauncher.Windows.Forms
private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1; private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator1;
private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator2; private RyzStudio.Windows.Forms.HorizontalSeparator horizontalSeparator2;
private TextBox textBox1; private TextBox textBox1;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
protected TilePanel parentPanel = null; protected TilePanel parentPanel = null;
public EditTileForm() : base() public EditTileForm() : base()
@ -60,6 +62,8 @@ namespace AppLauncher.Windows.Forms
this.pickerBox2 = new RyzStudio.Windows.ThemedForms.PickerBox(); this.pickerBox2 = new RyzStudio.Windows.ThemedForms.PickerBox();
this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator(); this.horizontalSeparator1 = new RyzStudio.Windows.Forms.HorizontalSeparator();
this.horizontalSeparator2 = new RyzStudio.Windows.Forms.HorizontalSeparator(); this.horizontalSeparator2 = new RyzStudio.Windows.Forms.HorizontalSeparator();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -180,6 +184,7 @@ namespace AppLauncher.Windows.Forms
this.textBox2.SubmitButton = null; this.textBox2.SubmitButton = null;
this.textBox2.TabIndex = 170; this.textBox2.TabIndex = 170;
this.textBox2.UseSystemPasswordChar = false; this.textBox2.UseSystemPasswordChar = false;
this.textBox2.OnButtonClick += new System.EventHandler(this.textBox2_OnButtonClick);
// //
// textBox3 // textBox3
// //
@ -212,6 +217,7 @@ namespace AppLauncher.Windows.Forms
this.textBox4.SubmitButton = null; this.textBox4.SubmitButton = null;
this.textBox4.TabIndex = 172; this.textBox4.TabIndex = 172;
this.textBox4.UseSystemPasswordChar = false; this.textBox4.UseSystemPasswordChar = false;
this.textBox4.OnButtonClick += new System.EventHandler(this.textBox4_OnButtonClick);
// //
// button1 // button1
// //
@ -276,6 +282,15 @@ namespace AppLauncher.Windows.Forms
this.horizontalSeparator2.Size = new System.Drawing.Size(380, 2); this.horizontalSeparator2.Size = new System.Drawing.Size(380, 2);
this.horizontalSeparator2.TabIndex = 177; this.horizontalSeparator2.TabIndex = 177;
// //
// folderBrowserDialog1
//
this.folderBrowserDialog1.Description = "Choose a directory";
//
// openFileDialog1
//
this.openFileDialog1.Filter = "All files|*";
this.openFileDialog1.Title = "Choose a file";
//
// EditTileForm // EditTileForm
// //
this.ClientSize = new System.Drawing.Size(400, 480); this.ClientSize = new System.Drawing.Size(400, 480);
@ -371,5 +386,37 @@ namespace AppLauncher.Windows.Forms
this.Close(); this.Close();
} }
private void textBox2_OnButtonClick(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(textBox2.Text))
{
if (File.Exists(textBox2.Text))
{
openFileDialog1.InitialDirectory = Path.GetDirectoryName(textBox2.Text);
}
}
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox2.Text = openFileDialog1.FileName;
}
}
private void textBox4_OnButtonClick(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(textBox4.Text))
{
if (Directory.Exists(textBox4.Text))
{
folderBrowserDialog1.SelectedPath = textBox4.Text;
}
}
if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox4.Text = folderBrowserDialog1.SelectedPath;
}
}
} }
} }

View File

@ -128,4 +128,10 @@
6dGYH+UCHCTQ9SfV+7pMvJIIaLL0Oudd1x2eUQ8MyeAeq0cAAAAASUVORK5CYII= 6dGYH+UCHCTQ9SfV+7pMvJIIaLL0Oudd1x2eUQ8MyeAeq0cAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>186, 17</value>
</metadata>
</root> </root>

View File

@ -1,5 +1,6 @@
using AppLauncher.Models; using AppLauncher.Models;
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -58,6 +59,23 @@ namespace AppLauncher.Windows.Forms
public bool IsAnimating => isAnimating; public bool IsAnimating => isAnimating;
public TileGroupModel Model
{
get
{
TileGroupModel rs = new TileGroupModel()
{
Title = label1.TitleText,
GridSize = new Size(panel1.GridSize.X, panel1.GridSize.Y),
IsExpanded = label1.Checked,
IsExclusive = groupInfo.IsExclusive,
Items = panel1.Tiles
};
return rs;
}
}
public async Task Collapse() public async Task Collapse()
{ {
await Task.Run(() => await Task.Run(() =>

View File

@ -1,8 +1,11 @@
using AppLauncher.Models; using AppLauncher.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms;
namespace AppLauncher.Windows.Forms namespace AppLauncher.Windows.Forms
{ {
@ -24,9 +27,24 @@ namespace AppLauncher.Windows.Forms
public TileLayoutPanel() : base() public TileLayoutPanel() : base()
{ {
InitializeComponent();
this.AllowDrop = true;
this.BackColor = System.Drawing.Color.Transparent; this.BackColor = System.Drawing.Color.Transparent;
} }
private void InitializeComponent()
{
this.SuspendLayout();
//
// TileLayoutPanel
//
this.Name = "TileLayoutPanel";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.panel_DragDrop);
this.DragOver += new System.Windows.Forms.DragEventHandler(this.panel_DragOver);
this.ResumeLayout(false);
}
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e); base.OnLoad(e);
@ -69,6 +87,20 @@ namespace AppLauncher.Windows.Forms
public int ExpandedHeight => expandedHeight; public int ExpandedHeight => expandedHeight;
public List<TileModel> Tiles
{
get
{
List<TileModel> rs = new List<TileModel>();
foreach (Item item in items)
{
rs.Add(item.Tile.ModelInfo);
}
return rs;
}
}
public void AddTile(TileModel tile) public void AddTile(TileModel tile)
{ {
Point gridSize = this.GridSize; Point gridSize = this.GridSize;
@ -351,5 +383,64 @@ namespace AppLauncher.Windows.Forms
return true; return true;
} }
private void panel_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void panel_DragDrop(object sender, DragEventArgs e)
{
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
if (fileList == null)
{
return;
}
if (fileList.Length <= 0)
{
return;
}
if (string.IsNullOrWhiteSpace(fileList[0]))
{
return;
}
TileModel model = new TileModel()
{
ProcessFilename = fileList[0],
Title = Path.GetFileName(fileList[0])
};
// exe
if (Path.GetExtension(fileList[0]).Equals(".exe", StringComparison.CurrentCultureIgnoreCase))
{
if (File.Exists(fileList[0]))
{
try
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(fileList[0]);
if (fvi != null)
{
model.Title = fvi.ProductName;
}
}
catch
{
// do nothing
}
}
}
this.AddTile(model);
}
} }
} }

View File

@ -34,6 +34,7 @@
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
@ -50,8 +51,7 @@
this.label1.Size = new System.Drawing.Size(70, 13); this.label1.Size = new System.Drawing.Size(70, 13);
this.label1.TabIndex = 24; this.label1.TabIndex = 24;
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.Click += new System.EventHandler(this.TilePanel_Click); this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseDoubleClick);
this.label1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TilePanel_MouseDoubleClick);
// //
// contextMenuStrip1 // contextMenuStrip1
// //
@ -59,19 +59,19 @@
this.editToolStripMenuItem, this.editToolStripMenuItem,
this.removeToolStripMenuItem}); this.removeToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(181, 70); this.contextMenuStrip1.Size = new System.Drawing.Size(118, 48);
// //
// editToolStripMenuItem // editToolStripMenuItem
// //
this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.editToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.editToolStripMenuItem.Text = "&Edit"; this.editToolStripMenuItem.Text = "&Edit";
this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click); this.editToolStripMenuItem.Click += new System.EventHandler(this.editToolStripMenuItem_Click);
// //
// removeToolStripMenuItem // removeToolStripMenuItem
// //
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.removeToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.removeToolStripMenuItem.Text = "&Remove"; this.removeToolStripMenuItem.Text = "&Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
// //
@ -88,8 +88,7 @@
this.pictureBox1.Size = new System.Drawing.Size(70, 38); this.pictureBox1.Size = new System.Drawing.Size(70, 38);
this.pictureBox1.TabIndex = 25; this.pictureBox1.TabIndex = 25;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.TilePanel_Click); this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseDoubleClick);
this.pictureBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TilePanel_MouseDoubleClick);
// //
// TilePanel // TilePanel
// //
@ -104,8 +103,7 @@
this.MinimumSize = new System.Drawing.Size(70, 70); this.MinimumSize = new System.Drawing.Size(70, 70);
this.Name = "TilePanel"; this.Name = "TilePanel";
this.Size = new System.Drawing.Size(70, 70); this.Size = new System.Drawing.Size(70, 70);
this.Click += new System.EventHandler(this.TilePanel_Click); this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.panel_MouseDoubleClick);
this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TilePanel_MouseDoubleClick);
this.contextMenuStrip1.ResumeLayout(false); this.contextMenuStrip1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -119,5 +117,6 @@
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem;
private System.Windows.Forms.ToolTip toolTip1;
} }
} }

View File

@ -82,6 +82,9 @@ namespace AppLauncher.Windows.Forms
} }
} }
toolTip1.SetToolTip(this, this.Title);
toolTip1.SetToolTip(pictureBox1, this.Title);
toolTip1.SetToolTip(label1, this.Title);
} }
private void panel_MouseDown(object sender, MouseEventArgs e) private void panel_MouseDown(object sender, MouseEventArgs e)
@ -92,7 +95,7 @@ namespace AppLauncher.Windows.Forms
return; return;
} }
if (e.Button != MouseButtons.Left) if (e.Button != MouseButtons.Right)
{ {
return; return;
} }
@ -125,7 +128,7 @@ namespace AppLauncher.Windows.Forms
} }
} }
private void TilePanel_MouseDoubleClick(object sender, MouseEventArgs e) private void panel_MouseDoubleClick(object sender, MouseEventArgs e)
{ {
if (this.ModelInfo == null) if (this.ModelInfo == null)
{ {
@ -153,17 +156,12 @@ namespace AppLauncher.Windows.Forms
{ {
Process.Start(p); Process.Start(p);
} }
catch catch (Exception exc)
{ {
// do nothing MessageBox.Show(exc.Message);
} }
} }
private void TilePanel_Click(object sender, EventArgs e)
{
// do nothing yet
}
private void editToolStripMenuItem_Click(object sender, EventArgs e) private void editToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (editForm == null) editForm = new EditTileForm(this); if (editForm == null) editForm = new EditTileForm(this);

View File

@ -120,4 +120,7 @@
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
</root> </root>