示例#1
0
        public ScaleBase GetScaleBase()
        {
            if (this.Common == null)
            {
                return(null);
            }
            if (this.scaleName == string.Empty)
            {
                return(null);
            }
            GaugeBase       gaugeBase       = this.GetGaugeBase();
            NamedCollection namedCollection = null;

            if (gaugeBase is CircularGauge)
            {
                namedCollection = ((CircularGauge)gaugeBase).Scales;
            }
            if (gaugeBase is LinearGauge)
            {
                namedCollection = ((LinearGauge)gaugeBase).Scales;
            }
            if (namedCollection == null)
            {
                return(null);
            }
            return((ScaleBase)namedCollection.GetByName(this.scaleName));
        }
示例#2
0
        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);
        }
        public string GetDefaultScaleName(string scaleName)
        {
            NamedCollection namedCollection = null;

            if (this is CircularGauge)
            {
                namedCollection = ((CircularGauge)this).Scales;
            }
            if (this is LinearGauge)
            {
                namedCollection = ((LinearGauge)this).Scales;
            }
            if (namedCollection.GetIndex(scaleName) != -1)
            {
                return(scaleName);
            }
            if (scaleName == "Default" && namedCollection.Count > 0)
            {
                return(namedCollection.GetByIndex(0).Name);
            }
            return(scaleName);
        }
示例#4
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            ArrayList arrayList = new ArrayList();

            if (context != null && context.Instance != null)
            {
                NamedElement    namedElement    = null;
                NamedCollection namedCollection = null;
                if (context.Instance is NamedElement)
                {
                    namedElement = (NamedElement)context.Instance;
                }
                if (context.Instance is IList && ((IList)context.Instance).Count > 0)
                {
                    namedElement = (NamedElement)((IList)context.Instance)[0];
                }
                if (namedElement != null && namedElement.Common != null && namedElement.ParentElement != null)
                {
                    if (namedElement.ParentElement is CircularGauge)
                    {
                        namedCollection = ((CircularGauge)namedElement.ParentElement).Scales;
                    }
                    if (namedElement.ParentElement is LinearGauge)
                    {
                        namedCollection = ((LinearGauge)namedElement.ParentElement).Scales;
                    }
                }
                if (namedCollection != null)
                {
                    foreach (NamedElement item in namedCollection)
                    {
                        arrayList.Add(item.Name);
                    }
                }
            }
            return(new StandardValuesCollection(arrayList));
        }