private void Button_Click_T4(object sender, RoutedEventArgs e) { CurrentAppState.ChangeTheme(4); }
public MainWindow() { InitializeComponent(); CurrentAppState.InitConfig(this); comboBox_uart_ports.Items.Clear(); foreach (var c in System.IO.Ports.SerialPort.GetPortNames()) { comboBox_uart_ports.Items.Add(c); } if (comboBox_uart_ports.Items.Count != 0) { comboBox_uart_ports.Text = comboBox_uart_ports.Items[0].ToString(); button_listen.IsEnabled = true; } else { button_listen.IsEnabled = false; comboBox_uart_ports.Text = ""; } text_box_main_2.Visibility = Visibility.Hidden; text_box_main_3.Visibility = Visibility.Hidden; if (CurrentAppState.CurrentAppConfig.LogsPathsHexIsListen) { CurrentAppState.LogsHexStream = new StreamWriter(CurrentAppState.CurrentAppConfig.LogsPathsHex, true, System.Text.Encoding.Default); } if (CurrentAppState.CurrentAppConfig.LogsPathsAsciiIsListen) { CurrentAppState.LogsAsciiStream = new StreamWriter(CurrentAppState.CurrentAppConfig.LogsPathsAscii, true, System.Text.Encoding.Default); } this.Closed += (object sender, EventArgs e) => { CurrentAppState.CurrentAppConfig.UartSettings = Uart.currentUartSettings; CurrentAppState.CurrentAppConfig.WindowsState = this.WindowState; CurrentAppState.CurrentAppConfig.WindowsWeight = this.Width; CurrentAppState.CurrentAppConfig.WindowsHeight = this.Height; CurrentAppState.CurrentAppConfig.WindowsLocationX = this.Left; CurrentAppState.CurrentAppConfig.WindowsLocationY = this.Top; CurrentAppState.CurrentAppConfig.CheckBoxAutoscrollIsChecked = checkBox_autoscroll.IsChecked; CurrentAppState.CurrentAppConfig.TextBoxCommandText = this.textBox_command.Text; CurrentAppState.CurrentAppConfig.CheckBoxHexCommandIsChecked = this.checkBox_hex_command.IsChecked; DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(AppConfig)); try { FileStream fileStream = new FileStream("AppConfig.json", FileMode.Truncate); jsonSerializer.WriteObject(fileStream, CurrentAppState.CurrentAppConfig); fileStream.Close(); } catch (System.IO.FileNotFoundException) { FileStream fileStream = new FileStream("AppConfig.json", FileMode.Create); jsonSerializer.WriteObject(fileStream, CurrentAppState.CurrentAppConfig); fileStream.Close(); }; }; // Автоскролин TextBox'ов if (checkBox_autoscroll.IsChecked == true) { text_box_main_1.TextChanged += TextBoxMain1TextChangeedHandler; text_box_main_2.TextChanged += TextBoxMain2TextChangeedHandler; text_box_main_3.TextChanged += TextBoxMain3TextChangeedHandler; } checkBox_autoscroll.Click += (object sender, RoutedEventArgs e) => { switch (checkBox_autoscroll.IsChecked) { case true: text_box_main_1.TextChanged += TextBoxMain1TextChangeedHandler; text_box_main_2.TextChanged += TextBoxMain2TextChangeedHandler; text_box_main_3.TextChanged += TextBoxMain3TextChangeedHandler; break; case false: text_box_main_1.TextChanged -= TextBoxMain1TextChangeedHandler; text_box_main_2.TextChanged -= TextBoxMain2TextChangeedHandler; text_box_main_3.TextChanged -= TextBoxMain3TextChangeedHandler; break; } }; // Запуск основных часов StartWatch(); }