Adding events for display closed/opened.
Display types now loaded dynamically from our MiniDisplay library.
Adding editor config.
Tested against Futaba GP1212A02.
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";
36 public int Brightness { get; set; }
39 /// See Display.TMiniDisplayType
42 public int DisplayType { get; set; }
45 public int TimerInterval { get; set; }
48 public bool ReverseScreen { get; set; }
51 public bool InverseColors { get; set; }
54 public bool ShowBorders { get; set; }
57 public bool ScaleToFit { get; set; }
60 public float MinFontSize { get; set; }
63 public string Separator { get; set; }
66 public string FontName { get; set; }
72 FontConverter cvt = new FontConverter();
73 Font font = cvt.ConvertFromInvariantString(FontName) as Font;
79 FontConverter cvt = new FontConverter();
80 FontName = cvt.ConvertToInvariantString(value);
87 /// Contain settings for each of our display type.
89 [TypeConverter(typeof(DisplaySettingsConverter))]
91 public class DisplaysSettings
93 public DisplaysSettings()
100 if (Displays == null)
102 Displays = new List<DisplaySettings>();
107 //public int CurrentSettingsIndex { get; set; }
110 public List<DisplaySettings> Displays { get; set; }
112 public override string ToString()
114 //Save settings into JSON string
115 MemoryStream stream = new MemoryStream();
116 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
117 ser.WriteObject(stream, this);
118 // convert stream to string
120 StreamReader reader = new StreamReader(stream);
121 string text = reader.ReadToEnd();
126 public class DisplaySettingsConverter : TypeConverter
128 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
130 if (sourceType == typeof(string))
133 return base.CanConvertFrom(context, sourceType);
136 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
138 string stringValue = value as string;
139 if (stringValue != null)
141 //Load settings form JSON string
142 byte[] byteArray = Encoding.UTF8.GetBytes(stringValue);
143 MemoryStream stream = new MemoryStream(byteArray);
144 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
145 DisplaysSettings settings = (DisplaysSettings)ser.ReadObject(stream);
150 return base.ConvertFrom(context, culture, value);