aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/WidgetManager.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-22 17:10:15 -0400
committerMichael <[email protected]>2017-04-22 17:10:15 -0400
commit40fc14a237f0bbe3e5237e5ce0806f46ecf0f56e (patch)
tree581143fe22e90708396a92afee52ac439a82eaba /ShiftOS.WinForms/WidgetManager.cs
parentc718fbb5654c77ae521f42fb9e42efb1a79992a9 (diff)
downloadshiftos_thereturn-40fc14a237f0bbe3e5237e5ce0806f46ecf0f56e.tar.gz
shiftos_thereturn-40fc14a237f0bbe3e5237e5ce0806f46ecf0f56e.tar.bz2
shiftos_thereturn-40fc14a237f0bbe3e5237e5ce0806f46ecf0f56e.zip
Add Widget Manager UI
You can now toggle visibility of widgets.
Diffstat (limited to 'ShiftOS.WinForms/WidgetManager.cs')
-rw-r--r--ShiftOS.WinForms/WidgetManager.cs35
1 files changed, 28 insertions, 7 deletions
diff --git a/ShiftOS.WinForms/WidgetManager.cs b/ShiftOS.WinForms/WidgetManager.cs
index 15e2076..fec09f9 100644
--- a/ShiftOS.WinForms/WidgetManager.cs
+++ b/ShiftOS.WinForms/WidgetManager.cs
@@ -48,13 +48,13 @@ namespace ShiftOS.WinForms
return types;
}
- internal static void SaveLocation(Type type, Point location)
+ internal static void SaveDetails(Type type, WidgetDetails location)
{
- var dict = new Dictionary<string, Point>();
+ var dict = new Dictionary<string, WidgetDetails>();
var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is DesktopWidgetAttribute) as DesktopWidgetAttribute;
try
{
- dict = JsonConvert.DeserializeObject<Dictionary<string, Point>>(Utils.ReadAllText(Paths.GetPath("widgets.dat")));
+ dict = JsonConvert.DeserializeObject<Dictionary<string, WidgetDetails>>(Utils.ReadAllText(Paths.GetPath("widgets.dat")));
dict[attrib.ToString()] = location;
}
@@ -69,20 +69,30 @@ namespace ShiftOS.WinForms
}
- internal static Point LoadLocation(Type type)
+ internal static WidgetDetails LoadDetails(Type type)
{
- var dict = new Dictionary<string, Point>();
+ var dict = new Dictionary<string, WidgetDetails>();
var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is DesktopWidgetAttribute) as DesktopWidgetAttribute;
try
{
- dict = JsonConvert.DeserializeObject<Dictionary<string, Point>>(Utils.ReadAllText(Paths.GetPath("widgets.dat")));
+ dict = JsonConvert.DeserializeObject<Dictionary<string, WidgetDetails>>(Utils.ReadAllText(Paths.GetPath("widgets.dat")));
return dict[attrib.ToString()];
}
catch
{
- return new Point(-1, -1);
+ var details = new WinForms.WidgetDetails
+ {
+ Location = new Point(-1, -1),
+ IsVisible = false
+ };
+ if (dict.ContainsKey(attrib.ToString()))
+ dict[attrib.ToString()] = details;
+ else
+ dict.Add(attrib.ToString(), details);
+ Utils.WriteAllText(Paths.GetPath("widgets.dat"), JsonConvert.SerializeObject(dict));
+ return details;
}
finally
{
@@ -90,4 +100,15 @@ namespace ShiftOS.WinForms
}
}
+
+ public class WidgetDetails
+ {
+ public WidgetDetails()
+ {
+ IsVisible = true;
+ }
+
+ public Point Location { get; set; }
+ public bool IsVisible { get; set; }
+ }
}