public override object GetObject(ITypeDescriptorContext context, object value)
        {
            IFormattableObject contextObject = null;

            var multi = context.Instance as object[];

            if (multi != null)
            {
                var objects = multi.OfType <IFormattableObject>()
                              .Concat(multi.OfType <KPI>().Select(kpi => new KPIFormatString(kpi)));
                contextObject = new FormattableObjectCollection(objects);
            }
            else if (context.Instance is KPI)
            {
                contextObject = new KPIFormatString(context.Instance as KPI);
            }
            else
            {
                contextObject = context.Instance as IFormattableObject;
            }

            if (contextObject == null)
            {
                return(null);
            }

            return(new Format(contextObject));
        }
        public Format(IFormattableObject baseObject)
        {
            this.baseObject = baseObject;

            // Set the format to Mixed, in case multiple objects with different formats have been selected:
            if ((baseObject as FormattableObjectCollection)?.Mixed ?? false)
            {
                numberFormat = NumberFormats.Mixed;
            }
            else
            {
                ApplyFormatString(baseObject.FormatString);
            }
        }