public Double  cal(int[] arr, int opration)
        {
            ShapeInterface area   = null;
            Double         result = 0;

            area   = Calculation.shapeobj(arr, opration);
            result = area.ShapeArea();
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Its a run button to run single line command and draw shape from single line command
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRun_Click(object sender, EventArgs e)
        {
            string   UserInput = this.UserInput.Text;
            Validate validate  = new Validate();

            string[] getInput = validate.getValidate(UserInput);
            this.UserInput.ResetText();
            if (getInput.Length > 1)
            {
                if (getInput[0] == "moveto")
                {
                    int x = Convert.ToInt32(getInput[1]);
                    int y = Convert.ToInt32(getInput[2]);
                    pos1 = x;
                    pos2 = y;
                }

                else if (getInput[0] == "line")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else if (getInput[0] == "rectangle")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else if (getInput[0] == "circle")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else if (getInput[0] == "triangle")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }
                else if (getInput[0] == "polygon")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else
                {
                    throw new Exception("Parameter Not Foundasdfasdf !!!");
                }
            }
        }
Exemplo n.º 3
0
 private void btPasteShape_Click(object sender, EventArgs e) {
     ToolStripItem contextMenuItem = (ToolStripItem)sender;
     System.Drawing.Point NewPos, Ctxtpos;
     if (contextMenuItem.Tag is System.Drawing.Point) {
         Ctxtpos = (System.Drawing.Point)contextMenuItem.Tag;  //Location is stored as point in tag
     } else {
         Ctxtpos = new System.Drawing.Point(0, 0);
     }
     System.Drawing.Size PosOffset = System.Drawing.Size.Empty;
     IDataObject Data = Clipboard.GetDataObject();
     ShapeInterface Shape = null;
     Core.CmdMacro Cmd = new Core.CmdMacro();
     String[] Formats = Data.GetFormats(false);
     // Determines whether the data is in a format you can use.
     if (Data.GetDataPresent("stream")) {
         //string test = Data.GetData(DataFormats.Text).ToString();
         SerializerXML _Stream = new SerializerXML("JKFLOW", "1.0.0.0");
         MemoryStream _MemStream = new MemoryStream((byte[])Data.GetData("stream"));
         _Stream.OpenInputStream(_MemStream);
         string NodeGroup;
         int StartNodeLevel = 0, CurrNodeLevel = 0;
         do {
             NodeGroup = _Stream.GetNodeName();
             CurrNodeLevel = _Stream.GetNodeLevel();
             if (CurrNodeLevel < StartNodeLevel) { break; }
             if (_Stream.GetNodeType() != Core.SerializerBase.NodeType.NodeEnd) {
                 if (NodeGroup == "Shape") {
                     ShapeInterface SourceShape = ShapeFactory.DeserializeShape(_Stream);
                     if (PosOffset.IsEmpty) {
                         PosOffset.Width = Ctxtpos.X - SourceShape.GetBoundingBox().Location.X;
                         PosOffset.Height = Ctxtpos.Y - SourceShape.GetBoundingBox().Location.Y;
                     }
                     NewPos = SourceShape.GetBoundingBox().Location + PosOffset;
                     Shape = ShapeFactory.CreateShape(SourceShape.GetShapeTypeName());
                     Cmd.AddCmd(new Core.CmdAddShape(GetModel(),
                         Shape, NewPos, NewPos + SourceShape.GetBoundingBox().Size));
                 }
             }
         } while (_Stream.ReadNext());
         _Stream.CloseInputStream();
         _Stream = null;
         GetModel().GetUndoStack().Push(Cmd);
     }
 }
        private static ShapeInterface  shapeobj(int[] arr, int operation)
        {
            ShapeInterface s = null;

            if (operation == 1)
            {
                s = new Circle(arr[0]);
            }
            else if (operation == 2)
            {
                s = new Triangle(arr[2], arr[4]);
            }
            else if (operation == 3)
            {
                s = new Rectangle(arr[1], arr[5]);
            }
            if (operation == 4)
            {
                s = new Square(arr[3]);
            }
            return(s);
        }
Exemplo n.º 5
0
 private void btCopyShape_Click(object sender, EventArgs e) {
     try {
         ToolStripItem contextMenuItem = (ToolStripItem)sender;
         Control contextMenu = (Control)contextMenuItem.GetCurrentParent();
         System.Drawing.Point Location = (contextMenu.Location);
         System.Drawing.Point PointA, PointB;
         Core.ElementEnumerator<Core.ShapeInterface> Iterator = GetModel().GetSelectedShapes();
         Core.CmdMacro Cmd = new Core.CmdMacro();
         List<ShapeInterface> Shapes = new List<ShapeInterface>();
         ShapeInterface Shape = null;
         DataObject _Data = new DataObject();
         int i = 0;
         SerializerXML _Stream = new SerializerXML("JKFLOW", "1.0.0.0");
         MemoryStream MemStream = new MemoryStream();
         _Stream.OpenOutputStream(MemStream);
         string Node = "Shape";
         while (Iterator.MoveNext()) {
             PointA = new System.Drawing.Point(Iterator.Current.GetBoundingBox().Left + 20, Iterator.Current.GetBoundingBox().Top + 20);
             PointB = new System.Drawing.Point(Iterator.Current.GetBoundingBox().Right + 20, Iterator.Current.GetBoundingBox().Bottom + 20);
             Shape = ShapeFactory.CreateShape(Iterator.Current.GetShapeTypeName());
             Shapes.Add(Shape);
             _Stream.WriteElementStart(Node);
             Iterator.Current.WriteToSerializer(_Stream);
             _Stream.WriteElementEnd(Node);
             Cmd.AddCmd(new Core.CmdAddShape(GetModel(), Shape, PointA, PointB));
             i++;
         }
         _Stream.CloseOutputStream();
         //if (i != 0) GetModel().GetUndoStack().Push(Cmd);
         _Data.SetData(DataFormats.Text, Cmd.GetText());
         _Data.SetData(Cmd.GetType(), Cmd);
         _Data.SetData("stream", MemStream.ToArray());
         Clipboard.SetDataObject(_Data);
     } catch (System.Runtime.InteropServices.ExternalException) {
         MessageBox.Show("The Clipboard could not be accessed. Please try again.");
     }
 }
Exemplo n.º 6
0
 public virtual void OnSetShapeTemplate(object sender, ShapeInterface Template) {
     Core.ShapeFactory.SetShapeTemplate(Template);
 }
Exemplo n.º 7
0
 public virtual void OnShapeSelected(object sender, ShapeInterface Shape) {
     if (Shape == null) return;
     GetModel().UnselectAll();
     Shape.Select(true);
 }
Exemplo n.º 8
0
        private void btnMultilineExecute_Click(object sender, EventArgs e)
        {
            string userInput = txtMultiLine.Text;

            string[] lineSeparate = userInput.Split('\n');

            foreach (string eachline in lineSeparate)
            {
                if (lineSeparate.Equals(" ") || lineSeparate.Equals(null))
                {
                }
                else
                {
                    string   UserInput = eachline;
                    Validate validate  = new Validate();
                    string[] getInput  = validate.getValidate(UserInput);
                    if (getInput.Length > 1)
                    {
                        if (getInput[0].Equals("moveto"))
                        {
                            int x = Convert.ToInt32(getInput[1]);
                            int y = Convert.ToInt32(getInput[2]);
                            pos1 = x;
                            pos2 = y;
                        }

                        else if (getInput[0].Equals("line"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("rectangle"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("circle"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("triangle"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("polygon"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else
                        {
                            throw new Exception("Parameter Not Found !!!");
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 public void LinkInterface(ShapeInterface _Display)
 {
     display = _Display;
 }