Exemplo n.º 1
0
        public void RemoveFigure(AbstractFigure figure)
        {
            _figures.Remove(figure);
            figure.OnUpdate -= Update;

            Update();
        }
Exemplo n.º 2
0
        public void Deserialize(string str)
        {
            rewind.RemoveAll();
            json = str;

            string[]      jsonRows = json.Split("\n");
            string[]      arrTypes = JsonSerializer.Deserialize(jsonRows[0], jsonRows.GetType()) as string[];
            List <string> notFound = new List <string>();

            System.Type myType;

            rewind.FigureList.Clear();

            for (int i = 0; i < arrTypes.Length; i++)
            {
                myType = System.Type.GetType(arrTypes[i], false, true);
                if (myType == null)
                {
                    myType = pluginControl.FindType(arrTypes[i]);
                }
                if (myType != null)
                {
                    AbstractFigure nfig = JsonSerializer.Deserialize(jsonRows[i + 1], myType) as AbstractFigure;
                    rewind.AddToFigureList(nfig = nfig.GetCopy());
                    nfig.Draw(Canva);
                }
                else
                if (!notFound.Contains(arrTypes[i]))
                {
                    MessageBox.Show(arrTypes[i] + " is missing");
                    notFound.Add(arrTypes[i]);
                }
            }
        }
Exemplo n.º 3
0
        public void TestFigureI()
        {
            figure = new FigureI();
            var schemePhase1 = new Scheme(new[] { "#", "#", "#", "#" });
            var schemePhase2 = new Scheme(new[] { "####" });

            Assert.AreEqual(schemePhase1, figure.GetScheme());
            Assert.AreEqual(1, figure.GetWidth());
            Assert.AreEqual(4, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase2, figure.GetScheme());
            Assert.AreEqual(4, figure.GetWidth());
            Assert.AreEqual(1, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase1, figure.GetScheme());
            Assert.AreEqual(1, figure.GetWidth());
            Assert.AreEqual(4, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase2, figure.GetScheme());
            Assert.AreEqual(4, figure.GetWidth());
            Assert.AreEqual(1, figure.GetHeight());
        }
Exemplo n.º 4
0
        public void TestFigureJ()
        {
            figure = new FigureJ();

            var schemePhase1 = new Scheme(new[] {".#", ".#", "##"} );
            var schemePhase2 = new Scheme(new[] { "#..", "###"} );
            var schemePhase3 = new Scheme(new[] { "##", "#.", "#." } );
            var schemePhase4 = new Scheme(new[] { "###", "..#" } );

            Assert.AreEqual(schemePhase1, figure.GetScheme());
            Assert.AreEqual(2, figure.GetWidth());
            Assert.AreEqual(3, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase2, figure.GetScheme());
            Assert.AreEqual(3, figure.GetWidth());
            Assert.AreEqual(2, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase3, figure.GetScheme());
            Assert.AreEqual(2, figure.GetWidth());
            Assert.AreEqual(3, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase4, figure.GetScheme());
            Assert.AreEqual(3, figure.GetWidth());
            Assert.AreEqual(2, figure.GetHeight());

            figure.Rotate();
            Assert.AreEqual(schemePhase1, figure.GetScheme());
            Assert.AreEqual(2, figure.GetWidth());
            Assert.AreEqual(3, figure.GetHeight());
        }
Exemplo n.º 5
0
        public void AddFigure(AbstractFigure figure)
        {
            _figures.AddLast(figure);
            figure.OnUpdate += Update;

            Update();
        }
Exemplo n.º 6
0
        private void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (PaintMode)
            {
                if (figure is TriangleFigure)
                {
                    if (figure.Points.Count % 3 == 0)
                    {
                        figure = figureFactory.CreateFigure(figure.FigureController);
                    }
                }
                if (!(figure is CurveFigure ||
                      figure is IrregularPolygonFigure ||
                      figure is TriangleFigure))
                {
                    figure = figureFactory.CreateFigure(figure.FigureController);
                }
                if (figure is PolygonFigure)
                {
                    PolygonFigure tmp = (PolygonFigure)figure;
                    tmp.N  = (int)numericUpDown.Value;
                    figure = tmp;
                }
                pictureBox.Image = canvas.TmpBitmap;

                figure.FigureController.MouseDownHandle(e.Location, pen, figure, canvas);
                pictureBox.Image = canvas.MainBitmap;
            }
            if (PaintMode == false)
            {
                toolController.MouseDownHandle(e.Location, pen, figure, canvas, container, tool);
                pictureBox.Image = canvas.MainBitmap;
            }
        }
 public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas)
 {
     _mouseDown = true;
     figure.Update(point);
     canvas.CreateLayer();
     GC.Collect();
 }
Exemplo n.º 8
0
        private void Delete_Fab(object sender, FileSystemEventArgs e)
        {
            int TypeID = 0;

            for (int i = 0; i < Types.Count; i++)
            {
                if (Types[i].Name == e.Name.Split('.')[0])
                {
                    TypeID = i;
                }
            }
            string    Name = FigList.DeleteFig(Types[TypeID]);
            DeleteDel Del  = new DeleteDel(DeleteFromList);

            if (Name != null)
            {
                lvFigures.Invoke(Del, Name);
            }
            SelectedFig    = null;
            SelectedFabric = 0;
            Types.RemoveAt(TypeID);
            Creators.RemoveAt(TypeID);
            Buttons.RemoveAt(TypeID);
            RedrawButtons(Buttons, TypeID);
            Domains.RemoveAt(TypeID);
            MainView.Image = Canvas;
        }
Exemplo n.º 9
0
 private void MarkFigure(AbstractFigure SelectedFig)
 {
     if (SelectedFig is IEditable)
     {
         SelectedFig.Mark();
         MainView.Image = Canvas;
     }
 }
 public void MouseUpHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas)
 {
     _mouseDown = false;
     figure.Markup.AddPolygon(figure.Points.ToArray());
     canvas.Graphics.DrawPath(pen, figure.Markup);
     canvas.SaveLayer();
     canvas.Graphics.Dispose();
 }
Exemplo n.º 11
0
 public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool)
 {
     mouseDown = true;
     if (tool is Pipette)
     {
         ((Pipette)tool).changeColor(pen.Color, pen, point, canvas);
     }
 }
Exemplo n.º 12
0
 public void OnMouseUp(AbstractFigure figure, ActionParamter paramter)
 {
     if (figure != null && figure.CheckDraw())
     {
         Canvas.Instanse.AddFigure(figure);
     }
     Canvas.Instanse.SetBitmap(Canvas.Instanse.GetTempBitmap());
 }
Exemplo n.º 13
0
        public string Serialaze(AbstractFigure figure)
        {
            JArray jArray = new JArray();

            jArray.Add("RightTriangle");
            jArray.Add(JsonConvert.SerializeObject((RightTriangleFigure)figure));
            return(jArray.ToString());
        }
Exemplo n.º 14
0
        public string Serialaze(AbstractFigure figure)
        {
            JArray jArray = new JArray();

            jArray.Add("NPointsFigure");
            jArray.Add(JsonConvert.SerializeObject((NPointsFigure)figure));
            return(jArray.ToString());
        }
Exemplo n.º 15
0
 public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool)
 {
     mouseDown = true;
     if (tool is MinusLens)
     {
         ((MinusLens)tool).zoom(canvas, point);
     }
 }
Exemplo n.º 16
0
        public void MoveFigureSquareTest(AbstractFigure figure, PointF delta, PointF[] expected)
        {
            figure.Move(delta);

            PointF[] actual = figure.GetPoints();

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 17
0
 public void Create(AbstractFigure item)
 {
     if (item == null)
     {
         throw new ArgumentNullException();
     }
     _listFigure.Add(item);
 }
Exemplo n.º 18
0
 public void MouseUpHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool)
 {
     mouseDown = false;
     //if (ModifiedFigure != null)
     //{
     //    figures.Insert(_modifiedFigureIndex, ModifiedFigure);
     //}
     //canvas.SaveLayer();
 }
Exemplo n.º 19
0
 public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas)
 {
     if (_mouseDown)
     {
         canvas.CreateLayer();
         canvas.Graphics.DrawPolygon(pen, figure.Update(point));
         GC.Collect();
     }
 }
Exemplo n.º 20
0
        private void UpdateFillerOfFigure(AbstractFigure figure)
        {
            var points = figure.GetFillerPoints();

            foreach (var point in points)
            {
                SetSymbol(FillerSymbol, point);
            }
        }
 public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas)
 {
     if (_mouseDown)
     {
         figure.Update(point);
         canvas.CreateLayer();
         GC.Collect();
     }
 }
Exemplo n.º 22
0
        public void MoveVertexSquareTest(AbstractFigure figure, PointF touchPoint, PointF delta, PointF[] expected)
        {
            figure.IsThisVertex(touchPoint);
            figure.MoveVertex(delta);

            PointF[] actual = figure.GetPoints();

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 23
0
 public void MouseDownHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas)
 {
     _mouseDown = true;
     if (_mouseDoubleDown == false)
     {
         figure.Update(point);
         canvas.SaveLayer();
         GC.Collect();
     }
 }
Exemplo n.º 24
0
        public void OnMouseDown(out AbstractFigure figure, ActionParamter paramter)
        {
            var p = paramter;

            figure       = p.Factory.CreateFigure();
            figure.Color = p.Color;
            figure.Width = p.Width;
            figure.DoStart(p.Point);
            //return new EmptyActionResult();
        }
 public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas)
 {
     if (_mouseDown)
     {
         PointF prevPoint = figure.Points[figure.Points.Count - 1];
         figure.Update(point);
         canvas.Graphics.DrawLine(pen, prevPoint, point);
         GC.Collect();
     }
 }
        public void MouseMoveHandle(PointF point, Pen pen, AbstractFigure figure, Canvas canvas, Container figures, AbstractTool tool)
        {
            if (mouseDown && ModifiedFigure != null)
            {
                switch (mode)
                {
                case "Move":
                {
                    canvas.CreateLayer();
                    PointF delta = new PointF(point.X - _pullStartPoint.X, point.Y - _pullStartPoint.Y);
                    if (tool is HandTool)
                    {
                        ((HandTool)tool).Move(delta, ModifiedFigure.Markup);
                    }
                    _pullStartPoint = point;
                    canvas.Graphics.DrawPath(pen, ModifiedFigure.Markup);
                    GC.Collect();
                    break;
                }

                case "Rotate":
                {
                    canvas.CreateLayer();
                    PointF delta = new PointF(point.X - _pullStartPoint.X, point.Y - _pullStartPoint.Y);
                    if (tool is HandTool)
                    {
                        ((HandTool)tool).Rotate(delta, ModifiedFigure.CentrePoint, ModifiedFigure.Markup);
                    }
                    _pullStartPoint = point;
                    canvas.Graphics.DrawPath(pen, ModifiedFigure.Markup);
                    GC.Collect();
                    break;
                }

                case "Resize":
                {
                    // Draw the rectangle to the screen before applying the
                    // transform.


//canvas.CreateLayer();
                    //// Create a matrix and scale it.
                    //Matrix myMatrix = new Matrix();
                    //myMatrix.Scale(2, 2, MatrixOrder.Append);

                    ////// Draw the rectangle to the screen again after applying the
                    ////// transform.
                    //ModifiedFigure.Markup.Transform(myMatrix);
                    //canvas.Graphics.DrawPath(pen, ModifiedFigure.Markup);
                    ////e.Graphics.DrawRectangle(myPen2, 50, 50, 100, 100);
                    break;
                }
                }
            }
        }
Exemplo n.º 27
0
        protected override void UpdateFigureView(AbstractFigure figure)
        {
            UpdateFillerOfFigure(figure);

            var contouesPoints = figure.GetСontoursPoints();

            foreach (var point in contouesPoints)
            {
                SetSymbol(СontourSymbol, point);
            }
        }
        private void DrawAllAseptModified(Pen pen, Canvas canvas, AbstractFigure figure, Container figures)
        {
            Bitmap Tmp = new Bitmap(canvas.MainBitmap.Width, canvas.MainBitmap.Height);

            canvas.Graphics = Graphics.FromImage(Tmp);
            for (int i = 0; i < figures.Length; i++)
            {
                canvas.Graphics.DrawPath(pen, figures[i].Markup);
            }
            canvas.MainBitmap = Tmp;
        }
Exemplo n.º 29
0
 private void lvFigures_SelectedIndexChanged(object sender, EventArgs e)
 {
     ReadrawSelected();
     if (lvFigures.SelectedIndices.Count > 0)
     {
         int ind = 0;
         ind         = lvFigures.SelectedIndices[0];
         SelectedFig = FigList.GetItem(ind);
         MarkFigure(SelectedFig);
     }
 }
Exemplo n.º 30
0
 public void OnMouseMove(AbstractFigure figure, ActionParamter paramter)
 {
     if (figure != null)
     {
         Color color = figure.Color;
         int   width = figure.Width;
         figure.Points[indPoint] = paramter.Point;
         figure.Mover.MoveFigure(color, width, figure.Points.ToArray());
     }
     Canvas.Instanse.GetBitmap();
 }
Exemplo n.º 31
0
 private void btnChangeFig_Click(object sender, EventArgs e)
 {
     if (SelectedFig != null)
     {
         SelectedFig.ChangeColor(PenColor.Color);
         SelectedFig.Draw();
         MainView.Image = Canvas;
         SelectedFig    = null;
         lvFigures.SelectedIndices.Clear();
     }
 }
Exemplo n.º 32
0
 public void ClearPos()
 {
     PrevPos.X    = -1;
     PrevPos.Y    = -1;
     ChosenFigure = null;
     if (ImFigure != null)
     {
         ImFigure.Remove(Canva);
         ImFigure = null;
     }
 }