Adding indicators layout demo.
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 public int Brightness { get; set; }
36 /// See Display.TMiniDisplayType
39 public int DisplayType { get; set; }
42 public int TimerInterval { get; set; }
45 public bool ReverseScreen { get; set; }
48 public bool InverseColors { get; set; }
51 public bool ShowBorders { get; set; }
54 public string FontName { get; set; }
60 FontConverter cvt = new FontConverter();
61 Font font = cvt.ConvertFromInvariantString(FontName) as Font;
67 FontConverter cvt = new FontConverter();
68 FontName = cvt.ConvertToInvariantString(value);
75 /// Contain settings for each of our display type.
77 [TypeConverter(typeof(DisplaySettingsConverter))]
79 public class DisplaysSettings
81 public DisplaysSettings()
90 Displays = new List<DisplaySettings>();
95 //public int CurrentSettingsIndex { get; set; }
98 public List<DisplaySettings> Displays { get; set; }
100 public override string ToString()
102 //Save settings into JSON string
103 MemoryStream stream = new MemoryStream();
104 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
105 ser.WriteObject(stream, this);
106 // convert stream to string
108 StreamReader reader = new StreamReader(stream);
109 string text = reader.ReadToEnd();
114 public class DisplaySettingsConverter : TypeConverter
116 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
118 if (sourceType == typeof(string))
121 return base.CanConvertFrom(context, sourceType);
124 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
126 string stringValue = value as string;
127 if (stringValue != null)
129 //Load settings form JSON string
130 byte[] byteArray = Encoding.UTF8.GetBytes(stringValue);
131 MemoryStream stream = new MemoryStream(byteArray);
132 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
133 DisplaysSettings settings = (DisplaysSettings)ser.ReadObject(stream);
138 return base.ConvertFrom(context, culture, value);