I'm trying to develop a tool add-in for ArcMap that facilitate printing map of chosen scale.The tool draws a frame and moves it with mouse,When the user click on map the chosen area will fit in page layout frame and the scale will be the exact value user has chosen previously.
My problem is: How to calculate my tool envelope dimensions (the movable frame dimensions)?
Here is my code:
double userScale = 1000; IGraphicsContainer graphicsContainer = ArcMap.Document.PageLayout as IGraphicsContainer;IFrameElement frameElement = graphicsContainer.FindFrame(ArcMap.Document.FocusMap);IMapFrame mapFrame = (IMapFrame)frameElement;IElement mapElement = (IElement)mapFrame;IGeometry geometry = mapElement.Geometry;IEnvelope envelope = geometry.Envelope;//Transform envelope from page to map coordinatestagRECT Rect = new tagRECT();//Transform from Page units to Device units(ArcMap.Document.PageLayout as IActiveView).ScreenDisplay.DisplayTransformation.TransformRect(envelope, ref Rect, (int)esriDisplayTransformationEnum.esriTransformToDevice + (int)esriDisplayTransformationEnum.esriTransformPosition);//Transform from Device units to Map units(ArcMap.Document.FocusMap as IActiveView).ScreenDisplay.DisplayTransformation.TransformRect(envelope, ref Rect, (int)esriDisplayTransformationEnum.esriTransformToMap + (int)esriDisplayTransformationEnum.esriTransformPosition);envelope.Width = envelope.Width * (userScale / ArcMap.Document.FocusMap.MapScale);envelope.Height = envelope.Height * (userScale / ArcMap.Document.FocusMap.MapScale);The last two lines responsible of adjusting the envelope by ratio of current map scale and user chosen one.but the result is not correct.
Any Idea?
أكثر...
My problem is: How to calculate my tool envelope dimensions (the movable frame dimensions)?
Here is my code:
double userScale = 1000; IGraphicsContainer graphicsContainer = ArcMap.Document.PageLayout as IGraphicsContainer;IFrameElement frameElement = graphicsContainer.FindFrame(ArcMap.Document.FocusMap);IMapFrame mapFrame = (IMapFrame)frameElement;IElement mapElement = (IElement)mapFrame;IGeometry geometry = mapElement.Geometry;IEnvelope envelope = geometry.Envelope;//Transform envelope from page to map coordinatestagRECT Rect = new tagRECT();//Transform from Page units to Device units(ArcMap.Document.PageLayout as IActiveView).ScreenDisplay.DisplayTransformation.TransformRect(envelope, ref Rect, (int)esriDisplayTransformationEnum.esriTransformToDevice + (int)esriDisplayTransformationEnum.esriTransformPosition);//Transform from Device units to Map units(ArcMap.Document.FocusMap as IActiveView).ScreenDisplay.DisplayTransformation.TransformRect(envelope, ref Rect, (int)esriDisplayTransformationEnum.esriTransformToMap + (int)esriDisplayTransformationEnum.esriTransformPosition);envelope.Width = envelope.Width * (userScale / ArcMap.Document.FocusMap.MapScale);envelope.Height = envelope.Height * (userScale / ArcMap.Document.FocusMap.MapScale);The last two lines responsible of adjusting the envelope by ratio of current map scale and user chosen one.but the result is not correct.
Any Idea?
أكثر...