Beispiel #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            SetCurrentValue(AccentColorBrushProperty, TryFindResource("AccentColorBrush") as SolidColorBrush);

            _listBox  = (ListBox)GetTemplateChild("PART_List");
            _popup    = (Popup)GetTemplateChild("PART_Popup_Color_Board");
            _button   = (ButtonBase)GetTemplateChild("PART_UnselectAll");
            _checkBox = (CheckBox)GetTemplateChild("PART_All_Visible");

            if (_listBox != null)
            {
                _listBox.SelectionChanged += OnListBoxSelectionChanged;

                _listBox.SetCurrentValue(ListBox.SelectionModeProperty, SelectionMode.Extended);

                _listBox.LayoutUpdated += (sender, args) =>
                {
                    UpdateVisibilityControlsVisibility();
                    UpdateColorEditingControlsVisibility();
                };
            }

            if (_button != null)
            {
                _button.Click += (s, e) =>
                {
                    if (_listBox != null)
                    {
                        _listBox.SetCurrentValue(Selector.SelectedIndexProperty, -1);
                    }
                };
            }

            if (_checkBox != null)
            {
                _checkBox.Checked   += (sender, args) => SetCurrentValue(IsAllVisibleProperty, true);
                _checkBox.Unchecked += (sender, args) => SetCurrentValue(IsAllVisibleProperty, false);
            }

            _colorBoard = new ColorBoard();

            if (_popup != null)
            {
                _popup.SetCurrentValue(Popup.ChildProperty, _colorBoard);
            }

            var b = new Binding("Color")
            {
                Mode   = BindingMode.TwoWay,
                Source = _colorBoard
            };

            SetBinding(EditingColorProperty, b);

            _colorBoard.DoneClicked   += ColorBoardDoneClicked;
            _colorBoard.CancelClicked += ColorBoardCancelClicked;
        }
Beispiel #2
0
        /// <summary>
        /// The on apply template.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup = (Popup) GetTemplateChild("PART_Popup");
            _toggleDropDown = (ToggleButton) GetTemplateChild("PART_ToggleButton");
            _colorBoard = new ColorBoard();
            _colorBoard.Color = Color;
            _colorBoard.SizeChanged += colorBoard_SizeChanged;
            _popup.Child = _colorBoard;
            _colorBoard.DoneClicked += colorBoard_DoneClicked;
            _colorBoard.CancelClicked += colorBoard_CancelClicked;

            var b = new Binding("Color");
            b.Mode = BindingMode.TwoWay;
            b.Source = _colorBoard;
            SetBinding(CurrentColorProperty, b);

            KeyDown += ColorPicker_KeyDown;
        }
Beispiel #3
0
        /// <summary>
        /// The on apply template.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup                     = (Popup)GetTemplateChild("PART_Popup");
            _toggleDropDown            = (ToggleButton)GetTemplateChild("PART_ToggleButton");
            _colorBoard                = new ColorBoard();
            _colorBoard.Color          = Color;
            _colorBoard.SizeChanged   += colorBoard_SizeChanged;
            _popup.Child               = _colorBoard;
            _colorBoard.DoneClicked   += colorBoard_DoneClicked;
            _colorBoard.CancelClicked += colorBoard_CancelClicked;

            var b = new Binding("Color");

            b.Mode   = BindingMode.TwoWay;
            b.Source = _colorBoard;
            SetBinding(CurrentColorProperty, b);

            KeyDown += ColorPicker_KeyDown;
        }
Beispiel #4
0
        /// <summary>
        /// The on apply template.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup = (Popup)GetTemplateChild("PART_Popup");

            _colorBoard = new ColorBoard();
            _colorBoard.SetCurrentValue(ColorBoard.ColorProperty, Color);
            _colorBoard.SizeChanged += OnColorBoardSizeChanged;

            _popup.SetCurrentValue(Popup.ChildProperty, _colorBoard);
            _colorBoard.DoneClicked   += OnColorBoardDoneClicked;
            _colorBoard.CancelClicked += OnColorBoardCancelClicked;

            var b = new Binding(nameof(ColorBoard.Color))
            {
                Mode   = BindingMode.TwoWay,
                Source = _colorBoard
            };

            SetBinding(CurrentColorProperty, b);

            KeyDown += OnColorPickerKeyDown;
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            AccentColorBrush = TryFindResource("AccentColorBrush") as SolidColorBrush;

            _listBox  = (ListBox)GetTemplateChild("PART_List");
            _popup    = (Popup)GetTemplateChild("PART_Popup_Color_Board");
            _button   = (ButtonBase)GetTemplateChild("PART_UnselectAll");
            _checkBox = (CheckBox)GetTemplateChild("PART_All_Visible");

            var settingsButton = (DropDownButton)GetTemplateChild("PART_Settings_Button");

            if (settingsButton != null)
            {
                settingsButton.ContentLayoutUpdated += (sender, args) =>
                {
                    if (_manualBindingReady)
                    {
                        return;
                    }

                    if (sender is ContentControl)
                    {
                        var settingsContent = sender as ContentControl;
                        ContentPresenter contentPresenter = FindVisualChild <ContentPresenter>(settingsContent);
                        if (contentPresenter == null)
                        {
                            return;
                        }

                        var content = contentPresenter.Content;
                        if (content == null)
                        {
                            return;
                        }

                        var qryAllChecks = (content as DependencyObject).Descendents().OfType <CheckBox>();

                        var allChecks           = qryAllChecks as CheckBox[] ?? qryAllChecks.ToArray();
                        var cbVisibilitySetting = allChecks.First(cb => cb.Name == "cbVisibilitySetting");
                        if (cbVisibilitySetting != null)
                        {
                            cbVisibilitySetting.IsChecked  = ShowColorVisibilityControls;
                            cbVisibilitySetting.Checked   += (o, e) => ShowColorVisibilityControls = true;
                            cbVisibilitySetting.Unchecked += (o, e) => ShowColorVisibilityControls = false;
                        }

                        var cbColorEditingSetting = allChecks.First(cb => cb.Name == "cbColorEditingSetting");
                        if (cbColorEditingSetting != null)
                        {
                            cbColorEditingSetting.IsChecked  = AllowColorEditing;
                            cbColorEditingSetting.Checked   += (o, e) => AllowColorEditing = true;
                            cbColorEditingSetting.Unchecked += (o, e) => AllowColorEditing = false;
                        }

                        var cbUseRegexSetting = allChecks.First(cb => cb.Name == "cbUseRegexSetting");
                        if (cbUseRegexSetting != null)
                        {
                            cbUseRegexSetting.IsChecked  = UseRegexFiltering;
                            cbUseRegexSetting.Checked   += (o, e) => UseRegexFiltering = true;
                            cbUseRegexSetting.Unchecked += (o, e) => UseRegexFiltering = false;
                        }

                        _manualBindingReady = true;
                    }
                };
            }

            if (_listBox != null)
            {
                _listBox.SelectionChanged += (sender, args) =>
                {
                    SelectedColorItems = GetSelectedList();
                    var handler = SelectionChanged;
                    if (handler != null)
                    {
                        handler(sender, args);
                    }
                };

                _listBox.SelectionMode = SelectionMode.Extended;

                _listBox.LayoutUpdated += (sender, args) =>
                {
                    UpdateVisibilityControlsVisibility();
                    UpdateColorEditingControlsVisibility();
                };
            }

            if (_button != null)
            {
                _button.Click += (s, e) =>
                {
                    if (_listBox != null)
                    {
                        _listBox.SelectedIndex = -1;
                    }
                };
            }

            if (_checkBox != null)
            {
                _checkBox.Checked   += (sender, args) => IsAllVisible = true;
                _checkBox.Unchecked += (sender, args) => IsAllVisible = false;
            }

            _colorBoard = new ColorBoard();
            if (_popup != null)
            {
                _popup.Child = _colorBoard;
            }

            var b = new Binding("Color")
            {
                Mode   = BindingMode.TwoWay,
                Source = _colorBoard
            };

            SetBinding(EditingColorProperty, b);

            _colorBoard.DoneClicked   += ColorBoardDoneClicked;
            _colorBoard.CancelClicked += ColorBoardCancelClicked;
        }