Example #1
0
 private List<BaseRailEle> ArrangeStrEle(List<BaseRailEle> paraList)
 {
     List<BaseRailEle> tempList = new List<BaseRailEle>();
     StraightRailEle strTemp = new StraightRailEle();
     CrossEle crossTemp = new CrossEle();
     Int16 num = Convert.ToInt16(paraList.Count);
     for (Int16 i = 0; i < num; i++)
     {
         for (Int16 j = 0; j < num; j++)
         {
             if (paraList[j].GraphType == 1)
             {
                 strTemp = (StraightRailEle)paraList[j];
                 if (strTemp.SegmentNumber == (i + 1))
                 {
                     tempList.Add(paraList[j]);
                     break;
                 }
             }
             else if (paraList[j].GraphType == 3)
             {
                 crossTemp = (CrossEle)paraList[j];
                 if (crossTemp.SegmentNumber == (i + 1))
                 {
                     tempList.Add(paraList[j]);
                     break;
                 }
             }
         }
     }
     return tempList;
 }
Example #2
0
        public object Clone(string str)
        {
            StraightRailEle cl = new StraightRailEle();

            cl.pen = pen;
            cl.PointList.AddRange(PointList);
            cl.lenght          = lenght;
            cl.DrawMultiFactor = DrawMultiFactor;
            cl.objectStaightOp.DrawMultiFactor = DrawMultiFactor;
            cl.railText = str;
            return(cl);
        }
Example #3
0
 public void Paste(string str)
 {
     if (CutAndCopyObjectList.Count > 0)
     {
         if (_CutOrCopy == CutOrCopy.CutOp)
         {
             int n = selectedDrawObjectList.Count;
             foreach (BaseRailEle obj in selectedDrawObjectList)
             {
                 drawObjectList.Remove(obj);
             }
         }
         else if (_CutOrCopy == CutOrCopy.CopyOp)
         {
             BaseRailEle o = CutAndCopyObjectList[0];
             if (1 == o.GraphType)
             {
                 StraightRailEle cl = (StraightRailEle)o;
                 StraightRailEle n  = (StraightRailEle)cl.Clone(str);
                 drawObjectList.Add(n);
                 SelectOne(n);
             }
             else if (2 == o.GraphType)
             {
                 CurvedRailEle cl = (CurvedRailEle)o;
                 CurvedRailEle n  = (CurvedRailEle)cl.Clone(str);
                 drawObjectList.Add(n);
                 SelectOne(n);
             }
             else if (3 == o.GraphType)
             {
                 CrossEle cl = (CrossEle)o;
                 CrossEle n  = (CrossEle)cl.Clone(str);
                 drawObjectList.Add(n);
                 SelectOne(n);
             }
             else if (4 == o.GraphType)
             {
                 RailLabal cl = (RailLabal)o;
                 RailLabal n  = (RailLabal)cl.Clone();
                 drawObjectList.Add(n);
                 SelectOne(n);
             }
             CutAndCopyObjectList.RemoveAt(0);
         }
     }
 }
Example #4
0
 public void CreateElement(Point mousePt, Size workRegionSize)
 {
     string str = this.tools.itemSelected.Text;
     switch (this.tools.itemSelected.Text)
     {
         case "Line":
             BaseRailElement.StraightRailEle strRailEle = new BaseRailElement.StraightRailEle();
             ++lineNumber;
             str += "_" + lineNumber.ToString();
             strRailEle.CreateEle(mousePt, workRegionSize, multiFactor, str);
             AddElement(strRailEle);
             drawDoc.SelectOne(strRailEle);
             workRegion.pictureBox1.Invalidate();
             proPage.propertyGrid1.SelectedObject = strRailEle;
             proPage.propertyGrid1.Refresh();
             break;
         case "Curve":
             BaseRailElement.CurvedRailEle curRailEle = new BaseRailElement.CurvedRailEle();
             ++curveNumber;
             str += "_" + curveNumber.ToString();
             curRailEle.CreateEle(mousePt, workRegionSize, multiFactor, str);
             AddElement(curRailEle);
             drawDoc.SelectOne(curRailEle);
             workRegion.pictureBox1.Invalidate();
             proPage.propertyGrid1.SelectedObject = curRailEle;
             proPage.propertyGrid1.Refresh();
             break;
         case "Cross":
             BaseRailElement.CrossEle croRailEle = new BaseRailElement.CrossEle();
             ++CrossNumber;
             str += "_" + CrossNumber.ToString();
             croRailEle.CreateEle(mousePt, workRegionSize, multiFactor, str);
             AddElement(croRailEle);
             drawDoc.SelectOne(croRailEle);
             workRegion.pictureBox1.Invalidate();
             proPage.propertyGrid1.SelectedObject = croRailEle;
             proPage.propertyGrid1.Refresh();
             break;
         case "Device":
             MessageBox.Show("a");
             break;
         default:
             break;
     }
     this.tools.itemSelected = null;
 }
Example #5
0
        private List <BaseRailEle> GetStrEle(List <BaseRailEle> paraList)
        {
            List <BaseRailEle> tempList  = new List <BaseRailEle>();
            StraightRailEle    strTemp   = new StraightRailEle();
            CrossEle           crossTemp = new CrossEle();
            Int16 num = Convert.ToInt16(paraList.Count);

            for (Int16 i = 0; i < num; i++)
            {
                if (paraList[i].GraphType == 1)
                {
                    strTemp = (StraightRailEle)paraList[i];
                    //if (strTemp.StartDot == "first dot")
                    //{
                    //    paraList[i].StartPoint = strTemp.PointList[0];
                    //    paraList[i].EndPoint = strTemp.PointList[1];
                    //}
                    //else if (strTemp.StartDot == "sec dot")
                    //{
                    //    paraList[i].StartPoint = strTemp.PointList[1];
                    //    paraList[i].EndPoint = strTemp.PointList[0];
                    //}
                    paraList[i].StartPoint = strTemp.PointList[0];
                    paraList[i].EndPoint   = strTemp.PointList[1];
                    tempList.Add(paraList[i]);
                }
                else if (paraList[i].GraphType == 3)
                {
                    crossTemp = (CrossEle)paraList[i];
                    //if (crossTemp.StartDot == "first dot")
                    //{
                    //    paraList[i].StartPoint = crossTemp.PointList[0];
                    //    paraList[i].EndPoint = crossTemp.PointList[5];
                    //}
                    //else if (crossTemp.StartDot == "sec dot")
                    //{
                    //    paraList[i].StartPoint = crossTemp.PointList[5];
                    //    paraList[i].EndPoint = crossTemp.PointList[0];
                    //}
                    paraList[i].StartPoint = crossTemp.PointList[0];
                    paraList[i].EndPoint   = crossTemp.PointList[5];
                }
            }
            return(tempList);
        }
Example #6
0
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     if (pic1)
     {
         PictureBox pic      = sender as PictureBox;
         Point      pt_new_e = PicPtTrans(sender, e);
         if (0 < pt_new_e.X && DrawRegion.Size.Width > pt_new_e.X && 0 < pt_new_e.Y && DrawRegion.Size.Height > pt_new_e.Y)
         {
             BaseRailElement.StraightRailEle strRailEle = new BaseRailElement.StraightRailEle();
             Point pt = new Point(pt_new_e.X, pt_new_e.Y);
             doc1.DrawObjectList.Add(strRailEle.CreatEle(pt, DrawRegion.Size, multiFactor));
             doc1.SelectOne(strRailEle);
             DrawRegion.Invalidate();
             propertyGrid1.SelectedObject = strRailEle;
             propertyGrid1.Invalidate();
         }
         pic1 = false;
     }
     this.Cursor = System.Windows.Forms.Cursors.Default;
 }
Example #7
0
 public object Clone(string str)
 {
     StraightRailEle cl = new StraightRailEle();
     cl.pen = pen;
     cl.PointList.AddRange(PointList);
     cl.lenght = lenght;
     cl.DrawMultiFactor = DrawMultiFactor;
     cl.objectStaightOp.DrawMultiFactor = DrawMultiFactor;
     cl.railText = str;
     return cl;
 }
Example #8
0
 private List<BaseRailEle> GetStrEle(List<BaseRailEle> paraList)
 {
     List<BaseRailEle> tempList = new List<BaseRailEle>();
     StraightRailEle strTemp = new StraightRailEle();
     CrossEle crossTemp = new CrossEle();
     Int16 num = Convert.ToInt16(paraList.Count);
     for (Int16 i = 0; i < num; i++)
     {
         if (paraList[i].GraphType == 1)
         {
             strTemp = (StraightRailEle)paraList[i];
             //if (strTemp.StartDot == "first dot")
             //{
             //    paraList[i].StartPoint = strTemp.PointList[0];
             //    paraList[i].EndPoint = strTemp.PointList[1];
             //}
             //else if (strTemp.StartDot == "sec dot")
             //{
             //    paraList[i].StartPoint = strTemp.PointList[1];
             //    paraList[i].EndPoint = strTemp.PointList[0];
             //}
             paraList[i].StartPoint = strTemp.PointList[0];
             paraList[i].EndPoint = strTemp.PointList[1];
             tempList.Add(paraList[i]);
         }
         else if (paraList[i].GraphType == 3)
         {
             crossTemp = (CrossEle)paraList[i];
             //if (crossTemp.StartDot == "first dot")
             //{
             //    paraList[i].StartPoint = crossTemp.PointList[0];
             //    paraList[i].EndPoint = crossTemp.PointList[5];
             //}
             //else if (crossTemp.StartDot == "sec dot")
             //{
             //    paraList[i].StartPoint = crossTemp.PointList[5];
             //    paraList[i].EndPoint = crossTemp.PointList[0];
             //}
             paraList[i].StartPoint = crossTemp.PointList[0];
             paraList[i].EndPoint = crossTemp.PointList[5];
         }
     }
     return tempList;
 }
Example #9
0
 private bool OpenXmlFile(DataSet ds)
 {
     try
     {
         DataTable dt = ds.Tables[0];
         for (int i = 0; i < dt.Rows.Count;i++ )
         {
             DataColumn dc = dt.Columns[0];
             if (dc.ColumnName == "GraphType")
             {
                 switch (dt.Rows[i][0].ToString())
                 {
                     case "1":
                         BaseRailElement.StraightRailEle strTemp = new BaseRailElement.StraightRailEle();
                         string str = "";
                         string[] strPointArray = { };
                         Point ptTemp = Point.Empty;
                         Int16 pointListVolStr = 0;
                         for (int j = 0; j < dt.Columns.Count; j++)
                         {
                             switch (dt.Columns[j].ColumnName)
                             {
                                 case "GraphType":
                                     strTemp.GraphType = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "Speed":
                                     strTemp.Speed = Convert.ToSingle(dt.Rows[i][j]);
                                     break;
                                 case "SegmentNumber":
                                     strTemp.SegmentNumber = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "TagNumber":
                                     strTemp.TagNumber = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "Lenght":
                                     strTemp.Lenght = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "StartAngle":
                                     strTemp.StartAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "StartDot":
                                     strTemp.StartDot = Convert.ToString(dt.Rows[i][j]);
                                     break;
                                 case "PointListVol":
                                     pointListVolStr = Convert.ToInt16(dt.Rows[i][j]);
                                     for (int k = 0; k < pointListVolStr; k++)
                                     {
                                         str = dt.Rows[i][j + k + 1].ToString();
                                         str = str.Substring(1, str.Length - 2);
                                         strPointArray = str.Split(',');
                                         ptTemp = new Point() { X = int.Parse(strPointArray[0].Substring(2)), Y = int.Parse(strPointArray[1].Substring(2)) };
                                         strTemp.PointList.Add(ptTemp);
                                     }
                                     break;
                                 case "DrawMultiFactor":
                                     strTemp.DrawMultiFactor = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "startPoint":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArray = str.Split(',');
                                     ptTemp = new Point() { X = int.Parse(strPointArray[0].Substring(2)), Y = int.Parse(strPointArray[1].Substring(2)) };
                                     strTemp.StartPoint = ptTemp;
                                     break;
                                 case "endPoint":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArray = str.Split(',');
                                     ptTemp = new Point() { X = int.Parse(strPointArray[0].Substring(2)), Y = int.Parse(strPointArray[1].Substring(2)) };
                                     strTemp.EndPoint = ptTemp;
                                     break;
                                 case "railText":
                                     strTemp.railText = dt.Rows[i][j].ToString();
                                     break;
                                 case "rotateAngle":
                                     strTemp.RotateAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "nextCoding":
                                     strTemp.NextCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "prevCoding":
                                     strTemp.PrevCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "Color":
                                     strTemp.PenColor = ColorTranslator.FromHtml(dt.Rows[i][j].ToString());
                                     break;
                                 case "DashStyle":
                                     strTemp.PenDashStyle = (System.Drawing.Drawing2D.DashStyle)(Convert.ToInt32(dt.Rows[i][j]));
                                     break;
                                 case "PenWidth":
                                     strTemp.PenWidth = Convert.ToSingle(dt.Rows[i][j]);
                                     break;
                             }
                         }
                         AddElement(strTemp);
                         break;
                     case "2":
                         BaseRailElement.CurvedRailEle curTemp = new BaseRailElement.CurvedRailEle();
                         string strcur = "";
                         string[] strPointArrayCur = { };
                         Point ptcur = Point.Empty;
                         for (int j = 0; j < dt.Columns.Count; j++)
                         {
                             switch (dt.Columns[j].ColumnName)
                             {
                                 case "GraphType":
                                     curTemp.GraphType = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "Speed":
                                     curTemp.Speed = Convert.ToSingle(dt.Rows[i][j]);
                                     break;
                                 case "SegmentNumber":
                                     curTemp.SegmentNumber = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "TagNumber":
                                     curTemp.TagNumber = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "StartAngle":
                                     curTemp.StartAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "SweepAngle":
                                     curTemp.SweepAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "Radiu":
                                     curTemp.Radiu = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "Center":
                                     strcur = dt.Rows[i][j].ToString();
                                     strcur = strcur.Substring(1, strcur.Length - 2);
                                     strPointArrayCur = strcur.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.Center = ptcur;
                                     break;
                                 case "FirstDot":
                                     strcur = dt.Rows[i][j].ToString();
                                     strcur = strcur.Substring(1, strcur.Length - 2);
                                     strPointArrayCur = strcur.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.FirstDot = ptcur;
                                     break;
                                 case "SecDot":
                                     strcur = dt.Rows[i][j].ToString();
                                     strcur = strcur.Substring(1, strcur.Length - 2);
                                     strPointArrayCur = strcur.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.SecDot = ptcur;
                                     break;
                                 case "DirectionCurvedAttribute":
                                     curTemp.DirectionCurvedAttribute = (BaseRailElement.CurvedRailEle.DirectonCurved)Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "startPoint":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArrayCur = str.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.StartPoint = ptcur;
                                     break;
                                 case "endPoint":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArrayCur = str.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.EndPoint = ptcur;
                                     break;
                                 case "startCoding":
                                     curTemp.StartCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "endCoding":
                                     curTemp.EndCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "railText":
                                     curTemp.railText = dt.Rows[i][j].ToString();
                                     break;
                                 case "rotateAngle":
                                     curTemp.RotateAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "oldRadiu":
                                     curTemp.oldRadiu = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "oldCenter":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArrayCur = str.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.oldCenter = ptcur;
                                     break;
                                 case "oldFirstDot":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArrayCur = str.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.oldFirstDot = ptcur;
                                     break;
                                 case "oldSecDot":
                                     str = dt.Rows[i][j].ToString();
                                     str = str.Substring(1, str.Length - 2);
                                     strPointArrayCur = str.Split(',');
                                     ptcur = new Point() { X = int.Parse(strPointArrayCur[0].Substring(2)), Y = int.Parse(strPointArrayCur[1].Substring(2)) };
                                     curTemp.oldSecDot = ptcur;
                                     break;
                                 case "Color":
                                     curTemp.PenColor = ColorTranslator.FromHtml(dt.Rows[i][j].ToString());
                                     break;
                                 case "DashStyle":
                                     curTemp.PenDashStyle = (System.Drawing.Drawing2D.DashStyle)(Convert.ToInt32(dt.Rows[i][j]));
                                     break;
                                 case "PenWidth":
                                     curTemp.PenWidth = Convert.ToSingle(dt.Rows[i][j]);
                                     break;
                             }
                         }
                         AddElement(curTemp);
                         break;
                     case "3":
                         BaseRailElement.CrossEle croTemp = new BaseRailElement.CrossEle();
                         string strcro = "";
                         string[] strPointArrayCro = { };
                         Point ptcro = Point.Empty;
                         Int16 pointListVolCro = 0;
                         for (int j = 0; j < dt.Columns.Count; j++)
                         {
                             switch (dt.Columns[j].ColumnName)
                             {
                                 case "GraphType":
                                     croTemp.GraphType = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "Speed":
                                     croTemp.Speed = Convert.ToSingle(dt.Rows[i][j]);
                                     break;
                                 case "SegmentNumber":
                                     croTemp.SegmentNumber = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "TagNumber":
                                     croTemp.TagNumber = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "Mirror":
                                     croTemp.Mirror = Convert.ToBoolean(dt.Rows[i][j]);
                                     break;
                                 case "FirstPart":
                                     croTemp.FirstPart = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "SecPart":
                                     croTemp.SecPart = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "ThPart":
                                     croTemp.ThPart = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "FourPart":
                                     strcro = dt.Rows[i][j].ToString();
                                     strcro = strcro.Substring(1, strcro.Length - 2);
                                     strPointArrayCro = strcro.Split(',');
                                     ptcro = new Point() { X = int.Parse(strPointArrayCro[0].Substring(2)), Y = int.Parse(strPointArrayCro[1].Substring(2)) };
                                     croTemp.FourPart = ptcro;
                                     break;
                                 case "StartAngle":
                                     croTemp.StartAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "RotateAngle":
                                     croTemp.RotateAngle = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "DirectionOfCross":
                                     croTemp.DirectionOfCross = (BaseRailElement.CrossEle.DirectionCross)Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "PointListVol":
                                     pointListVolCro = Convert.ToInt16(dt.Rows[i][j]);
                                     for (Int16 k = 0; k < pointListVolCro; k++)
                                     {
                                         strcro = dt.Rows[i][j + k + 1].ToString();
                                         strcro = strcro.Substring(1, strcro.Length - 2);
                                         strPointArrayCro = strcro.Split(',');
                                         ptcro = new Point() { X = int.Parse(strPointArrayCro[0].Substring(2)), Y = int.Parse(strPointArrayCro[1].Substring(2)) };
                                         croTemp.PointList.Add(ptcro);
                                     }
                                     break;
                                 case "drawMultiFactor":
                                     croTemp.DrawMultiFactor = Convert.ToInt16(dt.Rows[i][j]);
                                     break;
                                 case "startPoint":
                                     strcro = dt.Rows[i][j].ToString();
                                     strcro = strcro.Substring(1, strcro.Length - 2);
                                     strPointArrayCro = strcro.Split(',');
                                     ptcro = new Point() { X = int.Parse(strPointArrayCro[0].Substring(2)), Y = int.Parse(strPointArrayCro[1].Substring(2)) };
                                     croTemp.StartPoint = ptcro;
                                     break;
                                 case "endPoint":
                                     strcro = dt.Rows[i][j].ToString();
                                     strcro = strcro.Substring(1, strcro.Length - 2);
                                     strPointArrayCro = strcro.Split(',');
                                     ptcro = new Point() { X = int.Parse(strPointArrayCro[0].Substring(2)), Y = int.Parse(strPointArrayCro[1].Substring(2)) };
                                     croTemp.EndPoint = ptcro;
                                     break;
                                 case "startCoding":
                                     croTemp.StartCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "endCoding":
                                     croTemp.EndCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "railText":
                                     croTemp.railText = dt.Rows[i][j].ToString();
                                     break;
                                 case "lenghtOfStrai":
                                     croTemp.LenghtOfStrai = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "nextCoding":
                                     croTemp.NextCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "prevCoding":
                                     croTemp.PrevCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "thirdDotCoding":
                                     croTemp.ThirdDotCoding = Convert.ToInt32(dt.Rows[i][j]);
                                     break;
                                 case "startDot":
                                     croTemp.StartDot = dt.Rows[i][j].ToString();
                                     break;
                                 case "Color":
                                     croTemp.PenColor = ColorTranslator.FromHtml(dt.Rows[i][j].ToString());
                                     break;
                                 case "DashStyle":
                                     croTemp.PenDashStyle = (System.Drawing.Drawing2D.DashStyle)(Convert.ToInt32(dt.Rows[i][j]));
                                     break;
                                 case "PenWidth":
                                     croTemp.PenWidth = Convert.ToSingle(dt.Rows[i][j]);
                                     break;
                             }
                         }
                         AddElement(croTemp);
                         break;
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("this is a error when open xml save file");
         return false;
     }
     return true;
 }
Example #10
0
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     if (pic1)
     {
         PictureBox pic = sender as PictureBox;
         Point pt_new_e = PicPtTrans(sender, e);
         if (0 < pt_new_e.X && DrawRegion.Size.Width > pt_new_e.X && 0 < pt_new_e.Y && DrawRegion.Size.Height > pt_new_e.Y)
         {
             BaseRailElement.StraightRailEle strRailEle = new BaseRailElement.StraightRailEle();
             Point pt = new Point(pt_new_e.X, pt_new_e.Y);
             doc1.DrawObjectList.Add(strRailEle.CreatEle(pt, DrawRegion.Size, multiFactor));
             doc1.SelectOne(strRailEle);
             DrawRegion.Invalidate();
             propertyGrid1.SelectedObject = strRailEle;
             propertyGrid1.Invalidate();
         }
         pic1 = false;
     }
     this.Cursor = System.Windows.Forms.Cursors.Default;
 }
Example #11
0
        public override void OnMouseMove(Point point)
        {
            int dx = point.X - lastPoint.X;
            int dy = point.Y - lastPoint.Y;
            int n  = document.SelectedDrawObjectList.Count;
            int tempDrawMultiFactor = 1;

            switch (selectObject)
            {
            case SelectObject.SelectHandle:
                tempDrawMultiFactor = document.SelectedDrawObjectList[0].DrawMultiFactor;
                if ((dx != 0 && dx / tempDrawMultiFactor != 0) || (dy != 0 && dy / tempDrawMultiFactor != 0))
                {
                    if (document.SelectedDrawObjectList[0].GraphType == 1)
                    {
                        if (n == 1)
                        {
                            document.SelectedDrawObjectList[0].MoveHandle(_hit, lastPoint, point);
                        }
                    }
                    else if (document.SelectedDrawObjectList[0].GraphType == 2)
                    {
                        if (n == 1)
                        {
                            document.SelectedDrawObjectList[0].MoveHandle(_hit, lastPoint, point);
                        }
                    }
                    else if (document.SelectedDrawObjectList[0].GraphType == 3)
                    {
                        if (n == 1)
                        {
                            document.SelectedDrawObjectList[0].MoveHandle(_hit, lastPoint, point);
                        }
                    }
                    else if (document.SelectedDrawObjectList[0].GraphType == 4)
                    {
                        if (n == 1)
                        {
                            document.SelectedDrawObjectList[0].MoveHandle(_hit, lastPoint, point);
                        }
                    }
                    lastPoint.Offset(dx / tempDrawMultiFactor * tempDrawMultiFactor, dy / tempDrawMultiFactor * tempDrawMultiFactor);
                }
                break;

            case SelectObject.SelectEle:
                tempDrawMultiFactor = document.SelectedDrawObjectList[0].DrawMultiFactor;
                if ((dx != 0 && dx / tempDrawMultiFactor != 0) || (dy != 0 && dy / tempDrawMultiFactor != 0))
                {
                    for (int i = 0; i < n; i++)
                    {
                        if (document.SelectedDrawObjectList[i].GraphType == 1)
                        {
                            StraightRailEle de = (StraightRailEle)document.SelectedDrawObjectList[i];
                            document.SelectedDrawObjectList[i].Move(lastPoint, point);
                        }
                        else if (document.SelectedDrawObjectList[i].GraphType == 2)
                        {
                            CurvedRailEle de = (CurvedRailEle)document.SelectedDrawObjectList[i];
                            document.SelectedDrawObjectList[i].Move(lastPoint, point);
                        }
                        else if (document.SelectedDrawObjectList[i].GraphType == 3)
                        {
                            CrossEle de = (CrossEle)document.SelectedDrawObjectList[i];
                            document.SelectedDrawObjectList[i].Move(lastPoint, point);
                        }
                        else if (document.SelectedDrawObjectList[i].GraphType == 4)
                        {
                            RailLabal de = (RailLabal)document.SelectedDrawObjectList[i];
                            document.SelectedDrawObjectList[i].Move(lastPoint, point);
                        }
                    }
                    lastPoint.Offset(dx / tempDrawMultiFactor * tempDrawMultiFactor, dy / tempDrawMultiFactor * tempDrawMultiFactor);
                }
                break;

            case SelectObject.SelectNone:
                document.ChangeChooseSign(true, point);
                base.OnMouseMove(point);
                break;
            }
            Debug.WriteLine(string.Format("move pt is {0} lastpoint is {1} tempDrawMultiFactor is {2}", point, lastPoint, tempDrawMultiFactor));
        }