Esempio n. 1
0
 private bool ExceedsOrTouchesAllBox(WKSEnvelope envelope)
 {
     return(envelope.XMin <= _allBox.Min.X + _tolerance ||
            envelope.YMin <= _allBox.Min.Y + _tolerance ||
            envelope.XMax >= _allBox.Max.X - _tolerance ||
            envelope.YMax >= _allBox.Max.Y - _tolerance);
 }
Esempio n. 2
0
        private void BuildToleranceCache(WKSEnvelope tileEnvelope)
        {
            if (Tolerance <= 0)
            {
                return;
            }

            InitFilters();

            _netCache.Clear();
            _queryEnv.PutCoords(tileEnvelope.XMin - Tolerance, tileEnvelope.YMin - Tolerance,
                                tileEnvelope.XMax + Tolerance, tileEnvelope.YMax + Tolerance);

            for (var iTable = 0; iTable < InvolvedTables.Count; iTable++)
            {
                if (NonNetworkClassIndexList.Contains(iTable))
                {
                    continue;
                }

                _filters[iTable].Geometry = _queryEnv;
                foreach (
                    IRow feature in
                    Search(InvolvedTables[iTable], _filters[iTable], _helpers[iTable]))
                {
                    AddNetElements(new TableIndexRow(feature, iTable), _netCache);
                }
            }
        }
Esempio n. 3
0
        private void AddElements([CanBeNull] IList <NetElementXY> netElems,
                                 WKSEnvelope verificationEnvelope,
                                 WKSEnvelope tileEnvelope)
        {
            if (netElems == null || netElems.Count == 0)
            {
                return;
            }

            if (!HandleInCurrentTile(netElems[0], verificationEnvelope, tileEnvelope))
            {
                // Border object, handled in other tile
                return;
            }

            var lines = new List <DirectedRow>(netElems.Count);
            var elems = new List <NetElement>(netElems.Count);

            foreach (NetElementXY elem in netElems)
            {
                if (elem.Element is DirectedRow)
                {
                    lines.Add((DirectedRow)elem.Element);
                }

                elems.Add(elem.Element);
            }

            Assert.NotNull(ConnectedLinesList).Add(lines);
            Assert.NotNull(ConnectedElementsList).Add(elems);
        }
Esempio n. 4
0
        public static WKSEnvelope GetEnvelope([NotNull] IIndexedSegments baseGeometry,
                                              int part, int startSegmentIndex,
                                              double startFraction,
                                              int endSegmentIndex, double endFraction)
        {
            SegmentProxy segment  = baseGeometry.GetSegment(part, startSegmentIndex);
            double       startEnd = 1;

            if (startSegmentIndex == endSegmentIndex)
            {
                startEnd = endFraction;
            }

            WKSEnvelope box = segment.GetSubCurveBox(startFraction, startEnd);

            for (int i = startSegmentIndex + 1; i < endSegmentIndex - 1; i++)
            {
                segment = baseGeometry.GetSegment(part, i);
                box     = GetUnion(box, segment.GetSubCurveBox(0, 1));
            }

            if (endSegmentIndex > startSegmentIndex && endFraction > 0)
            {
                segment = baseGeometry.GetSegment(part, endSegmentIndex);
                box     = GetUnion(box, segment.GetSubCurveBox(0, endFraction));
            }

            return(box);
        }
Esempio n. 5
0
        private static IEnvelope GetClipEnvelope([NotNull] IEnvelope tileEnvelope,
                                                 [NotNull] Box allBox,
                                                 double tolerance,
                                                 out WKSEnvelope tileBox,
                                                 out WKSEnvelope clipBox)
        {
            Assert.ArgumentNotNull(tileEnvelope, nameof(tileEnvelope));
            Assert.ArgumentNotNull(allBox, nameof(allBox));

            tileEnvelope.QueryWKSCoords(out tileBox);

            // the tolerance needs to be enlarged, otherwise there can be missed
            // errors when features touch tile boundaries
            double offsetDistance = tolerance * 3;

            // the clip box is enlarged to the left/bottom, by the tolerance,
            // unless the tile is to the left/bottom of the test box
            clipBox.XMin = Math.Max(allBox.Min.X, tileBox.XMin - offsetDistance);
            clipBox.YMin = Math.Max(allBox.Min.Y, tileBox.YMin - offsetDistance);
            clipBox.XMax = tileBox.XMax;
            clipBox.YMax = tileBox.YMax;

            IEnvelope result = GeometryFactory.Clone(tileEnvelope);

            result.PutWKSCoords(ref clipBox);

            return(result);
        }
        private static bool IsDone([NotNull] IGeometry geometry, WKSEnvelope tileEnvelope)
        {
            WKSEnvelope geometryEnvelope = QaGeometryUtils.GetWKSEnvelope(geometry);

            return(geometryEnvelope.XMax < tileEnvelope.XMax &&
                   geometryEnvelope.YMax < tileEnvelope.YMax);
        }
Esempio n. 7
0
        private static WKSEnvelope GetUnion(WKSEnvelope x, WKSEnvelope y)
        {
            y.XMin = Math.Min(x.XMin, y.XMin);
            y.XMax = Math.Max(x.XMax, y.XMax);
            y.YMin = Math.Min(x.YMin, y.YMin);
            y.YMax = Math.Max(x.YMax, y.YMax);

            return(y);
        }
Esempio n. 8
0
        public static bool VerifyHandled([NotNull] IGeometry geometry,
                                         WKSEnvelope tileEnvelope,
                                         WKSEnvelope allEnvelope)
        {
            WKSEnvelope geometryEnvelope = QaGeometryUtils.GetWKSEnvelope(geometry);

            return((tileEnvelope.XMax >= allEnvelope.XMax ||
                    geometryEnvelope.XMax < tileEnvelope.XMax) &&
                   (tileEnvelope.YMax >= allEnvelope.YMax ||
                    geometryEnvelope.YMax < tileEnvelope.YMax));
        }
Esempio n. 9
0
        public static bool IsEmpty(WKSEnvelope wksEnvelope)
        {
            // Typically an empty envelope from ArcObjects can also have some (all?) coordinates initialized as 0
            // Empty envelopes created here only have NaN coordinates.
            if (double.IsNaN(wksEnvelope.XMin) || double.IsNaN(wksEnvelope.XMin) ||
                double.IsNaN(wksEnvelope.XMax) || double.IsNaN(wksEnvelope.YMax))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 10
0
        public static WKSEnvelope CreateWksEnvelope(double xMin, double yMin,
                                                    double xMax, double yMax)
        {
            var result = new WKSEnvelope
            {
                XMin = xMin,
                YMin = yMin,
                XMax = xMax,
                YMax = yMax
            };

            return(result);
        }
            private void RefreshInvoked(WKSEnvelope invalidateExtent)
            {
                m_invalidateExtent.PutWKSCoords(ref invalidateExtent);

                if (!m_invalidateExtent.IsEmpty)
                {
                    m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, m_weatherLayer, m_invalidateExtent);
                }
                else
                {
                    m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, m_weatherLayer, null);
                }

                m_activeView.ScreenDisplay.UpdateWindow();
            }
 public void Refresh(WKSEnvelope invalidateExtent)
 {
     try
     {
         // Invoke the RefreshInternal through its delegate
         if (!this.IsDisposed && this.IsHandleCreated)
         {
             Invoke(new RefreshHelper(RefreshInvoked), new object[] { invalidateExtent });
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message);
     }
 }
Esempio n. 13
0
        private void BuildNet(WKSEnvelope verificationEnvelope,
                              WKSEnvelope tileEnvelope,
                              double tolerance)
        {
            var xElements = new List <NetElementXY>(_netCache.Count);

            foreach (NetElement elem in _netCache)
            {
                var elemXY = new NetElementXY(elem, _queryPnt);
                xElements.Add(elemXY);
            }

            SortElements(xElements, tolerance,
                         neigbors => AddElements(neigbors, verificationEnvelope, tileEnvelope));
        }
Esempio n. 14
0
        private bool IsFeatureToCheck([NotNull] IFeature feature,
                                      TileState state,
                                      WKSEnvelope currentBox)
        {
            if (state == TileState.Final)
            {
                return(true);
            }

            double featureXMax;
            double featureYMax;

            GetEnvelopeMax(feature, out featureXMax, out featureYMax);

            return(featureXMax < currentBox.XMax && featureYMax < currentBox.YMax);
        }
Esempio n. 15
0
        private void RemoveHandledObjects(WKSEnvelope tileWksBox, WKSEnvelope allWksBox)
        {
            var areaFeaturesToRemove = new List <FeatureKey>(_cache.Count);

            foreach (
                KeyValuePair <FeatureKey, Dictionary <FeatureKey, T> > cachedPair in
                _cache)
            {
                var allRemoved = true;
                Dictionary <FeatureKey, T> borderConnections = cachedPair.Value;

                var borderFeaturesToRemove = new List <FeatureKey>(borderConnections.Count);

                foreach (
                    KeyValuePair <FeatureKey, T> borderPair in borderConnections)
                {
                    T borderConnection = borderPair.Value;

                    if (VerifyHandled(borderConnection, tileWksBox, allWksBox))
                    {
                        borderFeaturesToRemove.Add(borderPair.Key);
                    }
                    else
                    {
                        allRemoved = false;
                    }
                }

                if (!allRemoved)
                {
                    foreach (FeatureKey borderKey in borderFeaturesToRemove)
                    {
                        borderConnections.Remove(borderKey);
                    }
                }

                if (borderConnections.Count <= 0)
                {
                    areaFeaturesToRemove.Add(cachedPair.Key);
                }
            }

            foreach (FeatureKey areaFeatureKey in areaFeaturesToRemove)
            {
                _cache.Remove(areaFeatureKey);
            }
        }
Esempio n. 16
0
        public static string ToString(WKSEnvelope wksEnvelope, int numberOfDecimals = 3)
        {
            try
            {
                string format =
                    string.Format(
                        "XMin: {{0:N{0}}} YMin: {{1:N{0}}} XMax: {{2:N{0}}} YMax: {{3:N{0}}}",
                        numberOfDecimals);

                return(string.Format(format, wksEnvelope.XMin, wksEnvelope.YMin,
                                     wksEnvelope.XMax, wksEnvelope.YMax));
            }
            catch (Exception e)
            {
                return(HandleToStringException(e));
            }
        }
Esempio n. 17
0
        public override WKSEnvelope GetSubCurveBox(double fromRatio, double toRatio)
        {
            WKSPointZ from = fromRatio > 0
                                                 ? QaGeometryUtils.GetWksPoint(GetPointAt(fromRatio))
                                                 : FromPoint;
            WKSPointZ to = toRatio < 1
                                               ? QaGeometryUtils.GetWksPoint(GetPointAt(toRatio))
                                               : ToPoint;
            WKSEnvelope box = new WKSEnvelope
            {
                XMin = Math.Min(from.X, to.X),
                YMin = Math.Min(from.Y, to.Y),
                XMax = Math.Max(from.X, to.X),
                YMax = Math.Max(from.Y, to.Y)
            };

            return(box);
        }
Esempio n. 18
0
        public void Clear(WKSEnvelope tileWksBox, WKSEnvelope allWksBox)
        {
            var unhandledErrors = new List <TError>(_attributeErrors.Count);

            foreach (TError error in _attributeErrors)
            {
                if (
                    !EdgeMatchUtils.VerifyHandled(error.BorderConnection.Feature,
                                                  tileWksBox, allWksBox) ||
                    !EdgeMatchUtils.VerifyHandled(error.NeighborBorderConnection.Feature,
                                                  tileWksBox, allWksBox))
                {
                    unhandledErrors.Add(error);
                }
            }

            _attributeErrors.Clear();
            _attributeErrors.AddRange(unhandledErrors);
        }
Esempio n. 19
0
        public static WKSEnvelope GetWksEnvelope([NotNull] IGeometry geometry)
        {
            Assert.ArgumentNotNull(geometry, nameof(geometry));

            var envelope = geometry as IEnvelope;

            if (envelope != null)
            {
                return(GetWksEnvelope(envelope));
            }

            // TODO: Consider a ThreadLocal field to use QueryEnvelope
            envelope = geometry.Envelope;

            WKSEnvelope result = GetWksEnvelope(envelope);

            Marshal.ReleaseComObject(envelope);

            return(result);
        }
Esempio n. 20
0
        public override WKSEnvelope GetSubCurveBox(double fromRatio, double toRatio)
        {
            WKSEnvelope box = new WKSEnvelope();

            if (fromRatio > 0 || toRatio < 1)
            {
                ICurve     subCurve;
                const bool asRatio = true;
                InnerSegment.GetSubcurve(fromRatio, toRatio, asRatio, out subCurve);
                var segment = subCurve as ISegment;
                Assert.NotNull(segment, "segment expected from GetSubCurve() on segment");
                segment.QueryWKSEnvelope(ref box);
            }
            else
            {
                InnerSegment.QueryWKSEnvelope(ref box);
            }

            return(box);
        }
Esempio n. 21
0
        public void Clear(WKSEnvelope tileEnvelope, WKSEnvelope allEnvelope)
        {
            var toRemove = new List <TNeighborConnection>();

            foreach (TNeighborConnection neighborConnection in NeighborConnections)
            {
                if (
                    EdgeMatchUtils.VerifyHandled(
                        neighborConnection.NeighborBorderConnection.Feature.Shape,
                        tileEnvelope, allEnvelope))
                {
                    toRemove.Add(neighborConnection);
                }
            }

            foreach (TNeighborConnection remove in toRemove)
            {
                _neighborConnections.Remove(remove);
            }
        }
Esempio n. 22
0
        public static WKSEnvelope Expand(WKSEnvelope envelope, double dx, double dy,
                                         bool asRatio = false)
        {
            if (asRatio)
            {
                double width  = envelope.XMax - envelope.XMin;
                double height = envelope.YMax - envelope.YMin;

                // same logic as IEnvelope.Expand: move each side by half of the specified percentage.
                dx = width * (dx - 1) / 2;
                dy = height * (dy - 1) / 2;
            }

            envelope.XMin = envelope.XMin - dx;
            envelope.YMin = envelope.YMin - dy;
            envelope.XMax = envelope.XMax + dx;
            envelope.YMax = envelope.YMax + dy;

            return(envelope);
        }
        public void Clear(WKSEnvelope tileEnvelope, WKSEnvelope allEnvelope)
        {
            var toRemove = new List <FeatureKey>();

            foreach (
                KeyValuePair <FeatureKey, Dictionary <FeatureKey, TNeighbors> > areaPair in
                _borderConnections)
            {
                Dictionary <FeatureKey, TNeighbors> borderPairs = areaPair.Value;
                var borderConnectionRemoves = new List <FeatureKey>();
                foreach (KeyValuePair <FeatureKey, TNeighbors> borderPair in borderPairs)
                {
                    TNeighbors neighbors = borderPair.Value;
                    neighbors.Clear(tileEnvelope, allEnvelope);

                    if (IsDone(neighbors.BorderConnection.Feature.Shape, tileEnvelope))
                    {
                        borderConnectionRemoves.Add(borderPair.Key);
                    }
                }

                foreach (FeatureKey borderConnectionRemove in borderConnectionRemoves)
                {
                    borderPairs.Remove(borderConnectionRemove);
                }

                if (borderPairs.Count <= 0)
                {
                    toRemove.Add(areaPair.Key);
                }
            }

            foreach (FeatureKey remove in toRemove)
            {
                _borderConnections.Remove(remove);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Determines whether an envelope contains a point, i.e. the point is not disjoint and not
        /// on the envelope's boundary. No tolerance is applied.
        /// </summary>
        /// <param name="envelope">The envelope (containing)</param>
        /// <param name="point">The point (contained)</param>
        /// <returns>
        ///     <c>true</c> if the envelope contains the point; otherwise, <c>false</c>.
        /// </returns>
        public static bool Contains2D(WKSEnvelope envelope, WKSPointVA point)
        {
            if (point.m_x < envelope.XMin)
            {
                return(false);
            }

            if (point.m_y < envelope.YMin)
            {
                return(false);
            }

            if (point.m_x > envelope.XMax)
            {
                return(false);
            }

            if (point.m_y > envelope.YMax)
            {
                return(false);
            }

            return(true);
        }
        private static void DrawMapUnits(IEnvelope Envelope, bool showText, double ColumnX)
        {
            // BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
            double Text2BoxY = 0.2; //Y distance between the bottom of text and the next box
            double Text2BoxX = 0.1; //X distance between a box and the text that describes it
            double BoxX      = 0.4; //Width
            double BoxY      = 0.3; //Height

            // Setup a black color object, black outline
            IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();

            BlackInsides.Blue  = 0;
            BlackInsides.Red   = 0;
            BlackInsides.Green = 0;

            ILineSymbol BlackOutsides = new SimpleLineSymbolClass();

            BlackOutsides.Width = 1;
            BlackOutsides.Color = BlackInsides;

            // Whole bunch of variables to use while going through the loop below...
            #region Variables Galore!!!
            IMxDocument        Doc = ArcMap.Document;
            IPageLayout        pageLayout = Doc.ActiveView as IPageLayout;
            IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
            double             Xcoord, Ycoord;
            Xcoord = Envelope.XMin;
            Ycoord = Envelope.YMax;
            double                      IndentTerm   = 0;
            IPoint                      Point        = null;
            double                      StringLength = 0;
            string                      LegendText   = "";
            string                      ItemName     = "";
            string                      ItemDesc     = "";
            IElement                    Ele          = null;
            IEnvelope                   TempEnv      = null;
            IRgbColor                   BoxColr      = null;
            ISimpleFillSymbol           FillSym      = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            IFillShapeElement           FillEle      = null;
            IEnvelope                   FillEnv      = new EnvelopeClass();
            WKSEnvelope                 Patch        = new WKSEnvelope();
            IGeometry                   Geo          = null;
            string                      LabelText    = "";
            ESRI.ArcGIS.Geometry.IPoint LabelPoint   = new ESRI.ArcGIS.Geometry.PointClass();

            // Get the transparency of the MapUnitPolys Layer
            double transparency = 100;
            try
            {
                IFeatureLayer polyLayer    = commonFunctions.FindFeatureLayer(ArcMap.Editor.EditWorkspace, "MapUnitPolys");
                ILayerEffects layerEffects = polyLayer as ILayerEffects;
                transparency = layerEffects.Transparency;
            }
            catch { }

            #endregion

            // Get a reference to the DescriptionOfMapUnits entries
            var sortedDmuEntries = GetDmuSortedByHierarchy();

            // Loop through legend records
            foreach (KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
            {
                // Grab the DMU entry itself
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
                bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));


                // Find out how far to indent the legend item
                // Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
                IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;

                // Get the coordinates of the text for the legend entry - upper left corner
                // Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
                Point = new PointClass();
                double xAdditions = 0;
                if (isHeading)
                {
                    // Xcoord plus (indentation), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1);
                }
                else
                {
                    //Xcoord plus (indentation) + (Box width and margin), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
                }
                Point.PutCoords(Xcoord + xAdditions, Ycoord);

                // StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
                StringLength = 72 * (Envelope.Width - xAdditions);

                // Fix a couple of special characters in the legend string.
                // Then amalgamate item name and description
                ItemName = FixLegendTextCharacters(aDescription.Name);
                if (!isHeading)
                {
                    LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
                }
                else
                {
                    LegendText = ItemName;
                }



                // Format the legend text if it is not a heading. If it is, we're fine.
                if (!isHeading)
                {
                    LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
                }

                // Boldify the ItemName
                LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");

                // If the StratCorDiagram is being drawn
                if (showText == false)
                {
                    LegendText   = ".";     // placeholder
                    StringLength = 1;
                }

                // See if this legend item should be placed on a new column
                Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;

                TempEnv = new EnvelopeClass();
                Ele.QueryBounds(Doc.ActiveView.ScreenDisplay, TempEnv);

                // If the height of the formatted text is larger than the box + space specified
                if (TempEnv.Height > BoxY + Text2BoxY)
                {
                    // If the text will spill out below the envelope drawn by the user
                    if (Ycoord - TempEnv.Height < Envelope.YMin)
                    {
                        // Move to a new column - the last number is a fudge factor, looks like it is in inches
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }
                else     // The height of the formatted text is not larger than the box + space defined
                {
                    // If the box itself will spill out below the envelope drawn by the user
                    if (Ycoord - (BoxY + Text2BoxY) < Envelope.YMin)
                    {
                        // Move to a new column
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }

                // Only write the legend text if the legend is being drawn (not the StratCorDiagram)
                if (showText == true)
                {
                    GraphicsContainer.AddElement(Ele, 0);
                }

                if (!isHeading)
                {
                    FillEnv = new EnvelopeClass();

                    Patch.XMin = Point.X - BoxX - Text2BoxX;
                    Patch.YMax = Point.Y;
                    Patch.XMax = Point.X - Text2BoxX;
                    Patch.YMin = Point.Y - BoxY;
                    FillEnv.PutCoords(Patch.XMin, Patch.YMin, Patch.XMax, Patch.YMax);
                    Geo = FillEnv as IGeometry;

                    // Get the color of the box
                    BoxColr = new RgbColorClass();
                    if (aDescription.AreaFillRGB == null)
                    {
                        BoxColr.Red   = 255;
                        BoxColr.Green = 0;
                        BoxColr.Blue  = 0;
                    }
                    else
                    {
                        BoxColr.Red   = int.Parse(aDescription.AreaFillRGB.Split(';')[0]);
                        BoxColr.Green = int.Parse(aDescription.AreaFillRGB.Split(';')[1]);
                        BoxColr.Blue  = int.Parse(aDescription.AreaFillRGB.Split(';')[2]);
                    }

                    // Set the transparency for the legend color boxes
                    BoxColr.Red   = (int)((255 - BoxColr.Red) * transparency / 100 + BoxColr.Red);
                    BoxColr.Green = (int)((255 - BoxColr.Green) * transparency / 100 + BoxColr.Green);
                    BoxColr.Blue  = (int)((255 - BoxColr.Blue) * transparency / 100 + BoxColr.Blue);

                    // Draw the fill
                    FillSym         = new SimpleFillSymbolClass();
                    FillSym.Color   = BoxColr;
                    FillSym.Style   = esriSimpleFillStyle.esriSFSSolid;
                    FillSym.Outline = BlackOutsides;

                    FillEle = CreateFillElement(Geo, FillSym) as IFillShapeElement;

                    // Label the box
                    LabelText = aDescription.Label;

                    // Subscripting!!

                    for (int i = 0; i < LabelText.Length; i++)
                    {
                        string thisBit = LabelText.Substring(i, 1);
                        int    num;
                        if (int.TryParse(thisBit, out num)) // Checks if the character is numeric
                        {
                            LabelText = LabelText.Replace(thisBit, "<sub>" + thisBit + "</sub>");
                            i         = i + 5;
                        }
                    }
                    LabelText = LabelText.Replace("ir", "i<sub>r</sub>");
                    LabelText = LabelText.Replace("yc", "y<sub>c</sub>");

                    // Center the label
                    LabelPoint   = new PointClass();
                    LabelPoint.X = Point.X - BoxX / 2 - Text2BoxX;
                    LabelPoint.Y = Point.Y - BoxY / 2;

                    //LabelText = GetFormattedString(LabelText, "FGDCGeoAge", 8, StringLength, 0);
                    Ele = MakeTextElement(LabelPoint, LabelText, "FGDCGeoAge", true) as IElement;

                    // Add the box and label
                    IGroupElement3 group = new GroupElementClass();
                    group.AddElement(FillEle as IElement);
                    group.AddElement(Ele);
                    GraphicsContainer.AddElement(group as IElement, 0);
                }

                // Do a partial refresh
                //Doc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                // Setup the Y coordinates for the next entry
                // if the height of this item's text is bigger than the minimum distance between text and box
                if (TempEnv.Height > Text2BoxY)
                {
                    // Subtract the box height and the text height to get the new ycoord
                    Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                }
                else
                {
                    if (isHeading)
                    {
                        Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                    }
                    else
                    {
                        Ycoord = Ycoord - (BoxY + Text2BoxY);
                    }
                }
            }

            // Done, refresh, turn off the tool
            Doc.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }
 public void Refresh (WKSEnvelope invalidateExtent)
 {
   try
   {
     // Invoke the RefreshInternal through its delegate
     if (!this.IsDisposed && this.IsHandleCreated)
       Invoke(new RefreshHelper(RefreshInvoked), new object[] { invalidateExtent });
   }
   catch (Exception ex)
   {
     System.Diagnostics.Trace.WriteLine(ex.Message);
   }
 }
Esempio n. 27
0
 public static double Height(WKSEnvelope envelope)
 {
     return(envelope.YMax - envelope.YMin);
 }
Esempio n. 28
0
 public static double Width(WKSEnvelope envelope)
 {
     return(envelope.XMax - envelope.XMin);
 }
Esempio n. 29
0
 public static double Area(WKSEnvelope envelope)
 {
     return(Width(envelope) * Height(envelope));
 }
 private void RefreshInvoked(WKSEnvelope invalidateExtent)
 {
   m_invalidateExtent.PutWKSCoords(ref invalidateExtent);
   
   if (!m_invalidateExtent.IsEmpty)
     m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, m_weatherLayer, m_invalidateExtent);
   else
     m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, m_weatherLayer, null);        
   
   m_activeView.ScreenDisplay.UpdateWindow();
 }
Esempio n. 31
0
 public void Clear(WKSEnvelope tileWksBox, WKSEnvelope allWksBox)
 {
     RemoveHandledObjects(tileWksBox, allWksBox);
 }
        private void DrawLegend(IEnvelope Envelope)
        {
            // BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
            double BoxX = 0.4; //Width
            double BoxY = 0.3; //Height
            double Text2BoxY= 0.2; //Y distance between the bottom of text and the next box
            double Text2BoxX = 0.1; //X distance between a box and the text that describes it
            double ColumnX = 0.5; //Space between columns

            // Setup a black color object, black outline
            IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();
            BlackInsides.Blue = 0;
            BlackInsides.Red = 0;
            BlackInsides.Green = 0;

            ILineSymbol BlackOutsides = new SimpleLineSymbolClass();
            BlackOutsides.Width = 1;
            BlackOutsides.Color = BlackInsides;

            // Whole bunch of variables to use while going through the loop below...
            #region Variables Galore!!!
            IMxDocument Doc = ArcMap.Document;
            IPageLayout pageLayout = Doc.ActiveView as IPageLayout;
            IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
            double Xcoord, Ycoord;
            Xcoord = Envelope.XMin;
            Ycoord = Envelope.YMax;
            double IndentTerm = 0;
            IPoint Point = null;
            double StringLength = 0;
            string LegendText = "";
            string ItemName = "";
            string ItemDesc = "";
            IElement Ele = null;
            IEnvelope TempEnv = null;
            IRgbColor BoxColr = null;
            ISimpleFillSymbol FillSym = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            IFillShapeElement FillEle = null;
            IEnvelope FillEnv = new EnvelopeClass();
            WKSEnvelope Patch = new WKSEnvelope();
            IGeometry Geo = null;
            string LabelText = "";
            ESRI.ArcGIS.Geometry.IPoint LabelPoint = new ESRI.ArcGIS.Geometry.PointClass();
            #endregion

            // Get a reference to the DescriptionOfMapUnits entries
            var sortedDmuEntries = GetDmuSortedByHierarchy();

            // Loop through legend records
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
            {
                // Grab the DMU entry itself
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
                bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));

                // Find out how far to indent the legend item
                // Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
                IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;

                // Get the coordinates of the text for the legend entry - upper left corner
                // Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
                Point = new PointClass();
                double xAdditions = 0;
                if (isHeading)
                {
                    // Xcoord plus (indentation), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1);
                }
                else
                {
                    //Xcoord plus (indentation) + (Box width and margin), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
                }
                Point.PutCoords(Xcoord + xAdditions, Ycoord);

                // StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
                StringLength = 72 * (Envelope.Width - xAdditions);

                // Fix a couple of special characters in the legend string.
                // Then amalgamate item name and description
                ItemName = FixLegendTextCharacters(aDescription.Name);
                if (!isHeading)
                {
                    LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
                }
                else
                {
                    LegendText = ItemName;
                }

                // Format the legend text if it is not a heading. If it is, we're fine.
                if (!isHeading)
                {
                    LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
                }

                // Boldify the ItemName
                LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");

                // See if this legend item should be placed on a new column
                Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                TempEnv = new EnvelopeClass();
                Ele.QueryBounds(Doc.ActiveView.ScreenDisplay, TempEnv);

                // If the height of the formatted text is larger than the box + space specified
                if (TempEnv.Height > BoxY + Text2BoxY)
                {
                    // If the text will spill out below the envelope drawn by the user
                    if (Ycoord - TempEnv.Height < Envelope.YMin)
                    {
                        // Move to a new column - the last number is a fudge factor, looks like it is in inches
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }
                else // The height of the formatted text is not larfer than the box + space defined
                {
                    // If the box itself will spill out below the envelope drawn by the user
                    if (Ycoord - (BoxY + Text2BoxY) < Envelope.YMin)
                    {
                        // Move to a new column
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }

                // Add the text to the map
                GraphicsContainer.AddElement(Ele, 0);

                if (!isHeading)
                {
                    FillEnv = new EnvelopeClass();

                    Patch.XMin = Point.X - BoxX - Text2BoxX;
                    Patch.YMax =  Point.Y;
                    Patch.XMax = Point.X - Text2BoxX;
                    Patch.YMin = Point.Y - BoxY;
                    FillEnv.PutCoords(Patch.XMin, Patch.YMin, Patch.XMax, Patch.YMax);
                    Geo = FillEnv as IGeometry;

                    // Get the color of the box
                    BoxColr = new RgbColorClass();
                    if (aDescription.AreaFillRGB == null)
                    {
                        BoxColr.Red = 255;
                        BoxColr.Green = 0;
                        BoxColr.Blue = 0;
                    }
                    else
                    {
                        BoxColr.Red = int.Parse(aDescription.AreaFillRGB.Split(';')[0]);
                        BoxColr.Green = int.Parse(aDescription.AreaFillRGB.Split(';')[1]);
                        BoxColr.Blue = int.Parse(aDescription.AreaFillRGB.Split(';')[2]);
                    }

                    // Draw the fill
                    FillSym = new SimpleFillSymbolClass();
                    FillSym.Color = BoxColr;
                    FillSym.Style = esriSimpleFillStyle.esriSFSSolid;
                    FillSym.Outline = BlackOutsides;

                    FillEle = CreateFillElement(Geo, FillSym) as IFillShapeElement;

                    // Label the box
                    LabelText = aDescription.Label;

                    // Subscripting!!

                    for (int i = 0; i < LabelText.Length; i++)
                    {
                        string thisBit = LabelText.Substring(i, 1);
                        int num;
                        if (int.TryParse(thisBit, out num)) // Checks if the character is numeric
                        {
                            LabelText = LabelText.Replace(thisBit, "<sub>" + thisBit + "</sub>");
                            i = i + 5;
                        }
                    }
                    LabelText = LabelText.Replace("ir", "i<sub>r</sub>");
                    LabelText = LabelText.Replace("yc", "y<sub>c</sub>");

                    // Center the label
                    LabelPoint = new PointClass();
                    LabelPoint.X = Point.X - BoxX / 2 - Text2BoxX;
                    LabelPoint.Y = Point.Y - BoxY / 2;

                    //LabelText = GetFormattedString(LabelText, "FGDCGeoAge", 8, StringLength, 0);
                    Ele = MakeTextElement(LabelPoint, LabelText, "FGDCGeoAge", true) as IElement;

                    // Add the box and label
                    GraphicsContainer.AddElement(FillEle as IElement, 0);
                    GraphicsContainer.AddElement(Ele, 0);
                }

                // Do a partial refresh
                //Doc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                // Setup the Y coordinates for the next entry
                // if the height of this item's text is bigger than the minimum distance between text and box
                if (TempEnv.Height > Text2BoxY)
                {
                    // Subtract the box height and the text height to get the new ycoord
                    Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                }
                else
                {
                    if (isHeading)
                    {
                        Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                    }
                    else
                    {
                        Ycoord = Ycoord - (BoxY + Text2BoxY);
                    }
                }
            }

            // Done, refresh, turn off the tool
            Doc.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }
Esempio n. 33
0
 protected abstract bool VerifyHandled(T borderConnection, WKSEnvelope tileBox,
                                       WKSEnvelope allBox);