Beispiel #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);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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;
            }
        }