示例#1
0
 public void ToolMouseUp(object sender, MouseEventArgs e)
 {
     if (this.lineSegment != null)
     {
         if (e.Button == MouseButtons.Left)
         {
             lineSegment.Endpoint    = new System.Drawing.Point(e.X, e.Y);
             lineSegment.xfinish     = e.X;
             lineSegment.yfinish     = e.Y;
             this.selectedRectangle2 = this.canvas.GetRectangleObjectAt(e.X, e.Y);
             int result = IntersectOnVertex(lineSegment.xstart, lineSegment.ystart, lineSegment.xfinish, lineSegment.yfinish, selectedRectangle);
             SetNewIntersectCoordinateStart(result);
             lineSegment.Startpoint = new System.Drawing.Point(this.newXStart, this.newYStart);
             int resultfinish = IntersectOnVertex(lineSegment.xstart, lineSegment.ystart, lineSegment.xfinish, lineSegment.yfinish, selectedRectangle2);
             SetNewIntersectCoordinateFinish(resultfinish);
             lineSegment.Endpoint = new System.Drawing.Point(this.newXFinish, this.newYFinish);
             Debug.WriteLine("Objek yang terintersect : " + result);
             lineSegment.Select();
         }
         else if (e.Button == MouseButtons.Right)
         {
             canvas.RemoveDrawingObject(this.lineSegment);
         }
     }
 }
示例#2
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            /*this.xInitial = e.X;
            *  this.yInitial = e.Y;*/
            this.move          = new MoveCommand();
            this.move.xInitial = e.X;
            this.move.yInitial = e.Y;
            this.move.xInit    = e.X;
            this.move.yInit    = e.Y;

            if (e.Button == MouseButtons.Left && canvas != null)
            {
                canvas.DeselectAllObjects();
                Debug.WriteLine("Memanggil method SelectObjectAt pada Panel(DefaultPanel) melalui SelectionTool.cs..");
                //selectedObject = canvas.SelectObjectAt(e.X, e.Y);
                this.move.selectedObject = canvas.SelectObjectAt(e.X, e.Y);
                this.rectangle           = canvas.GetRectangleObjectAt(e.X, e.Y);
                if (this.move.selectedObject != null)
                {
                    canvas.GetButton(this.move.selectedObject.ID);
                    //selectedBtnObject = canvas.SelectButtonObjectByID(selectedObject.ID);
                    this.move.selectedBtnObject = canvas.SelectButtonObjectByID(this.move.selectedObject.ID);
                }
                Debug.WriteLine("Sudah selesai menjalankan method SelectObjectAt pada Panel(DefaultPanel) melalui SelectionTool.cs..");
            }
        }
示例#3
0
 public MindmapTree(RectangleSegment rec, IPanel panel)
 {
     this.nodeID    = rec.ID;
     this.child     = new List <MindmapTree>();
     this.rectChild = new List <RectangleSegment>();
     this.node      = rec;
     this.canvas    = panel;
 }
示例#4
0
 public AddChildCommand(IPanel canvas, RectangleSegment newRect, LineSegment lineChild, TextSegment textSegmentChild
                        , ButtonObject childBtnObject, Guid nodeID, List <RectangleSegment> rectChild, List <MindmapTree> child, RectangleSegment node)
 {
     this.childBtnObject   = childBtnObject;
     this.textSegmentChild = textSegmentChild;
     this.newRect          = newRect;
     this.lineChild        = lineChild;
     this.canvas           = canvas;
     this.nodeID           = nodeID;
     this.rectChild        = rectChild;
     this.child            = child;
     this.node             = node;
 }
示例#5
0
 public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     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);
         canvas.AddDrawingObject(lineSegment);
         selectedRectangle  = this.canvas.GetRectangleObjectAt(e.X, e.Y);
         lineSegment.xstart = e.X;
         lineSegment.ystart = e.Y;
         if (selectedRectangle != null)
         {
             //implemented later
         }
     }
 }
示例#6
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            Debug.WriteLine("Rectangle mouse down (untuk menggambar object baru) --> activated (Via class RectangleTool.cs");
            if (e.Button == MouseButtons.Left)
            {
                this.rectangle = new RectangleSegment(e.X, e.Y);
                Debug.WriteLine("Rectangle sudah digambar... (via class RectangleTool.cs)");
                this.canvas.AddDrawingObject(this.rectangle);
                this.canvas.AddRectangleObject(this.rectangle);
                Debug.WriteLine("Rectangle dimasukkan kedalam AddDrawingObject pada kanvas (via class RectangleTool.cs)");
                this.buttonObject = new ButtonObject(e.X, e.Y, this.rectangle.ID, this.canvas);
                this.canvas.AddButtonObject(this.buttonObject);

                //set koordinat vertex VX1 dan VY1
                this.rectangle.VX1 = e.X;
                this.rectangle.VY1 = e.Y;
            }
        }
示例#7
0
        private void Button_Click(object sender, EventArgs e)
        {
            RectangleSegment node = findRectangleByGuid(btnObject.btnID);

            if (node != null)
            {
                Debug.WriteLine("rectangle ID = " + node.ID);
            }
            mindmapTree = findNodeTree(node.ID);
            if (mindmapTree == null)
            {
                mindmapTree = new MindmapTree(node, this.tools.TargetCanvas);
                AddMindmapObject(mindmapTree);
            }
            mindmapTree.UnDoObject = _UnDoObject;
            mindmapTree.AddChild();
            Repaint();
            //MessageBox.Show("Tombol dengan ID "+btnObject.btnID+" telah diklik.");
        }
示例#8
0
 private int IntersectOnVertex(int xs1, int ys1, int xs2, int ys2, RectangleSegment selectedRectangle)
 {
     if (doIntersect(selectedRectangle.VX1, selectedRectangle.VY1, selectedRectangle.VX2, selectedRectangle.VY2, xs1, ys1, xs2, ys2))
     {
         return(1);
     }
     if (doIntersect(selectedRectangle.VX2, selectedRectangle.VY2, selectedRectangle.VX4, selectedRectangle.VY4, xs1, ys1, xs2, ys2))
     {
         return(2);
     }
     if (doIntersect(selectedRectangle.VX3, selectedRectangle.VY3, selectedRectangle.VX4, selectedRectangle.VY4, xs1, ys1, xs2, ys2))
     {
         return(3);
     }
     if (doIntersect(selectedRectangle.VX1, selectedRectangle.VY1, selectedRectangle.VX3, selectedRectangle.VY3, xs1, ys1, xs2, ys2))
     {
         return(4);
     }
     return(0);
 }
示例#9
0
        public void ToolMouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                text       = new TextSegment();
                text.Value = "Text";

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

                if (obj != null)
                {
                    rect = obj.getRect();

                    int widthrect  = rect.Width;
                    int heightrect = rect.Height;
                    int xrect      = rect.X;
                    int yrect      = rect.Y;
                    int xrect2     = rect.X2;
                    int yrect2     = rect.Y2;
                    text.Position = new System.Drawing.PointF((float)((xrect + xrect2) / 2) - (widthrect / 10), (float)((yrect + yrect2) / 2) - (heightrect / 10));
                    bool allowed = obj.Add(text);
                }
            }
        }
示例#10
0
        private void DrawChild(int xStart, int yStart, int xFinish, int yFinish, int addX, int addY, int divisor, int modder, int startingpointX, int startingpointY, int counterside)
        {
            //this.X = node.VX1 + 75 * NumofChild();
            //this.Y = (node.VY1 - 120);
            int newRectStart = 0, newRectFinish = 0, newRectStagnan = 0;
            int multiplier = 0;

            if (counterside % 2 == 0)
            {
                if (counterside == 0)
                {
                    this.X = xStart + addX * (NumofChild() % modder);
                    this.Y = yStart + addY;
                }
                else
                {
                    this.X = xStart + addX * ((NumofChild() + 1) % modder);
                    this.Y = yStart + addY;
                }
            }
            else
            {
                this.X = xStart + addX;
                this.Y = yStart + addY * (NumofChild() % modder);
            }

            /*if (counterside == 0)
             * {
             *  this.X = xStart + addX * (NumofChild() % modder);
             *  this.Y = yStart + addY;
             * }
             * else if (counterside == 2)
             * {
             *  this.X = xStart + addX * (NumofChild()+1 % modder);
             *  this.Y = yStart + addY;
             * }
             */
            this.newRect = new RectangleSegment(X, Y, 70, 50);

            rectChild.Add(newRect);
            this.canvas.AddDrawingObject(newRect);
            this.canvas.AddRectangleObject(newRect);
            if (counterside == 0)
            {
                multiplier = NumofChild() % modder;
            }
            else if (counterside == 2)
            {
                multiplier = (NumofChild() % modder) + 1;
            }
            //set koordinat VX1
            this.newRect.VX1 = this.newRect.X;
            this.newRect.VY1 = this.newRect.Y;

            //set koordinat VX2, VY2
            this.newRect.VX2 = this.newRect.VX1 + this.newRect.Width;
            this.newRect.VY2 = this.newRect.VY1;

            this.newRect.VX3 = this.newRect.VX1;
            this.newRect.VY3 = this.newRect.VY1 + this.newRect.Height;

            this.newRect.VX4 = this.newRect.VX1 + this.newRect.Width;
            this.newRect.VY4 = this.newRect.VY1 + this.newRect.Height;

            if (counterside == 0)
            {
                newRectStart   = this.newRect.VX3;
                newRectFinish  = this.newRect.VX4;
                newRectStagnan = this.newRect.VY3;
                lineChild      = new LineSegment(new System.Drawing.Point(((xFinish - xStart) / divisor) * multiplier + startingpointX, startingpointY), new System.Drawing.Point((newRectStart + newRectFinish) / 2, newRectStagnan));
            }
            else if (counterside == 1)
            {
                newRectStart   = this.newRect.VY1;
                newRectFinish  = this.newRect.VY3;
                newRectStagnan = this.newRect.VX1;
                lineChild      = new LineSegment(new System.Drawing.Point(((xFinish - xStart) / divisor) * multiplier + startingpointX, startingpointY), new System.Drawing.Point(newRectStagnan, 50));
                //lineChild = new LineSegment(new System.Drawing.Point( startingpointX, ((yFinish - yStart) / divisor) * multiplier + startingpointY), new System.Drawing.Point(newRectStagnan, (newRectFinish - newRectStart) / 2));
                //  Debug.WriteLine("HASIL PADA COUNTERSIDE 1 koordinat Y : " + ((yFinish - yStart) / divisor) * multiplier + startingpointY + " FINISH : " + (newRectStart + newRectFinish) / 2);
            }
            else if (counterside == 2)
            {
                newRectStart   = this.newRect.VX1;
                newRectFinish  = this.newRect.VX2;
                newRectStagnan = this.newRect.VY1;
                lineChild      = new LineSegment(new System.Drawing.Point(((xFinish - xStart) / divisor) * multiplier + startingpointX, startingpointY), new System.Drawing.Point((newRectStart + newRectFinish) / 2, newRectStagnan));
            }
            else if (counterside == 3)
            {
                newRectStart   = this.newRect.VY2;
                newRectFinish  = this.newRect.VY4;
                newRectStagnan = this.newRect.VX2;
                lineChild      = new LineSegment(new System.Drawing.Point(startingpointX, ((yFinish - yStart) / divisor) * multiplier + startingpointY), new System.Drawing.Point(newRectStagnan, (newRectStart + newRectFinish) / 2));
            }
            //lineChild = new LineSegment(new System.Drawing.Point(((node.VX2 - node.VX1) / 4) * NumofChild() + node.VX1, node.VY1), new System.Drawing.Point((newRect.VX3 + newRect.VX4) / 2, newRect.VY3));
            lineChild = new LineSegment(new System.Drawing.Point(((xFinish - xStart) / divisor) * multiplier + startingpointX, startingpointY), new System.Drawing.Point((newRectStart + newRectFinish) / 2, newRectStagnan));
            this.canvas.AddDrawingObject(lineChild);
            node.Subscribe(lineChild);
            newRect.Subscribe(lineChild);
            lineChild.AddVertexStartObject(node);
            lineChild.AddVertexEndObject(newRect);

            MindmapTree mindmapTree = new MindmapTree(newRect, this.canvas);

            child.Add(mindmapTree);
            this.canvas.AddMindmapObject(mindmapTree);
            childBtnObject = new ButtonObject(X, Y, newRect.ID, this.canvas);
            this.canvas.AddButtonObject(childBtnObject);
            textSegmentChild          = new TextSegment();
            textSegmentChild.Value    = "Child";
            textSegmentChild.Position = new System.Drawing.PointF((float)((newRect.X + (newRect.X + newRect.Width)) / 2), (float)((newRect.Y + (newRect.Y + newRect.Height)) / 2));
            bool added = newRect.Add(textSegmentChild);

            newRect.SetTextSegment(textSegmentChild);
            newRect.Select();
            Debug.WriteLine("Jumlah Node : " + NumofChild());
        }
示例#11
0
 public void AddRectangleObject(RectangleSegment rect)
 {
     this.rectangleObjects.Add(rect);
 }