Ejemplo n.º 1
0
        private void UpdateDisplayList()
        {
            ObservableCollection <object> ds = new ObservableCollection <object>();

            foreach (var light in BridgeManager.Instance.CurrentBridge.LightList)
            {
                ds.Add(light);
            }

            LightListView.ItemsSource = ds;
            HueBar.UpdateDisplayList();

            // Summary
            LightSummaryLabel.Text = ds.Count.ToString() + " LIGHTS";

            // Toggle button
            UpdateLightControlLabel();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the window.
        /// </summary>
        public ColorPickerPopup() : base(60, 35)
        {
            Border.AddToWindow(this);
            Title         = "Select color";
            CloseOnEscKey = true;
            CanDrag       = false;

            UsePixelPositioning = true;
            Center();
            otherColorPopup         = new OtherColorsPopup();
            otherColorPopup.Closed += (sender2, e2) =>
            {
                if (otherColorPopup.DialogResult)
                {
                    _barR.SelectedColor = otherColorPopup.SelectedColor.RedOnly();
                    _barG.SelectedColor = otherColorPopup.SelectedColor.GreenOnly();
                    _barB.SelectedColor = otherColorPopup.SelectedColor.BlueOnly();
                    _alphaInput.Text    = otherColorPopup.SelectedColor.A.ToString();
                }
            };

            _picker = new Controls.ColorPicker(Width - RideSideX - 1, Height - 11, Color.YellowGreen)
            {
                Position = new Point(1, 1)
            };
            _picker.SelectedColorChanged += _picker_SelectedColorChanged;
            Controls.Add(_picker);

            #region TextBoxes
            _redInput              = new TextBox(5);
            _redInput.IsNumeric    = true;
            _redInput.MaxLength    = 3;
            _redInput.Position     = new Point(Width - 7, Height - 14);
            _redInput.TextChanged += (sender, e) => { _barR.SelectedColor = new Color(int.Parse(_redInput.Text), 0, 0); };
            Controls.Add(_redInput);

            _greenInput              = new TextBox(5);
            _greenInput.IsNumeric    = true;
            _greenInput.MaxLength    = 3;
            _greenInput.Position     = new Point(Width - 7, Height - 13);
            _greenInput.TextChanged += (sender, e) => { _barG.SelectedColor = new Color(0, int.Parse(_greenInput.Text), 0); };
            Controls.Add(_greenInput);

            _blueInput              = new TextBox(5);
            _blueInput.IsNumeric    = true;
            _blueInput.MaxLength    = 3;
            _blueInput.Position     = new Point(Width - 7, Height - 12);
            _blueInput.TextChanged += (sender, e) => { _barB.SelectedColor = new Color(0, 0, int.Parse(_blueInput.Text)); };
            Controls.Add(_blueInput);

            _alphaInput           = new TextBox(5);
            _alphaInput.IsNumeric = true;
            _alphaInput.MaxLength = 3;
            _alphaInput.Position  = new Point(Width - 7, Height - 11);
            _alphaInput.Text      = "255";
            Controls.Add(_alphaInput);
            #endregion

            #region Bars
            _barH = new HueBar(Width - 2);

            _barH.Position      = new Point(1, Height - 9);
            _barH.ColorChanged += _barH_ColorChanged;
            Controls.Add(_barH);

            _barR = new ColorBar(Width - 2);

            _barR.StartingColor = Color.Black;
            _barR.EndingColor   = Color.Red;
            _barR.Position      = new Point(1, Height - 7);
            _barR.ColorChanged += bar_ColorChanged;
            Controls.Add(_barR);

            _barG = new ColorBar(Width - 2);

            _barG.StartingColor = Color.Black;
            _barG.EndingColor   = new Color(0, 255, 0);
            _barG.Position      = new Point(1, Height - 5);
            _barG.ColorChanged += bar_ColorChanged;
            Controls.Add(_barG);

            _barB = new ColorBar(Width - 2);

            _barB.StartingColor = Color.Black;
            _barB.EndingColor   = Color.Blue;
            _barB.Position      = new Point(1, Height - 3);
            _barB.ColorChanged += bar_ColorChanged;
            Controls.Add(_barB);


            _selectedColor      = _picker.SelectedColor;
            _barH.SelectedColor = _selectedColor;
            #endregion

            #region Buttons
            _okButton          = new Button(RideSideX - 4);
            _okButton.Text     = "OK";
            _okButton.Position = new Point(Width - RideSideX + 2, Height - 18);
            _okButton.Click   += (sender, r) =>
            {
                this.DialogResult = true;
                _selectedColor    = _selectedColor.SetAlpha(byte.Parse(_alphaInput.Text));
                AddPreviousColor(SelectedColor);
                Hide();
            };
            Controls.Add(_okButton);

            _cancelButton          = new Button(RideSideX - 4);
            _cancelButton.Text     = "Cancel";
            _cancelButton.Position = new Point(Width - RideSideX + 2, Height - 17);
            _cancelButton.Click   += (sender, r) => { this.DialogResult = false; Hide(); };
            Controls.Add(_cancelButton);

            _otherColorsButton          = new Button(RideSideX - 4);
            _otherColorsButton.Text     = "Other Colors";
            _otherColorsButton.Position = new Point(Width - RideSideX + 2, Height - 20);
            _otherColorsButton.Click   += (sender, e) => { otherColorPopup.Show(true); };
            Controls.Add(_otherColorsButton);
            #endregion

            _previousColors                      = new ListBox(RideSideX - 4, Height - 20 - 9 + 1, new SadConsole.UI.Themes.ListBoxItemColorTheme());
            _previousColors.Position             = new Point(Width - RideSideX + 2, 8);
            _previousColors.SelectedItemChanged += (sender, e) => { if (_previousColors.SelectedItem != null)
                                                                    {
                                                                        SelectedColor = (Color)_previousColors.SelectedItem;
                                                                    }
            };
            Controls.Add(_previousColors);

            var colors = Controls.GetThemeColors();

            this.Print(Width - RideSideX + 2, _redInput.Position.Y, "Red", colors.Red);
            this.Print(Width - RideSideX + 2, _greenInput.Position.Y, "Green", colors.Green);
            this.Print(Width - RideSideX + 2, _blueInput.Position.Y, "Blue", colors.Blue);
            this.Print(Width - RideSideX + 2, _alphaInput.Position.Y, "Alpha", colors.Gray);

            // Preview area
            this.Print(Width - RideSideX + 2, 1, "Selected Color");

            this.Fill(new Rectangle(Width - RideSideX + 2, 2, 14, 3), colors.ControlHostForeground, colors.ControlHostBackground, 219);

            // Current selected gradient colors
            this.Print(Width - RideSideX + 2, 5, SelectedColor.R.ToString().PadLeft(3, '0'), colors.Red);
            this.Print(Width - RideSideX + 2, 6, SelectedColor.G.ToString().PadLeft(3, '0'), colors.Green);
            this.Print(Width - RideSideX + 13, 5, SelectedColor.B.ToString().PadLeft(3, '0'), colors.Blue);

            // Previous Colors
            this.Print(Width - RideSideX + 2, _previousColors.Position.Y - 1, "Prior Colors");
        }
Ejemplo n.º 3
0
        public ColorPickerPopup() : base(Settings.Config.ColorPickerSettings.WindowWidth, Settings.Config.ColorPickerSettings.WindowHeight)
        {
            Center();

            otherColorPopup         = new OtherColorsPopup();
            otherColorPopup.Closed += (sender2, e2) =>
            {
                if (otherColorPopup.DialogResult)
                {
                    _barR.SelectedColor = otherColorPopup.SelectedColor.RedOnly();
                    _barG.SelectedColor = otherColorPopup.SelectedColor.GreenOnly();
                    _barB.SelectedColor = otherColorPopup.SelectedColor.BlueOnly();
                    _alphaInput.Text    = otherColorPopup.SelectedColor.A.ToString();
                }
            };

            _picker = new Controls.ColorPicker(TextSurface.Width - RideSideX - 1, TextSurface.Height - 11, Color.YellowGreen)
            {
                Position = new Point(1, 1)
            };
            _picker.SelectedColorChanged += _picker_SelectedColorChanged;
            Add(_picker);

            #region TextBoxes
            _redInput              = new InputBox(5);
            _redInput.IsNumeric    = true;
            _redInput.MaxLength    = 3;
            _redInput.Position     = new Point(TextSurface.Width - 7, TextSurface.Height - 14);
            _redInput.TextChanged += (sender, e) => { _barR.SelectedColor = new Color(int.Parse(_redInput.Text), 0, 0); };
            Add(_redInput);

            _greenInput              = new InputBox(5);
            _greenInput.IsNumeric    = true;
            _greenInput.MaxLength    = 3;
            _greenInput.Position     = new Point(TextSurface.Width - 7, TextSurface.Height - 13);
            _greenInput.TextChanged += (sender, e) => { _barG.SelectedColor = new Color(0, int.Parse(_greenInput.Text), 0); };
            Add(_greenInput);

            _blueInput              = new InputBox(5);
            _blueInput.IsNumeric    = true;
            _blueInput.MaxLength    = 3;
            _blueInput.Position     = new Point(TextSurface.Width - 7, TextSurface.Height - 12);
            _blueInput.TextChanged += (sender, e) => { _barB.SelectedColor = new Color(0, 0, int.Parse(_blueInput.Text)); };
            Add(_blueInput);

            _alphaInput           = new InputBox(5);
            _alphaInput.IsNumeric = true;
            _alphaInput.MaxLength = 3;
            _alphaInput.Position  = new Point(TextSurface.Width - 7, TextSurface.Height - 11);
            _alphaInput.Text      = "255";
            Add(_alphaInput);
            #endregion

            #region Bars
            _barH = new HueBar(base.TextSurface.RenderArea.Width - 2);

            _barH.Position      = new Point(1, TextSurface.Height - 9);
            _barH.ColorChanged += _barH_ColorChanged;
            Add(_barH);

            _barR = new ColorBar(base.TextSurface.RenderArea.Width - 2);

            _barR.StartingColor = Color.Black;
            _barR.EndingColor   = Color.Red;
            _barR.Position      = new Point(1, TextSurface.Height - 7);
            _barR.ColorChanged += bar_ColorChanged;
            Add(_barR);

            _barG = new ColorBar(base.TextSurface.RenderArea.Width - 2);

            _barG.StartingColor = Color.Black;
            _barG.EndingColor   = new Color(0, 255, 0);
            _barG.Position      = new Point(1, TextSurface.Height - 5);
            _barG.ColorChanged += bar_ColorChanged;
            Add(_barG);

            _barB = new ColorBar(base.TextSurface.RenderArea.Width - 2);

            _barB.StartingColor = Color.Black;
            _barB.EndingColor   = Color.Blue;
            _barB.Position      = new Point(1, TextSurface.Height - 3);
            _barB.ColorChanged += bar_ColorChanged;
            Add(_barB);


            _selectedColor      = _picker.SelectedColor;
            _barH.SelectedColor = _selectedColor;
            #endregion

            #region Buttons
            _okButton          = new Button(RideSideX - 4);
            _okButton.Text     = "OK";
            _okButton.Position = new Point(TextSurface.Width - RideSideX + 2, TextSurface.Height - 18);
            _okButton.Click   += (sender, r) =>
            {
                this.DialogResult = true;
                _selectedColor.A  = byte.Parse(_alphaInput.Text);
                AddPreviousColor(SelectedColor);
                Hide();
            };
            Add(_okButton);

            _cancelButton          = new Button(RideSideX - 4);
            _cancelButton.Text     = "Cancel";
            _cancelButton.Position = new Point(TextSurface.Width - RideSideX + 2, TextSurface.Height - 16);
            _cancelButton.Click   += (sender, r) => { this.DialogResult = false; Hide(); };
            Add(_cancelButton);

            _otherColorsButton          = new Button(RideSideX - 4);
            _otherColorsButton.Text     = "Other Colors";
            _otherColorsButton.Position = new Point(TextSurface.Width - RideSideX + 2, TextSurface.Height - 20);
            _otherColorsButton.Click   += (sender, e) => { otherColorPopup.Show(true); };
            Add(_otherColorsButton);
            #endregion

            _previousColors                      = new ListBox <ListBoxItemColor>(RideSideX - 4, TextSurface.Height - 20 - 9 + 1);
            _previousColors.Position             = new Point(TextSurface.Width - RideSideX + 2, 8);
            _previousColors.SelectedItemChanged += (sender, e) => { if (_previousColors.SelectedItem != null)
                                                                    {
                                                                        SelectedColor = (Color)_previousColors.SelectedItem;
                                                                    }
            };
            Add(_previousColors);

            this.CloseOnESC = true;
            this.Title      = "Select Color";
        }