Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
 void UndoClearAction()
 {
     while (TransferClass.ClearShape.Count != 0)
     {
         MyShape temp = TransferClass.ClearShape.Pop();
         MyCanvas.Children.Add(temp.Draw());
         TransferClass.ActiveShape.Push(temp);
     }
 }
Ejemplo n.º 3
0
        private void btnRedo_Click(object sender, RoutedEventArgs e)
        {
            if (TransferClass.Undo.Count == 0)
            {
                return;
            }
            MyShape shape = TransferClass.Undo.Pop();

            MyCanvas.Children.Add(shape.Draw());
            TransferClass.ActiveShape.Push(shape);
        }
Ejemplo n.º 4
0
        void AddShapeOnCanvas()
        {
            MyShape shape = TransferClass.NewShape;

            if (shape == null)
            {
                return;
            }
            TransferClass.ActiveShape.Push(shape);
            MyCanvas.Children.Add(shape.Draw());
        }
Ejemplo n.º 5
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);
        }