Exemplo n.º 1
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                text          = new Text();
                text.Value    = "Lorem Ipsum";
                text.Position = new System.Drawing.PointF((float)e.X, (float)e.Y);

                DrawingObject obj = canvas.GetObjectAt(e.X, e.Y);

                if (obj == null)
                {
                    canvas.AddDrawingObject(text);
                }
                else
                {
                    bool allowed = obj.AddDrawingObject(text);

                    if (!allowed)
                    {
                        canvas.AddDrawingObject(obj);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                text       = new Text();
                text.Value = "Text";
                text.X     = e.X;
                text.Y     = e.Y;

                DrawingObject obj = canvas.SelectObjectAt(e.X, e.Y);

                if (obj == null)
                {
                    canvas.AddDrawingObject(text);
                }
                else
                {
                    bool allowed = obj.Add(text);

                    if (!allowed)
                    {
                        canvas.AddDrawingObject(text);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void ToolMouseUp(object sender, MouseEventArgs e)
        {
            if (sourceObject != null)
            {
                foreach (DrawingObject obj in this.canvas.getListDrawingObject().Reverse <DrawingObject>())
                {
                    if (obj.intersect(e.Location))
                    {
                        if (obj.GetType() == typeof(Circle))
                        {
                            destinationObject = (Circle)obj;
                            Connector connect = new Connector(sourceObject, destinationObject);

                            sourceObject.addObserver(connect);
                            destinationObject.addObserver(connect);

                            canvas.AddDrawingObject(connect);
                            connect.ChangeState(StaticState.GetInstance());
                        }
                        break;
                    }
                }
            }
            sourceObject      = null;
            destinationObject = null;
        }
Exemplo n.º 4
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                actor             = new Actor(new Point(e.X, e.Y));
                actor.finishPoint = new Point(e.X, e.Y);

                DrawingObject drawingObject = canvas.GetObject(e.X, e.Y);

                if (drawingObject == null)
                {
                    canvas.AddDrawingObject(actor);
                }
                else
                {
                    textValue = drawingObject.GetText();
                    using (TextForm textForm = new TextForm(textValue, drawingObject, canvas))
                    {
                        if (textForm.ShowDialog() == DialogResult.OK)
                        {
                            textForm.ShowDialog();
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void ToolMouseDoubleClick(object sender, MouseEventArgs e)
        {
            string input;

            canvas.DeselectAllObjects();
            selectedObject = canvas.SelectObjectAt(e.X, e.Y);

            if (selectedObject != null && selectedObject is Text)
            {
                input = Microsoft.VisualBasic.Interaction.InputBox("Input Text", "Text Box", this.selectedObject.GetText(), 500, 300);

                if (input.Length > 0)
                {
                    this.selectedObject.SetText(input.ToString());
                    canvas.initUndoRedo();
                }
            }
            else
            {
                Text text = new Text();
                input      = Microsoft.VisualBasic.Interaction.InputBox("Input Text", "Text Box", "", 500, 300);
                text.Value = input;

                canvas.AddDrawingObject(text);
                text.X = e.X;
                text.Y = e.Y;
                canvas.initUndoRedo();
            }

            Debug.WriteLine("selection tool double click");
        }
Exemplo n.º 6
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         //DrawingObject clickObject = canvas.GetCanvasObject(e.X,e.Y);
         varChart          = new Chart(new System.Drawing.Point(e.X, e.Y));
         varChart.Endpoint = new System.Drawing.Point(e.X, e.Y);
         canvas.AddDrawingObject(varChart);
     }
     if (e.Button == MouseButtons.Right)
     {
         if (varChart.GetPointChartAll().Count == 0 || varChart.GetLabelYAll().Count == 0)
         {
             string s = "Isi point dan label x menggunakan XValue dan label y dengan YValue";
             using (Notifikasi form = new Notifikasi(s))
             {
                 if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     form.ShowDialog();
                 }
             }
         }
         else
         {
             using (TableChart form = new TableChart(varChart, canvas))
             {
                 if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     form.ShowDialog();
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         this.circle = new Circle(e.X, e.Y);
         canvas.AddDrawingObject(this.circle);
     }
 }
Exemplo n.º 8
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         lineSegment = new Polygon(new System.Drawing.Point(e.X, e.Y), new System.Drawing.Point(e.X, e.Y));
         canvas.AddDrawingObject(lineSegment);
     }
 }
Exemplo n.º 9
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            DrawingObject chart = canvas.GetChart(e.Location.X, e.Location.Y);

            PointArea     = chart;
            this.xInitial = e.X;
            this.yInitial = e.Y;

            if (chart != null)
            {
                if (e.Button == MouseButtons.Left && canvas != null)
                {
                    bool isAllowed = false;
                    if (chart.GetPointYAll().Count < 1)
                    {
                        isAllowed = true;
                    }
                    if (isAllowed)
                    {
                        int xChart      = chart.GetStartpoint().X;
                        int endyChart   = chart.GetStartpoint().Y;
                        int startyChart = chart.GetEndpoint().Y;
                        int temp        = e.Y - startyChart;
                        int charty      = startyChart + temp;
                        int county      = (endyChart - startyChart) / temp;
                        //int yTemp =
                        DrawingObject point;
                        for (int i = 0; i < county; i++)
                        {
                            point = new ChartPoint(new Point(xChart - 6, charty - 3), chart);
                            chart.AddYPoint(point);
                            point.Select();
                            canvas.AddDrawingObject(point);
                            Text text = new Text(new Point(xChart - 60, charty + temp / 2));
                            text.Endpoint = new Point(xChart - 6, charty - temp / 2);
                            text.ChangeText((Math.Sqrt(Math.Pow((point.GetStartpoint().Y - this.PointArea.GetEndpoint().Y), 2))).ToString());
                            chart.AddYLabel(text);
                            canvas.AddDrawingObject(text);
                            this.varChartPoint.Add(point);
                            this.textX.Add(text);
                            charty += temp;
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         varSquare          = new Square(new System.Drawing.Point(e.X, e.Y));
         varSquare.Endpoint = new System.Drawing.Point(e.X, e.Y);
         canvas.AddDrawingObject(varSquare);
     }
 }
Exemplo n.º 11
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (canvas.GetObjectAt(e.X, e.Y) == null)
         {
             TextPrompt input = new TextPrompt();
             if (input.ShowDialog() == DialogResult.OK)
             {
                 text       = new Text();
                 text.Value = input.getTxtInput();
                 text.X     = e.X;
                 text.Y     = e.Y;
                 canvas.AddDrawingObject(text);
             }
         }
         else
         {
         }
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (canvas.GetObjectAt(e.X, e.Y) is Text)
         {
             Text objectHere = (Text)canvas.GetObjectAt(e.X, e.Y);
             System.Diagnostics.Debug.WriteLine("Right Click");
             TextPrompt input = new TextPrompt();
             input.setTxtInput(objectHere.Value);
             if (input.ShowDialog() == DialogResult.OK)
             {
                 canvas.RemoveDrawingObject(canvas.GetObjectAt(e.X, e.Y));
                 text       = new Text();
                 text.Value = input.getTxtInput();
                 text.X     = e.X;
                 text.Y     = e.Y;
                 canvas.AddDrawingObject(text);
             }
             else
             {
                 System.Diagnostics.Debug.WriteLine("TextBox: " + e.X + " - " + e.Y);
             }
         }
     }
 }
Exemplo n.º 12
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         lineSegment          = new Line(new System.Drawing.Point(e.X, e.Y));
         lineSegment.Endpoint = new System.Drawing.Point(e.X, e.Y);
         this.lineSegment.ChangeState(PreviewState.GetInstance());
         canvas.AddDrawingObject(lineSegment);
     }
 }
Exemplo n.º 13
0
 public void Execute()
 {
     if (rectangle != null)
     {
         canvas.AddDrawingObject(rectangle);
         if (this.listChild.Count > 0)
         {
             undoredo.Undo(1);
             foreach (DrawingObject obj in this.listChild)
             {
                 obj.parentRectangle = this.rectangle;
                 rectangle.listChildObject.Add(obj);
             }
         }
     }
     else
     {
         canvas.AddDrawingObject(drawObj);
     }
 }
Exemplo n.º 14
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            this.xInitial = e.X;
            this.yInitial = e.Y;
            if (e.Button == MouseButtons.Left && canvas != null)
            {
                canvas.DeselectAllObject();
                selectedObject = canvas.SelectObjectAt(e.X, e.Y);
                if (selectedObject != null)
                {
                    PointArea = selectedObject.GetPointArea();

                    int index = PointArea.GetIndexPoint(selectedObject);
                    int count = PointArea.GetPointCount();


                    if (index > 0)
                    {
                        NeighbourKiri = PointArea.GetNeighbourKiri(selectedObject);
                    }
                    if (index != count - 1)
                    {
                        NeighbourKanan = PointArea.GetNeighbourKanan(selectedObject);
                    }

                    DrawingObject kanan = PointArea.GetConnectorKanan(selectedObject);
                    DrawingObject kiri  = PointArea.GetConnectorKiri(selectedObject);

                    if (kiri != null)
                    {
                        PointArea.RemoveConnector(kiri);
                        canvas.RemoveObject(kiri);
                    }
                    if (kanan != null)
                    {
                        PointArea.RemoveConnector(kanan);
                        canvas.RemoveObject(kanan);
                    }
                    if (index > 0 && index < count - 1)
                    {
                        Connector connector = new Connector(new Point(NeighbourKiri.GetStartpoint().X + 3, NeighbourKiri.GetStartpoint().Y + 3));
                        connector.Endpoint = new System.Drawing.Point(NeighbourKanan.GetStartpoint().X + 3, NeighbourKanan.GetStartpoint().Y + 3);
                        connector.SetSource(NeighbourKiri);
                        connector.SetDestination(NeighbourKanan);
                        varConnector = connector;
                        PointArea.AddConnectorPoint(connector);
                        canvas.AddDrawingObject(connector);
                    }
                    PointArea.RemovePoint(selectedObject);
                    canvas.RemoveObject(selectedObject);
                }
            }
        }
Exemplo n.º 15
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            //lineSegment = new LineSegment(new System.Drawing.Point(e.X, e.Y));

            if (e.Button == MouseButtons.Left)
            {
                lineSegment          = new LineSegment(new System.Drawing.Point(e.X, e.Y));
                lineSegment.Endpoint = new System.Drawing.Point(e.X, e.Y);
                this.canvas.SetOrUpdatePointsByGuid(lineSegment);
                canvas.AddDrawingObject(lineSegment);
            }
        }
Exemplo n.º 16
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         lineSegment          = new LineSegment(new Point(e.X, e.Y));
         lineSegment.Endpoint = new Point(e.X, e.Y);
         canvas.AddDrawingObject(lineSegment);
         if (canvas.GetObjectAt(e.X, e.Y) is Vertex)
         {
             startingObject = (Vertex)canvas.GetObjectAt(e.X, e.Y);
         }
     }
 }
Exemplo n.º 17
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            DrawingObject chart = canvas.GetChart(e.Location.X, e.Location.Y);

            PointArea     = chart;
            this.xInitial = e.X;
            this.yInitial = e.Y;

            if (chart != null)
            {
                if (e.Button == MouseButtons.Left && canvas != null)
                {
                    varChartPoint = new ChartPoint(e.Location, chart);

                    if (PointArea.Intersect(e.X, e.Y))
                    {
                        if (PointArea.GetPointAreaIntersect(varChartPoint, e.X, e.Y))
                        {
                            chart.AddGraphPoint(varChartPoint);
                            canvas.AddDrawingObject(varChartPoint);
                            if (chart.GetPointCount() > 1)
                            {
                                DrawingObject Neighbour = chart.GetNeighbourKiri(varChartPoint);
                                Connector     connector = new Connector(new Point(Neighbour.GetStartpoint().X + 3, Neighbour.GetStartpoint().Y + 3));
                                connector.Endpoint = new System.Drawing.Point(varChartPoint.GetStartpoint().X + 3, varChartPoint.GetStartpoint().Y + 3);
                                connector.SetSource(Neighbour);
                                connector.SetDestination(varChartPoint);
                                varConnector = connector;
                                chart.AddConnectorPoint(connector);
                                canvas.AddDrawingObject(connector);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            Cursor.Current = Cursor;
            if (e.Button == MouseButtons.Left)
            {
                if (canvas.GetObjectAt(e.X, e.Y) is Vertex)
                {
                    StartingObject = (Vertex)canvas.GetObjectAt(e.X, e.Y);
                    MakeLine();

                    line.Endpoint = new System.Drawing.Point(e.X, e.Y);
                    canvas.AddDrawingObject(line);
                    canvas.GetListSelectedObject().Clear();
                }
            }
        }
Exemplo n.º 19
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         lineSegment = new FreeHand(new System.Drawing.Point(e.X, e.Y), new System.Drawing.Point(e.X, e.Y));
         canvas.AddDrawingObject(lineSegment);
     }
     else if (e.Button == MouseButtons.Right)
     {
         canvas.DeselectAllObjects();
         DrawingObject selectedObject = canvas.SelectObjectAt(e.X, e.Y);
         if (selectedObject != null)
         {
             selectedObject.Flip();
         }
     }
 }
Exemplo n.º 20
0
        public void ToolMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && canvas != null)
            {
                canvas.DeselectAll();

                if (objectSource != null)
                {
                    objectDestination = canvas.SelectObject(e.X, e.Y);

                    Generalization connector = new Generalization(objectSource, objectDestination);
                    objectSource.Attach(connector);
                    objectDestination.Attach(connector);

                    canvas.AddDrawingObject(connector);
                    connector.ChangeState(StaticState.GetInstance());
                }
            }
        }
Exemplo n.º 21
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.useCase = new UseCase(e.X, e.Y);
                DrawingObject drawingObject = canvas.GetObject(e.X, e.Y);

                if (drawingObject == null)
                {
                    canvas.AddDrawingObject(useCase);
                }
                else
                {
                    textValue = drawingObject.GetText();
                    using (TextForm textForm = new TextForm(textValue, drawingObject, canvas))
                    {
                        if (textForm.ShowDialog() == DialogResult.OK)
                        {
                            textForm.ShowDialog();
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
        public void ToolMouseUp(object sender, MouseEventArgs e)
        {
            if (this.sourceObj != null)
            {
                foreach (DrawingObject obj in this.canvas.GetDrawingObjects().Reverse <DrawingObject>())
                {
                    if (obj.Intersect(e.X, e.Y) && obj.GetType() == typeof(Rectangle))
                    {
                        this.destObj = (Rectangle)obj;

                        Debug.WriteLine("Destination found");

                        this.connector.Destination = (Rectangle)obj;

                        connector.Source.AddObserver(connector);
                        connector.Destination.AddObserver(connector);

                        connector.ChangeState(StaticState.GetInstance());

                        canvas.AddDrawingObject(connector);
                    }
                }
            }
        }
Exemplo n.º 23
0
 public override void execute()
 {
     canvas.AddDrawingObject(obj);
 }
Exemplo n.º 24
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            DrawingObject chart = canvas.GetChart(e.Location.X, e.Location.Y);

            PointArea     = chart;
            this.xInitial = e.X;
            this.yInitial = e.Y;

            if (chart != null)
            {
                if (e.Button == MouseButtons.Left && canvas != null)
                {
                    bool isAllowed = false;
                    if (chart.GetPointXtAll().Count < 1)
                    {
                        isAllowed = true;
                    }
                    if (isAllowed)
                    {
                        int           yChart      = chart.GetEndpoint().Y;
                        int           yPointChart = chart.GetStartpoint().Y;
                        int           endxChart   = chart.GetEndpoint().X;
                        int           startxChart = chart.GetStartpoint().X;
                        int           temp        = e.X - startxChart;
                        int           chartx      = startxChart + temp;
                        int           countx      = (endxChart - startxChart) / temp;
                        DrawingObject point;
                        for (int i = 0; i < countx; i++)
                        {
                            ChartPoint varChartPoint = new ChartPoint(new Point(chartx - 3, yPointChart), chart);
                            chart.AddGraphPoint(varChartPoint);
                            canvas.AddDrawingObject(varChartPoint);
                            varChartPoint.Select();
                            if (chart.GetPointCount() > 1)
                            {
                                DrawingObject Neighbour = chart.GetNeighbourKiri(varChartPoint);
                                Connector     connector = new Connector(new Point(Neighbour.GetStartpoint().X + 3, Neighbour.GetStartpoint().Y + 3));
                                connector.Endpoint = new System.Drawing.Point(varChartPoint.GetStartpoint().X + 3, varChartPoint.GetStartpoint().Y + 3);
                                connector.SetSource(Neighbour);
                                connector.SetDestination(varChartPoint);
                                //varConnector = connector;
                                chart.AddConnectorPoint(connector);
                                canvas.AddDrawingObject(connector);

                                connector.Select();
                                canvas.DeselectAllObject();
                            }

                            point = new ChartPoint(new Point(chartx - 3, yChart), chart);
                            chart.AddXPoint(point);
                            point.Select();
                            canvas.AddDrawingObject(point);
                            Text text = new Text(new Point(chartx - temp / 2, yChart + 6));
                            text.Endpoint = new Point(chartx + temp / 2, yChart + 33);
                            text.ChangeText("Text" + (i + 1));
                            chart.AddXLabel(text);
                            canvas.AddDrawingObject(text);
                            this.varChartPoint.Add(point);
                            this.textX.Add(text);
                            chartx += temp;
                        }
                    }
                }
            }
        }
Exemplo n.º 25
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     line          = new Line(new System.Drawing.Point(e.X, e.Y));
     line.endPoint = new System.Drawing.Point(e.X, e.Y);
     canvas.AddDrawingObject(line);
 }
Exemplo n.º 26
0
 public void UnExecute()
 {
     canvas.AddDrawingObject(rectangle);
 }