Exemple #1
0
        ShapeCategory CheckShapeCategory(ComponentShape shape)
        {
            switch (shape)
            {
            case ComponentShape.Hexagon:
            case ComponentShape.Octagon:
                return(ShapeCategory.Polygon);

            default:
                return(ShapeCategory.Border);
            }
        }
Exemple #2
0
 protected override void InitDefaultStyle()
 {
     base.InitDefaultStyle();
     _shape = ComponentShape.Octagon;
 }
 protected override void InitDefaultStyle()
 {
     base.InitDefaultStyle();
     _shape = ComponentShape.RectangleRounded1;
 }
Exemple #4
0
        void OnComponentShapeChanged()
        {
            ComponentShape shape = this.Shape;

            container.Children.Clear();

            ShapeCategory shapeCategory = CheckShapeCategory(shape);

            if (shapeCategory == ShapeCategory.Border)
            {
                Border border = new Border();
                shapeElement = border;
                container.Children.Add(border);

                SolidColorBrush brush = new SolidColorBrush();
                border.BorderBrush = brush;
                Binding binding = new Binding("BorderColor")
                {
                    Source = this, Mode = BindingMode.OneWay
                };
                BindingOperations.SetBinding(brush, SolidColorBrush.ColorProperty, binding);

                brush             = new SolidColorBrush();
                border.Background = brush;
                binding           = new Binding("BackgroundColor")
                {
                    Source = this, Mode = BindingMode.OneWay
                };
                BindingOperations.SetBinding(brush, SolidColorBrush.ColorProperty, binding);

                binding = new Binding("BorderThickness")
                {
                    Source = this, Mode = BindingMode.OneWay
                };
                border.SetBinding(Border.BorderThicknessProperty, binding);

                if (shape == ComponentShape.RectangleRounded1)
                {
                    border.CornerRadius = new CornerRadius(10);
                }
                else if (shape == ComponentShape.RectangleRounded2)
                {
                    border.CornerRadius = new CornerRadius(5);
                }
            }
            else if (shapeCategory == ShapeCategory.Polygon)
            {
                Polygon polygon = new Polygon();
                shapeElement = polygon;
                container.Children.Add(polygon);

                SolidColorBrush brush = new SolidColorBrush();
                polygon.Stroke = brush;
                Binding binding = new Binding("BorderColor")
                {
                    Source = this, Mode = BindingMode.OneWay
                };
                BindingOperations.SetBinding(brush, SolidColorBrush.ColorProperty, binding);

                brush        = new SolidColorBrush();
                polygon.Fill = brush;
                binding      = new Binding("BackgroundColor")
                {
                    Source = this, Mode = BindingMode.OneWay
                };
                BindingOperations.SetBinding(brush, SolidColorBrush.ColorProperty, binding);

                binding = new Binding("BorderThickness")
                {
                    Source = this, Mode = BindingMode.OneWay
                };
                polygon.SetBinding(Polygon.StrokeThicknessProperty, binding);

                DecoratePolygon();
            }
        }