Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        private void LoadConfig()
        {
            var color = Configer.ReadByKey("bgcolor");

            if (string.IsNullOrEmpty(color))
            {
                color = "128,128,128";
            }
            string[] rgbs  = color.Split(',');
            var      alpha = Configer.ReadByKey("bgalpha");

            if (string.IsNullOrEmpty(alpha))
            {
                alpha = 90.ToString();
            }
            string allowDrag = Configer.ReadByKey("allowdrag");

            try
            {
                if (string.IsNullOrEmpty(allowDrag))
                {
                    this.MouseLeftButtonDown -= MainWindow_OnMouseLeftButtonDown;
                }
                else
                {
                    if (!Convert.ToBoolean(allowDrag))
                    {
                        this.MouseLeftButtonDown -= MainWindow_OnMouseLeftButtonDown;
                    }
                }
                this.Background =
                    new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * byte.Parse(alpha) / 100.0), byte.Parse(rgbs[0]),
                                                       byte.Parse(rgbs[1]), byte.Parse(rgbs[2])));
            }
            catch
            {
                MessageBox.Show("配置文件出错了.", "呵呵", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 4
0
        private void LoadConfig()
        {
            _isLoadConfig = true;
            var color = Configer.ReadByKey("bgcolor");

            if (string.IsNullOrEmpty(color))
            {
                color = "128,128,128";
            }
            string[] rgbs  = color.Split(',');
            var      alpha = Configer.ReadByKey("bgalpha");

            if (string.IsNullOrEmpty(alpha))
            {
                alpha = 60.ToString();
            }
            string allowDrag = Configer.ReadByKey("allowdrag");

            try
            {
                this.CheckBoxMultiScreen.IsChecked = !string.IsNullOrEmpty(allowDrag) && Convert.ToBoolean(allowDrag);
                this.TextBoxPa.Text        = alpha;
                this.LabelColor.Background =
                    new SolidColorBrush(Color.FromRgb(byte.Parse(rgbs[0]), byte.Parse(rgbs[1]), byte.Parse(rgbs[2])));
                this.Background =
                    new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * byte.Parse(alpha) / 100.0), byte.Parse(rgbs[0]),
                                                       byte.Parse(rgbs[1]), byte.Parse(rgbs[2])));
            }
            catch
            {
                MessageBox.Show("配置文件出错了.", "呵呵", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                _isLoadConfig = false;
            }
        }
Exemplo n.º 5
0
 private void CheckBoxMultiScreen_OnChecked(object sender, RoutedEventArgs e)
 {
     Configer.SaveConf("allowdrag", this.CheckBoxMultiScreen.IsChecked.ToString());
 }