Ejemplo n.º 1
0
        void openSchFile()
        {
            if (currFile == "" || currFile == null)
            {
                msgbox("Select a Valid File!", "Open File Error");
                return;
            }

            clearScreen();
            // ****************** Opening the File ******************
            String cFile = "";
            String tmpf  = "";

            cFile = currFile;
            shapeX t;
            // printf("\n%s\n", cFile);
            int shape, x, y, x2, y2, rot, ctx;

            ctx = 0;
            try {
                StreamReader file2 = new StreamReader(cFile);
                while ((tmpf = file2.ReadLine()) != null)
                {
                    if (tmpf.Equals("Data:"))
                    {
                        String [] pr = file2.ReadLine().Split(new string[] { " " }, StringSplitOptions.None);
                        shape   = Convert.ToInt32(pr[1]);
                        x       = Convert.ToInt32(pr[2]);
                        y       = Convert.ToInt32(pr[3]);
                        rot     = Convert.ToInt32(pr[4]);
                        x2      = Convert.ToInt32(pr[5]);
                        y2      = Convert.ToInt32(pr[6]);
                        t       = new shapeX(shape, x, y, rot);
                        t.lpx.X = x2; t.lpx.Y = y2;
                        compList.Add(t);
                        ctx++;
                    }
                    if (tmpf.Equals("Text:"))
                    {
                        tmpf = file2.ReadLine();
                        compList[ctx - 1].txt = tmpf;
                    }
                    if (tmpf.Equals("Font:"))
                    {
                        tmpf = file2.ReadLine();
                        //compList[ctx-1].fnt = Font.creat
                    }
                    if (tmpf.Equals("End:"))
                    {
                        msgbox("** End of File **", "Open File");
                        break;
                    }
                }
                file2.Close();
            } catch (IOException e) {
                msgbox("Error: " + e.Message, "Open File Error");
            }
            updateScreen();
        }
Ejemplo n.º 2
0
 void copyShape()
 {
     if (selectedShape != -1)
     {
         currShape = compList[selectedShape];
         updateScreen();
         setEdit("Paste");
     }
 }
Ejemplo n.º 3
0
 void cutShape()
 {
     if (selectedShape != -1)
     {
         currShape = compList[selectedShape];
         compList.RemoveAt(selectedShape);
         updateScreen();
         setEdit("Paste");
     }
 }
Ejemplo n.º 4
0
        private void addShapeX(int x, int y)
        {
            int comp = cbox1.SelectedIndex;

            if (flagPaste == true && selectedShape != -1)
            {
                shapeX t = new shapeX(currShape.shape, x, y, currShape.rot);
                t.lpx = currShape.lpx;  t.txt = currShape.txt;
                compList.Add(t); updateScreen();
                pasteShape(); flagPaste = false; selectedShape = -1; flagSelect = false; return;
            }
            if (flagSelect == true)
            {
                SelectShape(x, y);
            }
            if (flagCopy == true && selectedShape != -1)
            {
                copyShape(); return;
            }
            if (flagCut == true && selectedShape != -1)
            {
                cutShape(); return;
            }


            if (comp == 0 || comp == 1 || comp == 2 || comp == 5)
            {
                if (flagP1 == true)
                {
                    lp1 = new Point(x, y); flagP1 = false;
                }
                else
                {
                    shapeX t = new shapeX(comp, x, y, rotation);
                    t.lpx = lp1;
                    compList.Add(t);
                    updateScreen();
                    flagP1 = true;
                }
            }
            else
            {
                shapeX t = new shapeX(comp, x, y, rotation);
                if (comp == 3)
                {
                    t.txt = txtInput.Text;
                }
                compList.Add(t);
                updateScreen();
            }
        }
Ejemplo n.º 5
0
//************************Edit Options: Copy, Cut and Paste **************************
        void SelectShape(int x, int y)
        {
            shapeX t;
            int    rx1, rx2, ry1, ry2, comp, rg;

            selectedShape = -1;
            for (int i = 0; i < compList.Count(); i++)
            {
                t    = compList[i];
                comp = t.shape;
                if (comp == 0 || comp == 1 || comp == 2 || comp == 5)
                {
                }
                else
                {
                    if (t.rot == 0)
                    {
                        t.lpx.X = t.x + 40; t.lpx.Y = t.y + 20;
                    }
                    if (t.rot == 1)
                    {
                        t.lpx.X = t.x + 20; t.lpx.Y = t.y + 40;
                    }
                    if (t.rot == 2)
                    {
                        t.lpx.X = t.x - 40; t.lpx.Y = t.y - 20;
                    }
                    if (t.rot == 3)
                    {
                        t.lpx.X = t.x - 20; t.lpx.Y = t.y - 40;
                    }
                }


                if (t.x > t.lpx.X)
                {
                    rx2 = t.x; rx1 = t.lpx.X;
                }
                else
                {
                    rx1 = t.x; rx2 = t.lpx.X;
                }
                if (t.y > t.lpx.Y)
                {
                    ry2 = t.y; ry1 = t.lpx.Y;
                }
                else
                {
                    ry1 = t.y; ry2 = t.lpx.Y;
                }

                //drawComponent(g2, t.shape, t.x, t.y, t.rot, t.lpx, false, t.txt);
                rg = 4;
                if (x >= rx1 - rg && x <= rx2 + rg && y >= ry1 - rg && y <= ry2 + rg)
                {
                    selectedShape = i; currShape = compList[i]; break;
                }
            }
            //selectedShape = 2;
            MoveGraphics();
            showSelectedShape();
            if (selectedShape != -1)
            {
                flagSelect = false;
            }
        }