private void CheckForTypeDublicatesAndName(object value)
        {
            if (!IsCorrectType(value))
            {
                throw new NotSupportedException(SR.invalid_object_type(GetCollectionName(), elementType.Name));
            }
            if (value is int && base.List.IndexOf(value) != -1)
            {
                throw new NotSupportedException(SR.duplicate_object_failed(GetCollectionName()));
            }
            NamedElement namedElement = (NamedElement)value;

            if (namedElement.Name == null || namedElement.Name == string.Empty)
            {
                if (base.Count == 0)
                {
                    namedElement.Name = GetDefaultElementName(namedElement);
                }
                else
                {
                    namedElement.Name = GenerateUniqueName(namedElement);
                }
            }
            else if (!IsUniqueName(namedElement.Name))
            {
                throw new ArgumentException(SR.duplicate_name_failed);
            }
        }
 internal void SetByNameCheck(string name, NamedElement element)
 {
     if (!SetByName(name, element))
     {
         throw new ArgumentException(SR.element_not_found(elementType.Name, name, GetType().Name));
     }
 }
 internal NamedCollection(NamedElement parent, CommonElements common)
 {
     Common       = common;
     this.parent  = parent;
     nameToObject = new Hashtable();
     nameToIndex  = new Hashtable();
 }
        public void AddItem(NamedElement item)
        {
            ((IList)items).Add((object)item);
            StringEnumerator enumerator = fieldNames.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string    current   = enumerator.Current;
                    Hashtable hashtable = fieldsCache[current] as Hashtable;
                    if (hashtable == null)
                    {
                        continue;
                    }
                    PropertyInfo property = item.GetType().GetProperty("Item");
                    if (property != null)
                    {
                        object value = property.GetValue(item, new object[1]
                        {
                            current
                        });
                        if (value != null)
                        {
                            hashtable[value] = item;
                        }
                    }
                }
            }
            finally
            {
                (enumerator as IDisposable)?.Dispose();
            }
        }
        public virtual object Clone()
        {
            NamedCollection namedCollection = (NamedCollection)GetType().GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)[0].Invoke(new object[2]
            {
                parent,
                common
            });

            namedCollection.parent      = parent;
            namedCollection.common      = common;
            namedCollection.elementType = elementType;
            IEnumerator enumerator = GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    NamedElement namedElement = (NamedElement)((ICloneable)enumerator.Current).Clone();
                    namedCollection.InnerList.Add(namedElement);
                    namedElement.collection = namedCollection;
                }
                return(namedCollection);
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
Beispiel #6
0
 internal override string GetDefaultElementName(NamedElement el)
 {
     if (el is PathWidthRule)
     {
         return("PathWidthRule1");
     }
     return("PathRule1");
 }
Beispiel #7
0
 internal override string GetElementNameFormat(NamedElement el)
 {
     if (el is PathWidthRule)
     {
         return("PathWidthRule{0}");
     }
     return("PathRule{0}");
 }
 internal override void IsValidNameCheck(string name, NamedElement element)
 {
     base.IsValidNameCheck(name, element);
     if (name.IndexOf(' ') != -1)
     {
         throw new ArgumentException(SR.ExceptionCannotContainSpaces);
     }
 }
        internal virtual string GetElementNameFormat(NamedElement el)
        {
            string text = el.DefaultName;

            if (text == string.Empty)
            {
                text = el.GetType().Name;
            }
            return(text + "{0}");
        }
        internal bool SetByName(string name, NamedElement element)
        {
            int index = GetIndex(name);

            if (index != -1)
            {
                base.List[index] = element;
                return(true);
            }
            return(false);
        }
        public void SetFieldValue(NamedElement item, string fieldName, object value)
        {
            PropertyInfo property = item.GetType().GetProperty("Item");

            if (property != null)
            {
                property.SetValue(item, value, new object[1]
                {
                    fieldName
                });
            }
        }
        internal virtual void IsValidNameCheck(string name, NamedElement element)
        {
            if (name == null || name == string.Empty)
            {
                throw new ArgumentException(SR.empty_name_failed(elementType.Name));
            }
            NamedElement byName = GetByName(name);

            if (byName != null && byName != element)
            {
                throw new NotSupportedException(SR.duplicate_name_failed);
            }
        }
        internal string GenerateUniqueName(NamedElement element)
        {
            string elementNameFormat = GetElementNameFormat(element);

            for (int i = base.Count + 1; i < int.MaxValue; i++)
            {
                string text = string.Format(CultureInfo.InvariantCulture, elementNameFormat, i);
                if (IsUniqueName(text))
                {
                    return(text);
                }
            }
            throw new ApplicationException(SR.generate_name_failed);
        }
Beispiel #14
0
        internal override void Invalidate()
        {
            NamedElement     parentElement    = base.ParentElement;
            ColorSwatchPanel colorSwatchPanel = null;

            do
            {
                colorSwatchPanel = (parentElement as ColorSwatchPanel);
            }while (parentElement.ParentElement != null && colorSwatchPanel == null);
            if (colorSwatchPanel != null && colorSwatchPanel.AutoSize && base.Common != null)
            {
                base.Common.MapCore.InvalidateAndLayout();
            }
            else
            {
                base.Invalidate();
            }
        }
        internal virtual void Notify(MessageType msg, NamedElement element, object param)
        {
            if (IsSuspended)
            {
                return;
            }
            IEnumerator enumerator = GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ((NamedElement)enumerator.Current).Notify(msg, element, param);
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
 internal LegendItemsCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     elementType = typeof(LegendItem);
 }
Beispiel #17
0
 internal ShapeCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     elementType = typeof(Shape);
 }
Beispiel #18
0
 internal override string GetElementNameFormat(NamedElement el)
 {
     return("Shape{0}");
 }
Beispiel #19
0
 internal override string GetDefaultElementName(NamedElement el)
 {
     return("Shape1");
 }
Beispiel #20
0
 internal override string GetElementNameFormat(NamedElement el)
 {
     return("CustomWidth{0}");
 }
Beispiel #21
0
 internal override string GetDefaultElementName(NamedElement el)
 {
     return("CustomWidth1");
 }
Beispiel #22
0
 internal CustomWidthCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     elementType = typeof(CustomWidth);
 }
 internal MapImageCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     elementType = typeof(MapImage);
 }
Beispiel #24
0
 internal void InvokePostPaint(NamedElement sender)
 {
     MapControl.OnPostPaint(MapControl, new MapPaintEventArgs(MapControl, sender, graph));
 }
Beispiel #25
0
 internal override string GetDefaultElementName(NamedElement el)
 {
     return("GroupRule1");
 }
        public NamedElement GetItemById(object itemID)
        {
            NamedElement namedElement = null;

            if (itemID is string)
            {
                namedElement = items.GetByName((string)itemID);
            }
            if (namedElement == null)
            {
                object           key        = Field.ConvertToSupportedValue(itemID);
                StringEnumerator enumerator = fieldNames.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        string current = enumerator.Current;
                        namedElement = (GetItemsByFiledName(current)[key] as NamedElement);
                        if (namedElement != null)
                        {
                            break;
                        }
                    }
                }
                finally
                {
                    (enumerator as IDisposable)?.Dispose();
                }
            }
            if (namedElement == null && createNewItemForUnresoved)
            {
                namedElement = (NamedElement)Activator.CreateInstance(newItemsType);
                if (namedElement != null)
                {
                    if (itemID is string)
                    {
                        namedElement.Name = (string)itemID;
                    }
                    else
                    {
                        object           obj        = Field.ConvertToSupportedValue(itemID);
                        StringEnumerator enumerator = fieldNames.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                string current2 = enumerator.Current;
                                if (fields[current2].Type == obj.GetType())
                                {
                                    SetFieldValue(namedElement, current2, obj);
                                    break;
                                }
                            }
                        }
                        finally
                        {
                            (enumerator as IDisposable)?.Dispose();
                        }
                    }
                    AddItem(namedElement);
                }
            }
            return(namedElement);
        }
Beispiel #27
0
 internal GroupRuleCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     elementType = typeof(GroupRule);
 }
 internal override string GetDefaultElementName(NamedElement el)
 {
     return("LegendItem1");
 }
Beispiel #29
0
 internal override string GetElementNameFormat(NamedElement el)
 {
     return("GroupRule{0}");
 }
Beispiel #30
0
 internal void InvokeElementRemoved(NamedElement sender)
 {
     MapControl.OnElementRemoved(MapControl, new ElementEventArgs(MapControl, sender));
 }