示例#1
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);
        }