aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS/Desktop.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.Main/ShiftOS/Desktop.cs')
-rw-r--r--ShiftOS.Main/ShiftOS/Desktop.cs85
1 files changed, 46 insertions, 39 deletions
diff --git a/ShiftOS.Main/ShiftOS/Desktop.cs b/ShiftOS.Main/ShiftOS/Desktop.cs
index 06f1fc8..95e4d26 100644
--- a/ShiftOS.Main/ShiftOS/Desktop.cs
+++ b/ShiftOS.Main/ShiftOS/Desktop.cs
@@ -1,13 +1,10 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Forms;
+using ShiftOS.Engine.Misc;
using ShiftOS.Engine.WindowManager;
+using ShiftOS.Main.Properties;
+using ShiftOS.Main.ShiftOS.Apps;
namespace ShiftOS.Main.ShiftOS
{
@@ -19,50 +16,60 @@ namespace ShiftOS.Main.ShiftOS
timer1.Start();
- this.Closed += (sender, args) =>
- {
- Application.Exit();
- };
+ Closed += (sender, args) => { Application.Exit(); };
#region Disgusting taskbar code
- ShiftWM.Windows.CollectionChanged += (sender, args) =>
+ ShiftWM.Windows.ItemAdded += (sender, e) =>
{
- args.NewItems?.OfType<ShiftWindow>().ToList().ForEach(window =>
- {
- taskbar.Invoke(new Action(() =>
- {
- taskbar.Items.Add(new ToolStripButton
+ taskbar.Invoke(
+ new Action(
+ () =>
{
- Text = window.Title.Text,
- Image = window.Icon.ToBitmap(),
- Tag = window.Id
- });
- }));
- });
-
- args.OldItems?.OfType<ShiftWindow>().ToList().ForEach(window =>
- {
- taskbar.Invoke(new Action(() =>
- {
- var tbRemovalList = taskbar.Items.OfType<ToolStripItem>().Where(i => (uint) i.Tag == window.Id);
+ taskbar.Items.Add(
+ new ToolStripButton
+ {
+ Text = e.Item.Title.Text,
+ Image = e.Item.Icon.ToBitmap(),
+ Tag = e.Item.Id
+ });
+ }));
+ };
- tbRemovalList.ToList().ForEach(p => taskbar.Items.Remove(p));
- }));
- });
+ ShiftWM.Windows.ItemRemoved += (sender, e) =>
+ {
+ taskbar.Invoke(
+ new Action(
+ () =>
+ {
+ var tbRemovalList = taskbar.Items.OfType<ToolStripItem>().Where(i => (uint) i.Tag == e.Item.Id);
+
+ tbRemovalList.ToList().ForEach(p => taskbar.Items.Remove(p));
+ }));
};
#endregion
}
- private void timer1_Tick(object sender, EventArgs e) =>
+ void timer1_Tick(object sender, EventArgs e) =>
taskbarClock.Text = $"{DateTime.Now:t}";
- private void terminalToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Apps.Terminal trm = new Apps.Terminal();
+ void terminalToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var trm = new Terminal();
+ ShiftWM.Init(trm, "Terminal", null);
+ }
+
+ void textPadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var tp = new TextPad();
+ ShiftWM.Init(tp, "TextPad", Resources.iconTextPad);
+ }
- ShiftWM.Init(trm, "Terminal", null, false, true);
- }
- }
-}
+ void fileSkimmerToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var fs = new FileSkimmer();
+ ShiftWM.Init(fs, "File Skimmer", Resources.iconFileSkimmer);
+ }
+ }
+} \ No newline at end of file