Adding recording field value to client tree view.
2 // Copyright (C) 2014-2015 Stéphane Lenclud.
4 // This file is part of SharpDisplayManager.
6 // SharpDisplayManager is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // SharpDisplayManager is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with SharpDisplayManager. If not, see <http://www.gnu.org/licenses/>.
21 using System.Collections;
22 using System.Collections.Generic;
24 using System.Configuration;
26 using System.ComponentModel;
27 using System.Runtime.Serialization;
28 using System.Runtime.Serialization.Json;
32 namespace SharpDisplayManager
35 /// Display settings for the specified hardware type
38 public class DisplaySettings
40 public DisplaySettings()
45 ReverseScreen = false;
48 ShowVolumeLabel = false;
49 FontName = "Microsoft Sans Serif, 9.75pt";
53 ScrollingSpeedInPixelsPerSecond = 64;
58 public bool ShowVolumeLabel { get; set; }
61 public int Brightness { get; set; }
64 /// See Display.TMiniDisplayType
67 public int DisplayType { get; set; }
70 public int TimerInterval { get; set; }
73 public int ScrollingSpeedInPixelsPerSecond { get; set; }
76 public bool ReverseScreen { get; set; }
79 public bool InverseColors { get; set; }
82 public bool ShowBorders { get; set; }
85 public bool ScaleToFit { get; set; }
88 public float MinFontSize { get; set; }
91 public string Separator { get; set; }
94 public string FontName { get; set; }
100 FontConverter cvt = new FontConverter();
101 Font font = cvt.ConvertFromInvariantString(FontName) as Font;
107 FontConverter cvt = new FontConverter();
108 FontName = cvt.ConvertToInvariantString(value);
115 /// Contain settings for each of our display type.
117 [TypeConverter(typeof(DisplaySettingsConverter))]
119 public class DisplaysSettings
121 public DisplaysSettings()
128 if (Displays == null)
130 Displays = new List<DisplaySettings>();
135 //public int CurrentSettingsIndex { get; set; }
138 public List<DisplaySettings> Displays { get; set; }
140 public override string ToString()
142 //Save settings into JSON string
143 MemoryStream stream = new MemoryStream();
144 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
145 ser.WriteObject(stream, this);
146 // convert stream to string
148 StreamReader reader = new StreamReader(stream);
149 string text = reader.ReadToEnd();
154 public class DisplaySettingsConverter : TypeConverter
156 public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
158 if (sourceType == typeof(string))
161 return base.CanConvertFrom(context, sourceType);
164 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
166 string stringValue = value as string;
167 if (stringValue != null)
169 //Load settings form JSON string
170 byte[] byteArray = Encoding.UTF8.GetBytes(stringValue);
171 MemoryStream stream = new MemoryStream(byteArray);
172 DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DisplaysSettings));
173 DisplaysSettings settings = (DisplaysSettings)ser.ReadObject(stream);
178 return base.ConvertFrom(context, culture, value);