Changed: session settings + layout panel init-size
This commit is contained in:
parent
3a2ee532c7
commit
c49c9308c0
@ -55,6 +55,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Models\LauncherSession.cs" />
|
||||
<Compile Include="Models\TileModel.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
3
MainForm.Designer.cs
generated
3
MainForm.Designer.cs
generated
@ -178,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(620, 341);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(620, 340);
|
||||
this.flowLayoutPanel1.TabIndex = 27;
|
||||
this.flowLayoutPanel1.WrapContents = false;
|
||||
//
|
||||
@ -202,6 +202,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(633, 400);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimumSize = new System.Drawing.Size(633, 280);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Launcher";
|
||||
this.TitleContextMenuStrip = this.contextMenuStrip1;
|
||||
|
22
MainForm.cs
22
MainForm.cs
@ -277,8 +277,8 @@ namespace AppLauncher
|
||||
return;
|
||||
}
|
||||
|
||||
List<TileGroupModel> rs = JsonConvert.DeserializeObject<List<TileGroupModel>>(sourceCode);
|
||||
if (rs == null)
|
||||
LauncherSession launcherSession = JsonConvert.DeserializeObject<LauncherSession>(sourceCode);
|
||||
if (launcherSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -286,15 +286,19 @@ namespace AppLauncher
|
||||
int maxWidth = 0;
|
||||
flowLayoutPanel1.Controls.Clear();
|
||||
|
||||
foreach (TileGroupModel item in rs)
|
||||
if (launcherSession.Groups != null)
|
||||
{
|
||||
foreach (TileGroupModel item in launcherSession.Groups)
|
||||
{
|
||||
TTilePanelLayout panel = new TTilePanelLayout(item);
|
||||
maxWidth = Math.Max(maxWidth, panel.Width);
|
||||
|
||||
flowLayoutPanel1.Controls.Add(panel);
|
||||
}
|
||||
}
|
||||
|
||||
this.Width = maxWidth + SystemInformation.VerticalScrollBarWidth + 20 + flowLayoutPanel1.Left;
|
||||
this.Height = launcherSession.DefaultHeight;
|
||||
}
|
||||
|
||||
protected void newSession()
|
||||
@ -335,7 +339,13 @@ namespace AppLauncher
|
||||
|
||||
isBusy = true;
|
||||
|
||||
List<TileGroupModel> rs = new List<TileGroupModel>();
|
||||
LauncherSession launcherSession = new LauncherSession()
|
||||
{
|
||||
DefaultHeight = this.Height,
|
||||
Groups = new List<TileGroupModel>()
|
||||
};
|
||||
|
||||
launcherSession.Groups = new List<TileGroupModel>();
|
||||
for (int i = 0; i < flowLayoutPanel1.Controls.Count; i++)
|
||||
{
|
||||
if (flowLayoutPanel1.Controls[i].GetType() != typeof(TTilePanelLayout))
|
||||
@ -344,12 +354,12 @@ namespace AppLauncher
|
||||
}
|
||||
|
||||
TTilePanelLayout container = flowLayoutPanel1.Controls[i] as TTilePanelLayout;
|
||||
rs.Add(container.Model);
|
||||
launcherSession.Groups.Add(container.Model);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(rs));
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(launcherSession));
|
||||
|
||||
if (showNotices)
|
||||
{
|
||||
|
10
Models/LauncherSession.cs
Normal file
10
Models/LauncherSession.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AppLauncher.Models
|
||||
{
|
||||
public class LauncherSession
|
||||
{
|
||||
public int DefaultHeight { get; set; } = 280;
|
||||
public List<TileGroupModel> Groups { get; set; } = new List<TileGroupModel>();
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ namespace AppLauncher.Windows.Forms
|
||||
protected internal RyzStudio.Windows.Forms.TImageBox imageBox2;
|
||||
protected internal RyzStudio.Windows.Forms.TImageBox imageBox1;
|
||||
private NotifyIcon notifyIcon1;
|
||||
private Panel panel1;
|
||||
private IContainer components;
|
||||
|
||||
public AForm() : base()
|
||||
@ -38,17 +39,25 @@ namespace AppLauncher.Windows.Forms
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
|
||||
this.SuspendLayout();
|
||||
|
||||
imageBox3.Left = this.DisplayRectangle.Width - imageBox3.Width - 17;
|
||||
imageBox3.Top = 18;
|
||||
imageBox3.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
|
||||
|
||||
imageBox2.Left = imageBox3.Left - imageBox2.Width - 8;
|
||||
imageBox2.Top = 18;
|
||||
imageBox2.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
|
||||
|
||||
imageBox1.Left = imageBox2.Left - imageBox1.Width - 8;
|
||||
imageBox1.Top = 18;
|
||||
imageBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
|
||||
|
||||
panel1.Left = this.DisplayRectangle.Left;
|
||||
panel1.Top = this.DisplayRectangle.Height - panel1.Height;
|
||||
panel1.Width = this.DisplayRectangle.Width;
|
||||
panel1.Anchor = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom);
|
||||
|
||||
this.ResumeLayout();
|
||||
}
|
||||
|
||||
@ -182,6 +191,7 @@ namespace AppLauncher.Windows.Forms
|
||||
this.imageBox2 = new RyzStudio.Windows.Forms.TImageBox();
|
||||
this.imageBox1 = new RyzStudio.Windows.Forms.TImageBox();
|
||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.imageBox3)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.imageBox2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.imageBox1)).BeginInit();
|
||||
@ -249,9 +259,23 @@ namespace AppLauncher.Windows.Forms
|
||||
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
|
||||
this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.panel1.Cursor = System.Windows.Forms.Cursors.SizeNS;
|
||||
this.panel1.Location = new System.Drawing.Point(109, 114);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(200, 2);
|
||||
this.panel1.TabIndex = 149;
|
||||
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
|
||||
this.panel1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseMove);
|
||||
this.panel1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseUp);
|
||||
//
|
||||
// AForm
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(421, 321);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.imageBox1);
|
||||
this.Controls.Add(this.imageBox2);
|
||||
this.Controls.Add(this.imageBox3);
|
||||
@ -302,5 +326,27 @@ namespace AppLauncher.Windows.Forms
|
||||
notifyIcon1.Visible = !this.Visible;
|
||||
}
|
||||
|
||||
private void panel1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
isDragging = true;
|
||||
startPosition = e.Location;
|
||||
}
|
||||
}
|
||||
|
||||
private void panel1_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
isDragging = false;
|
||||
}
|
||||
|
||||
private void panel1_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (isDragging)
|
||||
{
|
||||
this.Size = new Size(this.Width, e.Y - startPosition.Y + this.Height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ namespace AppLauncher.Windows.Forms
|
||||
protected bool isAnimating = false;
|
||||
protected bool isChecked = true;
|
||||
protected Point lastMousePosition = new Point();
|
||||
protected Point gridSize = new Point();
|
||||
|
||||
public TTilePanelLayout(TileGroupModel model) : base()
|
||||
{
|
||||
@ -182,10 +183,11 @@ namespace AppLauncher.Windows.Forms
|
||||
{
|
||||
get
|
||||
{
|
||||
int w = (int)Math.Floor(decimal.Divide(this.Width, this.TileSize));
|
||||
int h = (int)Math.Floor(decimal.Divide(this.Height - labelHeight, this.TileSize));
|
||||
//int w = (int)Math.Floor(decimal.Divide(this.Width, this.TileSize));
|
||||
//int h = (int)Math.Floor(decimal.Divide(this.Height - labelHeight, this.TileSize));
|
||||
|
||||
return new Point(w, h);
|
||||
//return new Point(w, h);
|
||||
return gridSize;
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,20 +310,6 @@ namespace AppLauncher.Windows.Forms
|
||||
});
|
||||
}
|
||||
|
||||
public async Task CollapseNow()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (isAnimating) return;
|
||||
|
||||
isAnimating = true;
|
||||
|
||||
ThreadControl.SetHeight(this, this.CollapseHeight);
|
||||
|
||||
isAnimating = false;
|
||||
});
|
||||
}
|
||||
|
||||
public async Task Expand()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
@ -355,7 +343,7 @@ namespace AppLauncher.Windows.Forms
|
||||
return new Point((x * this.TileSize), ((y * this.TileSize) + labelHeight));
|
||||
}
|
||||
|
||||
public async Task InvalidateContainer(bool animate = true)
|
||||
public async Task InvalidateContainer()
|
||||
{
|
||||
if (isAnimating)
|
||||
{
|
||||
@ -367,16 +355,9 @@ namespace AppLauncher.Windows.Forms
|
||||
await this.Expand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animate)
|
||||
{
|
||||
await this.Collapse();
|
||||
}
|
||||
else
|
||||
{
|
||||
await this.CollapseNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGroup()
|
||||
@ -393,10 +374,7 @@ namespace AppLauncher.Windows.Forms
|
||||
}));
|
||||
}
|
||||
|
||||
public void AddRow()
|
||||
{
|
||||
this.SetGridSize(groupInfo.GridSize.Width, (groupInfo.GridSize.Height + 1));
|
||||
}
|
||||
public void AddRow() =>this.SetGridSize(groupInfo.GridSize.Width, (groupInfo.GridSize.Height + 1));
|
||||
|
||||
public void EditGroup() => EditGroupForm.ShowDialog(this);
|
||||
|
||||
@ -404,10 +382,9 @@ namespace AppLauncher.Windows.Forms
|
||||
{
|
||||
groupInfo = model;
|
||||
|
||||
this.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height);
|
||||
|
||||
isChecked = groupInfo.IsExpanded;
|
||||
|
||||
this.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height);
|
||||
this.LoadTiles(model.Items);
|
||||
|
||||
this.Invalidate();
|
||||
@ -416,7 +393,7 @@ namespace AppLauncher.Windows.Forms
|
||||
public void UpdateModel(TileGroupModel model)
|
||||
{
|
||||
groupInfo = model;
|
||||
isChecked = groupInfo.IsExpanded;
|
||||
//isChecked = groupInfo.IsExpanded;
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
@ -566,9 +543,12 @@ namespace AppLauncher.Windows.Forms
|
||||
|
||||
public void SetGridSize(int width, int height)
|
||||
{
|
||||
gridSize = new Point(width, height);
|
||||
|
||||
expandedHeight = (this.TileSize * height) + labelHeight;
|
||||
|
||||
this.Size = new Size((this.TileSize * width), expandedHeight);
|
||||
//this.Size = new Size((this.TileSize * width), expandedHeight);
|
||||
this.Size = new Size((this.TileSize * width), (isChecked ? this.ExpandedHeight : this.CollapseHeight));
|
||||
}
|
||||
|
||||
protected Point convertCoordToLocation(Point position) => new Point((position.X * this.TileSize), ((position.Y * this.TileSize) + labelHeight));
|
||||
@ -768,6 +748,5 @@ namespace AppLauncher.Windows.Forms
|
||||
|
||||
private void removeGroupMenuItem3_Click(object sender, EventArgs e) => this.Remove();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user