aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/WinformsDesktop.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-16 14:18:02 -0400
committerMichael <[email protected]>2017-04-16 14:18:02 -0400
commit5cb49f332856ac312e8840ec04c7869b892d4dd4 (patch)
tree30ffc6a06cefd0f964e86461407e79a933003204 /ShiftOS.WinForms/WinformsDesktop.cs
parent538f99faf7b381717079ea700d4f2e6e908537ea (diff)
downloadshiftos_thereturn-5cb49f332856ac312e8840ec04c7869b892d4dd4.tar.gz
shiftos_thereturn-5cb49f332856ac312e8840ec04c7869b892d4dd4.tar.bz2
shiftos_thereturn-5cb49f332856ac312e8840ec04c7869b892d4dd4.zip
Store widget locations in file
Diffstat (limited to 'ShiftOS.WinForms/WinformsDesktop.cs')
-rw-r--r--ShiftOS.WinForms/WinformsDesktop.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs
index 3050cdf..ee0f34d 100644
--- a/ShiftOS.WinForms/WinformsDesktop.cs
+++ b/ShiftOS.WinForms/WinformsDesktop.cs
@@ -452,7 +452,11 @@ namespace ShiftOS.WinForms
foreach(var widget in WidgetManager.GetAllWidgetTypes())
{
UserControl w = (UserControl)Activator.CreateInstance(widget.Value, null);
+
+ w.Location = WidgetManager.LoadLocation(w.GetType());
+
pnlwidgetlayer.Controls.Add(w);
+ MakeWidgetMovable(w);
Widgets.Add(w as IDesktopWidget);
}
}
@@ -481,6 +485,48 @@ namespace ShiftOS.WinForms
PopulatePanelButtons();
}
+ public void MakeWidgetMovable(Control w, Control startCtrl = null)
+ {
+ if (startCtrl == null)
+ startCtrl = w;
+
+ bool moving = false;
+
+ w.MouseDown += (o, a) =>
+ {
+ moving = true;
+ };
+
+ w.MouseMove += (o, a) =>
+ {
+ if (moving == true)
+ {
+ var mPos = Cursor.Position;
+ int mY = mPos.Y - desktoppanel.Height;
+ int mX = mPos.X;
+
+ int ctrlHeight = startCtrl.Height / 2;
+ int ctrlWidth = startCtrl.Width / 2;
+
+ startCtrl.Location = new Point(
+ mX - ctrlWidth,
+ mY - ctrlHeight
+ );
+
+ }
+ };
+
+ w.MouseUp += (o, a) =>
+ {
+ moving = false;
+ WidgetManager.SaveLocation(startCtrl.GetType(), w.Location);
+ };
+
+ foreach (Control c in w.Controls)
+ MakeWidgetMovable(c, startCtrl);
+
+ }
+
public ToolStripMenuItem GetALCategoryWithName(string text)
{
foreach (ToolStripMenuItem menuitem in apps.DropDownItems)