added desktop and some small additions and changes to shiftwm

This commit is contained in:
John T 2017-09-27 18:32:16 -04:00
parent dc7533184a
commit a25baf0820
23 changed files with 909 additions and 458 deletions

3
.vs/ProjectSettings.json Normal file
View file

@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}

Binary file not shown.

View file

@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}

BIN
.vs/slnx.sqlite Normal file

Binary file not shown.

View file

@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -30,6 +31,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Magick.NET-Q16-AnyCPU, Version=7.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
<HintPath>..\packages\Magick.NET-Q16-AnyCPU.7.0.7.300\lib\net40\Magick.NET-Q16-AnyCPU.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@ -48,6 +52,7 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="Tools.cs" />
<Compile Include="WindowManager\InfoboxTemplate.cs"> <Compile Include="WindowManager\InfoboxTemplate.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -75,6 +80,7 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" />
<None Include="Resources\nullIcon.png" /> <None Include="Resources\nullIcon.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

32
ShiftOS.Engine/Tools.cs Normal file
View file

@ -0,0 +1,32 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using ImageMagick;
namespace ShiftOS.Engine
{
/// <summary>
/// Random class full of unassorted [but also uncategorizable] tools.
/// </summary>
public static class Tools
{
public static Random Rnd = new Random();
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public extern static bool DestroyIcon(IntPtr handle);
public static Icon ToIcon(this Bitmap bm)
{
Icon tempicon = Icon.FromHandle(bm.GetHicon());
Icon newIcon = tempicon.Clone() as Icon;
//for some reason this exists
DestroyIcon(tempicon.Handle);
return newIcon;
}
}
}

View file

@ -1,11 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Media; using System.Media;
using System.IO; using System.IO;
@ -14,38 +8,39 @@ namespace ShiftOS.Engine.WindowManager
{ {
public partial class InfoboxTemplate : UserControl public partial class InfoboxTemplate : UserControl
{ {
Stream str; Stream _str;
public int buttonChoice; private int _buttonChoice;
public int buttonSelected; private int _buttonSelected;
public InfoboxTemplate(buttonType type) public InfoboxTemplate(ButtonType type)
{ {
InitializeComponent(); InitializeComponent();
switch (type) switch (type)
{ {
case buttonType.OK: case ButtonType.Ok:
btnOpt1.Text = "OK"; btnOpt1.Text = "OK";
btnOpt2.Hide(); btnOpt2.Hide();
btnOpt1.Location = new Point(109, 134); btnOpt1.Location = new Point(109, 134);
buttonChoice = 1; _buttonChoice = 1;
break; break;
case buttonType.OKCancel: case ButtonType.OkCancel:
btnOpt1.Text = "OK"; btnOpt1.Text = "OK";
btnOpt2.Text = "Cancel"; btnOpt2.Text = "Cancel";
buttonChoice = 2; _buttonChoice = 2;
break; break;
case buttonType.YesNo: case ButtonType.YesNo:
btnOpt1.Text = "Yes"; btnOpt1.Text = "Yes";
btnOpt2.Text = "No"; btnOpt2.Text = "No";
buttonChoice = 3; _buttonChoice = 3;
break; break;
} }
} }
public enum buttonType
public enum ButtonType
{ {
YesNo, YesNo,
OKCancel, OkCancel,
OK Ok
} }
private void btnOpt1_Click(object sender, EventArgs e) private void btnOpt1_Click(object sender, EventArgs e)
@ -53,12 +48,12 @@ namespace ShiftOS.Engine.WindowManager
switch (btnOpt1.Text) switch (btnOpt1.Text)
{ {
case "OK": case "OK":
buttonSelected = 1; _buttonSelected = 1;
ParentForm.Close(); ParentForm?.Close();
break; break;
case "Yes": case "Yes":
buttonSelected = 2; _buttonSelected = 2;
ParentForm.Close(); ParentForm?.Close();
break; break;
} }
} }
@ -68,27 +63,26 @@ namespace ShiftOS.Engine.WindowManager
switch (btnOpt2.Text) switch (btnOpt2.Text)
{ {
case "No": case "No":
buttonSelected = 3; _buttonSelected = 3;
break; break;
case "Cancel": case "Cancel":
buttonSelected = 4; _buttonSelected = 4;
break; break;
} }
} }
public void Play() public void Play()
{ {
str = Properties.Resources.infobox; _str = Properties.Resources.infobox;
SoundPlayer sp = new SoundPlayer(str); SoundPlayer sp = new SoundPlayer(_str);
sp.Play(); sp.Play();
sp.Stream.Position = 0; sp.Stream.Position = 0;
} }
private void InfoboxTemplate_Load(object sender, EventArgs e) private void InfoboxTemplate_Load(object sender, EventArgs e)
{ => Play();
Play();
}
private void changeSize_Tick(object sender, EventArgs e) private void changeSize_Tick(object sender, EventArgs e)
{ {
this.Height += label1.Height; this.Height += label1.Height;
this.Width += label1.Width; this.Width += label1.Width;

View file

@ -1,41 +1,81 @@
using System.Drawing; using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using static ShiftOS.Engine.WindowManager.InfoboxTemplate; using static ShiftOS.Engine.WindowManager.InfoboxTemplate;
namespace ShiftOS.Engine.WindowManager namespace ShiftOS.Engine.WindowManager
{ {
public class ShiftWM public static class ShiftWM
{ {
public ShiftWindow Init(UserControl content, string title, Image icon, bool ShowAsInfobox = false, bool resize = true) public static ObservableCollection<ShiftWindow> Windows { get; } = new ObservableCollection<ShiftWindow>();
public static ShiftWindow GetShiftWindow(this UserControl control)
{
return Windows.First(p => (uint) control.Tag == p.Id);
}
public static ShiftWindow Init(UserControl content, string title, Icon icon, bool showAsInfobox = false, bool resize = true)
{ {
// Setup Window // Setup Window
ShiftWindow app = new ShiftWindow(); ShiftWindow app = new ShiftWindow
app.Text = title; {
app.Title.Text = title; Text = title,
app.Width = content.Width + app.left.Width + app.right.Width; Title = {Text = title}
};
app.Width = content.Width + app.left.Width + app.right.Width;
app.Height = content.Height + app.bottom.Height + app.top.Height; app.Height = content.Height + app.bottom.Height + app.top.Height;
// Icon Setup // Icon Setup
if (icon == null) if (icon == null)
{ {
app.programIcon.Hide(); app.programIcon.Hide();
app.programIcon.Image = Properties.Resources.nullIcon; app.programIcon.Image = Properties.Resources.nullIcon;
app.Title.Location = new Point(2, 7); app.Title.Location = new Point(2, 7);
} }
else app.programIcon.Image = icon;
// Setup UC else
content.Parent = app.programContent; {
app.programIcon.Image = icon.ToBitmap();
app.Icon = icon;
}
// Setup UC
content.Parent = app.programContent;
content.BringToFront(); content.BringToFront();
content.Dock = DockStyle.Fill; content.Dock = DockStyle.Fill;
app.Show(); app.Show();
content.Tag = app.SetId();
Debug.WriteLine($"usercontrol: {content.Tag} window: {app.Id}");
app.Closed += (sender, args) =>
{
Windows.Remove((ShiftWindow) sender);
};
Windows.Add(app);
if (content is IShiftWindowExtensions extensions)
{
extensions.OnLoaded(app);
}
return app; return app;
} }
public InfoboxTemplate StartInfoboxSession(string title, string body, buttonType type)
public static InfoboxTemplate StartInfoboxSession(string title, string body, ButtonType type)
{ {
InfoboxTemplate info = new InfoboxTemplate(type); InfoboxTemplate info = new InfoboxTemplate(type)
info.label1.Text = body; {
Init(info, title, Properties.Resources.iconInfoBox_fw, true, false); label1 = { Text = body }
};
Init(info, title, Properties.Resources.iconInfoBox_fw.ToIcon(), true, false);
return info; return info;
} }
} }

View file

@ -28,220 +28,238 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.program = new System.Windows.Forms.Panel(); this.program = new System.Windows.Forms.Panel();
this.programContent = new System.Windows.Forms.Panel(); this.programContent = new System.Windows.Forms.Panel();
this.bottomleftcorner = new System.Windows.Forms.Panel(); this.bottomleftcorner = new System.Windows.Forms.Panel();
this.toprightcorner = new System.Windows.Forms.Panel(); this.toprightcorner = new System.Windows.Forms.Panel();
this.bottomrightcorner = new System.Windows.Forms.Panel(); this.bottomrightcorner = new System.Windows.Forms.Panel();
this.topleftcorner = new System.Windows.Forms.Panel(); this.topleftcorner = new System.Windows.Forms.Panel();
this.bottom = new System.Windows.Forms.Panel(); this.bottom = new System.Windows.Forms.Panel();
this.top = new System.Windows.Forms.Panel(); this.top = new System.Windows.Forms.Panel();
this.programIcon = new System.Windows.Forms.PictureBox(); this.programIcon = new System.Windows.Forms.PictureBox();
this.maximizebutton = new System.Windows.Forms.PictureBox(); this.maximizebutton = new System.Windows.Forms.PictureBox();
this.minimizebutton = new System.Windows.Forms.PictureBox(); this.minimizebutton = new System.Windows.Forms.PictureBox();
this.Title = new System.Windows.Forms.Label(); this.Title = new System.Windows.Forms.Label();
this.closebutton = new System.Windows.Forms.PictureBox(); this.closebutton = new System.Windows.Forms.PictureBox();
this.right = new System.Windows.Forms.Panel(); this.right = new System.Windows.Forms.Panel();
this.left = new System.Windows.Forms.Panel(); this.left = new System.Windows.Forms.Panel();
this.program.SuspendLayout(); this.program.SuspendLayout();
this.top.SuspendLayout(); this.top.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.programIcon)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.programIcon)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.closebutton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.closebutton)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// program // program
// //
this.program.BackColor = System.Drawing.Color.White; this.program.BackColor = System.Drawing.Color.White;
this.program.Controls.Add(this.programContent); this.program.Controls.Add(this.programContent);
this.program.Controls.Add(this.bottomleftcorner); this.program.Controls.Add(this.bottomleftcorner);
this.program.Controls.Add(this.toprightcorner); this.program.Controls.Add(this.toprightcorner);
this.program.Controls.Add(this.bottomrightcorner); this.program.Controls.Add(this.bottomrightcorner);
this.program.Controls.Add(this.topleftcorner); this.program.Controls.Add(this.topleftcorner);
this.program.Controls.Add(this.bottom); this.program.Controls.Add(this.bottom);
this.program.Controls.Add(this.top); this.program.Controls.Add(this.top);
this.program.Controls.Add(this.right); this.program.Controls.Add(this.right);
this.program.Controls.Add(this.left); this.program.Controls.Add(this.left);
this.program.Dock = System.Windows.Forms.DockStyle.Fill; this.program.Dock = System.Windows.Forms.DockStyle.Fill;
this.program.Location = new System.Drawing.Point(0, 0); this.program.Location = new System.Drawing.Point(0, 0);
this.program.Name = "program"; this.program.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.program.Size = new System.Drawing.Size(284, 261); this.program.Name = "program";
this.program.TabIndex = 11; this.program.Size = new System.Drawing.Size(426, 402);
// this.program.TabIndex = 11;
// programContent //
// // programContent
this.programContent.Dock = System.Windows.Forms.DockStyle.Fill; //
this.programContent.Location = new System.Drawing.Point(4, 30); this.programContent.Dock = System.Windows.Forms.DockStyle.Fill;
this.programContent.Name = "programContent"; this.programContent.Location = new System.Drawing.Point(6, 46);
this.programContent.Size = new System.Drawing.Size(276, 227); this.programContent.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.programContent.TabIndex = 11; this.programContent.Name = "programContent";
// this.programContent.Size = new System.Drawing.Size(414, 350);
// bottomleftcorner this.programContent.TabIndex = 11;
// //
this.bottomleftcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); // bottomleftcorner
this.bottomleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); //
this.bottomleftcorner.Location = new System.Drawing.Point(0, 257); this.bottomleftcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bottomleftcorner.Name = "bottomleftcorner"; this.bottomleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.bottomleftcorner.Size = new System.Drawing.Size(5, 4); this.bottomleftcorner.Location = new System.Drawing.Point(0, 395);
this.bottomleftcorner.TabIndex = 10; this.bottomleftcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.bottomleftcorner.Name = "bottomleftcorner";
// toprightcorner this.bottomleftcorner.Size = new System.Drawing.Size(8, 6);
// this.bottomleftcorner.TabIndex = 10;
this.toprightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); //
this.toprightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); // toprightcorner
this.toprightcorner.Location = new System.Drawing.Point(278, 0); //
this.toprightcorner.Name = "toprightcorner"; this.toprightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.toprightcorner.Size = new System.Drawing.Size(6, 30); this.toprightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.toprightcorner.TabIndex = 9; this.toprightcorner.Location = new System.Drawing.Point(417, 0);
// this.toprightcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// bottomrightcorner this.toprightcorner.Name = "toprightcorner";
// this.toprightcorner.Size = new System.Drawing.Size(9, 46);
this.bottomrightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.toprightcorner.TabIndex = 9;
this.bottomrightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); //
this.bottomrightcorner.Cursor = System.Windows.Forms.Cursors.SizeNWSE; // bottomrightcorner
this.bottomrightcorner.Location = new System.Drawing.Point(280, 257); //
this.bottomrightcorner.Name = "bottomrightcorner"; this.bottomrightcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bottomrightcorner.Size = new System.Drawing.Size(4, 4); this.bottomrightcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.bottomrightcorner.TabIndex = 4; this.bottomrightcorner.Cursor = System.Windows.Forms.Cursors.SizeNWSE;
// this.bottomrightcorner.Location = new System.Drawing.Point(420, 395);
// topleftcorner this.bottomrightcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.bottomrightcorner.Name = "bottomrightcorner";
this.topleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.bottomrightcorner.Size = new System.Drawing.Size(6, 6);
this.topleftcorner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.bottomrightcorner.TabIndex = 4;
this.topleftcorner.Location = new System.Drawing.Point(0, 0); //
this.topleftcorner.Name = "topleftcorner"; // topleftcorner
this.topleftcorner.Size = new System.Drawing.Size(7, 30); //
this.topleftcorner.TabIndex = 8; this.topleftcorner.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
// this.topleftcorner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
// bottom this.topleftcorner.Location = new System.Drawing.Point(0, 0);
// this.topleftcorner.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.bottom.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.topleftcorner.Name = "topleftcorner";
this.bottom.Cursor = System.Windows.Forms.Cursors.SizeNS; this.topleftcorner.Size = new System.Drawing.Size(10, 46);
this.bottom.Dock = System.Windows.Forms.DockStyle.Bottom; this.topleftcorner.TabIndex = 8;
this.bottom.Location = new System.Drawing.Point(4, 257); //
this.bottom.Name = "bottom"; // bottom
this.bottom.Size = new System.Drawing.Size(276, 4); //
this.bottom.TabIndex = 3; this.bottom.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
// this.bottom.Cursor = System.Windows.Forms.Cursors.SizeNS;
// top this.bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
// this.bottom.Location = new System.Drawing.Point(6, 396);
this.top.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.bottom.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.top.Controls.Add(this.programIcon); this.bottom.Name = "bottom";
this.top.Controls.Add(this.maximizebutton); this.bottom.Size = new System.Drawing.Size(414, 6);
this.top.Controls.Add(this.minimizebutton); this.bottom.TabIndex = 3;
this.top.Controls.Add(this.Title); //
this.top.Controls.Add(this.closebutton); // top
this.top.Dock = System.Windows.Forms.DockStyle.Top; //
this.top.ForeColor = System.Drawing.SystemColors.ControlText; this.top.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.top.Location = new System.Drawing.Point(4, 0); this.top.Controls.Add(this.programIcon);
this.top.Name = "top"; this.top.Controls.Add(this.maximizebutton);
this.top.Size = new System.Drawing.Size(276, 30); this.top.Controls.Add(this.minimizebutton);
this.top.TabIndex = 0; this.top.Controls.Add(this.Title);
this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag); this.top.Controls.Add(this.closebutton);
// this.top.Dock = System.Windows.Forms.DockStyle.Top;
// programIcon this.top.ForeColor = System.Drawing.SystemColors.ControlText;
// this.top.Location = new System.Drawing.Point(6, 0);
this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.top.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.programIcon.ErrorImage = null; this.top.Name = "top";
this.programIcon.InitialImage = null; this.top.Size = new System.Drawing.Size(414, 46);
this.programIcon.Location = new System.Drawing.Point(6, 7); this.top.TabIndex = 0;
this.programIcon.Name = "programIcon"; this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag);
this.programIcon.Size = new System.Drawing.Size(16, 16); //
this.programIcon.TabIndex = 7; // programIcon
this.programIcon.TabStop = false; //
// this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
// maximizebutton this.programIcon.ErrorImage = null;
// this.programIcon.InitialImage = null;
this.maximizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right; this.programIcon.Location = new System.Drawing.Point(9, 11);
this.maximizebutton.BackColor = System.Drawing.Color.Black; this.programIcon.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.maximizebutton.Location = new System.Drawing.Point(230, 4); this.programIcon.Name = "programIcon";
this.maximizebutton.Name = "maximizebutton"; this.programIcon.Size = new System.Drawing.Size(24, 25);
this.maximizebutton.Size = new System.Drawing.Size(21, 21); this.programIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.maximizebutton.TabIndex = 6; this.programIcon.TabIndex = 7;
this.maximizebutton.TabStop = false; this.programIcon.TabStop = false;
this.maximizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseDown); //
this.maximizebutton.MouseEnter += new System.EventHandler(this.maximizebutton_MouseEnter); // maximizebutton
this.maximizebutton.MouseLeave += new System.EventHandler(this.maximizebutton_MouseLeave); //
this.maximizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseUp); this.maximizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
// this.maximizebutton.BackColor = System.Drawing.Color.Black;
// minimizebutton this.maximizebutton.Location = new System.Drawing.Point(345, 6);
// this.maximizebutton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.minimizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right; this.maximizebutton.Name = "maximizebutton";
this.minimizebutton.BackColor = System.Drawing.Color.Black; this.maximizebutton.Size = new System.Drawing.Size(32, 32);
this.minimizebutton.Location = new System.Drawing.Point(207, 4); this.maximizebutton.TabIndex = 6;
this.minimizebutton.Name = "minimizebutton"; this.maximizebutton.TabStop = false;
this.minimizebutton.Size = new System.Drawing.Size(21, 21); this.maximizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseDown);
this.minimizebutton.TabIndex = 5; this.maximizebutton.MouseEnter += new System.EventHandler(this.maximizebutton_MouseEnter);
this.minimizebutton.TabStop = false; this.maximizebutton.MouseLeave += new System.EventHandler(this.maximizebutton_MouseLeave);
this.minimizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseDown); this.maximizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.maximizebutton_MouseUp);
this.minimizebutton.MouseEnter += new System.EventHandler(this.minimizebutton_MouseEnter); //
this.minimizebutton.MouseLeave += new System.EventHandler(this.minimizebutton_MouseLeave); // minimizebutton
this.minimizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseUp); //
// this.minimizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
// Title this.minimizebutton.BackColor = System.Drawing.Color.Black;
// this.minimizebutton.Location = new System.Drawing.Point(310, 6);
this.Title.AutoSize = true; this.minimizebutton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Title.BackColor = System.Drawing.Color.Transparent; this.minimizebutton.Name = "minimizebutton";
this.Title.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.minimizebutton.Size = new System.Drawing.Size(32, 32);
this.Title.ForeColor = System.Drawing.Color.White; this.minimizebutton.TabIndex = 5;
this.Title.Location = new System.Drawing.Point(25, 8); this.minimizebutton.TabStop = false;
this.Title.Name = "Title"; this.minimizebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseDown);
this.Title.Size = new System.Drawing.Size(98, 13); this.minimizebutton.MouseEnter += new System.EventHandler(this.minimizebutton_MouseEnter);
this.Title.TabIndex = 3; this.minimizebutton.MouseLeave += new System.EventHandler(this.minimizebutton_MouseLeave);
this.Title.Text = "Application Title"; this.minimizebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.minimizebutton_MouseUp);
this.Title.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag); //
// // Title
// closebutton //
// this.Title.AutoSize = true;
this.closebutton.Anchor = System.Windows.Forms.AnchorStyles.Right; this.Title.BackColor = System.Drawing.Color.Transparent;
this.closebutton.BackColor = System.Drawing.Color.Black; this.Title.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.closebutton.Location = new System.Drawing.Point(253, 4); this.Title.ForeColor = System.Drawing.Color.White;
this.closebutton.Name = "closebutton"; this.Title.Location = new System.Drawing.Point(38, 12);
this.closebutton.Size = new System.Drawing.Size(21, 21); this.Title.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.closebutton.TabIndex = 4; this.Title.Name = "Title";
this.closebutton.TabStop = false; this.Title.Size = new System.Drawing.Size(149, 21);
this.closebutton.Click += new System.EventHandler(this.closebutton_Click); this.Title.TabIndex = 3;
this.closebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseDown); this.Title.Text = "Application Title";
this.closebutton.MouseEnter += new System.EventHandler(this.closebutton_MouseEnter); this.Title.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Programtopbar_drag);
this.closebutton.MouseLeave += new System.EventHandler(this.closebutton_MouseLeave); //
this.closebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseUp); // closebutton
// //
// right this.closebutton.Anchor = System.Windows.Forms.AnchorStyles.Right;
// this.closebutton.BackColor = System.Drawing.Color.Black;
this.right.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.closebutton.Location = new System.Drawing.Point(380, 6);
this.right.Cursor = System.Windows.Forms.Cursors.SizeWE; this.closebutton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.right.Dock = System.Windows.Forms.DockStyle.Right; this.closebutton.Name = "closebutton";
this.right.Location = new System.Drawing.Point(280, 0); this.closebutton.Size = new System.Drawing.Size(32, 32);
this.right.Name = "right"; this.closebutton.TabIndex = 4;
this.right.Size = new System.Drawing.Size(4, 261); this.closebutton.TabStop = false;
this.right.TabIndex = 2; this.closebutton.Click += new System.EventHandler(this.closebutton_Click);
// this.closebutton.MouseDown += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseDown);
// left this.closebutton.MouseEnter += new System.EventHandler(this.closebutton_MouseEnter);
// this.closebutton.MouseLeave += new System.EventHandler(this.closebutton_MouseLeave);
this.left.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.closebutton.MouseUp += new System.Windows.Forms.MouseEventHandler(this.closebutton_MouseUp);
this.left.Dock = System.Windows.Forms.DockStyle.Left; //
this.left.Location = new System.Drawing.Point(0, 0); // right
this.left.Name = "left"; //
this.left.Size = new System.Drawing.Size(4, 261); this.right.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.left.TabIndex = 1; this.right.Cursor = System.Windows.Forms.Cursors.SizeWE;
// this.right.Dock = System.Windows.Forms.DockStyle.Right;
// ShiftWindow this.right.Location = new System.Drawing.Point(420, 0);
// this.right.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.right.Name = "right";
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.right.Size = new System.Drawing.Size(6, 402);
this.ClientSize = new System.Drawing.Size(284, 261); this.right.TabIndex = 2;
this.Controls.Add(this.program); //
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // left
this.Name = "ShiftWindow"; //
this.program.ResumeLayout(false); this.left.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.top.ResumeLayout(false); this.left.Dock = System.Windows.Forms.DockStyle.Left;
this.top.PerformLayout(); this.left.Location = new System.Drawing.Point(0, 0);
((System.ComponentModel.ISupportInitialize)(this.programIcon)).EndInit(); this.left.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).EndInit(); this.left.Name = "left";
((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).EndInit(); this.left.Size = new System.Drawing.Size(6, 402);
((System.ComponentModel.ISupportInitialize)(this.closebutton)).EndInit(); this.left.TabIndex = 1;
this.ResumeLayout(false); //
// ShiftWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(426, 402);
this.Controls.Add(this.program);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "ShiftWindow";
this.Text = "c";
this.program.ResumeLayout(false);
this.top.ResumeLayout(false);
this.top.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.programIcon)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.closebutton)).EndInit();
this.ResumeLayout(false);
} }

View file

@ -1,11 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -13,91 +8,86 @@ namespace ShiftOS.Engine.WindowManager
{ {
public partial class ShiftWindow : Form public partial class ShiftWindow : Form
{ {
public ShiftWindow() public uint Id { get; private set; }
public UserControl ChildControl { get; set; }
public ShiftWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2; public uint SetId()
{
do
{
Id = (uint)Tools.Rnd.Next(100000, 999999);
}
while (ShiftWM.Windows.FirstOrDefault(w => w.Id == Id) != null);
return Id;
}
private const int WM_NCLBUTTONDOWN = 0xA1;
private const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")] [DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, private static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam); int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")] [DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture(); private static extern bool ReleaseCapture();
private void Programtopbar_drag(object sender, MouseEventArgs e) private void Programtopbar_drag(object sender, MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Left) if (e.Button != MouseButtons.Left) return;
{
ReleaseCapture(); ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
} }
private void closebutton_Click(object sender, EventArgs e) private void closebutton_Click(object sender, EventArgs e)
{ => this.Close();
this.Close();
}
private void closebutton_MouseEnter(object sender, EventArgs e) private void closebutton_MouseEnter(object sender, EventArgs e)
{ => closebutton.BackColor = Color.Gray;
closebutton.BackColor = Color.Gray;
}
private void closebutton_MouseLeave(object sender, EventArgs e) private void closebutton_MouseLeave(object sender, EventArgs e)
{ => closebutton.BackColor = Color.Black;
closebutton.BackColor = Color.Black;
}
private void maximizebutton_MouseEnter(object sender, EventArgs e) private void maximizebutton_MouseEnter(object sender, EventArgs e)
{ => maximizebutton.BackColor = Color.Gray;
maximizebutton.BackColor = Color.Gray;
}
private void maximizebutton_MouseLeave(object sender, EventArgs e) private void maximizebutton_MouseLeave(object sender, EventArgs e)
{ => maximizebutton.BackColor = Color.Black;
maximizebutton.BackColor = Color.Black;
}
private void minimizebutton_MouseEnter(object sender, EventArgs e) private void minimizebutton_MouseEnter(object sender, EventArgs e)
{ => minimizebutton.BackColor = Color.Gray;
minimizebutton.BackColor = Color.Gray;
}
private void minimizebutton_MouseLeave(object sender, EventArgs e) private void minimizebutton_MouseLeave(object sender, EventArgs e)
{ => minimizebutton.BackColor = Color.Black;
minimizebutton.BackColor = Color.Black;
}
private void closebutton_MouseDown(object sender, MouseEventArgs e) private void closebutton_MouseDown(object sender, MouseEventArgs e)
{ => closebutton.BackColor = Color.Black;
closebutton.BackColor = Color.Black;
}
private void maximizebutton_MouseDown(object sender, MouseEventArgs e) private void maximizebutton_MouseDown(object sender, MouseEventArgs e)
{ => maximizebutton.BackColor = Color.Black;
maximizebutton.BackColor = Color.Black;
}
private void minimizebutton_MouseDown(object sender, MouseEventArgs e) private void minimizebutton_MouseDown(object sender, MouseEventArgs e)
{ => minimizebutton.BackColor = Color.Black;
minimizebutton.BackColor = Color.Black;
}
private void minimizebutton_MouseUp(object sender, MouseEventArgs e) private void minimizebutton_MouseUp(object sender, MouseEventArgs e)
{ => minimizebutton.BackColor = Color.Gray;
minimizebutton.BackColor = Color.Gray;
}
private void maximizebutton_MouseUp(object sender, MouseEventArgs e) private void maximizebutton_MouseUp(object sender, MouseEventArgs e)
{ => maximizebutton.BackColor = Color.Gray;
maximizebutton.BackColor = Color.Gray;
}
private void closebutton_MouseUp(object sender, MouseEventArgs e) private void closebutton_MouseUp(object sender, MouseEventArgs e)
{ => closebutton.BackColor = Color.Gray;
closebutton.BackColor = Color.Gray; }
}
} public interface IShiftWindowExtensions
{
void OnLoaded(ShiftWindow window);
}
} }

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Magick.NET-Q16-AnyCPU" version="7.0.7.300" targetFramework="net45" />
</packages>

View file

@ -1,8 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ShiftOS.Main.ShiftOS;
namespace ShiftOS.Main namespace ShiftOS.Main
{ {
@ -16,7 +15,10 @@ namespace ShiftOS.Main
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TestForm());
Parallel.Invoke(
() => Application.Run(new TestForm()),
() => Application.Run(new Desktop()));
} }
} }
} }

View file

@ -76,6 +76,12 @@
<Compile Include="ShiftOS\Apps\TestForm.Designer.cs"> <Compile Include="ShiftOS\Apps\TestForm.Designer.cs">
<DependentUpon>TestForm.cs</DependentUpon> <DependentUpon>TestForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="ShiftOS\Desktop.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ShiftOS\Desktop.Designer.cs">
<DependentUpon>Desktop.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="HijackScreen.resx"> <EmbeddedResource Include="HijackScreen.resx">
<DependentUpon>HijackScreen.cs</DependentUpon> <DependentUpon>HijackScreen.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@ -101,6 +107,9 @@
<EmbeddedResource Include="ShiftOS\Apps\TestForm.resx"> <EmbeddedResource Include="ShiftOS\Apps\TestForm.resx">
<DependentUpon>TestForm.cs</DependentUpon> <DependentUpon>TestForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="ShiftOS\Desktop.resx">
<DependentUpon>Desktop.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View file

@ -28,32 +28,47 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.icon = new System.Windows.Forms.PictureBox();
// ((System.ComponentModel.ISupportInitialize)(this.icon)).BeginInit();
// label1 this.SuspendLayout();
// //
this.label1.AutoSize = true; // label1
this.label1.Location = new System.Drawing.Point(18, 16); //
this.label1.Name = "label1"; this.label1.AutoSize = true;
this.label1.Size = new System.Drawing.Size(35, 13); this.label1.Location = new System.Drawing.Point(27, 25);
this.label1.TabIndex = 0; this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Text = "label1"; this.label1.Name = "label1";
// this.label1.Size = new System.Drawing.Size(51, 20);
// ShiftDemo this.label1.TabIndex = 0;
// this.label1.Text = "label1";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; // icon
this.Controls.Add(this.label1); //
this.Name = "ShiftDemo"; this.icon.Location = new System.Drawing.Point(31, 61);
this.Size = new System.Drawing.Size(300, 300); this.icon.Name = "icon";
this.ResumeLayout(false); this.icon.Size = new System.Drawing.Size(300, 300);
this.PerformLayout(); this.icon.TabIndex = 1;
this.icon.TabStop = false;
//
// ShiftDemo
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.icon);
this.Controls.Add(this.label1);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "ShiftDemo";
this.Size = new System.Drawing.Size(450, 462);
((System.ComponentModel.ISupportInitialize)(this.icon)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
public System.Windows.Forms.Label label1; public System.Windows.Forms.Label label1;
} private System.Windows.Forms.PictureBox icon;
}
} }

View file

@ -7,14 +7,20 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ShiftOS.Engine.WindowManager;
namespace ShiftOS.Main namespace ShiftOS.Main
{ {
public partial class ShiftDemo : UserControl public partial class ShiftDemo : UserControl, IShiftWindowExtensions
{ {
public ShiftDemo() public ShiftDemo()
{ {
InitializeComponent(); InitializeComponent();
} }
}
public void OnLoaded(ShiftWindow window)
{
icon.Image = this.GetShiftWindow().Icon.ToBitmap();
}
}
} }

View file

@ -1,11 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ShiftOS.Engine.WindowManager; using ShiftOS.Engine.WindowManager;
@ -13,11 +7,10 @@ namespace ShiftOS.Main.ShiftOS.Apps
{ {
public partial class SelectColor : UserControl public partial class SelectColor : UserControl
{ {
ShiftWM shiftWM = new ShiftWM(); Color _finalColor;
Color finalColor; int _colorType1;
int colorType1; int _colorType2;
int colorType2; int _colorType3;
int colorType3;
public SelectColor() public SelectColor()
{ {
InitializeComponent(); InitializeComponent();
@ -28,31 +21,31 @@ namespace ShiftOS.Main.ShiftOS.Apps
{ {
try try
{ {
colorType1 = Convert.ToInt32(textBox1.Text); _colorType1 = Convert.ToInt32(textBox1.Text);
colorType2 = Convert.ToInt32(textBox2.Text); _colorType2 = Convert.ToInt32(textBox2.Text);
colorType3 = Convert.ToInt32(textBox3.Text); _colorType3 = Convert.ToInt32(textBox3.Text);
} }
catch(Exception ex) catch(FormatException ex)
{ {
shiftWM.StartInfoboxSession("Error!", "Failed to parse integer. Error:\n" + ex, InfoboxTemplate.buttonType.OK); ShiftWM.StartInfoboxSession("Error!", "Failed to parse integer. Error:\n" + ex, InfoboxTemplate.ButtonType.Ok);
} }
if (colorType1 > 255 || colorType2 > 255 || colorType3 > 255) if (_colorType1 > 255 || _colorType2 > 255 || _colorType3 > 255)
{ {
shiftWM.StartInfoboxSession("Error!", "A value cannot be greater than 255!", InfoboxTemplate.buttonType.OK); ShiftWM.StartInfoboxSession("Error!", "A value cannot be greater than 255!", InfoboxTemplate.ButtonType.Ok);
} }
else else
{ {
try try
{ {
ShiftWindow sw = new ShiftWindow(); ShiftWindow sw = new ShiftWindow();
finalColor = Color.FromArgb(colorType1, colorType2, colorType3); _finalColor = Color.FromArgb(_colorType1, _colorType2, _colorType3);
this.BackColor = finalColor; BackColor = _finalColor;
shiftWM.StartInfoboxSession("Success!", "Changed color to:\n" + colorType1.ToString() + ", " + colorType2.ToString() + ", " + colorType3.ToString() + ".", InfoboxTemplate.buttonType.OK); ShiftWM.StartInfoboxSession("Success!", "Changed color to:\n" + _colorType1.ToString() + ", " + _colorType2.ToString() + ", " + _colorType3.ToString() + ".", InfoboxTemplate.ButtonType.Ok);
} }
catch (Exception ex) catch (Exception)
{ {
shiftWM.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.buttonType.OK); ShiftWM.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.ButtonType.Ok);
} }
} }
} }

View file

@ -1,12 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ShiftOS.Engine;
using ShiftOS.Engine.WindowManager; using ShiftOS.Engine.WindowManager;
namespace ShiftOS.Main.ShiftOS.Apps namespace ShiftOS.Main.ShiftOS.Apps
@ -14,7 +8,6 @@ namespace ShiftOS.Main.ShiftOS.Apps
public partial class Shifter : UserControl public partial class Shifter : UserControl
{ {
public int colorType; //This is a check to see what option was chosen. public int colorType; //This is a check to see what option was chosen.
ShiftWM wm = new ShiftWM();
public Shifter() public Shifter()
{ {
InitializeComponent(); InitializeComponent();
@ -23,7 +16,7 @@ namespace ShiftOS.Main.ShiftOS.Apps
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
colorType = 1; colorType = 1;
wm.Init(new SelectColor(), "Select a color", Properties.Resources.iconColourPicker_fw); ShiftWM.Init(new SelectColor(), "Select a color", Properties.Resources.iconColourPicker_fw.ToIcon());
} }
} }
} }

View file

@ -28,61 +28,95 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.textBox1 = new System.Windows.Forms.TextBox(); this.components = new System.ComponentModel.Container();
this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button(); this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout(); this.button2 = new System.Windows.Forms.Button();
// this.comboBox1 = new System.Windows.Forms.ComboBox();
// textBox1 this.systemIconsBindingSource = new System.Windows.Forms.BindingSource(this.components);
// ((System.ComponentModel.ISupportInitialize)(this.systemIconsBindingSource)).BeginInit();
this.textBox1.Location = new System.Drawing.Point(12, 13); this.SuspendLayout();
this.textBox1.Name = "textBox1"; //
this.textBox1.Size = new System.Drawing.Size(260, 20); // textBox1
this.textBox1.TabIndex = 0; //
this.textBox1.Text = "Title"; this.textBox1.Location = new System.Drawing.Point(18, 20);
// this.textBox1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// textBox2 this.textBox1.Name = "textBox1";
// this.textBox1.Size = new System.Drawing.Size(388, 26);
this.textBox2.Location = new System.Drawing.Point(12, 39); this.textBox1.TabIndex = 0;
this.textBox2.Name = "textBox2"; this.textBox1.Text = "Title";
this.textBox2.Size = new System.Drawing.Size(260, 20); //
this.textBox2.TabIndex = 1; // textBox2
this.textBox2.Text = "Contents"; //
// this.textBox2.Location = new System.Drawing.Point(18, 60);
// button1 this.textBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.textBox2.Name = "textBox2";
this.button1.Location = new System.Drawing.Point(12, 65); this.textBox2.Size = new System.Drawing.Size(388, 26);
this.button1.Name = "button1"; this.textBox2.TabIndex = 1;
this.button1.Size = new System.Drawing.Size(128, 23); this.textBox2.Text = "Contents";
this.button1.TabIndex = 2; //
this.button1.Text = "Create Window"; // button1
this.button1.UseVisualStyleBackColor = true; //
this.button1.Click += new System.EventHandler(this.Button1_Click); this.button1.Location = new System.Drawing.Point(13, 149);
// this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// button2 this.button1.Name = "button1";
// this.button1.Size = new System.Drawing.Size(192, 35);
this.button2.Location = new System.Drawing.Point(146, 65); this.button1.TabIndex = 2;
this.button2.Name = "button2"; this.button1.Text = "Create Window";
this.button2.Size = new System.Drawing.Size(126, 23); this.button1.UseVisualStyleBackColor = true;
this.button2.TabIndex = 4; this.button1.Click += new System.EventHandler(this.Button1_Click);
this.button2.Text = "Test Shifter"; //
this.button2.UseVisualStyleBackColor = true; // button2
this.button2.Click += new System.EventHandler(this.button2_Click); //
// this.button2.Location = new System.Drawing.Point(217, 149);
// TestForm this.button2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
// this.button2.Name = "button2";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.button2.Size = new System.Drawing.Size(189, 35);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.button2.TabIndex = 4;
this.ClientSize = new System.Drawing.Size(284, 100); this.button2.Text = "Test Shifter";
this.Controls.Add(this.button2); this.button2.UseVisualStyleBackColor = true;
this.Controls.Add(this.button1); this.button2.Click += new System.EventHandler(this.button2_Click);
this.Controls.Add(this.textBox2); //
this.Controls.Add(this.textBox1); // comboBox1
this.Name = "TestForm"; //
this.Text = "TestForm"; this.comboBox1.FormattingEnabled = true;
this.ResumeLayout(false); this.comboBox1.Items.AddRange(new object[] {
this.PerformLayout(); "Application",
"Asterisk",
"Error",
"Exclamation",
"Hand",
"Information",
"Question",
"Shield",
"Warning",
"WinLogo"});
this.comboBox1.Location = new System.Drawing.Point(18, 104);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(388, 28);
this.comboBox1.TabIndex = 5;
//
// systemIconsBindingSource
//
this.systemIconsBindingSource.DataSource = typeof(System.Drawing.SystemIcons);
//
// TestForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(426, 198);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "TestForm";
this.Text = "TestForm";
((System.ComponentModel.ISupportInitialize)(this.systemIconsBindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
} }
@ -92,5 +126,7 @@
private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
} private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.BindingSource systemIconsBindingSource;
}
} }

View file

@ -1,5 +1,8 @@
using System; using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using ShiftOS.Engine;
using ShiftOS.Engine.WindowManager; using ShiftOS.Engine.WindowManager;
using ShiftOS.Main.ShiftOS.Apps; using ShiftOS.Main.ShiftOS.Apps;
@ -7,8 +10,6 @@ namespace ShiftOS.Main
{ {
public partial class TestForm : Form public partial class TestForm : Form
{ {
public ShiftWM shiftWM = new ShiftWM();
public TestForm() public TestForm()
{ {
InitializeComponent(); InitializeComponent();
@ -16,14 +17,16 @@ namespace ShiftOS.Main
private void Button1_Click(object sender, EventArgs e) private void Button1_Click(object sender, EventArgs e)
{ {
ShiftDemo demo = new ShiftDemo(); ShiftDemo demo = new ShiftDemo {label1 = {Text = textBox2.Text}};
demo.label1.Text = textBox2.Text;
shiftWM.Init(demo, textBox1.Text, null); var item = typeof(SystemIcons).GetProperties()
shiftWM.StartInfoboxSession(textBox1.Text, textBox2.Text, InfoboxTemplate.buttonType.OK); .First(p => p.Name == comboBox1.SelectedItem as string);
ShiftWM.Init(demo, textBox1.Text, (item.GetMethod.Invoke(null, new object[0]) as Icon));
ShiftWM.StartInfoboxSession(textBox1.Text, textBox2.Text, InfoboxTemplate.ButtonType.Ok);
} }
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ => ShiftWM.Init(new Shifter(), "Shifter", Properties.Resources.iconShifter.ToIcon());
shiftWM.Init(new Shifter(), "Shifter", Properties.Resources.iconShifter); }
} }
} }

View file

@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="systemIconsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>

111
ShiftOS.Main/ShiftOS/Desktop.Designer.cs generated Normal file
View file

@ -0,0 +1,111 @@
namespace ShiftOS.Main.ShiftOS
{
partial class Desktop
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.listView1 = new System.Windows.Forms.ListView();
this.taskbar = new System.Windows.Forms.ToolStrip();
this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton();
this.taskbarClock = new System.Windows.Forms.ToolStripLabel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.taskbar.SuspendLayout();
this.SuspendLayout();
//
// listView1
//
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(1962, 1236);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// taskbar
//
this.taskbar.Dock = System.Windows.Forms.DockStyle.Bottom;
this.taskbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.taskbar.ImageScalingSize = new System.Drawing.Size(24, 24);
this.taskbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripDropDownButton1,
this.taskbarClock});
this.taskbar.Location = new System.Drawing.Point(0, 1204);
this.taskbar.Name = "taskbar";
this.taskbar.Size = new System.Drawing.Size(1962, 32);
this.taskbar.TabIndex = 1;
this.taskbar.Text = "toolStrip1";
//
// toolStripDropDownButton1
//
this.toolStripDropDownButton1.Image = global::ShiftOS.Main.Properties.Resources.iconWebBrowser;
this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripDropDownButton1.Name = "toolStripDropDownButton1";
this.toolStripDropDownButton1.Size = new System.Drawing.Size(131, 29);
this.toolStripDropDownButton1.Tag = ((uint)(0u));
this.toolStripDropDownButton1.Text = "Programs";
//
// taskbarClock
//
this.taskbarClock.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.taskbarClock.Image = global::ShiftOS.Main.Properties.Resources.iconClock;
this.taskbarClock.Name = "taskbarClock";
this.taskbarClock.Size = new System.Drawing.Size(70, 29);
this.taskbarClock.Tag = ((uint)(0u));
this.taskbarClock.Text = "0:00";
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Desktop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1962, 1236);
this.Controls.Add(this.taskbar);
this.Controls.Add(this.listView1);
this.Name = "Desktop";
this.Text = "Desktop";
this.taskbar.ResumeLayout(false);
this.taskbar.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ToolStrip taskbar;
private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton1;
private System.Windows.Forms.ToolStripLabel taskbarClock;
private System.Windows.Forms.Timer timer1;
}
}

View file

@ -0,0 +1,61 @@
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.WindowManager;
namespace ShiftOS.Main.ShiftOS
{
public partial class Desktop : Form
{
public Desktop()
{
InitializeComponent();
timer1.Start();
this.Closed += (sender, args) =>
{
Application.Exit();
};
#region Disgusting taskbar code
ShiftWM.Windows.CollectionChanged += (sender, args) =>
{
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
});
}));
});
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));
}));
});
};
#endregion
}
private void timer1_Tick(object sender, EventArgs e) =>
taskbarClock.Text = $"{DateTime.Now:t}";
}
}

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="taskbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>159, 17</value>
</metadata>
</root>