ArcMapAddinDistanceAndDirection.ViewModels.TabBaseViewModel.RemoveGraphics C# (CSharp) Метод

RemoveGraphics() приватный Метод

Method used to remove graphics from the graphics container Elements are tagged with a GUID on the IElementProperties.Name property Removes graphics from all tabs, not just the tab that is currently active
private RemoveGraphics ( IGraphicsContainer gc, bool removeOnlyTemporary ) : void
gc IGraphicsContainer
removeOnlyTemporary bool
Результат void
        private void RemoveGraphics(IGraphicsContainer gc, bool removeOnlyTemporary)
        {
            if (gc == null || !GraphicsList.Any())
                return;

            // keep track of the graphics that we need to remove from the GraphicsList
            List<Graphic> removedGraphics = new List<Graphic>();

            var elementList = new List<IElement>();
            gc.Reset();
            var element = gc.Next();
            while (element != null)
            {
                var eleProps = element as IElementProperties;
                foreach (Graphic graphic in GraphicsList)
                {
                    if (graphic.UniqueId.Equals(eleProps.Name))
                    {
                        if (graphic.IsTemp == removeOnlyTemporary)
                        {
                            elementList.Add(element);
                            removedGraphics.Add(graphic);
                        }     
                            
                        break;
                    }
                }

                element = gc.Next();
            }

            foreach (var ele in elementList)
            {
                gc.DeleteElement(ele);
            }

            // clean up the GraphicsList and remove the necessary graphics from it
            foreach (Graphic graphic in removedGraphics)
            {
                GraphicsList.Remove(graphic);
            }

            elementList.Clear();
            RaisePropertyChanged(() => HasMapGraphics);
        }