Exemple #1
0
 private void TrackLine_lv_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (TrackLine_lv.SelectedItems.Count != 0)
     {
         deleteBtn.Enabled = true;
         TrackLine _tl = tLine[TrackLine_lv.SelectedItems[0].Index];
         id_tb.Text         = _tl.trackLineID.ToString();
         describe_tb.Text   = _tl.trackText.ToString();
         leftX_tb.Text      = _tl.selfLeftPoint.X.ToString();
         leftY_tb.Text      = _tl.selfLeftPoint.Y.ToString();
         rightX_tb.Text     = _tl.selfRightPoint.X.ToString();
         rightY_tb.Text     = _tl.selfRightPoint.Y.ToString();
         leftWayTo_tb.Text  = _tl.leftWayTo;
         rightWayTo_tb.Text = _tl.rightWayTo;
         if (_tl.leftTrackPoint != null)
         {
             lPoint_tb.Text = _tl.leftTrackPoint.trackPointID.ToString();
         }
         if (_tl.rightTrackPoint != null)
         {
             rPoint_tb.Text = _tl.rightTrackPoint.trackPointID.ToString();
         }
     }
     else
     {
         deleteBtn.Enabled = false;
     }
 }
Exemple #2
0
 private void SaveBtn_Click(object sender, EventArgs e)
 {
     try
     {
         TrackLine _tl = new TrackLine();
         if ((id_tb.Text.Length != 0 &&
              describe_tb.Text.Length != 0 &&
              leftX_tb.Text.Length != 0 &&
              leftY_tb.Text.Length != 0 &&
              rightX_tb.Text.Length != 0 &&
              rightY_tb.Text.Length != 0)
             )
         {
             _tl.trackLineID    = int.Parse(id_tb.Text);
             _tl.trackText      = describe_tb.Text;
             _tl.selfLeftPoint  = new Point(int.Parse(leftX_tb.Text), int.Parse(leftY_tb.Text));
             _tl.selfRightPoint = new Point(int.Parse(rightX_tb.Text), int.Parse(rightY_tb.Text));
             if (lPoint_tb.Text.Length != 0 &&
                 tempLPoint != null)
             {
                 _tl.leftTrackPoint = tempLPoint;
             }
             if (rPoint_tb.Text.Length != 0 &&
                 tempRPoint != null)
             {
                 _tl.rightTrackPoint = tempRPoint;
             }
             if (TrackLine_lv.SelectedItems.Count != 0)
             {
                 tLine.RemoveAt(TrackLine_lv.SelectedItems[0].Index);
             }
             if (leftWayTo_tb.Text.Length != 0)
             {
                 _tl.leftWayTo = leftWayTo_tb.Text;
             }
             if (rightWayTo_tb.Text.Length != 0)
             {
                 _tl.rightWayTo = rightWayTo_tb.Text;
             }
             tLine.Add(_tl);
             tLine.Sort();
             removeText();
             initUI();
         }
         else
         {
             MessageBox.Show("请填写可填写内容", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception e1)
     {
         MessageBox.Show(e1.ToString().Split('。')[0] + "。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemple #3
0
        private void paintLine(TrackLine _tl)
        {
            if (_tl == null)
            {
                return;
            }
            else if (_tl.selfLeftPoint == null ||
                     _tl.selfRightPoint == null)
            {
                return;
            }
            Point  point1    = _tl.selfLeftPoint;
            Point  point2    = _tl.selfRightPoint;
            String pointText = _tl.trackLineID.ToString();
            Pen    p         = new Pen(Color.Gray, 3);

            graphic.DrawLine(p, transformScreenOffsets(point1.X, true), transformScreenOffsets(point1.Y, false), transformScreenOffsets(point2.X, true), transformScreenOffsets(point2.Y, false));
            Font font = new Font("微软雅黑", 10.0f, FontStyle.Bold);
            //graphic.DrawString(pointText, base.Font, Brushes.White, 0, 0, new StringFormat(StringFormatFlags.DirectionVertical));
            Font font1 = new Font("微软雅黑", 8.0f, FontStyle.Bold);
            Font font2 = new Font("微软雅黑", 12.0f, FontStyle.Bold);
            //graphic.DrawString(_tl.selfLeftPoint.ToString(), font1, Brushes.Yellow, point1.X, point1.Y - 20, new StringFormat(StringFormatFlags.DirectionVertical));
            //graphic.DrawString(_tl.selfRightPoint.ToString(), font1, Brushes.Yellow, point2.X, point2.Y - 20, new StringFormat(StringFormatFlags.DirectionVertical));
            bool hasGotIt = false;

            //方向文字

            if (_tl.leftWayTo != null && _tl.leftWayTo.Length != 0)
            {
                graphic.DrawString("⇋ " + _tl.leftWayTo, font2, Brushes.Green, transformScreenOffsets(point1.X - 40, true), transformScreenOffsets((((point1.Y + point2.Y) / 2) - 35), false));
            }
            if (_tl.rightWayTo != null && _tl.rightWayTo.Length != 0)
            {
                graphic.DrawString(_tl.rightWayTo + "⇌", font2, Brushes.Green, transformScreenOffsets(point2.X - 40, true), transformScreenOffsets((((point1.Y + point2.Y) / 2) - 35), false));
            }
            if (startTrackNum <= _tl.trackLineID && _tl.trackLineID <= stopTrackNum)
            {
                //真正的站台字符画中间
                graphic.DrawString(pointText, font, Brushes.White, transformScreenOffsets(((1920 / 2) - 20), true), transformScreenOffsets((((point1.Y + point2.Y) / 2) - 20), false));
                hasGotIt = true;
            }
            if (startTrackNum == 0 && stopTrackNum == 0)
            {
                graphic.DrawString(pointText, font, Brushes.White, transformScreenOffsets(((point1.X + point2.X) / 2), true), transformScreenOffsets((((point1.Y + point2.Y) / 2) - 20), false));
            }
            if (pointShown)
            {//绘制坐标&有效绘画区域
                if (!hasGotIt)
                {
                    graphic.DrawString(pointText, font, Brushes.White, transformScreenOffsets(((point1.X + point2.X) / 2), true), transformScreenOffsets((((point1.Y + point2.Y) / 2) - 20), false));
                }
                graphic.DrawString("(" + _tl.selfLeftPoint.X.ToString() + ",\n" + _tl.selfLeftPoint.Y.ToString() + ")", font1, Brushes.Yellow, transformScreenOffsets(point1.X, true), transformScreenOffsets((point1.Y - 30), false));
                graphic.DrawString("(" + _tl.selfRightPoint.X.ToString() + ",\n" + _tl.selfRightPoint.Y.ToString() + ")", font1, Brushes.Yellow, transformScreenOffsets(point2.X, true), transformScreenOffsets((point2.Y - 30), false));
                Pen p1 = new Pen(Color.Yellow, 5);

                /*
                 * graphic.DrawLine(p, 0, 100 / zoomX, 1920 / zoomX, 100 / zoomX);
                 * graphic.DrawLine(p, 0, 850 / zoomX, 1920 / zoomX, 850 / zoomX);
                 * graphic.DrawString("上边界建议(Y=100)", font1, Brushes.Yellow, 940/zoomX, 80 / zoomX);
                 * graphic.DrawString("下边界建议(Y=850)", font1, Brushes.Yellow, 940/zoomX, 830 / zoomX);
                 */
            }
        }