Exemplo n.º 1
0
        private void colorPickerControlValueChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e)
        {
            Type var_type = VariableObject.GetType();

            System.Windows.Media.Color ctrlClr = (System.Windows.Media.Color)((ColorPicker)sender).SelectedColor;
            Aurora.Utils.RealColor     clr     = (Aurora.Utils.RealColor)VariableObject;
            clr.SetMediaColor(ctrlClr);
            VariableObject = clr;
        }
        private void colorPickerControlValueChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e)
        {
            Type var_type = VarRegistry.GetVariableType(VariableName);

            System.Windows.Media.Color ctrlClr = (System.Windows.Media.Color)((ColorPicker)sender).SelectedColor;
            Aurora.Utils.RealColor     clr     = VarRegistry.GetVariable <Aurora.Utils.RealColor>(VariableName);
            clr.SetMediaColor(ctrlClr);
            VarRegistry.SetVariable(VariableName, clr);
        }
Exemplo n.º 3
0
        private void UpdateControls()
        {
            if (String.IsNullOrWhiteSpace(VariableTitle))
            {
                this.txtBlk_name.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.txtBlk_name.Visibility = Visibility.Visible;
                this.txtBlk_name.Text       = VariableTitle;
            }

            if (String.IsNullOrWhiteSpace(VariableRemark))
            {
                this.txtBlk_remark.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.txtBlk_remark.Visibility = Visibility.Visible;
                this.txtBlk_remark.Text       = VariableRemark;
            }

            if (VariableDefaultObject == null)
            {
                this.btn_reset.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.btn_reset.Visibility = Visibility.Visible;
            }

            //Create a control here...
            grd_control.Children.Clear();

            if (VariableObject != null)
            {
                Type var_type = VariableObject.GetType();

                if (var_type == typeof(bool))
                {
                    CheckBox chkbx_control = new CheckBox();
                    chkbx_control.Content    = "";
                    chkbx_control.IsChecked  = (bool)VariableObject;
                    chkbx_control.Checked   += Chkbx_control_VarChanged;
                    chkbx_control.Unchecked += Chkbx_control_VarChanged;

                    grd_control.Children.Add(chkbx_control);
                }
                else if (var_type == typeof(string))
                {
                    TextBox txtbx_control = new TextBox();
                    txtbx_control.Text         = (string)VariableObject;
                    txtbx_control.TextChanged += Txtbx_control_TextChanged;

                    grd_control.Children.Add(txtbx_control);
                }
                else if (var_type == typeof(int))
                {
                    IntegerUpDown intUpDown_control = new IntegerUpDown();
                    intUpDown_control.Value         = (int)VariableObject;
                    intUpDown_control.ValueChanged += IntUpDown_control_ValueChanged;

                    grd_control.Children.Add(intUpDown_control);
                }
                else if (var_type == typeof(long))
                {
                    LongUpDown longUpDown_control = new LongUpDown();
                    longUpDown_control.Value         = (long)VariableObject;
                    longUpDown_control.ValueChanged += LongUpDown_control_ValueChanged;

                    grd_control.Children.Add(longUpDown_control);
                }
                else if (var_type == typeof(float))
                {
                    DoubleUpDown floatUpDown_control = new DoubleUpDown();
                    floatUpDown_control.Value         = (float)VariableObject;
                    floatUpDown_control.ValueChanged += FloatUpDown_control_ValueChanged;

                    grd_control.Children.Add(floatUpDown_control);
                }
                else if (var_type == typeof(double))
                {
                    DoubleUpDown doubleUpDown_control = new DoubleUpDown();
                    doubleUpDown_control.Value         = (double)VariableObject;
                    doubleUpDown_control.ValueChanged += DoubleUpDown_control_ValueChanged;

                    grd_control.Children.Add(doubleUpDown_control);
                }
                else if (var_type == typeof(System.Drawing.Color))
                {
                    ColorPicker colorPickerDrawing_control = new ColorPicker();
                    colorPickerDrawing_control.SelectedColor         = Utils.ColorUtils.DrawingColorToMediaColor((System.Drawing.Color)VariableObject);
                    colorPickerDrawing_control.ColorMode             = ColorMode.ColorCanvas;
                    colorPickerDrawing_control.SelectedColorChanged += ColorPickerDrawing_control_SelectedColorChanged;

                    grd_control.Children.Add(colorPickerDrawing_control);
                }
                else if (var_type == typeof(System.Windows.Media.Color))
                {
                    ColorPicker colorPickerMedia_control = new ColorPicker();
                    colorPickerMedia_control.SelectedColor         = (System.Windows.Media.Color)VariableObject;
                    colorPickerMedia_control.ColorMode             = ColorMode.ColorCanvas;
                    colorPickerMedia_control.SelectedColorChanged += ColorPickerMedia_control_SelectedColorChanged;

                    grd_control.Children.Add(colorPickerMedia_control);
                }
                else if (var_type == typeof(Aurora.Settings.KeySequence))
                {
                    Aurora.Controls.KeySequence ctrl = new Aurora.Controls.KeySequence();
                    ctrl.Sequence         = (Aurora.Settings.KeySequence)VariableObject;
                    ctrl.SequenceUpdated += keySequenceControlValueChanged;
                    ctrl.RecordingTag     = VariableTitle;

                    grd_control.Children.Add(ctrl);
                }
                else if (var_type == typeof(Aurora.Utils.RealColor))
                {
                    ColorPicker ctrl = new ColorPicker();
                    ctrl.ColorMode = ColorMode.ColorCanvas;
                    Aurora.Utils.RealColor clr = (Aurora.Utils.RealColor)VariableObject;

                    ctrl.SelectedColor         = clr.GetMediaColor();
                    ctrl.SelectedColorChanged += colorPickerControlValueChanged;
                    grd_control.Children.Add(ctrl);
                }
                else if (var_type.IsEnum)
                {
                    ComboBox cmbbxEnum_control = new ComboBox();
                    cmbbxEnum_control.ItemsSource       = Enum.GetValues(var_type);
                    cmbbxEnum_control.SelectedValue     = (Enum)VariableObject;
                    cmbbxEnum_control.SelectionChanged += CmbbxEnum_control_SelectionChanged;

                    grd_control.Children.Add(cmbbxEnum_control);
                }
            }

            grd_control.UpdateLayout();
        }
        private void UpdateControls()
        {
            string var_title = VarRegistry.GetTitle(VariableName);

            if (String.IsNullOrWhiteSpace(var_title))
            {
                this.txtBlk_name.Text = VariableName;
            }
            else
            {
                this.txtBlk_name.Text = var_title;
            }

            string var_remark = VarRegistry.GetRemark(VariableName);

            if (String.IsNullOrWhiteSpace(var_remark))
            {
                this.txtBlk_remark.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.txtBlk_remark.Text = var_remark;
            }

            //Create a control here...
            Type var_type = VarRegistry.GetVariableType(VariableName);

            grd_control.Children.Clear();

            if (var_type == typeof(bool))
            {
                CheckBox chkbx_control = new CheckBox();
                chkbx_control.Content    = "";
                chkbx_control.IsChecked  = VarRegistry.GetVariable <bool>(VariableName);
                chkbx_control.Checked   += Chkbx_control_VarChanged;
                chkbx_control.Unchecked += Chkbx_control_VarChanged;

                grd_control.Children.Add(chkbx_control);
            }
            else if (var_type == typeof(string))
            {
                TextBox txtbx_control = new TextBox();
                txtbx_control.Text         = VarRegistry.GetVariable <string>(VariableName);
                txtbx_control.TextChanged += Txtbx_control_TextChanged;

                grd_control.Children.Add(txtbx_control);
            }
            else if (var_type == typeof(int))
            {
                if (VarRegistry.GetFlags(VariableName).HasFlag(VariableFlags.UseHEX))
                {
                    TextBox hexBox = new TextBox();
                    hexBox.PreviewTextInput += HexBoxOnPreviewTextInput;
                    hexBox.Text              = string.Format("{0:X}", VarRegistry.GetVariable <int>(VariableName));
                    hexBox.TextChanged      += HexBox_TextChanged;
                    grd_control.Children.Add(hexBox);
                }
                else
                {
                    IntegerUpDown intUpDown_control = new IntegerUpDown();

                    intUpDown_control.Value = VarRegistry.GetVariable <int>(VariableName);
                    int max_val, min_val = 0;
                    if (VarRegistry.GetVariableMax <int>(VariableName, out max_val))
                    {
                        intUpDown_control.Maximum = max_val;
                    }
                    if (VarRegistry.GetVariableMin <int>(VariableName, out min_val))
                    {
                        intUpDown_control.Minimum = min_val;
                    }

                    intUpDown_control.ValueChanged += IntUpDown_control_ValueChanged;

                    grd_control.Children.Add(intUpDown_control);
                }
            }
            else if (var_type == typeof(long))
            {
                LongUpDown longUpDown_control = new LongUpDown();
                longUpDown_control.Value = VarRegistry.GetVariable <long>(VariableName);
                long max_val, min_val = 0;
                if (VarRegistry.GetVariableMax <long>(VariableName, out max_val))
                {
                    longUpDown_control.Maximum = max_val;
                }
                if (VarRegistry.GetVariableMin <long>(VariableName, out min_val))
                {
                    longUpDown_control.Minimum = min_val;
                }

                longUpDown_control.ValueChanged += LongUpDown_control_ValueChanged;

                grd_control.Children.Add(longUpDown_control);
            }
            else if (var_type == typeof(Aurora.Settings.KeySequence))
            {
                Aurora.Controls.KeySequence ctrl = new Aurora.Controls.KeySequence();
                ctrl.RecordingTag = var_title;

                ctrl.Sequence         = VarRegistry.GetVariable <Aurora.Settings.KeySequence>(VariableName);
                ctrl.SequenceUpdated += keySequenceControlValueChanged;

                grd_control.Children.Add(ctrl);
            }
            else if (var_type == typeof(Aurora.Utils.RealColor))
            {
                ColorPicker ctrl = new ColorPicker();
                ctrl.ColorMode = ColorMode.ColorCanvas;
                Aurora.Utils.RealColor clr = VarRegistry.GetVariable <Aurora.Utils.RealColor>(VariableName);

                ctrl.SelectedColor         = clr.GetMediaColor();
                ctrl.SelectedColorChanged += colorPickerControlValueChanged;
                grd_control.Children.Add(ctrl);
            }
            //else
            //throw new Exception($"Type {var_type} is not supported!");

            grd_control.UpdateLayout();
        }