public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolNewDisplacement.OnMouseDown implementation object Miss = Type.Missing; IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { //IGeoReference pGR = pRasterLayer as IGeoReference; IPoint mapPoint = pMapCtr.ToMapPoint(X, Y); m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay; if (bFlag == true)//起始点 { //IPointCollection pPCFrom; //IPointCollection pPCTo = new MultipointClass(); //pPCTo.AddPoint(mapPoint, ref Miss, ref Miss); //pPCFrom = pGR.PointsTransform(pPCTo, false); // OriginPoints.AddPoint(mapPoint); //IPoint pt = pPCFrom.get_Point(0); m_NewLineFeedback.Start(mapPoint); OriginPoints.AddPoint(mapPoint); bFlag = false; } else//目标点 { TargetPoints.AddPoint(mapPoint); bFlag = true; IPolyline pPline = m_NewLineFeedback.Stop(); m_FrmVectorLinkTable.RefreshDataTable(); //RefreshLayer(); } } }
public void RefreshLayer() { if (pGraphicsLayer != null) { IGraphicsContainer pGC = pGraphicsLayer as IGraphicsContainer; int nCount = OriginPoints.PointCount; pGC.DeleteAllElements(); for (int i = 0; i < nCount; i++) { IPolyline ppl = new PolylineClass(); ppl.FromPoint = OriginPoints.get_Point(i); ppl.ToPoint = TargetPoints.get_Point(i); IRgbColor pColor = new RgbColorClass(); ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass(); pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound; ILineProperties pLineProp = pCartoLineSymbol as ILineProperties; pLineProp.DecorationOnTop = true; ILineDecoration pLineDecoration = new LineDecorationClass(); ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass(); pSimpleLineDecoElem.AddPosition(1); IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbolClass(); pArrowMarkerSym.Size = 8; pArrowMarkerSym.Color = pColor; pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol; pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement); pLineProp.LineDecoration = pLineDecoration; ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol; pLineSymbol.Color = pColor; pLineSymbol.Width = 1; ILineElement pLineElem = new LineElementClass(); pLineElem.Symbol = pLineSymbol; IElement pElem = pLineElem as IElement; pElem.Geometry = ppl; pGC.AddElement(pElem, 0); // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect; // pGCS.SelectAllElements(); //bool bbb = pGCS.ElementSelected(pElement); //pGC.UpdateElement(pElement); // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect; // pGCS.SelectAllElements(); //bool bbb = pGCS.ElementSelected(pElement); //pGC.UpdateElement(pElement); //pElement = new MarkerElementClass(); //pElement.Geometry = m_OriginPoints.get_Point(i); //ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass(); //sms.Style = esriSimpleMarkerStyle.esriSMSSquare; //sms.Size = 9; //IMarkerElement im = pElement as IMarkerElement; //im.Symbol = sms ; // IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer; // pGraphicsContainer.AddElement(pElement, 0); //pGC.AddElement(pElement,0); //pGC.UpdateElement(pElement); //IMarkerElement pMarkerEle = new MarkerElementClass(); //IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbol(); ////pPictureMarkerSymbol.Color = sitecolor as IColor; //pPictureMarkerSymbol.Size = 10; //pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, // GetParentPathofExe() + @"Resource\Globe.bmp"); //IElement pEle = pMarkerEle as IElement; //pEle.Geometry = ppl.FromPoint; //pMarkerEle.Symbol = pPictureMarkerSymbol; //IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer; ////site.pEle = pEle; //pGraphicsContainer.AddElement(pEle, 0); } IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { if (OriginPoints.PointCount == 0) { pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); } else { pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } } } }
public IEnumerable <double> PutOriginPoints(OriginPoints originPoints) { Algorithm algo = new Algorithm(); return(algo.GetInitialCenterPoint(originPoints)); }