Exemple #1
0
        protected override DependencyObject GetContainerForItemOverride()
        {
            MultiSliderThumb multiSliderThumb = new MultiSliderThumb();

            multiSliderThumb.AddHandler(Mouse.MouseDownEvent, (Delegate) new MouseButtonEventHandler(this.Thumb_OnPointerButtonDown));
            return((DependencyObject)multiSliderThumb);
        }
Exemple #2
0
        private static Style GetDefaultStyle()
        {
            Style           style           = new Style(typeof(MultiSliderThumb));
            ControlTemplate controlTemplate = new ControlTemplate(typeof(MultiSliderThumb));

            style.Setters.Add((SetterBase) new Setter(Control.TemplateProperty, (object)controlTemplate));
            Brush brush = MultiSliderThumb.MakeCheckerboardBrush(MultiSliderThumb.checkerboardSize);

            style.Setters.Add((SetterBase) new Setter(Control.BackgroundProperty, (object)brush));
            FrameworkElementFactory frameworkElementFactory = new FrameworkElementFactory(typeof(Canvas), "mainCanvas");

            controlTemplate.VisualTree = frameworkElementFactory;
            GeometryConverter       geometryConverter = new GeometryConverter();
            FrameworkElementFactory child1            = new FrameworkElementFactory(typeof(Path), "outerPath");

            child1.SetValue(Shape.FillProperty, (object)Brushes.White);
            child1.SetValue(Shape.StrokeProperty, (object)Brushes.Black);
            child1.SetValue(Shape.StrokeThicknessProperty, (object)1.0);
            child1.SetValue(Shape.StrokeLineJoinProperty, (object)PenLineJoin.Round);
            child1.SetValue(Path.DataProperty, geometryConverter.ConvertFromInvariantString("M 0 8 L 8 0 L 16 8 L 16 20 L 0 20 Z"));
            child1.SetValue(Canvas.TopProperty, (object)12.0);
            child1.SetValue(Canvas.LeftProperty, (object)-8.0);
            frameworkElementFactory.AppendChild(child1);
            FrameworkElementFactory child2 = new FrameworkElementFactory(typeof(Path), "innerPath");

            child2.SetValue(Shape.FillProperty, (object)Brushes.Black);
            child2.SetValue(Shape.StrokeProperty, (object)Brushes.Black);
            child2.SetValue(UIElement.VisibilityProperty, (object)Visibility.Hidden);
            child2.SetValue(Shape.StrokeThicknessProperty, (object)1.0);
            child2.SetValue(Shape.StrokeLineJoinProperty, (object)PenLineJoin.Round);
            child2.SetValue(Path.DataProperty, geometryConverter.ConvertFromInvariantString("M 3 0 L 6 3 L 0 3 Z"));
            child2.SetValue(Canvas.TopProperty, (object)15.0);
            child2.SetValue(Canvas.LeftProperty, (object)-3.0);
            frameworkElementFactory.AppendChild(child2);
            FrameworkElementFactory child3 = new FrameworkElementFactory(typeof(Rectangle), "innerRectangle");

            child3.SetValue(Shape.FillProperty, (object)new TemplateBindingExtension(Control.ForegroundProperty));
            child3.SetValue(Shape.FillProperty, (object)Brushes.Blue);
            child3.SetValue(Shape.StrokeProperty, (object)Brushes.Black);
            child3.SetValue(Shape.StrokeThicknessProperty, (object)0.25);
            child3.SetValue(Shape.StrokeLineJoinProperty, (object)PenLineJoin.Round);
            child3.SetValue(FrameworkElement.WidthProperty, (object)12.0);
            child3.SetValue(FrameworkElement.HeightProperty, (object)8.0);
            child3.SetValue(Canvas.TopProperty, (object)21.0);
            child3.SetValue(Canvas.LeftProperty, (object)-6.0);
            frameworkElementFactory.AppendChild(child3);
            Trigger trigger = new Trigger();

            trigger.Property = Selector.IsSelectedProperty;
            trigger.Value    = (object)true;
            trigger.Setters.Add((SetterBase) new Setter(UIElement.VisibilityProperty, (object)Visibility.Visible, "innerPath"));
            trigger.Setters.Add((SetterBase) new Setter(Shape.StrokeThicknessProperty, (object)2.0, "outerPath"));
            controlTemplate.Triggers.Add((TriggerBase)trigger);
            return(style);
        }
Exemple #3
0
        private bool Update(Point pointerPosition, MultiSlider.SequencePosition sequencePosition)
        {
            if (sequencePosition == MultiSlider.SequencePosition.First)
            {
                if (pointerPosition.X < -2.0 || (pointerPosition.X > this.RenderSize.Width + 2.0 || pointerPosition.Y < -2.0) || pointerPosition.Y > this.RenderSize.Height + 2.0)
                {
                    return(false);
                }
            }
            else if (pointerPosition.Y > this.RenderSize.Height + 16.0)
            {
                if (!this.haveRemovedThumb && MultiSlider.DragOff.CanExecute((object)null, (IInputElement)this) && this.Items.Count > this.MinimumItemCount)
                {
                    MultiSlider.DragOff.Execute((object)null, (IInputElement)this);
                    this.haveRemovedThumb = true;
                }
                if (this.haveRemovedThumb)
                {
                    return(true);
                }
            }
            double minimum = this.Minimum;
            double maximum = this.Maximum;
            double num1    = pointerPosition.X / this.ActualWidth;
            double num2    = Math.Round(Math.Min(maximum, Math.Max(minimum, minimum + num1 * (maximum - minimum))), 3);

            if (sequencePosition == MultiSlider.SequencePosition.First)
            {
                ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, (object)null);
                if (MultiSlider.Click.CanExecute((object)num2, (IInputElement)this))
                {
                    MultiSlider.Click.Execute((object)num2, (IInputElement)this);
                }
            }
            else if (this.haveRemovedThumb)
            {
                if (MultiSlider.DragOn.CanExecute((object)null, (IInputElement)this))
                {
                    MultiSlider.DragOn.Execute((object)null, (IInputElement)this);
                }
                this.haveRemovedThumb = false;
            }
            if (sequencePosition == MultiSlider.SequencePosition.Middle)
            {
                MultiSliderThumb multiSliderThumb = this.ItemContainerGenerator.ContainerFromItem(this.SelectedItem) as MultiSliderThumb;
                if (multiSliderThumb != null && multiSliderThumb.SliderValue != num2)
                {
                    multiSliderThumb.SliderValue = num2;
                    ValueEditorUtils.ExecuteCommand(this.ContinueEditCommand, (IInputElement)this, (object)null);
                }
            }
            return(true);
        }
Exemple #4
0
        private void Thumb_OnPointerButtonDown(object sender, MouseButtonEventArgs args)
        {
            this.lastMousePosition = args.MouseDevice.GetPosition((IInputElement)this);
            MultiSliderThumb thumb = sender as MultiSliderThumb;

            if (args.ChangedButton != MouseButton.Left || thumb == null)
            {
                return;
            }
            this.Focus();
            this.haveRemovedThumb = false;
            this.SelectedIndex    = this.ElementIndex(thumb);
            ValueEditorUtils.ExecuteCommand(this.BeginEditCommand, (IInputElement)this, (object)null);
            InputManager.Current.PostNotifyInput += new NotifyInputEventHandler(this.Current_PostNotifyInput);
            this.isButtonDown = true;
            args.MouseDevice.Capture((IInputElement)this);
            args.Handled = true;
        }
Exemple #5
0
        private static Style GetDefaultStyle()
        {
            Style           style           = new Style(typeof(MultiSlider));
            ControlTemplate controlTemplate = new ControlTemplate(typeof(MultiSlider));

            style.Setters.Add((SetterBase) new Setter(Control.TemplateProperty, (object)controlTemplate));
            Brush brush = MultiSliderThumb.MakeCheckerboardBrush(MultiSlider.checkerboardSize);

            style.Setters.Add((SetterBase) new Setter(Control.BackgroundProperty, (object)brush));
            FrameworkElementFactory frameworkElementFactory = new FrameworkElementFactory(typeof(Grid), "mainGrid");

            frameworkElementFactory.SetValue(UIElement.ClipToBoundsProperty, (object)false);
            frameworkElementFactory.SetValue(FrameworkElement.WidthProperty, (object)new TemplateBindingExtension(FrameworkElement.WidthProperty));
            frameworkElementFactory.SetValue(FrameworkElement.HeightProperty, (object)new TemplateBindingExtension(FrameworkElement.HeightProperty));
            controlTemplate.VisualTree = frameworkElementFactory;
            FrameworkElementFactory child1 = new FrameworkElementFactory(typeof(Border), "mainBorder");

            child1.SetValue(Border.BackgroundProperty, (object)new TemplateBindingExtension(Control.BackgroundProperty));
            child1.SetValue(Border.BorderBrushProperty, (object)new TemplateBindingExtension(Control.BorderBrushProperty));
            child1.SetValue(Border.BorderThicknessProperty, (object)new TemplateBindingExtension(Control.BorderThicknessProperty));
            frameworkElementFactory.AppendChild(child1);
            FrameworkElementFactory child2 = new FrameworkElementFactory(typeof(Border), "fillBorder");

            child2.SetValue(Border.BackgroundProperty, (object)new TemplateBindingExtension(Control.ForegroundProperty));
            child2.SetValue(Border.BorderBrushProperty, (object)Brushes.Transparent);
            child2.SetValue(Border.BorderThicknessProperty, (object)new TemplateBindingExtension(Control.BorderThicknessProperty));
            frameworkElementFactory.AppendChild(child2);
            FrameworkElementFactory child3 = new FrameworkElementFactory(typeof(Canvas), "itemsCanvas");

            child3.SetValue(UIElement.ClipToBoundsProperty, (object)false);
            child3.SetValue(Panel.IsItemsHostProperty, (object)true);
            frameworkElementFactory.AppendChild(child3);
            Trigger trigger = new Trigger();

            trigger.Property = UIElement.IsEnabledProperty;
            trigger.Value    = (object)false;
            trigger.Setters.Add((SetterBase) new Setter(UIElement.OpacityProperty, (object)0.5));
            style.Triggers.Add((TriggerBase)trigger);
            return(style);
        }
Exemple #6
0
 private int ElementIndex(MultiSliderThumb thumb)
 {
     return(this.ItemContainerGenerator.IndexFromContainer((DependencyObject)thumb));
 }
Exemple #7
0
        static MultiSliderThumb()
        {
            Style defaultStyle = MultiSliderThumb.GetDefaultStyle();

            FrameworkElement.StyleProperty.OverrideMetadata(typeof(MultiSliderThumb), (PropertyMetadata) new FrameworkPropertyMetadata((object)defaultStyle));
        }