本文整理汇总了C#中AxMapControl.TrackLine方法的典型用法代码示例。如果您正苦于以下问题:C# AxMapControl.TrackLine方法的具体用法?C# AxMapControl.TrackLine怎么用?C# AxMapControl.TrackLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxMapControl
的用法示例。
在下文中一共展示了AxMapControl.TrackLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatLine
/// <summary>
/// 测量线
/// </summary>
/// <param name="axMapControl"></param>
public static void CreatLine(AxMapControl axMapControl)
{
try
{
IActiveView pActiveView = axMapControl.ActiveView;
IScreenDisplay screenDisplay = pActiveView.ScreenDisplay;
ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
IRgbColor rgbClolor = new RgbColorClass();
lineSymbol.Width = 2;
rgbClolor.Red = 255;
lineSymbol.Color = rgbClolor;
IPolyline pLine = axMapControl.TrackLine() as IPolyline;
screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
screenDisplay.SetSymbol((ISymbol)lineSymbol);
screenDisplay.DrawPolyline(pLine);
screenDisplay.FinishDrawing();
double l = Math.Abs(pLine.Length*100);
//axMapControl.Map.MapUnits = esriUnits.esriKilometers;
//DialogResult r =MessageBox.Show("长度为:" + l.ToString() + "公里(km)","长度测量结果");
MessageBox.Show("长度为:" + Convert.ToDouble(l).ToString("0.000") + "千米(km)", "长度测量结果");
IGraphicsContainer pDeletElement = axMapControl.ActiveView.FocusMap as IGraphicsContainer;
pDeletElement.DeleteAllElements();
axMapControl.ActiveView.Refresh();
//screenDisplay.RemoveAllCaches();
// typeof(AxMapControl).GetEvent("OnMouseDown").RemoveEventHandler(axMapControl,);
}
catch
{ }
}
示例2: AddLineByWrite
public void AddLineByWrite(AxMapControl axMapControl1, IFeatureLayer l, double x, double y)
{
ESRI.ArcGIS.Geometry.esriGeometryType featype = l.FeatureClass.ShapeType;
if (featype == esriGeometryType.esriGeometryPolyline)//�жϲ��Ƿ�Ϊ�߲�
{
//IFeatureLayer l = MapCtr.Map.get_Layer(0) as IFeatureLayer;
IFeatureClass fc = l.FeatureClass;
IFeatureClassWrite fr = fc as IFeatureClassWrite;
IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;
IFeature f;
//��ѡ����������
object Missing = Type.Missing;
IPoint p = new PointClass();
w.StartEditing(true);
w.StartEditOperation();
f = fc.CreateFeature();
//����һ�������߶���
IRgbColor color = new RgbColor();
// ������ɫ����
color.Red = 255;
color.Transparency = 255;
//ISimpleLineSymbol PlyLine = new SimpleLineSymbolClass();
//PlyLine.Color = color;
//PlyLine.Style = esriSimpleLineStyle.esriSLSInsideFrame;
//PlyLine.Width = 1;
IGeometry iGeom = axMapControl1.TrackLine();
AddLine(axMapControl1, iGeom);
f.Shape = iGeom;
fr.WriteFeature(f);
w.StopEditOperation();
w.StopEditing(true);
}
}