2017-09-27 22:32:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
2017-11-05 23:47:46 +00:00
|
|
|
|
using ShiftOS.Engine.Misc;
|
2017-09-27 22:32:16 +00:00
|
|
|
|
using ShiftOS.Engine.WindowManager;
|
2017-11-05 23:47:46 +00:00
|
|
|
|
using ShiftOS.Main.Properties;
|
|
|
|
|
using ShiftOS.Main.ShiftOS.Apps;
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
|
|
|
|
namespace ShiftOS.Main.ShiftOS
|
|
|
|
|
{
|
|
|
|
|
public partial class Desktop : Form
|
|
|
|
|
{
|
|
|
|
|
public Desktop()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
timer1.Start();
|
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
Closed += (sender, args) => { Application.Exit(); };
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
|
|
|
|
#region Disgusting taskbar code
|
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
ShiftWm.Windows.CollectionChanged += (sender, args) =>
|
2017-09-27 22:32:16 +00:00
|
|
|
|
{
|
2017-11-05 23:47:46 +00:00
|
|
|
|
args.NewItems?.OfType<ShiftWindow>()
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(
|
|
|
|
|
window =>
|
|
|
|
|
{
|
|
|
|
|
taskbar.Invoke(
|
|
|
|
|
new Action(
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
taskbar.Items.Add(
|
|
|
|
|
new ToolStripButton
|
|
|
|
|
{
|
|
|
|
|
Text = window.Title.Text,
|
|
|
|
|
Image = window.Icon.ToBitmap(),
|
|
|
|
|
Tag = window.Id
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
});
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
args.OldItems?.OfType<ShiftWindow>()
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(
|
|
|
|
|
window =>
|
|
|
|
|
{
|
|
|
|
|
taskbar.Invoke(
|
|
|
|
|
new Action(
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
var tbRemovalList = taskbar.Items.OfType<ToolStripItem>().Where(i => (uint) i.Tag == window.Id);
|
|
|
|
|
|
|
|
|
|
tbRemovalList.ToList().ForEach(p => taskbar.Items.Remove(p));
|
|
|
|
|
}));
|
|
|
|
|
});
|
2017-09-27 22:32:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void timer1_Tick(object sender, EventArgs e) =>
|
2017-09-27 22:32:16 +00:00
|
|
|
|
taskbarClock.Text = $"{DateTime.Now:t}";
|
2017-10-14 15:23:41 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void terminalToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var trm = new Terminal();
|
2017-10-14 15:23:41 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
ShiftWm.Init(trm, "Terminal", null);
|
|
|
|
|
}
|
2017-11-05 20:13:06 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
void textPadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var tp = new TextPad();
|
|
|
|
|
ShiftWm.Init(tp, "TextPad", Resources.iconTextPad.ToIcon());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|