public NamedCollection(NamedElement parent, CommonElements common)
 {
     this.Common       = common;
     this.parent       = parent;
     this.nameToObject = new Hashtable();
     this.nameToIndex  = new Hashtable();
 }
        private void CheckForTypeDublicatesAndName(object value)
        {
            if (!this.IsCorrectType(value))
            {
                throw new NotSupportedException(SR.invalid_object_type(this.GetCollectionName(), this.elementType.Name));
            }
            if (value is int && base.List.IndexOf(value) != -1)
            {
                throw new NotSupportedException(SR.duplicate_object_failed(this.GetCollectionName()));
            }
            NamedElement namedElement = (NamedElement)value;

            if (namedElement.Name != null && !(namedElement.Name == string.Empty))
            {
                if (this.IsUniqueName(namedElement.Name))
                {
                    return;
                }
                throw new ArgumentException(SR.duplicate_name_failed);
            }
            if (base.Count == 0)
            {
                namedElement.Name = this.GetDefaultElementName(namedElement);
            }
            else
            {
                namedElement.Name = this.GenerateUniqueName(namedElement);
            }
        }
示例#3
0
 public override string GetElementNameFormat(NamedElement el)
 {
     if (el is PathWidthRule)
     {
         return("PathWidthRule{0}");
     }
     return("PathRule{0}");
 }
 public void SetByNameCheck(string name, NamedElement element)
 {
     if (this.SetByName(name, element))
     {
         return;
     }
     throw new ArgumentException(SR.element_not_found(this.elementType.Name, name, base.GetType().Name));
 }
示例#5
0
 public override string GetDefaultElementName(NamedElement el)
 {
     if (el is PathWidthRule)
     {
         return("PathWidthRule1");
     }
     return("PathRule1");
 }
示例#6
0
 public override void IsValidNameCheck(string name, NamedElement element)
 {
     base.IsValidNameCheck(name, element);
     if (name.IndexOf(' ') == -1)
     {
         return;
     }
     throw new ArgumentException(SR.ExceptionCannotContainSpaces);
 }
 public virtual void Notify(MessageType msg, NamedElement element, object param)
 {
     if (!this.IsSuspended)
     {
         foreach (NamedElement item in this)
         {
             item.Notify(msg, element, param);
         }
     }
 }
        public virtual string GetElementNameFormat(NamedElement el)
        {
            string text = el.DefaultName;

            if (text == string.Empty)
            {
                text = el.GetType().Name;
            }
            return(text + "{0}");
        }
        public NamedElement GetByNameCheck(string name)
        {
            NamedElement byName = this.GetByName(name);

            if (byName == null)
            {
                throw new ArgumentException(SR.element_not_found(this.elementType.Name, name, base.GetType().Name));
            }
            return(byName);
        }
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList arrayList = new ArrayList();

            if (context != null && context.Instance != null && context.Instance is NamedElement)
            {
                NamedElement namedElement = (NamedElement)context.Instance;
            }
            arrayList.Add("(none)");
            return(new StandardValuesCollection(arrayList));
        }
        public bool SetByName(string name, NamedElement element)
        {
            int index = this.GetIndex(name);

            if (index != -1)
            {
                base.List[index] = element;
                return(true);
            }
            return(false);
        }
示例#12
0
        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
                });
            }
        }
        public string GenerateUniqueName(NamedElement element)
        {
            string elementNameFormat = this.GetElementNameFormat(element);

            for (int i = base.Count + 1; i < 2147483647; i++)
            {
                string text = string.Format(CultureInfo.InvariantCulture, elementNameFormat, i);
                if (this.IsUniqueName(text))
                {
                    return(text);
                }
            }
            throw new ApplicationException(SR.generate_name_failed);
        }
 public virtual void IsValidNameCheck(string name, NamedElement element)
 {
     if (name != null && !(name == string.Empty))
     {
         NamedElement byName = this.GetByName(name);
         if (byName == null)
         {
             return;
         }
         if (byName == element)
         {
             return;
         }
         throw new NotSupportedException(SR.duplicate_name_failed);
     }
     throw new ArgumentException(SR.empty_name_failed(this.elementType.Name));
 }
        public 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();
            }
        }
        public virtual object Clone()
        {
            ConstructorInfo[] constructors    = base.GetType().GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic);
            NamedCollection   namedCollection = (NamedCollection)constructors[0].Invoke(new object[2]
            {
                this.parent,
                this.common
            });

            namedCollection.parent      = this.parent;
            namedCollection.common      = this.common;
            namedCollection.elementType = this.elementType;
            foreach (ICloneable item in this)
            {
                NamedElement namedElement = (NamedElement)item.Clone();
                namedCollection.InnerList.Add(namedElement);
                namedElement.collection = namedCollection;
            }
            return(namedCollection);
        }
示例#17
0
        public void AddItem(NamedElement item)
        {
            ((IList)this.items).Add((object)item);
            StringEnumerator enumerator = this.fieldNames.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string    current   = enumerator.Current;
                    Hashtable hashtable = this.fieldsCache[current] as Hashtable;
                    if (hashtable != null)
                    {
                        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
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
 public override string GetElementNameFormat(NamedElement el)
 {
     return(base.GetElementNameFormat(el).Replace("Data", ""));
 }
 public override string GetElementNameFormat(NamedElement el)
 {
     return("Color{0}");
 }
 public override string GetDefaultElementName(NamedElement el)
 {
     return("Color1");
 }
 public SwatchColorCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     base.elementType = typeof(SwatchColor);
 }
示例#22
0
 public override string GetElementNameFormat(NamedElement el)
 {
     return("PredefinedSymbol{0}");
 }
示例#23
0
 public override string GetDefaultElementName(NamedElement el)
 {
     return("PredefinedSymbol1");
 }
示例#24
0
 public PredefinedSymbolCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     base.elementType = typeof(PredefinedSymbol);
 }
 public LegendCellColumnCollection(Legend legend, NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     base.elementType = typeof(LegendCellColumn);
     this.legend      = legend;
 }
示例#26
0
 public LegendCellCollection(LegendItem legendItem, NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     base.elementType = typeof(LegendCell);
     this.legendItem  = legendItem;
 }
 public override string GetElementNameFormat(NamedElement el)
 {
     return("ShapeRule{0}");
 }
 public override string GetDefaultElementName(NamedElement el)
 {
     return("ShapeRule1");
 }
 public ShapeRuleCollection(NamedElement parent, CommonElements common)
     : base(parent, common)
 {
     base.elementType = typeof(ShapeRule);
 }
 public override string GetDefaultElementName(NamedElement el)
 {
     return(string.Format(CultureInfo.InvariantCulture, this.GetElementNameFormat(el), 1));
 }