private void TextBoxPa_OnTextChanged(object sender, TextChangedEventArgs e) { //屏蔽中文输入和非法字符粘贴输入 TextBox textBox = sender as TextBox; byte num; if (byte.TryParse(textBox.Text, out num)) { if (num > 100) { num = 100; } _lastInputText = num.ToString(); } else { if (string.IsNullOrEmpty(textBox.Text)) { textBox.Text = "0"; num = 0; } else { textBox.Text = _lastInputText; num = byte.Parse(_lastInputText); } } if (_isLoadConfig) { return; } var color = Configer.ReadByKey("bgcolor"); if (string.IsNullOrEmpty(color)) { color = "128,128,128"; } string[] rgps = color.Split(','); try { this.Background = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * num / 100.0), byte.Parse(rgps[0]), byte.Parse(rgps[1]), byte.Parse(rgps[2]))); Configer.SaveConf("bgalpha", num.ToString()); } catch { MessageBox.Show("配置文件出错了.", "呵呵", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void LabelColor_OnMouseUp(object sender, MouseButtonEventArgs e) { System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog(); var result = colorDialog.ShowDialog(null); if (result == System.Windows.Forms.DialogResult.OK) { var color = colorDialog.Color; var alpha = Convert.ToByte(color.A * int.Parse(this.TextBoxPa.Text) / 100.0); var backBrush = new SolidColorBrush(Color.FromArgb(alpha, color.R, color.G, color.B)); this.LabelColor.Background = backBrush; this.Background = backBrush; Configer.SaveConf("bgcolor", color.R + "," + color.G + "," + color.B); } }
private void CheckBoxMultiScreen_OnChecked(object sender, RoutedEventArgs e) { Configer.SaveConf("allowdrag", this.CheckBoxMultiScreen.IsChecked.ToString()); }