public override TypeConverter.StandardValuesCollection GetStandardValuesCore(ITypeDescriptorContext context, TypeConverter.StandardValuesCollection collection)
        {
            List <IComponent> list = CommandBaseConverter.DiscoverCommandsSources(collection);

            list.Insert(0, null);
            return(new TypeConverter.StandardValuesCollection(list));
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (!(value is string))
            {
                return(base.ConvertFrom(context, culture, value));
            }
            string text1 = ((string)value).Trim();

            if (!string.Equals(text1, CommandBaseConverter.none) && (context != null))
            {
                List <IComponent> sourceList =
                    CommandBaseConverter.DiscoverCommandsSources(base.GetComponentsReferences(context));
                if (sourceList != null &&
                    sourceList.Count > 0)
                {
                    for (int i = 0; i < sourceList.Count; i++)
                    {
                        string name = sourceList[i].ToString();
                        if (text1.Equals(name))
                        {
                            return(sourceList[i]);
                        }
                    }
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
Beispiel #3
0
        public override object ConvertFrom(
            ITypeDescriptorContext context,
            CultureInfo culture,
            object value)
        {
            if (!(value is string))
            {
                return(base.ConvertFrom(context, culture, value));
            }
            string a = ((string)value).Trim();

            if (!string.Equals(a, CommandBaseConverter.none) && context != null)
            {
                List <CommandBase> commandBaseList = CommandBaseConverter.DiscoverCommands(this.GetComponentsReferences(context));
                if (commandBaseList != null && commandBaseList.Count > 0)
                {
                    for (int index = 0; index < commandBaseList.Count; ++index)
                    {
                        string str = commandBaseList[index].ToString();
                        if (a.Equals(str))
                        {
                            return((object)commandBaseList[index]);
                        }
                    }
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
 protected static void TransferListUniquePart <T>(List <T> sourceList, List <T> destinationList)
 {
     for (int index = 0; index < sourceList.Count; ++index)
     {
         CommandBaseConverter.TransferListUniquePart <T>(sourceList[index], destinationList);
     }
 }
Beispiel #5
0
        public override TypeConverter.StandardValuesCollection GetStandardValuesCore(
            ITypeDescriptorContext context,
            TypeConverter.StandardValuesCollection collection)
        {
            List <CommandBase> commandBaseList = CommandBaseConverter.DiscoverCommands(collection);

            commandBaseList?.Insert(0, (CommandBase)null);
            return(new TypeConverter.StandardValuesCollection((ICollection)commandBaseList));
        }
Beispiel #6
0
        public override TypeConverter.StandardValuesCollection GetStandardValuesCore(ITypeDescriptorContext context, TypeConverter.StandardValuesCollection collection)
        {
            List <CommandBase> list = CommandBaseConverter.DiscoverCommands(collection);

            if (list != null)
            {
                list.Insert(0, null);
            }
            return(new TypeConverter.StandardValuesCollection(list));
        }
        public static List <CommandBase> DiscoverCommands(
            TypeConverter.StandardValuesCollection collection)
        {
            List <CommandBase> commandBaseList = CommandBaseConverter.DiscoverCommands(CommandBaseConverter.DiscoverCommandsSources(collection));

            if (commandBaseList != null && commandBaseList.Count > 0)
            {
                return(commandBaseList);
            }
            return((List <CommandBase>)null);
        }
Beispiel #8
0
        public override TypeConverter.StandardValuesCollection GetStandardValuesCore(ITypeDescriptorContext context, TypeConverter.StandardValuesCollection collection)
        {
            List <IComponent> list = CommandBaseConverter.DiscoverCommandsContexts(collection);

            if (context != null && list != null && (context.GetService(typeof(IDesignerHost)) != null))
            {
                for (int i = (list.Count - 1); i >= 0; i--)
                {
                    if (list[i].Site == null)
                    {
                        list.RemoveAt(i);
                    }
                }
                list.Insert(0, null);
            }
            return(new TypeConverter.StandardValuesCollection(list));
        }
        public static List <IComponent> DiscoverCommandsSources(List <IComponent> list)
        {
            List <IComponent> destinationList = new List <IComponent>(1);

            for (int index = 0; index < list.Count; ++index)
            {
                List <IComponent> sourceList = CommandBaseConverter.DiscoverCommandsSources(list[index]);
                if (sourceList != null && sourceList.Count > 0)
                {
                    CommandBaseConverter.TransferListUniquePart <IComponent>(sourceList, destinationList);
                }
            }
            if (destinationList.Count > 0)
            {
                return(destinationList);
            }
            return((List <IComponent>)null);
        }
Beispiel #10
0
        public override TypeConverter.StandardValuesCollection GetStandardValuesCore(
            ITypeDescriptorContext context,
            TypeConverter.StandardValuesCollection collection)
        {
            List <IComponent> componentList = CommandBaseConverter.DiscoverCommandsContexts(collection);

            if (context != null && componentList != null && context.GetService(typeof(IDesignerHost)) != null)
            {
                for (int index = componentList.Count - 1; index >= 0; --index)
                {
                    if (componentList[index].Site == null)
                    {
                        componentList.RemoveAt(index);
                    }
                }
                componentList.Insert(0, (IComponent)null);
            }
            return(new TypeConverter.StandardValuesCollection((ICollection)componentList));
        }
        public static List <IComponent> DiscoverCommandsSources(
            ICommand command,
            TypeConverter.StandardValuesCollection collection)
        {
            List <IComponent> componentList1 = CommandBaseConverter.DiscoverCommandsSources(collection);
            List <IComponent> componentList2 = new List <IComponent>(1);

            for (int index = 0; index < componentList1.Count; ++index)
            {
                if (componentList1[index].GetType().IsAssignableFrom(command.ContextType))
                {
                    componentList2.Add(componentList1[index]);
                }
            }
            if (componentList2.Count > 0)
            {
                return(componentList2);
            }
            return((List <IComponent>)null);
        }
        public static List <IComponent> DiscoverCommandsSources(
            TypeConverter.StandardValuesCollection collection)
        {
            List <IComponent> list = new List <IComponent>(1);

            for (int index = 0; index < collection.Count; ++index)
            {
                IComponent component = collection[index] as IComponent;
                if (component != null)
                {
                    list.Add(component);
                }
            }
            List <IComponent> componentList = CommandBaseConverter.DiscoverCommandsSources(list);

            if (componentList != null && componentList.Count > 0)
            {
                return(componentList);
            }
            return((List <IComponent>)null);
        }
        public static List <IComponent> DiscoverCommandsSources(IComponent source)
        {
            if (source == null)
            {
                return((List <IComponent>)null);
            }
            List <IComponent> destinationList = new List <IComponent>(1);

            if (CommandBaseConverter.DiscoverCommands(source) != null)
            {
                CommandBaseConverter.TransferListUniquePart <IComponent>(source, destinationList);
            }
            if (source is RadControl)
            {
                RootRadElement rootElement = (source as RadControl).RootElement;
                if (rootElement != null && rootElement.Children.Count > 0)
                {
                    for (int index = 0; index < rootElement.Children.Count; ++index)
                    {
                        IComponent child = rootElement.Children[index] as IComponent;
                        if (child != null && child is IItemsOwner)
                        {
                            List <IComponent> sourceList = CommandBaseConverter.DiscoverCommandsSources(child);
                            if (destinationList != null)
                            {
                                CommandBaseConverter.TransferListUniquePart <IComponent>(sourceList, destinationList);
                            }
                        }
                    }
                }
            }
            if (destinationList.Count > 0)
            {
                return(destinationList);
            }
            return((List <IComponent>)null);
        }
        public static List <IComponent> DiscoverCommandsContexts(IComponent source)
        {
            if (source == null)
            {
                return((List <IComponent>)null);
            }
            List <IComponent> destinationList = new List <IComponent>(1);

            if (typeof(RadControl).IsAssignableFrom(source.GetType()) || typeof(RadItem).IsAssignableFrom(source.GetType()))
            {
                CommandBaseConverter.TransferListUniquePart <IComponent>(source, destinationList);
            }
            if (source is RadControl)
            {
                RootRadElement rootElement = (source as RadControl).RootElement;
                if (rootElement != null && rootElement.Children.Count > 0)
                {
                    foreach (RadElement child in rootElement.Children)
                    {
                        IComponent source1 = child as IComponent;
                        if (source1 != null && child is IItemsOwner)
                        {
                            List <IComponent> sourceList = CommandBaseConverter.DiscoverCommandsContexts(source1);
                            if (destinationList != null)
                            {
                                CommandBaseConverter.TransferListUniquePart <IComponent>(sourceList, destinationList);
                            }
                        }
                    }
                }
            }
            if (destinationList.Count > 0)
            {
                return(destinationList);
            }
            return((List <IComponent>)null);
        }
 protected virtual TypeConverter.StandardValuesCollection GetComponentsReferences(
     ITypeDescriptorContext context)
 {
     return(CommandBaseConverter.GetReferences(context, typeof(IComponent)));
 }