private void deleteGraphicsPath(GraphicsObject gObject)
        {
            try {
                g.DrawPath(clearPen, gObject.gPath);
                listGObject.Remove(gObject);
                drawCollection(listGObject, blackPen);
            }
            catch (System.ArgumentNullException)
            {

            }
            catch (System.NullReferenceException)
            {
                //MessageBox.Show("Попытка вызова пустого класса?");
            }
        }
Exemplo n.º 2
0
        private void imageBox_MouseClick(object sender, MouseEventArgs e)
        {
            try {
                switch (typeEdit)
                {
                    case "drawText":
                        timer1.Enabled = false;
                        listGObject.Add(drawText(e.X, e.Y, stf.text, blackPen ));
                        drawCollection(listGObject, blackPen);
                       // typeEdit = null;
                        break;

                    case "drawRetangle":
                        timer1.Enabled = false;
                        g.Clear(foneColor);
                        listGObject.Add(drawRetangle(e.X, e.Y, blackPen));
                        drawCollection(listGObject, blackPen); // рисуем фигуры

                        typeEdit = null; // фигура поставлена
                        break;

                    case "edit":
                        if (checkBox1.Checked) deleteGraphicsPath(searchGpaphicsPath(listGObject, e.X, e.Y));
                        else
                        {
                            gObject = searchGpaphicsPath(listGObject, e.X, e.Y);
                            listGObject.Remove(gObject);
                            lenght = gObject.lenght();
                            height = gObject.height();
                            stf.text = gObject.text;
                            typeEdit = "editMove";
                            timer1.Enabled = true;
                        }
                        break;

                    case "editMove":
                        firstStart = true;
                        switch (gObject.type)
                        {
                            case "line":
                                gObject.setLine(bx, by, bx + lenght, by + height);
                                g.DrawPath(clearPen, gObject.gPath);
                                gObject.setLine(e.X, e.Y, e.X + lenght, e.Y + height);
                                bx = e.X;
                                by = e.Y;
                                g.DrawPath(blackPen, gObject.gPath);
                                listGObject.Add(gObject);
                                typeEdit = "edit";
                                timerStop = true;
                                break;

                            case "retangle":
                                gObject.setRetangle(bx, by, gObject.x2, gObject.y2);
                                g.DrawPath(clearPen, gObject.gPath);
                                gObject.setRetangle(e.X, e.Y, gObject.x2, gObject.y2);
                                bx = e.X;
                                by = e.Y;
                                g.DrawPath(blackPen, gObject.gPath);
                                listGObject.Add(gObject);
                                typeEdit = "edit";
                                timerStop = true;
                                break;

                            case "text":
                                drawText(bx, by, stf.text, clearPen);
                               listGObject.Add(drawText(e.X, e.Y, stf.text, clearPen));
                                typeEdit = "edit";
                                timerStop = true;
                                break;
                            case "lineAndText":
                                drawLineAndText(bx, by, bx + lenght, by + height, stf.text, clearPen);
                                listGObject.Add(drawLineAndText(e.X, e.Y, x1 + lenght, by + height, stf.text, blackPen));
                                typeEdit = "edit";
                                timerStop = true;
                                break;

                        }
                        break;
                    default:
                        return;
                }
            }
            catch (System.ArgumentNullException) { typeEdit = "edit"; }
            catch (System.NullReferenceException) { typeEdit = "edit"; }
        }
Exemplo n.º 3
0
 private GraphicsObject drawText(int x, int y, string text, Pen pen)
 {
     gObject = new GraphicsObject("text");
     gObject.x1 = x; gObject.y1 = y; gObject.text = text;
     if (gObject.Create())
     {
         g.DrawPath(pen, gObject.gPath);
         return gObject;
     }
     else
     {
         MessageBox.Show("Не указан текст!");
         typeEdit = null;
         return null;
     }
 }
Exemplo n.º 4
0
 private GraphicsObject drawRetangle(int x, int y, Pen pen)
 {
     gObject = new GraphicsObject("retangle");
     if (gObject.setRetangle(x, y, (int)retLength.Value, (int)retHeight.Value))
     {
        // Debug1.setInfo(gObject.zoneX1, gObject.zoneX11, gObject.zoneY1, gObject.zoneY11);
         g.DrawPath(pen, gObject.gPath);
         return gObject;
     }
     else return null;
 }
Exemplo n.º 5
0
 private GraphicsObject drawLineAndText(int x1, int y1, int x2, int y2, string text, Pen pen)
 {
     gObject = new GraphicsObject("lineAndText");
     gObject.x1 = x1; gObject.y1 = y1; gObject.x2 = x2; gObject.y2 = y2; gObject.text = text;
     if (gObject.Create())
     {
         g.DrawPath(pen, gObject.gPath);
         return gObject;
     }
     else
     {
         MessageBox.Show("Не указан текст!");
         typeEdit = null;
         return null;
     }
 }
Exemplo n.º 6
0
        private GraphicsObject drawLine(int x1, int y1, int x2, int y2, Pen pen)
        {
            gObject = new GraphicsObject("line");

            if (gObject.setLine(x1, y1, x2, y2))
            {
               // Debug1.setInfo(gObject.zoneX1, gObject.zoneX11, gObject.zoneY1, gObject.zoneY11);
                g.DrawPath(pen, gObject.gPath);
                return gObject;
            }
            else return null;
        }
Exemplo n.º 7
0
        // загрузчик моделей
        private string binaryLoad(string fileName)
        {
            FileStream myStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryReader BR = new BinaryReader(myStream);
            GraphicsObject sgo;
            listGObject.Clear();
            string typeModel = BR.ReadString(); // читает тип модели
            label2.Text = BR.ReadString();
            label3.Text = BR.ReadString();
            label4.Text = BR.ReadString();
            while(BR.PeekChar() != - 1)
            {
                sgo = new GraphicsObject();
                sgo.type = BR.ReadString();
                sgo.text = BR.ReadString();
                sgo.x1 = BR.ReadInt32();
                sgo.x2 = BR.ReadInt32();
                sgo.y1 = BR.ReadInt32();
                sgo.y2 = BR.ReadInt32();
                sgo.Create();
                listGObject.Add(sgo);

            }

            BR.Close();
            myStream.Close();
            g.Clear(foneColor);
            drawCollection(listGObject, blackPen);
              //  MessageBox.Show(typeModel);
            return typeModel;
        }
        private void imageBox_MouseClick(object sender, MouseEventArgs e)
        {
            try {
                if (typeEdit == 5)
                {
                    if (gObject.type == "line")
                    {
                        gObject.setLine(bx, by, bx + lenght, by + height);
                        g.DrawPath(clearPen, gObject.gPath);
                        gObject.setLine(e.X, e.Y, e.X + lenght, e.Y + height);
                        bx = e.X;
                        by = e.Y;
                        g.DrawPath(blackPen, gObject.gPath);
                        listGObject.Add(gObject);
                        typeEdit = 0;
                        timer1.Enabled = false;
                    }
                    if (gObject.type == "retangle")
                    {
                        gObject.setRetangle(bx, by, gObject.x2, gObject.y2);
                        g.DrawPath(clearPen, gObject.gPath);
                        gObject.setRetangle(e.X, e.Y, gObject.x2, gObject.y2);
                        bx = e.X;
                        by = e.Y;
                        g.DrawPath(blackPen, gObject.gPath);
                        listGObject.Add(gObject);
                        typeEdit = 0;
                        timer1.Enabled = false;
                    }

                }

                if (typeEdit == 3)
                {
                    if (checkBox1.Checked) deleteGraphicsPath(searchGpaphicsPath(listGObject, e.X, e.Y));
                    else
                    {
                        gObject = searchGpaphicsPath(listGObject, e.X, e.Y);
                        listGObject.Remove(gObject);
                        lenght = gObject.lenght();
                        height = gObject.height();
                        typeEdit = 5;
                        timer1.Enabled = true;
                    }

                    //  MessageBox.Show("тычок:  " + e.X + "-" + e.Y );
                }

            }
            catch (System.ArgumentNullException) { typeEdit = 3; }
            catch (System.NullReferenceException) { typeEdit = 3; }

            if (typeEdit == 2) // если фигура выбрана
                {

                    timer1.Enabled = false;
                    g.Clear(foneColor);
                    listGObject.Add(drawRetangle(e.X, e.Y, blackPen));
                    drawCollection(listGObject, blackPen); // рисуем фигуры

                    typeEdit = 0; // фигура поставлена
                }
        }
 private GraphicsObject drawLine(int x1, int y1, int x2, int y2, Pen pen)
 {
     gObject = new GraphicsObject("line", x1 ,y1, x2, y2);
        // gObject.x1 = x1; gObject.x2 = x2; gObject.y1 = y1; gObject.y2 = y2;
     if (gObject.Create())
     {
         g.DrawPath(pen, gObject.gPath);
         return gObject;
     }
     else return null;
 }