2024-07-01 00:55:19 +00:00
|
|
|
|
using System;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO;
|
2021-07-31 20:59:35 +00:00
|
|
|
|
using System.Linq;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2024-07-06 15:30:37 +00:00
|
|
|
|
using RokettoLaunch.Models;
|
2024-07-12 22:54:44 +00:00
|
|
|
|
using RyzStudio;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
using RyzStudio.Windows.Forms;
|
|
|
|
|
using RyzStudio.Windows.ThemedForms.ButtonTextBox;
|
|
|
|
|
using RyzStudio.Windows.TileForms;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-06 15:30:37 +00:00
|
|
|
|
namespace RokettoLaunch
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private readonly FileSessionManager _fileSessionManager;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private bool _isBusy = false;
|
|
|
|
|
private bool _requestExit = false;
|
|
|
|
|
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
public MainForm()
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2024-07-12 22:54:44 +00:00
|
|
|
|
this.AutoScaleMode = AutoScaleMode.None;
|
2024-07-09 19:54:25 +00:00
|
|
|
|
this.Text = Application.ProductName;
|
2024-07-06 15:30:37 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
_fileSessionManager = new FileSessionManager();
|
|
|
|
|
_fileSessionManager.OpenFileDialog = openFileDialog1;
|
|
|
|
|
_fileSessionManager.SaveFileDialog = saveFileDialog1;
|
2024-07-05 21:43:19 +00:00
|
|
|
|
_fileSessionManager.OnNewing += fileSessionManager_OnNewSession;
|
|
|
|
|
_fileSessionManager.OnLoading += fileSessionManager_OnLoadSession;
|
|
|
|
|
_fileSessionManager.OnSaving += fileSessionManager_OnSaveSession;
|
|
|
|
|
_fileSessionManager.OnClearing += fileSessionManager_OnClearSession;
|
|
|
|
|
_fileSessionManager.OnFilenameChanged += fileSessionManager_OnFilenameChanged;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-09 19:54:25 +00:00
|
|
|
|
notifyIcon1.Text = Application.ProductName;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
protected async override void OnShown(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnShown(e);
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-09 19:54:25 +00:00
|
|
|
|
var args = WinApplication.GetCommandLine();
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
string jsonfigFilename = args.Where(x => (x.Key.Equals("o") || x.Key.Equals("open"))).Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(jsonfigFilename))
|
|
|
|
|
{
|
2024-07-09 19:54:25 +00:00
|
|
|
|
jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig");
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(jsonfigFilename) && File.Exists(jsonfigFilename))
|
|
|
|
|
{
|
|
|
|
|
await _fileSessionManager.OpenSession(jsonfigFilename);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
this.CurrentSession = new AppOptions();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
InvalidateOptions();
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
protected async override void OnClosing(CancelEventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
base.OnClosing(e);
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
if (this.CurrentSession == null)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
this.CurrentSession = new AppOptions();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (this.CurrentSession.HideOnClose && !_requestExit)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
this.Visible = !this.Visible;
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
_requestExit = false;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
await _fileSessionManager.CloseSession();
|
|
|
|
|
|
|
|
|
|
if ((this.CurrentSession?.ShowToggleHotkey ?? new ThKeyCodeTextBox.Results()).Key != Keys.None)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
#if !DEBUG
|
|
|
|
|
RyzStudio.Runtime.InteropServices.User32.UnregisterHotKey((IntPtr)Handle, 1);
|
|
|
|
|
#endif
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
2021-07-23 13:38:07 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
protected override void WndProc(ref Message m)
|
|
|
|
|
{
|
|
|
|
|
switch (m.Msg)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
case RyzStudio.Runtime.InteropServices.User32.WM_HOTKEY:
|
|
|
|
|
if (m.WParam.ToInt32() == 1)
|
|
|
|
|
{
|
|
|
|
|
this.Visible = !this.Visible;
|
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
break;
|
|
|
|
|
case RyzStudio.Runtime.InteropServices.User32.WM_QUERYENDSESSION:
|
2024-07-05 21:43:19 +00:00
|
|
|
|
_requestExit = true;
|
|
|
|
|
|
2024-07-09 19:54:25 +00:00
|
|
|
|
Application.Exit();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
base.WndProc(ref m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
public AppOptions CurrentSession { get; set; } = null;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InvalidateOptions()
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
/// todo: big icons
|
|
|
|
|
|
|
|
|
|
#if !DEBUG
|
|
|
|
|
UIControl.Invoke(this, (x) =>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
RyzStudio.Runtime.InteropServices.User32.UnregisterHotKey((IntPtr)Handle, 1);
|
|
|
|
|
});
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
if ((this.CurrentSession?.ShowToggleHotkey ?? new ThKeyCodeTextBox.Results()).Key != Keys.None)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
UIControl.Invoke(this, (x) =>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-06 15:30:37 +00:00
|
|
|
|
RyzStudio.Runtime.InteropServices.User32.RegisterHotKey((IntPtr)Handle, 1, this.CurrentSession.ShowToggleHotkey.ModifierCode, this.CurrentSession.ShowToggleHotkey.KeyCode);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
});
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
UIControl.SetTopMost(this, this.CurrentSession.AlwaysOnTop);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private void menuStrip1_MenuActivate(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
closeToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close);
|
|
|
|
|
|
|
|
|
|
saveToolStripMenuItem.Enabled = (_fileSessionManager.SessionState == FileSessionManager.SessionStateEnum.Open);
|
|
|
|
|
saveAsToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close);
|
|
|
|
|
|
|
|
|
|
addGroupToolStripMenuItem.Enabled = (_fileSessionManager.SessionState != FileSessionManager.SessionStateEnum.Close);
|
|
|
|
|
|
|
|
|
|
showBigIconsToolStripMenuItem.Checked = this.CurrentSession?.ShowBigIcons ?? true;
|
|
|
|
|
alwaysOnTopToolStripMenuItem.Checked = this.CurrentSession?.AlwaysOnTop ?? false;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 21:12:56 +00:00
|
|
|
|
private void tileContainer_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Middle)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var control = (sender as Control);
|
|
|
|
|
if (control == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var container = UIControl.GetParentsUntil<TileContainer>(sender as Control);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newCoord = container.GetNextCoord();
|
|
|
|
|
|
|
|
|
|
var tileModel = new TileModel()
|
|
|
|
|
{
|
|
|
|
|
Title = "New Tile",
|
|
|
|
|
IsGroup = false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var newTile = new RokettoLaunch.Windows.Forms.TilePanel();
|
|
|
|
|
newTile.ContextMenuStrip = tileMenu1;
|
|
|
|
|
newTile.LoadInfo(tileModel);
|
|
|
|
|
|
|
|
|
|
container.Add(newTile, newCoord.X, newCoord.Y);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
#region Main Menu
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// New
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private async void newToolStripMenuItem_Click(object sender, EventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (_isBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
await _fileSessionManager.NewSession();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Open
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
private async void openToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (_isBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
await _fileSessionManager.OpenSession();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Close
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private async void closeToolStripMenuItem_Click(object sender, EventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (_isBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
await _fileSessionManager.CloseSession();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Save
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private async void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (_isBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
await _fileSessionManager.SaveSession();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Save As
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private async void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (_isBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
await _fileSessionManager.SaveAsSession();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Exit
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
private void exitToolStripMenuItem2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (_isBusy)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_requestExit = true;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-07-31 19:27:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add group
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-07-05 23:30:02 +00:00
|
|
|
|
private async void addGroupToolStripMenuItem_Click(object sender, EventArgs e)
|
2021-07-31 19:27:29 +00:00
|
|
|
|
{
|
2024-07-05 23:30:02 +00:00
|
|
|
|
await AddNewTileGroup();
|
2021-07-31 19:27:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Show big icons
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
private void showBigIconsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.CurrentSession == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
this.CurrentSession.ShowBigIcons = !this.CurrentSession.ShowBigIcons;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
2024-07-01 00:55:19 +00:00
|
|
|
|
/// Always on top
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2024-07-01 00:55:19 +00:00
|
|
|
|
private void alwaysOnTopToolStripMenuItem_Click(object sender, EventArgs e)
|
2021-07-22 23:45:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (this.CurrentSession == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
this.CurrentSession.AlwaysOnTop = !this.CurrentSession.AlwaysOnTop;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
this.TopMost = this.CurrentSession.AlwaysOnTop;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Options
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
var form = new OptionsForm(this.CurrentSession);
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
this.CurrentSession = form.Result;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
InvalidateOptions();
|
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// View help
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
private void viewHelpToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-07-01 00:55:19 +00:00
|
|
|
|
RyzStudio.Diagnostics.Process.Execute(AppResource.AppHelpURL);
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-01 14:25:33 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// About
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
2021-07-22 23:45:30 +00:00
|
|
|
|
private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-07-06 15:30:37 +00:00
|
|
|
|
var form = new RyzStudio.Windows.ThemedForms.AboutForm();
|
|
|
|
|
form.ProductURL = AppResource.AppProductURL;
|
|
|
|
|
form.AuthorURL = AppResource.AppAuthorURL;
|
|
|
|
|
form.CompanyURL = AppResource.AppCompanyURL;
|
|
|
|
|
form.ProductCopyrightStartYear = 2020;
|
|
|
|
|
form.ProductLogo = AppResource.icon_64;
|
|
|
|
|
|
|
|
|
|
form.ShowDialog();
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
#endregion
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
#region Notification Icon
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
|
|
|
|
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
this.Visible = !this.Visible;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
_requestExit = true;
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
#region File Session Manager
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private async Task<bool> fileSessionManager_OnNewSession(FileSessionManager sender)
|
|
|
|
|
{
|
2024-07-05 23:30:02 +00:00
|
|
|
|
return await Task.Run(async () =>
|
2024-07-05 21:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
var form = new NewForm();
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var result = form.Result;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
UIControl.Clear(flowLayoutPanel1);
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
this.CurrentSession.TilesPerRow = result.ColumnCount;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < result.GroupCount; i++)
|
|
|
|
|
{
|
2024-07-05 23:30:02 +00:00
|
|
|
|
await AddNewTileGroup();
|
2024-07-05 21:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutoResize();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> fileSessionManager_OnLoadSession(FileSessionManager sender, string filename)
|
2021-07-31 20:59:35 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
return await Task.Run(async () =>
|
|
|
|
|
{
|
2024-07-12 22:54:44 +00:00
|
|
|
|
var result = GenericResult.Create();
|
|
|
|
|
|
|
|
|
|
switch (Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
case ".json":
|
|
|
|
|
case ".jsonfig":
|
|
|
|
|
this.CurrentSession = RyzStudio.Text.Json.JsonSerialiser.DeserialiseFile<AppOptions>(filename);
|
|
|
|
|
break;
|
|
|
|
|
case ".jsnx":
|
|
|
|
|
this.CurrentSession = await RyzStudio.IO.Compression.ZFile.ReadFile<AppOptions>(filename, "Document.json");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
this.CurrentSession = null;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (this.CurrentSession == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Unable to read session", "Load session");
|
2021-07-31 20:59:35 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (this.CurrentSession == null)
|
|
|
|
|
{
|
|
|
|
|
this.CurrentSession = new AppOptions();
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
// Reposition + resize
|
|
|
|
|
if (!this.CurrentSession.StartPosition.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
UIControl.SetLocation(this, this.CurrentSession.StartPosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.CurrentSession.Height > 0)
|
|
|
|
|
{
|
|
|
|
|
UIControl.SetClientHeight(this, this.CurrentSession.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InvalidateOptions();
|
|
|
|
|
|
|
|
|
|
// Load tiles
|
|
|
|
|
await LoadTileGroups(this.CurrentSession.Groups);
|
|
|
|
|
|
|
|
|
|
AutoResize();
|
|
|
|
|
|
|
|
|
|
UIControl.SetFocus(this);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
private async Task<bool> fileSessionManager_OnSaveSession(FileSessionManager sender, string filename, bool showNotices)
|
2024-07-01 00:55:19 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(filename))
|
2024-07-01 00:55:19 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (!flowLayoutPanel1.Controls.OfType<TileContainer>().Any())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 22:54:44 +00:00
|
|
|
|
return await Task.Run(async () =>
|
2024-07-05 21:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
if (_isBusy)
|
2024-07-01 00:55:19 +00:00
|
|
|
|
{
|
2024-07-05 21:43:19 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
_isBusy = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
// update session
|
|
|
|
|
if (this.CurrentSession == null)
|
|
|
|
|
{
|
|
|
|
|
this.CurrentSession = new AppOptions();
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
this.CurrentSession.StartPosition = this.Location;
|
|
|
|
|
this.CurrentSession.Height = this.Height;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
this.CurrentSession.Groups = new List<TileGroupModel>();
|
|
|
|
|
foreach (var container in flowLayoutPanel1.Controls.OfType<RyzStudio.Windows.TileForms.TileContainer>())
|
|
|
|
|
{
|
|
|
|
|
this.CurrentSession.Groups.Add((TileGroupModel)container.Tag);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 22:54:44 +00:00
|
|
|
|
var result = GenericResult.Create();
|
|
|
|
|
|
|
|
|
|
switch (Path.GetExtension(filename?.ToLower()?.Trim() ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
case ".json":
|
|
|
|
|
case ".jsonfig":
|
|
|
|
|
result = RyzStudio.Text.Json.JsonSerialiser.SerialiseFile(filename, this.CurrentSession);
|
|
|
|
|
break;
|
|
|
|
|
case ".jsnx":
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.IO.File.Delete(filename);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception)
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = await RyzStudio.IO.Compression.ZFile.WriteFile(filename, "Document.json", this.CurrentSession);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
result = GenericResult.Fault("Format not supported");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
if (result.IsSuccess)
|
|
|
|
|
{
|
|
|
|
|
if (showNotices)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Session saved!", "Save session", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-05 21:43:19 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2024-07-12 22:54:44 +00:00
|
|
|
|
if (showNotices)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(result.Message, "Save session");
|
|
|
|
|
}
|
2024-07-05 21:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_isBusy = false;
|
|
|
|
|
|
2024-07-12 22:54:44 +00:00
|
|
|
|
return result.IsSuccess;
|
2024-07-05 21:43:19 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> fileSessionManager_OnClearSession(FileSessionManager sender)
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
UIControl.Clear(flowLayoutPanel1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task fileSessionManager_OnFilenameChanged(FileSessionManager sender, string filename)
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
switch (sender.SessionState)
|
|
|
|
|
{
|
|
|
|
|
case FileSessionManager.SessionStateEnum.New:
|
2024-07-09 19:54:25 +00:00
|
|
|
|
UIControl.SetText(this, "New Session - " + Application.ProductName);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
break;
|
|
|
|
|
case FileSessionManager.SessionStateEnum.Open:
|
2024-07-09 19:54:25 +00:00
|
|
|
|
UIControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Application.ProductName);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
break;
|
|
|
|
|
case FileSessionManager.SessionStateEnum.Close:
|
2024-07-09 19:54:25 +00:00
|
|
|
|
UIControl.SetText(this, Application.ProductName);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-07-01 00:55:19 +00:00
|
|
|
|
});
|
2021-07-31 20:59:35 +00:00
|
|
|
|
}
|
2021-07-22 23:45:30 +00:00
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Tile Container
|
2024-07-01 00:55:19 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add Tile
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void addGroupToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripMenuItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var form = new EditTileForm();
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var result = form.Result;
|
|
|
|
|
var newCoord = container.GetNextCoord();
|
|
|
|
|
|
2024-07-06 15:30:37 +00:00
|
|
|
|
var newTile = new RokettoLaunch.Windows.Forms.TilePanel();
|
2024-07-11 21:12:56 +00:00
|
|
|
|
newTile.ContextMenuStrip = tileMenu1;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
newTile.LoadInfo(result);
|
|
|
|
|
|
|
|
|
|
container.Add(newTile, newCoord.X, newCoord.Y);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add Tile Group
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void toolStripMenuItem4_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripMenuItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var form = new EditTileFolderForm();
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var result = form.Result;
|
|
|
|
|
var newCoord = container.GetNextCoord();
|
|
|
|
|
|
2024-07-06 15:30:37 +00:00
|
|
|
|
var newTile = new RokettoLaunch.Windows.Forms.TilePanel();
|
2024-07-11 21:12:56 +00:00
|
|
|
|
newTile.ContextMenuStrip = tileMenu1;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
newTile.LoadInfo(result);
|
|
|
|
|
|
|
|
|
|
container.Add(newTile, newCoord.X, newCoord.Y);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Edit
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void editToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripMenuItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var model = UIControl.GetTag<TileGroupModel>(container);
|
|
|
|
|
|
|
|
|
|
var form = new EditGroupForm(model);
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var result = form.Result;
|
|
|
|
|
|
|
|
|
|
container.Title = result.Title;
|
|
|
|
|
container.Tag = result;
|
|
|
|
|
|
|
|
|
|
container.Invalidate();
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-05 23:30:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Duplicate
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private async void toolStripMenuItem5_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripMenuItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var model = UIControl.GetTag<TileGroupModel>(container);
|
|
|
|
|
model.IsExpanded = true;
|
|
|
|
|
|
|
|
|
|
await AddTileGroups(model);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-07-01 00:55:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Row - Add Row
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void addRowToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripDropDownItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
container.AddRow();
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Row - Remove Row
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void removeRowToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripDropDownItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
container.RemoveRow();
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move Top
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void topToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripDropDownItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIControl.MoveTop(flowLayoutPanel1, container);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move Up
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void upToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripDropDownItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIControl.MoveUp(flowLayoutPanel1, container);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move Down
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void downToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripDropDownItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIControl.MoveDown(flowLayoutPanel1, container);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move Bottom
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void bottomToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripDropDownItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIControl.MoveBottom(flowLayoutPanel1, container);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Remove
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var container = UIControl.GetOwner<RyzStudio.Windows.TileForms.TileContainer>((ToolStripMenuItem)sender);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flowLayoutPanel1.Controls.Remove(container);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
2024-07-01 00:55:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-07-11 21:12:56 +00:00
|
|
|
|
#region Tile
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Edit
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void editToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var tile = UIControl.GetOwner<RokettoLaunch.Windows.Forms.TilePanel>((ToolStripMenuItem)sender);
|
|
|
|
|
if (tile == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tile.ModelInfo.IsGroup)
|
|
|
|
|
{
|
|
|
|
|
var form = new EditTileFolderForm(tile.ModelInfo);
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
tile.LoadInfo(form.Result);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var form = new EditTileForm(tile.ModelInfo);
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
tile.LoadInfo(form.Result);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Duplicate
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void toolStripMenuItem6_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var tile = UIControl.GetOwner<RokettoLaunch.Windows.Forms.TilePanel>((ToolStripMenuItem)sender);
|
|
|
|
|
if (tile == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var container = UIControl.GetParentsUntil<TileContainer>(tile);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newCoord = container.GetNextCoord();
|
|
|
|
|
|
|
|
|
|
var newTile = new RokettoLaunch.Windows.Forms.TilePanel();
|
|
|
|
|
newTile.ContextMenuStrip = tileMenu1;
|
|
|
|
|
newTile.LoadInfo(tile.ModelInfo);
|
|
|
|
|
|
|
|
|
|
container.Add(newTile, newCoord.X, newCoord.Y);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Remove
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void removeToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var tile = UIControl.GetOwner<RokettoLaunch.Windows.Forms.TilePanel>((ToolStripMenuItem)sender);
|
|
|
|
|
if (tile == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var container = UIControl.GetParentsUntil<TileContainer>(tile);
|
|
|
|
|
if (container == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
container.Controls?.Remove(tile);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
2024-07-05 23:30:02 +00:00
|
|
|
|
private async Task AddNewTileGroup()
|
2024-07-05 21:43:19 +00:00
|
|
|
|
{
|
|
|
|
|
var group = new TileGroupModel();
|
|
|
|
|
group.Title = "New Group";
|
|
|
|
|
group.IsExpanded = true;
|
|
|
|
|
group.GridSize = new System.Drawing.Size(this.CurrentSession.TilesPerRow, 1);
|
|
|
|
|
|
2024-07-05 23:30:02 +00:00
|
|
|
|
await AddTileGroups(group);
|
|
|
|
|
|
|
|
|
|
_fileSessionManager.HasChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task AddTileGroups(TileGroupModel model)
|
|
|
|
|
{
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
var panel = new RyzStudio.Windows.TileForms.TileContainer();
|
|
|
|
|
panel.Title = model.Title;
|
|
|
|
|
panel.IsOpen = model.IsExpanded;
|
|
|
|
|
panel.TitleContextMenuStrip = tileContainerMenu1;
|
2024-07-11 21:12:56 +00:00
|
|
|
|
panel.PaddingBottom = 0;
|
2024-07-05 23:30:02 +00:00
|
|
|
|
panel.AutoSizeHeight = true;
|
|
|
|
|
panel.Tag = model;
|
|
|
|
|
panel.AutoSize(model.GridSize.Width, model.GridSize.Height);
|
2024-07-11 21:12:56 +00:00
|
|
|
|
panel.Height += 4;
|
|
|
|
|
|
|
|
|
|
panel.MouseClick += tileContainer_MouseClick;
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
2024-07-05 23:30:02 +00:00
|
|
|
|
UIControl.Add(flowLayoutPanel1, panel);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
2024-07-05 23:30:02 +00:00
|
|
|
|
// Load tiles
|
|
|
|
|
foreach (var item2 in model.Items ?? new List<TileModel>())
|
|
|
|
|
{
|
2024-07-11 21:12:56 +00:00
|
|
|
|
var newTile = new RokettoLaunch.Windows.Forms.TilePanel();
|
|
|
|
|
newTile.ContextMenuStrip = tileMenu1;
|
|
|
|
|
newTile.LoadInfo(item2);
|
2024-07-05 23:30:02 +00:00
|
|
|
|
|
2024-07-11 21:12:56 +00:00
|
|
|
|
panel.Add(newTile, item2.Position.X, item2.Position.Y);
|
2024-07-05 23:30:02 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2024-07-05 21:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AutoResize()
|
|
|
|
|
{
|
|
|
|
|
if (flowLayoutPanel1.Controls.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var width = 0;
|
|
|
|
|
foreach (var item in flowLayoutPanel1.Controls.OfType<TileContainer>())
|
|
|
|
|
{
|
|
|
|
|
width = Math.Max(width, item.Width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIControl.SetClientWidth(this, width + panel1.Padding.Horizontal + this.Padding.Horizontal + SystemInformation.VerticalScrollBarWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task LoadTileGroups(List<TileGroupModel> groupList)
|
|
|
|
|
{
|
2024-07-05 23:30:02 +00:00
|
|
|
|
UIControl.Clear(flowLayoutPanel1);
|
2024-07-05 21:43:19 +00:00
|
|
|
|
|
2024-07-05 23:30:02 +00:00
|
|
|
|
foreach (var item in groupList ?? new List<TileGroupModel>())
|
|
|
|
|
{
|
|
|
|
|
await AddTileGroups(item);
|
|
|
|
|
}
|
2024-07-05 21:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-22 23:45:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|