Cleaning up design tab by removing layout debug buttons.
Separator changes now reflected instantly.
2 using System.Collections;
3 using System.Collections.Generic;
5 using System.Configuration;
7 using System.ComponentModel;
8 using System.Runtime.Serialization;
9 using System.Runtime.Serialization.Json;
13 namespace SharpDisplayManager
16 /// Display settings for the specified hardware type
19 public class DisplaySettings
21 public DisplaySettings()
26 ReverseScreen = false;
29 FontName = "Microsoft Sans Serif, 9.75pt";
33 ScrollingSpeedInPixelsPerSecond = 64;
37 public int Brightness { get; set; }
40 /// See Display.TMiniDisplayType
43 public int DisplayType { get; set; }
46 public int TimerInterval { get; set; }
49 public int ScrollingSpeedInPixelsPerSecond { get; set; }
52 public bool ReverseScreen { get; set; }
55 public bool InverseColors { get; set; }
58 public bool ShowBorders { get; set; }
61 public bool ScaleToFit { get; set; }
64 public float MinFontSize { get; set; }
67 public string Separator { get; set; }
70 public string FontName { get; set; }
76 FontConverter cvt = new FontConverter();
77 Font font = cvt.ConvertFromInvariantString(FontName) as Font;
83 FontConverter cvt = new FontConverter();
84 FontName = cvt.ConvertToInvariantString(value);
91 /// Contain settings for each of our display type.
93 [TypeConverter(typeof(DisplaySettingsConverter))]
95 public class DisplaysSettings
97 public DisplaysSettings()
104 if (Displays == null)
106 Displays = new List<DisplaySettings>();
111 //public int CurrentSettingsIndex { get; set; }
114 public List<DisplaySettings> Displays { get; set; }
116 public override string ToString()
118 //Save settings into JSON string
119 MemoryStream stream = new MemoryStream();
120 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
121 ser.WriteObject(stream, this);
122 // convert stream to string
124 StreamReader reader = new StreamReader(stream);
125 string text = reader.ReadToEnd();
130 public class DisplaySettingsConverter : TypeConverter
132 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
134 if (sourceType == typeof(string))
137 return base.CanConvertFrom(context, sourceType);
140 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
142 string stringValue = value as string;
143 if (stringValue != null)
145 //Load settings form JSON string
146 byte[] byteArray = Encoding.UTF8.GetBytes(stringValue);
147 MemoryStream stream = new MemoryStream(byteArray);
148 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
149 DisplaysSettings settings = (DisplaysSettings)ser.ReadObject(stream);
154 return base.ConvertFrom(context, culture, value);