예제 #1
0
 public void DeselectAllShapes()
 {
     foreach (Shape SelectedShape in ShapesDrawn)
     {
         SelectedShape.Deselect();
     }
 }
예제 #2
0
        public MainWindow()
        {
            _shape       = SelectedShape.Free;
            _strokeOrNot = SelectStrokeOrNot.None;

            InitializeComponent();
        }
예제 #3
0
        private HitTestInfo?HitTest(Point pt)
        {
            HitTestInfo?hti = null;

            foreach (var cp in m_ControlPoints)
            {
                hti = cp.HitTest(pt);
                if (hti.HasValue)
                {
                    return(hti);
                }
            }

            if (SelectedShape != null)
            {
                hti = SelectedShape.HitTest(pt);
                if (hti.HasValue)
                {
                    return(hti);
                }
            }

            foreach (var p in InverseShapes)
            {
                hti = p.HitTest(pt);
                if (hti.HasValue)
                {
                    return(hti);
                }
            }
            return(null);
        }
예제 #4
0
        //--------------------------------------------------------------------------------------------------


        #endregion

        #region Visualization

        void _UpdateAisShape()
        {
            try
            {
                if (_AisShape != null)
                {
                    // Remove AIS Shape
                    WorkspaceController.Workspace.AisContext.Remove(_AisShape, false);
                    WorkspaceController.Workspace.AisContext.Erase(_AisShape, false);
                    _AisShape = null;
                }

                var ocShape = SelectedNode?.BrepShape;
                var trsf    = SelectedShape?.GetTransformation();
                if (ocShape != null && trsf != null)
                {
                    // Init AIS Shape
                    _AisShape = new AIS_Shape(ocShape);
                    _AisShape.SetLocalTransformation(trsf.Value);
                    _AisShape.SetZLayer(-2); // Graphic3d_ZLayerId_Top
                    _AisShape.SetColor(Quantity_NameOfColor.Quantity_NOC_BLUE1.ToColor());
                    _AisShape.Attributes().LineAspect().SetColor(Quantity_NameOfColor.Quantity_NOC_BLUE1.ToColor());
                    _AisShape.SetWidth(3);
                    _AisShape.Attributes().PointAspect().SetScale(3);

                    WorkspaceController.Workspace.AisContext.Display(_AisShape, false);
                    WorkspaceController.Workspace.AisContext.Deactivate(_AisShape);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            WorkspaceController.Invalidate();
        }
예제 #5
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            foreach (var aShape in myCollector.GetShapes())
            {
                Pen        myPen   = new Pen(aShape.drawColor, 5);
                SolidBrush myBrush = new SolidBrush(aShape.fillColor);
                Rectangle  rect    = aShape.rectangle;

                SelectedShape selectedShapeTemp = SelectedShape.circle;
                if (aShape is MySquare)
                {
                    selectedShapeTemp = SelectedShape.square;
                }
                else if (aShape is MyRectangle)
                {
                    selectedShapeTemp = SelectedShape.rectangle;
                }


                drawMyShape(e.Graphics, myPen, myBrush, rect, selectedShapeTemp);
            }

            if (firstLocation != null && secondLocation != null)
            {
                Pen        myPen   = new Pen(colorDialog1.Color, 5);
                SolidBrush myBrush = new SolidBrush(colorDialog2.Color);

                Rectangle rect = GetRectangle();
                drawMyShape(e.Graphics, myPen, myBrush, rect, selectedShape);
            }

            e.Graphics.Dispose();
        }
예제 #6
0
        protected override void OnPropertyChanged(string name)
        {
            base.OnPropertyChanged(name);
            switch (name)
            {
            case "SelectedStyle":
                LevelBasedStyleChanged();
                break;

            case "SelectedShape":
                if (SelectedShape != null)
                {
                    LevelBasedShapeChanged();
                    SelectedDiagramLevelShapes[SelectedLevel] = SelectedShape.ToString();
                }
                break;

            case "IsStraightConnectorType":
                ConnectorTypeChanged();
                break;

            case "SelectedLevel":
                UpdateTopics();
                SelectedLevelChanged();
                break;
            }
        }
예제 #7
0
 private void LevelBasedShapeChanged()
 {
     if (SelectedShape != null)
     {
         string obj = SelectedShape.ToString();
         if (SelectedDiagramLevelShapes.ContainsKey(SelectedLevel))
         {
             SelectedDiagramLevelShapes[SelectedLevel] = obj;
         }
         else
         {
             SelectedDiagramLevelShapes.Add(SelectedLevel, obj);
         }
         foreach (NodeViewModel nodeVM in StyleDiagram.Nodes as NodeCollection)
         {
             if (((nodeVM is Root) ? (nodeVM as Root).Level : (nodeVM as RootChild).Level) == SelectedLevel)
             {
                 //nodeVM.Shape = Application.Current.Resources[obj];
                 if (nodeVM is Root)
                 {
                     (nodeVM as Root).ShapeName = obj.ToString();
                 }
                 else
                 {
                     (nodeVM as RootChild).ShapeName = obj.ToString();
                 }
             }
         }
     }
 }
예제 #8
0
 public void UnExecute()
 {
     foreach (Shape SelectedShape in AllShape)
     {
         SelectedShape.Translate(XPoint, YPoint, -1 * XDistance, -1 * YDistance);
     }
 }
예제 #9
0
 private void MouseDown_Select(Point eLocation)
 {
     //Nếu nhấn phím CTRL, sẽ chọn đồng thời nhiều shape. Nếu hình đã chọn mà chọn lần 2, sẽ thành bỏ chọn
     if (IsCTRL_pressed)
     {
         DrawObj.ForEach((Action <MyShapes>)(shape =>
         {
             if (shape.Select(eLocation))
             {
                 shape.IsSelected = !shape.IsSelected;
             }
         }));
     }
     //Nếu không nhấn CTRL, chỉ có thể chọn duy nhất 1 hình rồi return
     else
     {
         SelectedShape = SelectShape(eLocation);
         FirstPoint    = eLocation;
         if (SelectedShape != null)
         {
             UpdateInfo();
             if (IsZooming)
             {
                 SelectedShape.SelectPoint(eLocation);
             }
             IsDrawRegion = false;
         }
         else    //Draw a rectangle region
         {
             IsDrawRegion   = true;
             SelectedRegion = new Rectangle(eLocation, new Size(0, 0));
         }
     }
     RePaint();
 }
예제 #10
0
 public override void SetOutlineColor(Color InputColor)
 {
     base.SetOutlineColor(InputColor);
     foreach (Shape SelectedShape in GroupShape)
     {
         SelectedShape.SetOutlineColor(InputColor);
     }
 }
예제 #11
0
        public void OriginalOutlineColorTest()
        {
            SelectedShape target = new SelectedShape(); // TODO: Initialize to an appropriate value
            uint          actual;

            actual = target.OriginalOutlineColor;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #12
0
        public void OriginalDrawFillTest()
        {
            SelectedShape target = new SelectedShape(); // TODO: Initialize to an appropriate value
            bool          actual;

            actual = target.OriginalDrawFill;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #13
0
        public void ShapeIndexTest()
        {
            SelectedShape target = new SelectedShape(); // TODO: Initialize to an appropriate value
            int           actual;

            actual = target.ShapeIndex;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #14
0
 private void CanvasPaint(object Sender, PaintEventArgs Event)
 {
     foreach (Shape SelectedShape in ShapesDrawn)
     {
         SelectedShape.SetGraphics(Event.Graphics);
         SelectedShape.Draw();
     }
 }
예제 #15
0
        public void OriginalTransparencyTest()
        {
            SelectedShape target = new SelectedShape(); // TODO: Initialize to an appropriate value
            float         actual;

            actual = target.OriginalTransparency;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #16
0
 public override void RenderOnModify()
 {
     foreach (Shape SelectedShape in GroupShape)
     {
         SelectedShape.SetGraphics(ShapeGraphics);
         SelectedShape.RenderOnModify();
     }
 }
예제 #17
0
        public void AddSelectedShapeTest()
        {
            SelectInfo    target   = new SelectInfo(); // TODO: Initialize to an appropriate value
            SelectedShape newShape = null;             // TODO: Initialize to an appropriate value

            target.AddSelectedShape(newShape);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
예제 #18
0
        private void OnPickShapes(object sender, EventArgs e)
        {
            var pickerDialog = new ShapePickerDialog();

            if (pickerDialog.ShowDialog() == DialogResult.OK)
            {
                _currentShape = pickerDialog.SelectedShape;
            }
        }
예제 #19
0
 private void Copy_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (SelectedShape != null)
     {
         var xDoc = new XDocument(new XElement("x"));
         SelectedShape.Export(xDoc.Root, XDrawingExportFormat.DrawingImage);
         Clipboard.SetText(xDoc.Root.FirstNode.ToString());
     }
 }
예제 #20
0
        private void pickShapeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShapePickerDialog dlg = new ShapePickerDialog();

            if (DialogResult.OK == dlg.ShowDialog())
            {
                currentShape = dlg.SelectedShape;
            }
        }
예제 #21
0
        public void AddTest()
        {
            SelectedShape target      = new SelectedShape(); // TODO: Initialize to an appropriate value
            int           ShapeIndex  = 0;                   // TODO: Initialize to an appropriate value
            Color         SelectColor = new Color();         // TODO: Initialize to an appropriate value

            target.Add(ShapeIndex, SelectColor);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
예제 #22
0
 public Form1()
 {
     InitializeComponent();
     myCollector = new ShapeCollector();
     myCollector.CapacityFull    += onCapacityFull;
     myCollector.CapacityReached += onCapacityReached;
     selectedShape   = SelectedShape.none;
     isDrawing       = false;
     capacityReached = false;
 }
예제 #23
0
        private void DrawShape(string Type, Canvas canvas, MouseButtonEventArgs e)
        {
            Shape Rendershape         = null;
            RadialGradientBrush brush = new RadialGradientBrush();

            if (Type == "CIRCLE")
            {
                SelectedShape Shape1 = SelectedShape.Circle;
                Rendershape = new Ellipse()
                {
                    Height = 40, Width = 40
                };
                brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#f23207"), 0.250));
                brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#f57b5f"), 0.500));
                brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#f7b7a8"), 1));
                Rendershape.Fill = brush;
            }
            else
            {
                SelectedShape Shape1 = SelectedShape.Rectangle;
                Rendershape = new Rectangle()
                {
                    Height = 40, Width = 40
                };
                brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#0d4091"), 0.250));
                brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#366bbf"), 0.500));
                brush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#80acf2"), 1));
                Rendershape.Fill = brush;
            }

            double px              = (double)e.GetPosition(canvas).X;
            double currentX        = Rendershape.Height;
            double py              = (double)e.GetPosition(canvas).Y;
            double currentY        = Rendershape.Width;
            double framewidth      = canvas.ActualWidth;
            double frameheight     = canvas.ActualHeight;
            Point  position        = canvas.PointToScreen(new Point(0d, 0d)),
                   controlPosition = this.PointToScreen(new Point(0d, 0d));

            position.X -= controlPosition.X;
            position.Y -= controlPosition.Y;
            if (px + 45L > framewidth)
            {
                double newX = framewidth - 45;
                px = newX;
            }
            if (py + 45L > frameheight)
            {
                double newY = frameheight - 45;
                py = newY;
            }
            Canvas.SetLeft(Rendershape, px);
            Canvas.SetTop(Rendershape, py);
            canvasPosition.Children.Add(Rendershape);
        }
예제 #24
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (radioButtonCircle.Checked)
     {
         SelectedShape = SelectedShape.Circle;
     }
     else
     {
         SelectedShape = SelectedShape.Rectangle;
     }
 }
예제 #25
0
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsMouseDown && SelectedShape != null)
            {
                SelectedShape.Move(e.X - PrevX, e.Y - PrevY);
                Invalidate();

                PrevX = e.X;
                PrevY = e.Y;
            }
        }
예제 #26
0
 public Shape GetShapeAt(int x, int y)
 {
     foreach (Shape SelectedShape in ShapesDrawn)
     {
         if (SelectedShape.Intersect(x, y))
         {
             return(SelectedShape);
         }
     }
     return(null);
 }
예제 #27
0
        public List <Shape> SelectShapeAt(int x, int y, int width, int height)
        {
            List <Shape> SelectedShapes = new List <Shape>();

            foreach (Shape SelectedShape in ShapesDrawn)
            {
                if (SelectedShape.Inside(x, y, width, height))
                {
                    SelectedShape.Select();
                    SelectedShapes.Add(SelectedShape);
                }
            }

            return(SelectedShapes);
        }
예제 #28
0
파일: Model.cs 프로젝트: 106820026/Painter
        // 調整座標位置
        private void RefactorCoordinate(IShape shape)
        {
            double x1 = Math.Min(shape.X1, shape.X2);
            double y1 = Math.Min(shape.Y1, shape.Y2);
            double x2 = Math.Max(shape.X1, shape.X2);
            double y2 = Math.Max(shape.Y1, shape.Y2);

            if (CurrentMode != 1 || (IsSelected && SelectedShape.GetType().ToString() != LINE_TYPE)) // 線的不能改
            {
                shape.X1 = x1;
                shape.Y1 = y1;
                shape.X2 = x2;
                shape.Y2 = y2;
            }
        }
예제 #29
0
        public override bool Intersect(int xTest, int yTest)
        {
            bool IntersectShape = false;

            foreach (Shape SelectedShape in GroupShape)
            {
                if (SelectedShape.Intersect(xTest, yTest))
                {
                    IntersectShape = true;
                    break;
                }
            }

            return(IntersectShape);
        }
예제 #30
0
        public static void ShapeFlipTriggered(bool isHorizontal)
        {
            AudioManager.PlayCue("flip");

            if (isHorizontal)
            {
                CurrentPuzzle.CountHorizontalFlip();
                SelectedShape.StartFlipHorizontal();
            }
            else
            {
                CurrentPuzzle.CountVerticalFlip();
                SelectedShape.StartFlipVertical();
            }
        }
예제 #31
0
		/// <summary>
		/// Getting Shape type
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Shape_Click(object sender, RoutedEventArgs e)
		{
			var currentElement = (Control)sender;
			currentShape = (SelectedShape)Enum.Parse(typeof(SelectedShape), currentElement.Name);
		}
예제 #32
0
 private void rectOption_Click(object sender, RoutedEventArgs e)
 {
     currentShape = SelectedShape.Rectangle;
 }
예제 #33
0
 private void lineOption_Click(object sender, RoutedEventArgs e)
 {
     currentShape = SelectedShape.Line;
 }
예제 #34
0
 private void circleOption_Click(object sender, RoutedEventArgs e)
 {
     currentShape = SelectedShape.Circle;
 }
 /// <summary>
 /// Draw line
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLineDrawClick(object sender, RoutedEventArgs e)
 {
     Shape1 = SelectedShape.Line;
     DrawShape();
 }
 /// <summary>
 /// Draw triangle
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnTriangleDrawClick(object sender, RoutedEventArgs e)
 {
     Shape1 = SelectedShape.Triangle;
     DrawShape();
 }