private static string FindIdleMessage(Settings currentSettings) { foreach (Message message in currentSettings.Messages) { if ((message.Status == Status.Idle) && (message.Windows.Count == 0)) { string str = string.Empty; for (int i = 0; i < message.Lines[0].values.Count; i++) { str = str + message.Lines[0].values[i].Evaluate(); } return str.Trim(); } } return string.Empty; }
private static Settings Load() { Settings settings; if (File.Exists(Config.GetFile(Config.Dir.Config, "MiniDisplay.xml"))) { Log.Info("MiniDisplay.Settings.Load() - Loading settings from configuration file"); XmlSerializer serializer = new XmlSerializer(typeof (Settings)); XmlTextReader xmlReader = new XmlTextReader(Config.GetFile(Config.Dir.Config, "MiniDisplay.xml")); settings = (Settings)serializer.Deserialize(xmlReader); xmlReader.Close(); settings.IdleMessage = FindIdleMessage(settings); return settings; } Log.Info("MiniDisplay.Settings.Load() - Loading default settings"); settings = new Settings(); Default(settings); Log.Info("MiniDisplay.Settings.Load() - Loaded default settings"); settings.IdleMessage = FindIdleMessage(settings); return settings; }
private static void Default(Settings _settings) { _settings.DisableGUISetup = false; _settings.TranslateFrom = new string[] { "\x00a9", "\x00ae", "\x00e9", "\x00e8", "\x00ea", "\x00fc", "\x00e4", "\x00f6", "\x00dc", "\x00c4", "\x00d6", "\x00df" }; _settings.TranslateTo = new string[] {"(c)", "(R)", "e", "e", "e", "ue", "ae", "oe", "Ue", "Ae", "Oe", "ss"}; _settings.BackLightControl = false; _settings.Backlight = 0x7f; _settings.ContrastControl = false; _settings.Contrast = 0x7f; _settings.CustomCharacters = new int[][] { new int[] {12, 30, 30, 30, 30, 30, 30, 12}, new int[] {0x66, 0xff, 0xff, 0xf6, 240, 240, 240, 0x60} }; Message item = new Message(); item.Status = Status.Idle; item.Lines.Add(new Line(new Text("MediaPortal"), Alignment.Centered)); item.Lines.Add(new Line(new Property("#time"), Alignment.Centered)); _settings.Messages.Add(item); item = new Message(); item.Status = Status.Dialog; item.Lines.Add(new Line(new Property("#DialogLabel"), Alignment.Centered)); item.Lines.Add(new Line(new Property("#DialogItem"), Alignment.Centered)); _settings.Messages.Add(item); item = new Message(); item.Status = Status.Action; item.Windows.Add(1); item.Lines.Add(new Line(new Property("#currentmodule"))); Line line = new Line(); line.values.Add(new Property("#TV.View.channel")); line.values.Add(new Parse(": #TV.View.title", new NotNullCondition("#TV.View.title"))); line.values.Add(new Text(": #736", new IsNullCondition("#TV.View.title"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.Action; item.Windows.Add(0x4a38); item.Lines.Add(new Line("#currentmodule, Level: #tetris_level")); item.Lines.Add(new Line("Score: #tetris_score (#tetris_lines lines)")); _settings.Messages.Add(item); item = new Message(); item.Status = Status.Action; item.Lines.Add(new Line(new Property("#currentmodule"))); line = new Line(); line.values.Add(new Property("#highlightedbutton")); line.values.Add(new Property("#selecteditem", new IsNullCondition("#highlightedbutton"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.PlayingMusic; line = new Line(); line.values.Add(new Property("#Play.Current.Title")); line.values.Add(new Parse(" by #Play.Current.Artist", new NotNullCondition("#Play.Current.Artist"))); line.values.Add(new Parse(", from the album #Play.Current.Album", new NotNullCondition("#Play.Current.Album"))); item.Lines.Add(line); line = new Line(); line.values.Add(new Parse("#currentplaytime/#duration")); line.values.Add(new Text(" (#112)", new NotNullCondition("#paused"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.PlayingRadio; line = new Line(); line.values.Add(new Property("#Play.Current.Title")); item.Lines.Add(line); line = new Line(); line.values.Add(new Parse("#currentplaytime")); line.values.Add(new Text(" (#112)", new NotNullCondition("#paused"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.PlayingTV; item.Lines.Add(new Line(new Property("#TV.View.channel"))); line = new Line(); line.values.Add(new Parse("#TV.View.title (#TV.View.start->#TV.View.stop)", new NotNullCondition("#TV.View.title"))); line.values.Add(new Text(": #736", new IsNullCondition("#TV.View.title"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.PlayingRecording; item.Lines.Add(new Line(new Property("#Play.Current.Title"))); line = new Line(); line.values.Add(new Parse("#currentplaytime/#duration")); line.values.Add(new Text(" (#112)", new NotNullCondition("#paused"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.Timeshifting; item.Lines.Add(new Line(new Property("#TV.View.channel"))); line = new Line(); line.values.Add(new Parse("#TV.View.title (#TV.View.start->#TV.View.stop)", new NotNullCondition("#TV.View.title"))); line.values.Add(new Text(" (#112)", new AndCondition(new Condition[] { new NotNullCondition("#paused"), new NotNullCondition("#TV.View.title") }))); line.values.Add(new Text(": #736", new IsNullCondition("#TV.View.title"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.PlayingVideo; item.Lines.Add(new Line(new Property("#Play.Current.Title"))); line = new Line(); line.values.Add(new Parse("#currentplaytime/#duration")); line.values.Add(new Text(" (#112)", new NotNullCondition("#paused"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.PlayingDVD; item.Lines.Add(new Line(new Text("DVD"))); line = new Line(); line.values.Add(new Parse("#currentplaytime/#duration")); line.values.Add(new Text(" (#112)", new NotNullCondition("#paused"))); item.Lines.Add(line); _settings.Messages.Add(item); item = new Message(); item.Status = Status.Action; item.Lines.Add(new Line("TV Programs on ##TV.Guide.Day")); _settings.Messages.Add(item); item = new Message(); item.Lines.Add(new Line(new Property("#currentmodule"))); item.Lines.Add(new Line(new Property("#selecteditem"))); _settings.Messages.Add(item); }