/// <summary> /// 得到移动信息 /// </summary> /// <param name="fromx">起始坐标X</param> /// <param name="fromy">起始坐标Y</param> /// <param name="tox">目的地坐标X</param> /// <param name="toy">目的地坐标Y</param> /// <returns>移动信息类</returns> private StepXY GetSetp(float fromx, float fromy, float tox, float toy) { float lenghtX = tox - fromx; float lengthY = toy - fromy; StepXY stepxy = new StepXY(); if (lenghtX > 0) { stepxy.IsRtoL = true; } else { stepxy.IsRtoL = false; } if (lengthY > 0) { stepxy.IsTtoB = true; } else { stepxy.IsTtoB = false; } if (Math.Abs(lenghtX) > Math.Abs(lengthY)) { stepxy.X = lenghtX / Math.Abs(lenghtX); stepxy.Y = lengthY / Math.Abs(lenghtX); } else { stepxy.X = lenghtX / Math.Abs(lengthY); stepxy.Y = lengthY / Math.Abs(lengthY); } return(stepxy); }
public void MoverCreate(string route, string datatime, string stations, string stationpoints, string name, string Zfilepath, string Ffilepath, List <string> stationrecord) { this.StationsRecord = stationrecord; this.Route = route; this.Routes = route.Split('|'); string[] xy = this.Routes[0].Split(','); this.X = float.Parse(xy[0]); this.Y = float.Parse(xy[1]); this.Oldleft = float.Parse(xy[0]); this.Oldtop = float.Parse(xy[1]); xy = this.Routes[1].Split(','); this.step = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1])); this.ZFilePath = Zfilepath; this.FFilePath = Ffilepath; if (datatime != null && datatime != "") { this.DateAndTime = datatime; this.DataAndTimes = DateAndTime.Split('|'); } if (stations != null && stations != "") { this.NextStation = stations; NextStations = NextStation.Split('|'); } if (stationpoints != null && stationpoints != "") { this.NextStationPoint = stationpoints; NextStationPoints = NextStationPoint.Split('|'); } //PicBox = new PictureBox(); //PicBox.SizeMode = PictureBoxSizeMode.StretchImage; //PicBox.BackColor = System.Drawing.Color.Transparent; //PicBox.Size = new System.Drawing.Size(50, 50); labHead = name; labFoot = ""; if (DataAndTimes.Length > 0) { labFoot = labFoot + DataAndTimes[0]; //NowDatetime++; } if (NextStations.Length > 0) { labFoot = labFoot + "\r\n目的地:" + NextStations[0]; //NowNextStation++; } if (Step.IsRtoL) { this.MoverImage = new System.Drawing.Bitmap(ZFilePath); this.NowFilePath = ZFilePath; } else { this.MoverImage = new System.Drawing.Bitmap(FFilePath); this.NowFilePath = FFilePath; } }
public void ReadyForReMove() { NowIndex = 1; NowDatetime = 0; NowNextStation = 0; this.Route = route; this.Routes = route.Split('|'); string[] xy = this.Routes[0].Split(','); this.X = float.Parse(xy[0]); this.Y = float.Parse(xy[1]); this.Oldleft = float.Parse(xy[0]); this.Oldtop = float.Parse(xy[1]); xy = this.Routes[1].Split(','); this.step = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1])); if (DataAndTimes.Length > 0) { labFoot = DataAndTimes[0]; //NowDatetime++; } if (NextStations.Length > 0) { labFoot = labFoot + "\r\n目的地:" + NextStations[0]; //NowNextStation++; } if (Step.IsRtoL) { ImageAnimator.StopAnimate(this.MoverImage, null); this.MoverImage = new System.Drawing.Bitmap(ZFilePath); this.NowFilePath = ZFilePath; if (ImageAnimator.CanAnimate(this.MoverImage)) { ImageAnimator.Animate(this.MoverImage, null); } } else { ImageAnimator.StopAnimate(this.MoverImage, null); this.MoverImage = new System.Drawing.Bitmap(FFilePath); this.NowFilePath = FFilePath; if (ImageAnimator.CanAnimate(this.MoverImage)) { ImageAnimator.Animate(this.MoverImage, null); } } }
/// <summary> /// 移动一次 /// </summary> /// <returns>成功返回true,失败返回false</returns> public bool Move() { try { string nowposition = this.X.ToString() + "," + this.Y.ToString(); if (NowIndex < Routes.Length) { if (ComparePoint(nowposition, this.Routes[NowIndex], step.IsRtoL, step.IsTtoB)) { //Czlt-2010-10-13 this.OldX = this.X; this.OldY = this.Y; this.X += step.X * ZzhaMapGis.Speed * ZzhaMapGis.MoverBili; this.y += step.Y * ZzhaMapGis.Speed * ZzhaMapGis.MoverBili; if (!ComparePoint(this.X.ToString() + "," + this.Y.ToString(), this.Routes[NowIndex], step.IsRtoL, step.IsTtoB)) { this.X = float.Parse(Routes[NowIndex].Split(',')[0]); this.Y = float.Parse(Routes[NowIndex].Split(',')[1]); } return(true); } else { NowIndex++; if (NowIndex >= this.Routes.Length) { return(false); } else { if (StationsRecord.Contains(X.ToString() + "," + Y.ToString())) { string nowxy = X.ToString() + "," + Y.ToString(); if (nowxy.Trim() == NextStationPoints[NowNextStation].Trim()) { if (NowDatetime < DataAndTimes.Length && NowNextStation < NextStations.Length) { //Czlt-2010-10-13 this.StrPassTime = DataAndTimes[NowDatetime]; //当前分站时间 this.StrStationName = NextStations[NowNextStation]; //当前分站名称 this.StationSum = NextStations.Length - 1; //共有多少个分站 NowDatetime = NowDatetime + 2; NowNextStation++; LabFoot = DataAndTimes[NowDatetime] + "\r\n目的地:" + NextStations[NowNextStation]; //Czlt-2010-10-13-下一个分站序数 this.NowStationsIndex = NowNextStation; } } } string[] xy = this.Routes[NowIndex].Split(','); this.step = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1])); return(true); } } } else { return(false); } } catch (Exception ex) { return(false); } }
/// <summary> /// 得到移动信息 /// </summary> /// <param name="fromx">起始坐标X</param> /// <param name="fromy">起始坐标Y</param> /// <param name="tox">目的地坐标X</param> /// <param name="toy">目的地坐标Y</param> /// <returns>移动信息类</returns> private StepXY GetSetp(float fromx, float fromy, float tox, float toy) { float lenghtX = tox - fromx; float lengthY = toy - fromy; StepXY stepxy = new StepXY(); if (lenghtX > 0) { stepxy.IsRtoL = true; } else { stepxy.IsRtoL = false; } if (lengthY > 0) { stepxy.IsTtoB = true; } else { stepxy.IsTtoB = false; } if (Math.Abs(lenghtX) > Math.Abs(lengthY)) { stepxy.X = lenghtX / Math.Abs(lenghtX); stepxy.Y = lengthY / Math.Abs(lenghtX); } else { stepxy.X = lenghtX / Math.Abs(lengthY); stepxy.Y = lengthY / Math.Abs(lengthY); } return stepxy; }
public void ReadyForReMove() { NowIndex = 1; NowDatetime = 0; NowNextStation = 0; this.Route = route; this.Routes = route.Split('|'); string[] xy = this.Routes[0].Split(','); this.X = float.Parse(xy[0]); this.Y = float.Parse(xy[1]); this.Oldleft = float.Parse(xy[0]); this.Oldtop = float.Parse(xy[1]); xy = this.Routes[1].Split(','); this.step = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1])); if (DataAndTimes.Length > 0) { labFoot = DataAndTimes[0]; //NowDatetime++; } if (NextStations.Length > 0) { labFoot = labFoot + "\r\n目的地:" + NextStations[0]; //NowNextStation++; } if (Step.IsRtoL) { ImageAnimator.StopAnimate(this.MoverImage, null); this.MoverImage = new System.Drawing.Bitmap(ZFilePath); this.NowFilePath = ZFilePath; if (ImageAnimator.CanAnimate(this.MoverImage)) ImageAnimator.Animate(this.MoverImage, null); } else { ImageAnimator.StopAnimate(this.MoverImage, null); this.MoverImage = new System.Drawing.Bitmap(FFilePath); this.NowFilePath = FFilePath; if (ImageAnimator.CanAnimate(this.MoverImage)) ImageAnimator.Animate(this.MoverImage, null); } }
/// <summary> /// 移动一次 /// </summary> /// <returns>成功返回true,失败返回false</returns> public bool Move() { try { string nowposition = this.X.ToString() + "," + this.Y.ToString(); if (NowIndex < Routes.Length) { if (ComparePoint(nowposition, this.Routes[NowIndex], step.IsRtoL, step.IsTtoB)) { //Czlt-2010-10-13 this.OldX = this.X; this.OldY = this.Y; this.X += step.X * ZzhaMapGis.Speed * ZzhaMapGis.MoverBili; this.y += step.Y * ZzhaMapGis.Speed * ZzhaMapGis.MoverBili; if (!ComparePoint(this.X.ToString() + "," + this.Y.ToString(), this.Routes[NowIndex], step.IsRtoL, step.IsTtoB)) { this.X = float.Parse(Routes[NowIndex].Split(',')[0]); this.Y = float.Parse(Routes[NowIndex].Split(',')[1]); } return true; } else { NowIndex++; if (NowIndex >= this.Routes.Length) { return false; } else { if (StationsRecord.Contains(X.ToString() + "," + Y.ToString())) { string nowxy = X.ToString() + "," + Y.ToString(); if (nowxy.Trim() == NextStationPoints[NowNextStation].Trim()) { if (NowDatetime < DataAndTimes.Length && NowNextStation < NextStations.Length) { //Czlt-2010-10-13 this.StrPassTime = DataAndTimes[NowDatetime]; //当前分站时间 this.StrStationName = NextStations[NowNextStation]; //当前分站名称 this.StationSum = NextStations.Length-1; //共有多少个分站 NowDatetime = NowDatetime + 2; NowNextStation++; LabFoot = DataAndTimes[NowDatetime] + "\r\n目的地:" + NextStations[NowNextStation]; //Czlt-2010-10-13-下一个分站序数 this.NowStationsIndex = NowNextStation; } } } string[] xy = this.Routes[NowIndex].Split(','); this.step = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1])); return true; } } } else { return false; } } catch (Exception ex) { return false; } }
public void MoverCreate(string route, string datatime, string stations, string stationpoints, string name, string Zfilepath, string Ffilepath, List<string> stationrecord) { this.StationsRecord = stationrecord; this.Route = route; this.Routes = route.Split('|'); string[] xy = this.Routes[0].Split(','); this.X = float.Parse(xy[0]); this.Y = float.Parse(xy[1]); this.Oldleft = float.Parse(xy[0]); this.Oldtop = float.Parse(xy[1]); xy = this.Routes[1].Split(','); this.step = GetSetp(this.X, this.Y, float.Parse(xy[0]), float.Parse(xy[1])); this.ZFilePath = Zfilepath; this.FFilePath = Ffilepath; if (datatime != null && datatime != "") { this.DateAndTime = datatime; this.DataAndTimes = DateAndTime.Split('|'); } if (stations != null && stations != "") { this.NextStation = stations; NextStations = NextStation.Split('|'); } if (stationpoints != null && stationpoints != "") { this.NextStationPoint = stationpoints; NextStationPoints = NextStationPoint.Split('|'); } //PicBox = new PictureBox(); //PicBox.SizeMode = PictureBoxSizeMode.StretchImage; //PicBox.BackColor = System.Drawing.Color.Transparent; //PicBox.Size = new System.Drawing.Size(50, 50); labHead = name; labFoot = ""; if (DataAndTimes.Length > 0) { labFoot = labFoot + DataAndTimes[0]; //NowDatetime++; } if (NextStations.Length > 0) { labFoot = labFoot + "\r\n目的地:" + NextStations[0]; //NowNextStation++; } if (Step.IsRtoL) { this.MoverImage = new System.Drawing.Bitmap(ZFilePath); this.NowFilePath = ZFilePath; } else { this.MoverImage = new System.Drawing.Bitmap(FFilePath); this.NowFilePath = FFilePath; } }