public bool ReplayTrackings(TrackingReplay.TrackPoint curCarInfos,bool isMoveToMapView) { MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); bool bResult = true; try { oCarLocation.X = curCarInfos.X; oCarLocation.Y = curCarInfos.Y; if (this._index == 0) { this._trackingPointEvent = this._trackingLayer.AddEvent(oCarLocation, this._trackingPointSymbolIndex); this._index++; return bResult; } this._trackingPointEvent.MoveTo(oCarLocation.X, oCarLocation.Y); this._index++; } catch { bResult = false; } finally { oCarLocation = null; } return bResult; }
public void UpdateCarLocation(GPSTrackingMonitor.Communications.MessagePool trackingMessagePool) { MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); MapObjects2.GeoEvent oGeoevent = null; GPSTrackingMonitor.Communications.MessagePool.ValueCollection oTrackingMessages = trackingMessagePool.Values; foreach (CommnicationMessage.GPSTrackingMessage oTrackingMessage in oTrackingMessages) { oCarLocation.X = oTrackingMessage.X; oCarLocation.Y = oTrackingMessage.Y; oGeoevent = this._trackingLayer.FindEvent(oTrackingMessage.CarNumber); if (oGeoevent == null) { // this.AddCustomSymbol(oTrackingMessage.CarNumber); oGeoevent = this._trackingLayer.AddEvent(oCarLocation, this._carSymbolIndex); oGeoevent.Tag = oTrackingMessage.CarNumber; } else { if (oGeoevent.X == oTrackingMessage.X && oGeoevent.Y == oTrackingMessage.Y) continue; oGeoevent.MoveTo(oTrackingMessage.X, oTrackingMessage.Y); } } this._trackingLayer.Refresh(true, this._mapControl.Extent); }
public void UpdateLabelLocation(GPSTrackingMonitor.Communications.MessagePool trackingMessagePool) { if (trackingMessagePool == null || trackingMessagePool.Count == 0) return; MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); MapObjects2.TextSymbol oLabelSymbol = new MapObjects2.TextSymbolClass(); oLabelSymbol.Font.Name = "Arial"; oLabelSymbol.Font.Size = 8; oLabelSymbol.Color = (uint)MapObjects2.ColorConstants.moYellow; oLabelSymbol.HorizontalAlignment = MapObjects2.AlignmentConstants.moAlignCenter; oLabelSymbol.VerticalAlignment = MapObjects2.AlignmentConstants.moAlignCenter; int iGeoEventCount = this._trackingLayer.EventCount; MapObjects2.GeoEvent oGeoEvent = null; double dVerticalOffset = this._mapControl.ToMapDistance(10f); for (int i = 0; i < iGeoEventCount; i++) { oGeoEvent = this._trackingLayer.get_Event(i); oCarLocation.X = oGeoEvent.X; oCarLocation.Y = oGeoEvent.Y + dVerticalOffset; this._mapControl.DrawText(oGeoEvent.Tag, oCarLocation, oLabelSymbol); } }
public bool ReplayTrackings(TrackingReplay.TrackPoint curCarInfos, bool isMoveToMapView) { MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); bool bResult = true; try { oCarLocation.X = curCarInfos.X; oCarLocation.Y = curCarInfos.Y; if (this._index == 0) { this._trackingPointEvent = this._trackingLayer.AddEvent(oCarLocation, this._trackingPointSymbolIndex); this._index++; return(bResult); } this._trackingPointEvent.MoveTo(oCarLocation.X, oCarLocation.Y); this._index++; } catch { bResult = false; } finally { oCarLocation = null; } return(bResult); }
public void UpdateLabelLocation(GPSTrackingMonitor.Communications.MessagePool trackingMessagePool) { if (trackingMessagePool == null || trackingMessagePool.Count == 0) { return; } MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); MapObjects2.TextSymbol oLabelSymbol = new MapObjects2.TextSymbolClass(); oLabelSymbol.Font.Name = "Arial"; oLabelSymbol.Font.Size = 8; oLabelSymbol.Color = (uint)MapObjects2.ColorConstants.moYellow; oLabelSymbol.HorizontalAlignment = MapObjects2.AlignmentConstants.moAlignCenter; oLabelSymbol.VerticalAlignment = MapObjects2.AlignmentConstants.moAlignCenter; int iGeoEventCount = this._trackingLayer.EventCount; MapObjects2.GeoEvent oGeoEvent = null; double dVerticalOffset = this._mapControl.ToMapDistance(10f); for (int i = 0; i < iGeoEventCount; i++) { oGeoEvent = this._trackingLayer.get_Event(i); oCarLocation.X = oGeoEvent.X; oCarLocation.Y = oGeoEvent.Y + dVerticalOffset; this._mapControl.DrawText(oGeoEvent.Tag, oCarLocation, oLabelSymbol); } }
public void UpdateCarLocation(GPSTrackingMonitor.Communications.MessagePool trackingMessagePool) { MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); MapObjects2.GeoEvent oGeoevent = null; GPSTrackingMonitor.Communications.MessagePool.ValueCollection oTrackingMessages = trackingMessagePool.Values; foreach (CommnicationMessage.GPSTrackingMessage oTrackingMessage in oTrackingMessages) { oCarLocation.X = oTrackingMessage.X; oCarLocation.Y = oTrackingMessage.Y; oGeoevent = this._trackingLayer.FindEvent(oTrackingMessage.CarNumber); if (oGeoevent == null) { // this.AddCustomSymbol(oTrackingMessage.CarNumber); oGeoevent = this._trackingLayer.AddEvent(oCarLocation, this._carSymbolIndex); oGeoevent.Tag = oTrackingMessage.CarNumber; } else { if (oGeoevent.X == oTrackingMessage.X && oGeoevent.Y == oTrackingMessage.Y) { continue; } oGeoevent.MoveTo(oTrackingMessage.X, oTrackingMessage.Y); } } this._trackingLayer.Refresh(true, this._mapControl.Extent); }
private void mnuCarLocate_Click(object sender, EventArgs e) { string sCarNumber = this.GetSelectedCarNumber(); MapObjects2.GeoEvent oGeoEvent = GlobeVariables.MainMapControl.TrackingLayer.FindEvent(sCarNumber); MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); oCarLocation.X = oGeoEvent.X; oCarLocation.Y = oGeoEvent.Y; MapUtil.MapOperation oMapOper = new GPSTrackingMonitor.MapUtil.MapOperation(); oMapOper.ZoomAndCenterMap(0.02, oCarLocation, ref GlobeVariables.MainMapControl); GlobeVariables.MainMapControl.Refresh(); GlobeVariables.MainMapControl.FlashShape(oCarLocation, 5); }
private void btnSearch_Click(object sender, EventArgs e) { this.dgvSearchResult.DataSource = null; Utilities.CarSearch oSearchCar = new GPSTrackingMonitor.Utilities.CarSearch(GlobeVariables.RealtimeCarInfosTable.Copy()); switch (this.cbbSearchType.SelectedIndex) { case 0: this.dgvSearchResult.DataSource = oSearchCar.SearchByCarNumber(this.txtCarNumber.Text.Trim(), this.ckbAllMatched.Checked); break; case 1: double dSearchRaduis = 0; double dCoordX = 0; double dCoordY = 0; if (!double.TryParse(this.txtCoordX.Text.Trim(), out dCoordX) || !double.TryParse(this.txtCoordY.Text.Trim(), out dCoordY) || !double.TryParse(this.txtSearchRaduis.Text.Trim(), out dSearchRaduis)) { MessageBox.Show("请确定输入了正确的参数.", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MapObjects2.Point oCenterPoint = new MapObjects2.PointClass(); oCenterPoint.X = dCoordX; oCenterPoint.Y = dCoordY; this.dgvSearchResult.DataSource = oSearchCar.SearchByCarLocation(oCenterPoint, dSearchRaduis); break; case 2: try { this.dgvSearchResult.DataSource = oSearchCar.SearchByCustomFilter(this.txtCustomFilter.Text); } catch (Exception ex) { MessageBox.Show("请确定您输入了正确的过滤条件。\r\n\r\n错误信息如下:\r\n\r\n" + ex.StackTrace); } break; } }
private void btnSearch_Click(object sender, EventArgs e) { this.dgvSearchResult.DataSource = null; Utilities.CarSearch oSearchCar = new GPSTrackingMonitor.Utilities.CarSearch(GlobeVariables.RealtimeCarInfosTable.Copy()); switch (this.cbbSearchType.SelectedIndex) { case 0: this.dgvSearchResult.DataSource = oSearchCar.SearchByCarNumber(this.txtCarNumber.Text.Trim(), this.ckbAllMatched.Checked); break; case 1: double dSearchRaduis = 0; double dCoordX = 0; double dCoordY = 0; if (!double.TryParse(this.txtCoordX.Text.Trim(), out dCoordX) || !double.TryParse(this.txtCoordY.Text.Trim(), out dCoordY) || !double.TryParse(this.txtSearchRaduis.Text.Trim(), out dSearchRaduis)) { MessageBox.Show("��ȷ����������ȷ�IJ���.", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MapObjects2.Point oCenterPoint = new MapObjects2.PointClass(); oCenterPoint.X = dCoordX; oCenterPoint.Y = dCoordY; this.dgvSearchResult.DataSource = oSearchCar.SearchByCarLocation(oCenterPoint, dSearchRaduis); break; case 2: try { this.dgvSearchResult.DataSource = oSearchCar.SearchByCustomFilter(this.txtCustomFilter.Text); } catch (Exception ex) { MessageBox.Show("��ȷ������������ȷ�Ĺ���������\r\n\r\n������Ϣ����:\r\n\r\n" + ex.StackTrace); } break; } }
public void AddTrackingPath(TrackPoints pointsInTrackingPath) { MapObjects2.Line oTrackingPath = new MapObjects2.LineClass(); MapObjects2.Points oPoints = new MapObjects2.PointsClass(); foreach (TrackPoint item in pointsInTrackingPath) { MapObjects2.Point oPoint = new MapObjects2.PointClass(); oPoint.X = item.X; oPoint.Y = item.Y; oPoints.Add(oPoint); } oTrackingPath.Parts.Add(oPoints); this.AddTrackingPath(oTrackingPath); }
private void dgvSearchResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (this.dgvSearchResult.DataSource != null && this.dgvSearchResult.RowCount > 0 && this.dgvSearchResult.SelectedRows.Count > 0) { string sCarNumber = this.dgvSearchResult.SelectedRows[0].Cells["CarNumber"].Value.ToString(); MapObjects2.GeoEvent oGeoEvent = GlobeVariables.MainMapControl.TrackingLayer.FindEvent(sCarNumber); MapObjects2.Point oCarLocation = new MapObjects2.PointClass(); oCarLocation.X = oGeoEvent.X; oCarLocation.Y = oGeoEvent.Y; MapUtil.MapOperation oMapOper = new GPSTrackingMonitor.MapUtil.MapOperation(); oMapOper.ZoomAndCenterMap(0.02, oCarLocation, ref GlobeVariables.MainMapControl); GlobeVariables.MainMapControl.Refresh(); GlobeVariables.MainMapControl.FlashShape(oCarLocation, 5); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBox_SelectedIndexChanged(object sender, System.EventArgs e) { if (mapMain.TrackingLayer.EventCount > 0) { mapMain.TrackingLayer.RemoveEvent(0); } if (listBox.SelectedItems.Count > 0) { string slName = listBox.SelectedItem.ToString(); string s; MapObjects2.Point selectP = new MapObjects2.PointClass(); for (int i = 0; i < s_Info.Length; i++) { s = s_Info[i].s_Name + "热力站"; if (slName == s) { selectP.X = System.Convert.ToDouble(s_Info[i].s_East); selectP.Y = System.Convert.ToDouble(s_Info[i].s_West); mapMain.CenterAt(selectP.X, selectP.Y); MapObjects2.Symbol selectS = mapMain.TrackingLayer.get_Symbol(0); selectS.Color = System.Convert.ToUInt32(MapObjects2.ColorConstants.moBlue); selectS.Size = 10; mapMain.TrackingLayer.AddEvent(selectP, 0); } } } if (this.timer1.Enabled == false) { this.timer1.Enabled = true; } else { this.timer1.Enabled = false; this.timer1.Enabled = true; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBox_SelectedIndexChanged(object sender, System.EventArgs e) { if(axMap1.TrackingLayer.EventCount>0) axMap1.TrackingLayer.RemoveEvent(0); if(listBox.SelectedItems.Count>0) { string slName=listBox.SelectedItem.ToString(); string s; MapObjects2.Point selectP=new MapObjects2.PointClass(); for(int i=0;i<s_Info.Length;i++) { s=s_Info[i].s_Name; if(slName==s) { selectP.X=System.Convert.ToDouble(s_Info[i].s_East); selectP.Y=System.Convert.ToDouble(s_Info[i].s_West); axMap1.CenterAt(selectP.X,selectP.Y); MapObjects2.Symbol selectS=axMap1.TrackingLayer.get_Symbol(0); selectS.Color=System.Convert.ToUInt32(MapObjects2.ColorConstants.moBlue); selectS.Size=10; axMap1.TrackingLayer.AddEvent(selectP,0); break; } } } if(this.timer1.Enabled==false) this.timer1.Enabled=true; else { this.timer1.Enabled=false; this.timer1.Enabled=true; } }
/// <summary> /// axMap1 mouse down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void axMap1_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e) { switch(tBarIndex) { case 1: { MapObjects2.Rectangle zoomInRect=new MapObjects2.RectangleClass(); MapObjects2.Point zoomInPt=new MapObjects2.PointClass(); zoomInRect=this.axMap1.TrackRectangle(); if (zoomInRect.Height>0 && zoomInRect.Width>0) { axMap1.Extent=zoomInRect; axMap1.Extent=axMap1.Extent; } else { zoomInPt=axMap1.ToMapPoint(e.x,e.y); axMap1.CenterAt(zoomInPt.X,zoomInPt.Y); zoomRect=axMap1.Extent; sr=0.5; zoomRect.ScaleRectangle(sr); axMap1.Extent=zoomRect; axMap1.Extent=axMap1.Extent; } ShowLayers(); axMap2.Extent=axMap2.Extent; iScale=System.Convert.ToInt64(mapLayer.CalcScale(this.axMap1)); // MessageBox.Show(iScale.ToString()); // if(iScale<=MAX_SCALE) // { // MessageBox.Show("ѡ��ͼ�α�����С��������ѡ��!","����",MessageBoxButtons.OK,MessageBoxIcon.Warning); // zoomFull(); // return; // } break; } case 2: { MapObjects2.Rectangle zoomOutRect=new MapObjects2.RectangleClass(); MapObjects2.Point zoomOutPt=new MapObjects2.PointClass(); zoomOutRect=axMap1.TrackRectangle(); if(zoomOutRect.Height>0 && zoomOutRect.Width>0) { sr=axMap1.Extent.Width/zoomOutRect.Width; axMap1.CenterAt(zoomOutRect.Center.X,zoomOutRect.Center.Y); } else { zoomOutPt=axMap1.ToMapPoint(e.x,e.y); axMap1.CenterAt(zoomOutPt.X,zoomOutPt.Y); sr=2; } zoomRect=axMap1.Extent; zoomRect.ScaleRectangle(sr); axMap1.Extent=zoomRect; axMap1.Extent=axMap1.Extent; ShowLayers(); axMap2.Extent=axMap2.Extent; break; } case 3: { axMap1.Pan(); axMap2.Extent=axMap2.Extent; break; } default: { if(radioButton1.Checked==false) { MapObjects2.Point point; point=axMap1.ToMapPoint(e.x,e.y); // MessageBox.Show(point.X.ToString()); // MessageBox.Show(point.Y.ToString()); for(int i=0;i<s_Info.Length;i++) { if(point.X>System.Convert.ToDouble( s_Info[i].s_East)-20 && point.X<System.Convert.ToDouble(s_Info[i].s_East)+20 && point.Y>System.Convert.ToDouble(s_Info[i].s_West)-20 && point.Y<System.Convert.ToDouble(s_Info[i].s_West)+20 ) { // Point position=new Point(); GisMapSName=s_Info[i].s_Name; GisMapSNo=s_Info[i].s_No; // position.X=e.x+POSITIONX; // position.Y=e.y+POSITIONY; // GisMapMenu.Show(this,position); if(GisMapSNo=="2"||GisMapSNo=="3") { frmDataNowD f=new frmDataNowD(GisMapSName,GisMapSNo); f.ShowDialog(); break; } else { frmDataNow f=new frmDataNow(GisMapSName); f.ShowDialog(); break; } } } } break; } } }
/// <summary> /// mapMain mouse down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mapMain_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e) { switch (tBarIndex) { case 1: { MapObjects2.Rectangle zoomInRect = new MapObjects2.RectangleClass(); MapObjects2.Point zoomInPt = new MapObjects2.PointClass(); zoomInRect = this.mapMain.TrackRectangle(); if (zoomInRect.Height > 0 && zoomInRect.Width > 0) { mapMain.Extent = zoomInRect; mapMain.Extent = mapMain.Extent; } else { zoomInPt = mapMain.ToMapPoint(e.x, e.y); mapMain.CenterAt(zoomInPt.X, zoomInPt.Y); zoomRect = mapMain.Extent; sr = 0.5; zoomRect.ScaleRectangle(sr); mapMain.Extent = zoomRect; mapMain.Extent = mapMain.Extent; } ShowLayers(); mapEye.Extent = mapEye.Extent; iScale = System.Convert.ToInt64(mapLayer.CalcScale(this.mapMain)); if (iScale <= MAX_SCALE) { MessageBox.Show("选择图形比例过小,请重新选择!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); zoomFull(); return; } break; } case 2: { MapObjects2.Rectangle zoomOutRect = new MapObjects2.RectangleClass(); MapObjects2.Point zoomOutPt = new MapObjects2.PointClass(); zoomOutRect = mapMain.TrackRectangle(); if (zoomOutRect.Height > 0 && zoomOutRect.Width > 0) { sr = mapMain.Extent.Width / zoomOutRect.Width; mapMain.CenterAt(zoomOutRect.Center.X, zoomOutRect.Center.Y); } else { zoomOutPt = mapMain.ToMapPoint(e.x, e.y); mapMain.CenterAt(zoomOutPt.X, zoomOutPt.Y); sr = 2; } zoomRect = mapMain.Extent; zoomRect.ScaleRectangle(sr); mapMain.Extent = zoomRect; mapMain.Extent = mapMain.Extent; ShowLayers(); mapEye.Extent = mapEye.Extent; break; } case 3: { mapMain.Pan(); mapEye.Extent = mapEye.Extent; break; } default: { if (radioButton1.Checked == false) { MapObjects2.Point point; point = mapMain.ToMapPoint(e.x, e.y); for (int i = 0; i < s_Info.Length; i++) { if (point.X > System.Convert.ToDouble( s_Info[i].s_East) - 5 && point.X <System.Convert.ToDouble(s_Info[i].s_East) + 5 && point.Y> System.Convert.ToDouble(s_Info[i].s_West) - 5 && point.Y < System.Convert.ToDouble(s_Info[i].s_West) + 5 ) { Point position = new Point(); GisMapSName = s_Info[i].s_Name; GisMapSNo = s_Info[i].s_No; // position.X=e.x+POSITIONX; // position.Y=e.y+POSITIONY; // GisMapMenu.Show(this,position); if (GisMapSNo == "2") { frmDataNowD f = new frmDataNowD(GisMapSName); f.ShowDialog(); } else { frmDataNow f = new frmDataNow(GisMapSName); f.ShowDialog(); } } } } break; } } }