Пример #1
0
        private void 生成2分格底图结构ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //生成2分格的底图结构
            TrainBasicPicture TrainBasicPicture2 = new TrainBasicPicture
            {
                Width  = this.pictureBox1.Width - 30,
                Height = this.pictureBox1.Height - 30,
                TrainBasicPicturePos =
                    new PointF(this.pictureBox1.Location.X + 10, this.pictureBox1.Location.Y + 10)
            }; //声明5分格底图结构实例

            trainsDiagram     = TrainBasicPicture2.DrawTrainBasicPicture(TrainBasicPicture.Scale.TwoMinutes);
            pictureBox1.Image = trainsDiagram; //将返回的bitmap设置为picbox的背景图片
            _flag             = 2;             //当前的flag为10分格数
        }
Пример #2
0
        private void 生成2分格底图结构ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //生成2分格的底图结构
            //this.panelofPic.SetAutoScrollMargin(100000, 100);//使用scrollbar来控制显示图像的范围
            TrainBasicPicture trainBasicPicture2 = new TrainBasicPicture
            {
                Width  = this.panelofPic.Width * 5,
                Height = this.panelofPic.Height,
                TrainBasicPicturePos =
                    new PointF(this.pictureBox1.Location.X + 10, this.pictureBox1.Location.Y + 10)
            };                                                                                                //声明5分格底图结构实例

            pictureBox1.Image = trainBasicPicture2.DrawTrainBasicPicture(TrainBasicPicture.Scale.TwoMinutes); //将返回的bitmap设置为picbox的背景图片
            _flag             = 2;                                                                            //当前的flag为10分格数
        }
Пример #3
0
        public Bitmap trainsDiagram;                                             //底图

        private void 生成底图结构ToolStripMenuItem_Click_1(object sender, EventArgs e) //10分格的底图结构生成
        {
            //生成10分格底图结构
            //this.panelofPic.SetAutoScrollMargin(400, 100);//使用scrollbar来控制显示图像的范围
            TrainBasicPicture trainBasicPicture10 = new TrainBasicPicture
            {
                Width  = this.pictureBox1.Width - 100,
                Height = this.pictureBox1.Height - 100,
                TrainBasicPicturePos =
                    new PointF(this.pictureBox1.Location.X + 10, this.pictureBox1.Location.Y + 10)
            }; //声明10分格底图结构实例

            //底图结构的宽度
            //底图结构的高度
            pictureBox1.Image = trainBasicPicture10.DrawTrainBasicPicture(TrainBasicPicture.Scale.TenMinutes); //将返回的bitmap设置为picbox的背景图片
            _flag             = 10;                                                                            //当前的flag为10分格数
        }
Пример #4
0
        /// <summary>
        /// 绘制沪宁线的G字头列车运行线
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void 沪宁线高铁车次绘制ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            markedTrains.Clear();//刷新操作之后,被选中的列车不再算数

            //设置滚动条的位置,防止刷新时左边的车站不对
            this.panelofPic.HorizontalScroll.Value = 0;
            this.pictureBox_stations.Image         = null;    //点击刷新的时候进行左侧的车站情况置空
            //默认是生成2分格的底图结构
            pictureBox1.Height = this.panelofPic.Height - 30; //注意这里参数控制的是下面的白带宽度(picturebox能否使得pannel出现滚动条)

            pictureBox1.Width  = this.panelofPic.Width * 3;
            trainBasicPicture2 = new TrainBasicPicture
            {
                Width  = this.pictureBox1.Width - 40,  //控制的是图和picturebox之间的关系
                Height = this.pictureBox1.Height - 80, //控制的是图和picturebox之间的关系
                TrainBasicPicturePos =
                    new PointF(this.pictureBox1.Location.X + 10, this.pictureBox1.Location.Y + 30)
            }; //声明5分格底图结构实例
            trainsDiagram = trainBasicPicture2.DrawTrainBasicPicture(TrainBasicPicture.Scale.TenMinutes);

            List <string> trainIdList = GetTrainId();

            //List<string> trainIdList = new List<string> { "G7001" };
            if (trainIdList != null)
            {
                trains = new List <Trains>();//车的集合
                for (int i = 0; i < trainIdList.Count; i++)
                {
                    if (i == 0)
                    {
                        Train train = new Train
                        {
                            TrainId           = trainIdList[i],     //车次
                            BasicBitmap       = trainsDiagram,      //存储图
                            trainBasicPicture = trainBasicPicture2, //底图对象
                            isFirstTrain      = true
                        };
                        trainsDiagram = train.DrawTrainLine(out List <TrainLine> trainLineList);
                        //注意这里需要区分列车是上行还是下行,它们的起始点相反

                        trains.Add(new Trains(trainLineList, train.TrainId, trainLineList[0].StartPo,
                                              trainLineList[trainLineList.Count - 1].EndPo));
                    }
                    else
                    {
                        Train train = new Train
                        {
                            TrainId           = trainIdList[i],     //车次
                            BasicBitmap       = trainsDiagram,      //存储图
                            trainBasicPicture = trainBasicPicture2, //底图对象
                            isFirstTrain      = false
                        };
                        trainsDiagram = train.DrawTrainLine(out List <TrainLine> trainLineList);

                        if (int.Parse(train.TrainId.Replace("G", "")) % 2 == 0)
                        {
                            trains.Add(new Trains(trainLineList, train.TrainId, trainLineList[0].StartPo,
                                                  trainLineList[trainLineList.Count - 1].EndPo));
                        }
                        else
                        {
                            trains.Add(new Trains(trainLineList, train.TrainId,
                                                  trainLineList[trainLineList.Count - 1].EndPo, trainLineList[0].StartPo));
                        }
                    }

                    pictureBox1.Image = trainsDiagram;
                }
            }
            else
            {
                MessageBox.Show("车次数量为0");
            }
        }