コード例 #1
0
 private void setActive(GoodShape shape)
 {
     if(shape != null)
     {
         if (bo != null) bo.hide();
         bo = shape.Bound;
         currentShape = shape;
         sim.setObjects(shape.GetType(), ShapeInfo);
         bo.show();
         bo.Focus();
     }
 }
コード例 #2
0
        void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point pos = e.GetPosition(drawingSurface);
            if (bo != null)
                if (!bo.contains(pos))
                {
                    bo.hide();
                    bo = null;
                    return;
                }
            if (bo == null)
            {
                bo = new Bound(canvas, pos);
                bo.LostFocus += bo_LostFocus;
                bo.Focus();
                if (Star.IsChecked == true)
                {

                    currentShape = new GoodStar(5, 0.4, bo);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), BorderThickness.Value);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if (Polygon.IsChecked == true)
                {

                    currentShape = new GoodPolygon(7, bo);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), BorderThickness.Value);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if(Ellipse.IsChecked == true)
                {
                    currentShape = new GoodEllipse(bo);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), BorderThickness.Value);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if (Rectangle.IsChecked == true)
                {
                    currentShape = new GoodRectangle(bo, 0, 0);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), 1);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if (Picker.IsChecked == true)
                {

                }
            }
        }