Наследование: System.Windows.Controls.Control
Пример #1
0
        /// <summary>
        /// When overridden in a derived class, returns a <see cref="T:System.Windows.DataTemplate"/> based on custom logic.
        /// </summary>
        /// <returns>
        /// Returns a <see cref="T:System.Windows.DataTemplate"/> or null. The default value is null.
        /// </returns>
        /// <param name="item">The data object for which to select the template.</param><param name="container">The data-bound object.</param>
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is null)
            {
                return(null);
            }

            ListBox listBox = null;
            var     parent  = container;

            while (parent != null)
            {
                parent  = VisualTreeHelper.GetParent(parent);
                listBox = parent as ListBox;
                if (listBox != null)
                {
                    break;
                }
            }

            if (listBox is null)
            {
                return(null);
            }

            ColorGallery colorGallery = null;

            while (parent != null)
            {
                parent       = VisualTreeHelper.GetParent(parent);
                colorGallery = parent as ColorGallery;
                if (colorGallery != null)
                {
                    break;
                }
            }

            if (colorGallery is null)
            {
                return(null);
            }

            var index = listBox.Items.IndexOf(item);

            if (index < colorGallery.Columns)
            {
                return(listBox.TryFindResource("GradientColorTopDataTemplate") as DataTemplate);
            }

            if (index >= listBox.Items.Count - colorGallery.Columns)
            {
                return(listBox.TryFindResource("GradientColorBottomDataTemplate") as DataTemplate);
            }

            return(listBox.TryFindResource("GradientColorCenterDataTemplate") as DataTemplate);
        }
Пример #2
0
        // Handles selected color changed
        private static void OnSelectedColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorGallery gallery = d as ColorGallery;

            // Raise event
            gallery.RaiseEvent(new RoutedEventArgs(ColorGallery.SelectedColorChangedEvent));
            // Set color in gallery
            Color?color = (Color?)e.NewValue;

            gallery.UpdateSelectedColor(color);
        }
Пример #3
0
        private static void OnThemeColorsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ColorGallery gal = d as ColorGallery;

            gal.ThemeColors.Clear();
            if (e.NewValue != null)
            {
                foreach (Color color in (e.NewValue as IEnumerable <Color>))
                {
                    gal.ThemeColors.Add(color);
                }
            }
        }
Пример #4
0
    void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
    {
        switch (connectionId)
        {
        case 1:
            this.CancelButton = ((Fluent.Button)(target));
            return;

        case 2:
            this.OKButton = ((Fluent.Button)(target));
            return;

        case 3:
            this.RowsTextBox = ((Fluent.Spinner)(target));
            return;

        case 4:
            this.CellsTextBox = ((Fluent.Spinner)(target));
            return;

        case 5:
            this.BorderColorButton = ((Fluent.DropDownButton)(target));
            return;

        case 6:
            this.BorderColorGallery = ((Fluent.ColorGallery)(target));
            return;

        case 7:
            this.BackgroundColorGallery = ((Fluent.ColorGallery)(target));
            return;

        case 8:
            this.PreviewBox = ((System.Windows.Controls.RichTextBox)(target));
            return;

        case 9:
            this.CellBorderColorButton = ((Fluent.DropDownButton)(target));
            return;

        case 10:
            this.CellBorderColorGallery = ((Fluent.ColorGallery)(target));
            return;

        case 11:
            this.CellBackgroundColorGallery = ((Fluent.ColorGallery)(target));
            return;
        }
        this._contentLoaded = true;
    }
Пример #5
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.window = ((Fluent.Sample.ColorGallery.Window)(target));
                return;

            case 2:
                this.A = ((Fluent.RibbonGroupBox)(target));
                return;

            case 3:
                this.colorPickerStandard = ((Fluent.DropDownButton)(target));
                return;

            case 4:
                this.colorGalleryStandard = ((Fluent.ColorGallery)(target));
                return;

            case 5:
                this.colorPickerThemed = ((Fluent.DropDownButton)(target));
                return;

            case 6:
                this.colorGalleryThemed = ((Fluent.ColorGallery)(target));
                return;

            case 7:
                this.colorPickerHighlight = ((Fluent.DropDownButton)(target));
                return;

            case 8:
                this.colorGalleryHighlight = ((Fluent.ColorGallery)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #6
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.groupL = ((Fluent.RibbonGroupBox)(target));
                return;

            case 2:
                this.select = ((Fluent.Button)(target));

            #line 52 "..\..\MainWindow.xaml"
                this.select.Click += new System.Windows.RoutedEventHandler(this.SelectButton_Click);

            #line default
            #line hidden
                return;

            case 3:
                this.cobFF = ((Fluent.ComboBox)(target));
                return;

            case 4:
                this.cobFS = ((Fluent.ComboBox)(target));
                return;

            case 5:
                this.cobFC = ((Fluent.ComboBox)(target));
                return;

            case 6:
                this.colorGallery = ((Fluent.ColorGallery)(target));

            #line 75 "..\..\MainWindow.xaml"
                this.colorGallery.SelectedColorChanged += new System.Windows.RoutedEventHandler(this.ColorGallery_SelectedColorChanged);

            #line default
            #line hidden
                return;

            case 7:

            #line 92 "..\..\MainWindow.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.EraserButton_Click);

            #line default
            #line hidden
                return;

            case 8:

            #line 93 "..\..\MainWindow.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ArrowButton_Click);

            #line default
            #line hidden
                return;

            case 9:

            #line 94 "..\..\MainWindow.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.PenButton_Click);

            #line default
            #line hidden
                return;

            case 10:
                this.Tools = ((Fluent.RibbonGroupBox)(target));
                return;

            case 11:
                this.toolsGallery = ((Fluent.InRibbonGallery)(target));

            #line 123 "..\..\MainWindow.xaml"
                this.toolsGallery.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.InRibbonGallery_SelectionChanged);

            #line default
            #line hidden
                return;

            case 12:
                this.gro = ((Fluent.RibbonGroupBox)(target));
                return;

            case 13:
                this.IsCheckBox14 = ((Fluent.CheckBox)(target));
                return;

            case 14:
                this.IsCheckBox15 = ((Fluent.CheckBox)(target));
                return;

            case 15:
                this.IsCheckBox16 = ((Fluent.CheckBox)(target));
                return;

            case 16:
                this.canvas = ((System.Windows.Controls.InkCanvas)(target));

            #line 174 "..\..\MainWindow.xaml"
                this.canvas.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.ink_MouseWheel);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }