Changed: save on exit prompt
This commit is contained in:
parent
c49c9308c0
commit
045b55dbb3
31
MainForm.cs
31
MainForm.cs
@ -4,6 +4,7 @@ using Newtonsoft.Json;
|
||||
using RyzStudio.Windows.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
@ -41,6 +42,36 @@ namespace AppLauncher
|
||||
this.Visible = true;
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
base.OnClosing(e);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sessionFilename))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult dr = MessageBox.Show("Save existing session?", "Exit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||
if (dr == DialogResult.Yes)
|
||||
{
|
||||
bool rv = saveFile(sessionFilename);
|
||||
if (!rv)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
else if (dr == DialogResult.No)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else if (dr == DialogResult.Cancel)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ToggleSize()
|
||||
{
|
||||
if (this.Width > collapsedWidth)
|
||||
|
@ -222,7 +222,7 @@ namespace AppLauncher.Windows.Forms
|
||||
this.imageBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.imageBox2.ErrorImage = null;
|
||||
this.imageBox2.Image = global::AppLauncher.Resource1.maximise_20;
|
||||
this.imageBox2.ImageHover = global::AppLauncher.Resource1.maximise2_20;
|
||||
this.imageBox2.ImageHover = global::AppLauncher.Resource1.maximise_20;
|
||||
this.imageBox2.ImageNormal = global::AppLauncher.Resource1.maximise_20;
|
||||
this.imageBox2.ImageSelected = global::AppLauncher.Resource1.maximise2_20;
|
||||
this.imageBox2.InitialImage = null;
|
||||
@ -302,9 +302,9 @@ namespace AppLauncher.Windows.Forms
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
this.WindowState = ((this.WindowState == FormWindowState.Maximized) ? FormWindowState.Normal : FormWindowState.Maximized);
|
||||
//this.WindowState = ((this.WindowState == FormWindowState.Maximized) ? FormWindowState.Normal : FormWindowState.Maximized);
|
||||
|
||||
imageBox2.IsSelected = (this.WindowState == FormWindowState.Maximized);
|
||||
//imageBox2.IsSelected = (this.WindowState == FormWindowState.Maximized);
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
|
@ -157,11 +157,32 @@ namespace AppLauncher.Windows.Forms
|
||||
isChecked = !isChecked;
|
||||
|
||||
this.Invalidate();
|
||||
|
||||
await this.InvalidateContainer();
|
||||
|
||||
// exclusivity
|
||||
if (isChecked)
|
||||
{
|
||||
if (this.Model.IsExclusive)
|
||||
{
|
||||
if (this.FlowLayoutPanel != null)
|
||||
{
|
||||
foreach (TTilePanelLayout item in this.FlowLayoutPanel.Controls.OfType<TTilePanelLayout>())
|
||||
{
|
||||
if (item.Equals(this))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
await item.Collapse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
@ -191,6 +212,8 @@ namespace AppLauncher.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnableAnimation { get; set; } = true;
|
||||
|
||||
public int CollapseHeight => labelHeight + collapseHeight;
|
||||
|
||||
public int ExpandedHeight => expandedHeight + this.Padding.Bottom;
|
||||
@ -296,17 +319,23 @@ namespace AppLauncher.Windows.Forms
|
||||
if (isAnimating) return;
|
||||
|
||||
isAnimating = true;
|
||||
isChecked = false;
|
||||
|
||||
if (this.EnableAnimation)
|
||||
{
|
||||
while (this.Height > this.CollapseHeight)
|
||||
{
|
||||
ThreadControl.SetHeight(this, (this.Height - collapseIncrement));
|
||||
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadControl.SetHeight(this, this.CollapseHeight);
|
||||
|
||||
isAnimating = false;
|
||||
|
||||
this.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
@ -317,7 +346,10 @@ namespace AppLauncher.Windows.Forms
|
||||
if (isAnimating) return;
|
||||
|
||||
isAnimating = true;
|
||||
isChecked = true;
|
||||
|
||||
if (this.EnableAnimation)
|
||||
{
|
||||
while (this.Height < this.ExpandedHeight)
|
||||
{
|
||||
ThreadControl.SetHeight(this, (this.Height + expandIncrement));
|
||||
@ -325,10 +357,13 @@ namespace AppLauncher.Windows.Forms
|
||||
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadControl.SetHeight(this, this.ExpandedHeight);
|
||||
|
||||
isAnimating = false;
|
||||
|
||||
this.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
@ -393,7 +428,7 @@ namespace AppLauncher.Windows.Forms
|
||||
public void UpdateModel(TileGroupModel model)
|
||||
{
|
||||
groupInfo = model;
|
||||
//isChecked = groupInfo.IsExpanded;
|
||||
isChecked = groupInfo.IsExpanded;
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
@ -417,7 +452,6 @@ namespace AppLauncher.Windows.Forms
|
||||
if (confirmedPosition == null)
|
||||
{
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// place control
|
||||
@ -547,7 +581,6 @@ namespace AppLauncher.Windows.Forms
|
||||
|
||||
expandedHeight = (this.TileSize * height) + labelHeight;
|
||||
|
||||
//this.Size = new Size((this.TileSize * width), expandedHeight);
|
||||
this.Size = new Size((this.TileSize * width), (isChecked ? this.ExpandedHeight : this.CollapseHeight));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user