Making App tab the last one again.
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 ShowVolumeLabel = false;
30 FontName = "Microsoft Sans Serif, 9.75pt";
34 ScrollingSpeedInPixelsPerSecond = 64;
39 public bool ShowVolumeLabel { get; set; }
42 public int Brightness { get; set; }
45 /// See Display.TMiniDisplayType
48 public int DisplayType { get; set; }
51 public int TimerInterval { get; set; }
54 public int ScrollingSpeedInPixelsPerSecond { get; set; }
57 public bool ReverseScreen { get; set; }
60 public bool InverseColors { get; set; }
63 public bool ShowBorders { get; set; }
66 public bool ScaleToFit { get; set; }
69 public float MinFontSize { get; set; }
72 public string Separator { get; set; }
75 public string FontName { get; set; }
81 FontConverter cvt = new FontConverter();
82 Font font = cvt.ConvertFromInvariantString(FontName) as Font;
88 FontConverter cvt = new FontConverter();
89 FontName = cvt.ConvertToInvariantString(value);
96 /// Contain settings for each of our display type.
98 [TypeConverter(typeof(DisplaySettingsConverter))]
100 public class DisplaysSettings
102 public DisplaysSettings()
109 if (Displays == null)
111 Displays = new List<DisplaySettings>();
116 //public int CurrentSettingsIndex { get; set; }
119 public List<DisplaySettings> Displays { get; set; }
121 public override string ToString()
123 //Save settings into JSON string
124 MemoryStream stream = new MemoryStream();
125 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
126 ser.WriteObject(stream, this);
127 // convert stream to string
129 StreamReader reader = new StreamReader(stream);
130 string text = reader.ReadToEnd();
135 public class DisplaySettingsConverter : TypeConverter
137 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
139 if (sourceType == typeof(string))
142 return base.CanConvertFrom(context, sourceType);
145 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
147 string stringValue = value as string;
148 if (stringValue != null)
150 //Load settings form JSON string
151 byte[] byteArray = Encoding.UTF8.GetBytes(stringValue);
152 MemoryStream stream = new MemoryStream(byteArray);
153 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
154 DisplaysSettings settings = (DisplaysSettings)ser.ReadObject(stream);
159 return base.ConvertFrom(context, culture, value);