public static void SetOptions(Options options) { if (options != null) { using (StreamWriter writer = File.CreateText(optionsFileName)) { writer.WriteLine("OpenStreamsInNewTab " + (options.OpenStreamsInNewTab ? "true" : "false")); writer.WriteLine("ShowStreamFeedWhenOpening " + (options.ShowStreamFeedWhenOpening ? "true" : "false")); writer.WriteLine("ShowTimestampsInChat " + (options.ShowTimestampsInChat ? "true" : "false")); writer.WriteLine("EnableDebugLogging " + (options.EnableDebugLogging ? "true" : "false")); writer.WriteLine("ChatTextSize " + options.ChatTextSize.ToString()); writer.WriteLine("ShowEmoticonsInChat " + (options.ShowEmoticonsInChat ? "true" : "false")); writer.WriteLine("LogAllIRCTraffic " + (options.LogAllIRCTraffic ? "true" : "false")); } } }
private void OptionsClick(object sender, RoutedEventArgs e) { var optionsControl = new Controls.Options(); var ibd = new IconBitmapDecoder(new Uri("pack://application:,,,/LivestreamBuddyNew;component/livestream-ICON.ico"), BitmapCreateOptions.None, BitmapCacheOption.Default); var brush = new LinearGradientBrush((Color) ColorConverter.ConvertFromString("#FF515151"), Colors.LightGray, new Point(.5, 0), new Point(.5, 1)); var newWindow = new Window { Width = 325, MinWidth = 325, Height = 375, MinHeight = 375, Title = "Options", Icon = ibd.Frames[0], Background = brush, Content = new Border {Padding = new Thickness(13, 13, 13, 13), Child = optionsControl} }; optionsControl.OnSaved += delegate { userOptions = optionsControl.UserOptions; newWindow.Close(); }; newWindow.Show(); }
public static Options GetOptions() { // Defaults var options = new Options(); using (FileStream stream = File.Open(optionsFileName, FileMode.OpenOrCreate)) { using (var reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { string[] values = line.Split(' '); bool bTemp; int iTemp; if (values.Length >= 2) { switch (values[0].ToLower()) { case "openstreamsinnewtab": if (bool.TryParse(values[1], out bTemp)) { options.OpenStreamsInNewTab = bTemp; } break; case "showstreamfeedwhenopening": if (bool.TryParse(values[1], out bTemp)) { options.ShowStreamFeedWhenOpening = bTemp; } break; case "showtimestampsinchat": if (bool.TryParse(values[1], out bTemp)) { options.ShowTimestampsInChat = bTemp; } break; case "enabledebuglogging": if (bool.TryParse(values[1], out bTemp)) { options.EnableDebugLogging = bTemp; } break; case "chattextsize": if (int.TryParse(values[1], out iTemp)) { if (iTemp < 1) { iTemp = 14; } options.ChatTextSize = iTemp; } break; case "showemoticonsinchat": if (bool.TryParse(values[1], out bTemp)) { options.ShowEmoticonsInChat = bTemp; } break; case "logallirctraffic": if (bool.TryParse(values[1], out bTemp)) { options.LogAllIRCTraffic = bTemp; } break; } } } } } return options; }