Changed: save on exit prompt

This commit is contained in:
Ray 2020-05-18 01:37:54 +01:00
parent c49c9308c0
commit 045b55dbb3
3 changed files with 78 additions and 14 deletions

View File

@ -4,6 +4,7 @@ using Newtonsoft.Json;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -41,6 +42,36 @@ namespace AppLauncher
this.Visible = true; 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() public async Task ToggleSize()
{ {
if (this.Width > collapsedWidth) if (this.Width > collapsedWidth)

View File

@ -222,7 +222,7 @@ namespace AppLauncher.Windows.Forms
this.imageBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.imageBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.imageBox2.ErrorImage = null; this.imageBox2.ErrorImage = null;
this.imageBox2.Image = global::AppLauncher.Resource1.maximise_20; 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.ImageNormal = global::AppLauncher.Resource1.maximise_20;
this.imageBox2.ImageSelected = global::AppLauncher.Resource1.maximise2_20; this.imageBox2.ImageSelected = global::AppLauncher.Resource1.maximise2_20;
this.imageBox2.InitialImage = null; this.imageBox2.InitialImage = null;
@ -302,9 +302,9 @@ namespace AppLauncher.Windows.Forms
{ {
if (e.Button == MouseButtons.Left) 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) else if (e.Button == MouseButtons.Right)
{ {

View File

@ -157,11 +157,32 @@ namespace AppLauncher.Windows.Forms
isChecked = !isChecked; isChecked = !isChecked;
this.Invalidate(); this.Invalidate();
await this.InvalidateContainer(); 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 else
{ {
// do nothing
} }
} }
else if (e.Button == MouseButtons.Right) 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 CollapseHeight => labelHeight + collapseHeight;
public int ExpandedHeight => expandedHeight + this.Padding.Bottom; public int ExpandedHeight => expandedHeight + this.Padding.Bottom;
@ -296,17 +319,23 @@ namespace AppLauncher.Windows.Forms
if (isAnimating) return; if (isAnimating) return;
isAnimating = true; isAnimating = true;
isChecked = false;
if (this.EnableAnimation)
{
while (this.Height > this.CollapseHeight) while (this.Height > this.CollapseHeight)
{ {
ThreadControl.SetHeight(this, (this.Height - collapseIncrement)); ThreadControl.SetHeight(this, (this.Height - collapseIncrement));
Thread.Sleep(10); Thread.Sleep(10);
} }
}
ThreadControl.SetHeight(this, this.CollapseHeight); ThreadControl.SetHeight(this, this.CollapseHeight);
isAnimating = false; isAnimating = false;
this.Invalidate();
}); });
} }
@ -317,7 +346,10 @@ namespace AppLauncher.Windows.Forms
if (isAnimating) return; if (isAnimating) return;
isAnimating = true; isAnimating = true;
isChecked = true;
if (this.EnableAnimation)
{
while (this.Height < this.ExpandedHeight) while (this.Height < this.ExpandedHeight)
{ {
ThreadControl.SetHeight(this, (this.Height + expandIncrement)); ThreadControl.SetHeight(this, (this.Height + expandIncrement));
@ -325,10 +357,13 @@ namespace AppLauncher.Windows.Forms
Thread.Sleep(10); Thread.Sleep(10);
} }
}
ThreadControl.SetHeight(this, this.ExpandedHeight); ThreadControl.SetHeight(this, this.ExpandedHeight);
isAnimating = false; isAnimating = false;
this.Invalidate();
}); });
} }
@ -393,7 +428,7 @@ namespace AppLauncher.Windows.Forms
public void UpdateModel(TileGroupModel model) public void UpdateModel(TileGroupModel model)
{ {
groupInfo = model; groupInfo = model;
//isChecked = groupInfo.IsExpanded; isChecked = groupInfo.IsExpanded;
this.Invalidate(); this.Invalidate();
} }
@ -417,7 +452,6 @@ namespace AppLauncher.Windows.Forms
if (confirmedPosition == null) if (confirmedPosition == null)
{ {
continue; continue;
} }
// place control // place control
@ -547,7 +581,6 @@ namespace AppLauncher.Windows.Forms
expandedHeight = (this.TileSize * height) + labelHeight; 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)); this.Size = new Size((this.TileSize * width), (isChecked ? this.ExpandedHeight : this.CollapseHeight));
} }