Пример #1
0
        public static Brush CreateBackgroundBrush(Color color, BackgroundColorStyle style)
        {
            switch (style)
            {
            case BackgroundColorStyle.Solid:
                return(new SolidColorBrush(color));

            case BackgroundColorStyle.Radial:
                return(new RadialGradientBrush(Colors.White, color));

            case BackgroundColorStyle.LeftToRight:
                return(new LinearGradientBrush(color, Colors.White, new Point(0, 0.5), new Point(1.1, 0.5)));

            case BackgroundColorStyle.RightToLeft:
                return(new LinearGradientBrush(color, Colors.White, new Point(1, 0.5), new Point(-0.1, 0.5)));

            case BackgroundColorStyle.TopToBottom:
                return(new LinearGradientBrush(color, Colors.White, new Point(0.5, 0), new Point(0.5, 1.1)));

            case BackgroundColorStyle.BottomToTop:
                return(new LinearGradientBrush(color, Colors.White, new Point(0.5, 1), new Point(0.5, -0.1)));

            case BackgroundColorStyle.TopLeftToBottomRight:
                return(new LinearGradientBrush(color, Colors.White, new Point(0.0, 0.0), new Point(1.1, 1.1)));

            case BackgroundColorStyle.BottomRightToTopLeft:
                return(new LinearGradientBrush(color, Colors.White, new Point(1, 1), new Point(-0.1, -0.1)));

            default:
                return(new SolidColorBrush(color));
            }
        }
Пример #2
0
        public StyleButton(MainWindow owner, Color backgroundColor, BackgroundColorStyle backgroundStyle, Color foregroundColor)
        {
            this.backgroundColor = backgroundColor;
            this.backgroundStyle = backgroundStyle;
            this.foregroundColor = foregroundColor;
            this.owner           = owner;
            this.Background      = Brushes.White;
            this.Width           = 40;
            this.Height          = 40;
            this.Margin          = new System.Windows.Thickness(2);
            this.Focusable       = false;

            Canvas canvas = new Canvas();

            this.Content = canvas;
            this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            this.VerticalContentAlignment   = System.Windows.VerticalAlignment.Top;

            MyShape shape = ShapeFactory.CreateFlowchartSymbol9();

            shape.Draw(28, 28, new MyPoint(0, 0), Statics.CreateBackgroundBrush(backgroundColor, backgroundStyle), OnMouseDown, canvas);

            TextBlock textBlock = new TextBlock();

            textBlock.Foreground       = new SolidColorBrush(foregroundColor);
            textBlock.Text             = "A";
            textBlock.IsHitTestVisible = false;
            textBlock.Margin           = new System.Windows.Thickness(10, 5, 0, 0);

            canvas.Children.Add(textBlock);

            this.Click += OnClick;
        }
Пример #3
0
        private void SetBackgroundStyleColor(BackgroundColorStyle style)
        {
            switch (style)
            {
            case BackgroundColorStyle.Solid:
                radioButton1.IsChecked = true;
                break;

            case BackgroundColorStyle.Radial:
                radioButton2.IsChecked = true;
                break;

            case BackgroundColorStyle.LeftToRight:
                radioButton3.IsChecked = true;
                break;

            case BackgroundColorStyle.RightToLeft:
                radioButton4.IsChecked = true;
                break;

            case BackgroundColorStyle.TopToBottom:
                radioButton5.IsChecked = true;
                break;

            case BackgroundColorStyle.BottomToTop:
                radioButton6.IsChecked = true;
                break;

            case BackgroundColorStyle.TopLeftToBottomRight:
                radioButton7.IsChecked = true;
                break;

            case BackgroundColorStyle.BottomRightToTopLeft:
                radioButton8.IsChecked = true;
                break;
            }
        }
Пример #4
0
        public ShapeButton(MyShape shape, MainWindow owner, Color backgroundColor, Color foreGroundColor, BackgroundColorStyle backgroundStyle, WrapPanel wrapPanel)
        {
            this.Shape           = shape;
            this.Owner           = owner;
            this.Button          = new Button();;
            this.BackgroundColor = backgroundColor;
            this.ForeGroundColor = foreGroundColor;
            this.BackgroundStyle = backgroundStyle;

            if (!Statics.ShapeLibrary.ContainsKey(shape.Name))
            {
                Statics.ShapeLibrary.Add(shape.Name, shape);
            }

            Canvas canvas = new Canvas();

            Button.Content = canvas;
            Button.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            Button.VerticalContentAlignment   = System.Windows.VerticalAlignment.Top;
            Button.Background = Brushes.White;

            Brush brush = new SolidColorBrush(Colors.SteelBlue);

            double x = (61 - shape.LeftSideWidth) / 2;
            double y = (35 - shape.LeftSideHeight) / 2;

            canvas.Margin = new Thickness(x, y, 0, 0);

            shape.Draw(shape.LeftSideWidth, shape.LeftSideHeight, new MyPoint(0, 0), brush, OnClick, canvas);
            Button.Width   = 68;
            Button.Height  = 45;
            Button.Padding = new Thickness(0);
            Button.Click  += OnClick;
            Button.Margin  = new Thickness(5);

            wrapPanel.Children.Add(Button);
        }