public void TestItNow() { var originalProfile = new TimeProfile { Name = "Test time profile" }; var originalNode = new TimeNode(TimeSpan.FromHours(7)); originalNode.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20)); originalNode.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300)); originalProfile.Nodes.Add(originalNode); var str = TimeProfileSerializer.Serialize(originalProfile); Assert.IsNotNull(str); var deserializedProfile = TimeProfileSerializer.Deserialize(str) as TimeProfile; Assert.IsNotNull(deserializedProfile); Assert.AreEqual(originalProfile.Name, deserializedProfile.Name); Assert.AreEqual(originalProfile.Nodes.Count, deserializedProfile.Nodes.Count); var deserializedNode = deserializedProfile.Nodes[0]; Assert.AreEqual(originalNode.TimeOfDay, deserializedNode.TimeOfDay); var originalBrightnessProperty = originalNode.Properties.First(_ => _.Name == NodeProperty.Brightness); var deserializedBrightnessProperty = deserializedNode.Properties.First(_ => _.Name == NodeProperty.Brightness); Assert.AreEqual(originalBrightnessProperty.Name, deserializedBrightnessProperty.Name); Assert.AreEqual(originalBrightnessProperty.Value, deserializedBrightnessProperty.Value); var originalColorTemperatureProperty = originalNode.Properties.First(_ => _.Name == NodeProperty.Brightness); var deserializedColorTemperatureProperty = deserializedNode.Properties.First(_ => _.Name == NodeProperty.Brightness); Assert.AreEqual(originalColorTemperatureProperty.Name, deserializedColorTemperatureProperty.Name); Assert.AreEqual(originalColorTemperatureProperty.Value, deserializedColorTemperatureProperty.Value); }
private static TimeProfile CreateDefaultProfile() { var result = new TimeProfile(); var wakeUpTime = new TimeNode(TimeSpan.FromHours(7)); wakeUpTime.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20)); wakeUpTime.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300)); result.Nodes.Add(wakeUpTime); var morning = new TimeNode(TimeSpan.FromHours(8)); morning.Properties.Add(new NodeProperty(NodeProperty.Brightness, 80)); morning.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 6500)); result.Nodes.Add(morning); var srsModeOver = new TimeNode(TimeSpan.FromHours(17)); srsModeOver.Properties.Add(new NodeProperty(NodeProperty.Brightness, 80)); srsModeOver.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 6500)); result.Nodes.Add(srsModeOver); var afterDinner = new TimeNode(TimeSpan.FromHours(19)); afterDinner.Properties.Add(new NodeProperty(NodeProperty.Brightness, 40)); afterDinner.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 5000)); result.Nodes.Add(afterDinner); var bedTime = new TimeNode(TimeSpan.FromHours(22)); bedTime.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20)); bedTime.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300)); result.Nodes.Add(bedTime); return result; }
public static string Serialize(TimeProfile profile) { var sb = new StringBuilder(); var stream = new StringWriter(sb); Serializer.Serialize(stream, profile); return sb.ToString(); }
public MainForm(bool startHidden) { _forceHide = startHidden; Log.Debug("Loading Form1"); this.Load += OnLoad; this.Closing += OnClosing; Application.ApplicationExit += ApplicationExit; InitializeComponent(); _profile = LoadProfile(); _checkTimer = new Timer(TimerCallBack, null, 500, 10000); LoadTray(); }
public static TimeProfile Create() { Log.Info("Creating default time profile"); var result = new TimeProfile(); var wakeUpTime = new TimeNode(TimeSpan.FromHours(7)); wakeUpTime.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20)); wakeUpTime.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300)); result.AddNode(wakeUpTime); var morning = new TimeNode(TimeSpan.FromHours(8)); morning.Properties.Add(new NodeProperty(NodeProperty.Brightness, 80)); morning.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 6500)); result.AddNode(morning); var srsModeOver = new TimeNode(TimeSpan.FromHours(17)); srsModeOver.Properties.Add(new NodeProperty(NodeProperty.Brightness, 80)); srsModeOver.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 6500)); result.AddNode(srsModeOver); var afterDinner = new TimeNode(TimeSpan.FromHours(19)); afterDinner.Properties.Add(new NodeProperty(NodeProperty.Brightness, 40)); afterDinner.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 5000)); result.AddNode(afterDinner); var bedTime = new TimeNode(TimeSpan.FromHours(22)); bedTime.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20)); bedTime.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300)); result.AddNode(bedTime); return(result); }