public String CreateObjName()
        {
            int No = 1;

            for (int n = 0; n <= ObjList.Count() - 1; n++)
            {
                if (ObjList[n].ObjName == (ActivedObjType.ToString() + No.ToString()))
                {
                    No = No + 1;
                }
            }
            return(ActivedObjType.ToString() + No.ToString());
        }
Example #2
0
        //protected override void OnPaint(PaintEventArgs pe)
        //{
        //    //SolidBrush brush = new SolidBrush(_backColor);
        //   // pe.Graphics.FillRectangle(brush, this.ClientRectangle);
        //    using (Bitmap bufferimage = new Bitmap(this.Width, this.Height))
        //    {
        //        Graphics g = Graphics.FromImage(bufferimage);
        //        if (objList != null)
        //        {
        //            ObjList.Draw(g, this);
        //        }
        //        using (Graphics tg = pe.Graphics)
        //        {
        //            tg.DrawImage(bufferimage, 0, 0);  //把画布贴到画面上
        //        }
        //        g.Dispose();

        //    }
        //   // brush.Dispose();
        //    // Calling the base class OnPaint
        //    base.OnPaint(pe);
        //}
        private void VisualGraph_Paint(object sender, PaintEventArgs e)
        {
            SolidBrush brush = new SolidBrush(_backColor);

            e.Graphics.FillRectangle(brush, this.ClientRectangle);
            if (ShowGrid)
            {
                //   ControlPaint.DrawGrid(e.Graphics, this.ClientRectangle, gridSize, this.BackColor);
            }
            if (objList != null)
            {
                ObjList.Draw(e.Graphics, this);
            }

            brush.Dispose();
        }
Example #3
0
        public void LoadFromXml(string file)
        {
            XmlDocument   xdoc = new XmlDocument();
            XmlTextReader xtr  = new XmlTextReader(file);

            xdoc.Load(xtr);
            int n = xdoc.DocumentElement.ChildNodes.Count;

            for (int i = 0; i < n; i++)
            {
                XmlElement xe             = (XmlElement)xdoc.DocumentElement.ChildNodes[i];
                string     drawObjectType = xe.GetAttribute("Type");
                if (drawObjectType.Equals("VisualGraph"))
                {
                    DocFromXml(xe);
                }
                else
                {
                    DrawObject drawObject = null;
                    switch (drawObjectType)
                    {
                    case "DrawEllipse":
                        drawObject = (DrawObject)Activator.CreateInstance(typeof(DrawEllipse));
                        break;

                    case "DrawLine":
                        drawObject = (DrawObject)Activator.CreateInstance(typeof(DrawLine));
                        break;

                    case "DrawPic":
                        drawObject = (DrawObject)Activator.CreateInstance(typeof(DrawPic));
                        break;

                    case "DrawRectangle":
                        drawObject = (DrawObject)Activator.CreateInstance(typeof(DrawRectangle));
                        break;

                    case "DrawText":
                        drawObject = (DrawObject)Activator.CreateInstance(typeof(DrawText));
                        break;
                    }
                    drawObject.ReadFromXml(xe);
                    ObjList.AddObject(drawObject);
                }
            }
        }
Example #4
0
        private void VisualGraph_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.PageUnit  = GraphicsUnit.Pixel;
            e.Graphics.PageScale = M_Scalef;

            SolidBrush brush = new SolidBrush(_backColor);

            e.Graphics.FillRectangle(brush, this.ClientRectangle);
            if (ShowGrid)
            {
                ControlPaint.DrawGrid(e.Graphics, this.ClientRectangle, gridSize, this.BackColor);
            }
            if (objList != null)
            {
                ObjList.Draw(e.Graphics, this);
            }
            DrawSelectAll(e.Graphics);
            brush.Dispose();
        }
Example #5
0
 protected override void OnPaint(PaintEventArgs pe)
 {
     using (Bitmap bufferimage = new Bitmap(this.Width, this.Height))
     {
         Graphics   g     = Graphics.FromImage(bufferimage);
         SolidBrush brush = new SolidBrush(_backColor);
         g.FillRectangle(brush, this.ClientRectangle);
         brush.Dispose();
         if (objList != null)
         {
             ObjList.Draw(g, this);
         }
         using (Graphics tg = pe.Graphics)
         {
             tg.DrawImage(bufferimage, 0, 0);   //把画布贴到画面上
         }
         g.Dispose();
     }
     base.OnPaint(pe);
 }
        public void LoadFromXml(string file)
        {
            XmlDocument   xdoc = new XmlDocument();
            XmlTextReader xtr  = new XmlTextReader(file);

            xdoc.Load(xtr);
            int n = xdoc.DocumentElement.ChildNodes.Count;

            for (int i = 0; i < n; i++)
            {
                XmlElement xe             = (XmlElement)xdoc.DocumentElement.ChildNodes[i];
                string     drawObjectType = xe.GetAttribute("Type");
                if (drawObjectType.Equals("VisualGraph"))
                {
                    DocFromXml(xe);
                }
                else
                {
                    DrawObject drawObject = (DrawObject)Activator.CreateInstance("VisualGraph", "VisualGraph." + drawObjectType).Unwrap();
                    drawObject.ReadFromXml(xe);
                    ObjList.AddObject(drawObject);
                }
            }
        }