protected override void Initialize(Activity activity)
        {
            base.Initialize(activity);
            IExtenderListService service = (IExtenderListService)base.GetService(typeof(IExtenderListService));

            if (service != null)
            {
                bool flag = false;
                foreach (IExtenderProvider provider in service.GetExtenderProviders())
                {
                    if (provider.GetType() == typeof(ConditionPropertyProviderExtender))
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    IExtenderProviderService service2 = (IExtenderProviderService)base.GetService(typeof(IExtenderProviderService));
                    if (service2 != null)
                    {
                        service2.AddExtenderProvider(new ConditionPropertyProviderExtender());
                    }
                }
            }
        }
        private void EnsureDesignerExtender()
        {
            bool flag = true;
            IExtenderListService service = base.GetService(typeof(IExtenderListService)) as IExtenderListService;

            if (service != null)
            {
                foreach (IExtenderProvider provider in service.GetExtenderProviders())
                {
                    if (provider.GetType() == typeof(FreeFormDesignerPropertyExtender))
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag)
            {
                IExtenderProviderService service2 = base.GetService(typeof(IExtenderProviderService)) as IExtenderProviderService;
                if (service2 != null)
                {
                    service2.AddExtenderProvider(new FreeFormDesignerPropertyExtender());
                    TypeDescriptor.Refresh(base.Activity);
                }
            }
        }
        protected override void Initialize(Activity activity)
        {
            base.Initialize(activity);

            IExtenderListService extenderListService = (IExtenderListService)GetService(typeof(IExtenderListService));

            if (extenderListService != null)
            {
                bool foundCAGExtender = false;
                foreach (IExtenderProvider extenderProvider in extenderListService.GetExtenderProviders())
                {
                    if (extenderProvider.GetType() == typeof(ConditionPropertyProviderExtender))
                    {
                        foundCAGExtender = true;
                    }
                }

                if (!foundCAGExtender)
                {
                    IExtenderProviderService extenderProviderService = (IExtenderProviderService)GetService(typeof(IExtenderProviderService));
                    if (extenderProviderService != null)
                    {
                        extenderProviderService.AddExtenderProvider(new ConditionPropertyProviderExtender());
                    }
                }
            }
        }
Example #4
0
        internal static void FilterDependencyProperties(IServiceProvider serviceProvider, Activity activity)
        {
            IExtenderListService extenderListService = serviceProvider.GetService(typeof(IExtenderListService)) as IExtenderListService;

            if (extenderListService != null)
            {
                Dictionary <string, DependencyProperty> dependencyProperyies = new Dictionary <string, DependencyProperty>();
                foreach (DependencyProperty property in activity.MetaDependencyProperties)
                {
                    dependencyProperyies.Add(property.Name, property);
                }

                List <string> disallowedProperties = new List <string>();
                foreach (IExtenderProvider extenderProvider in extenderListService.GetExtenderProviders())
                {
                    if (!extenderProvider.CanExtend(activity))
                    {
                        ProvidePropertyAttribute[] propertyAttributes = extenderProvider.GetType().GetCustomAttributes(typeof(ProvidePropertyAttribute), true) as ProvidePropertyAttribute[];
                        foreach (ProvidePropertyAttribute propertyAttribute in propertyAttributes)
                        {
                            disallowedProperties.Add(propertyAttribute.PropertyName);
                        }
                    }
                }

                foreach (string propertyName in disallowedProperties)
                {
                    if (dependencyProperyies.ContainsKey(propertyName))
                    {
                        activity.RemoveProperty(dependencyProperyies[propertyName]);
                    }
                }
            }
        }
Example #5
0
        // This utility method connects the designer to various
        // services it will use.
        private void InitializeServices()
        {
            // Acquire a reference to DesignerActionService.
            this.actionService = GetService(typeof(DesignerActionService)) as DesignerActionService;

            // Acquire a reference to DesignerActionUIService.
            this.actionUiService = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;

            // Acquire a reference to IComponentChangeService.
            this.changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            // Acquire a reference to IDesignerHost.
            this.host = GetService(typeof(IDesignerHost)) as IDesignerHost;

            // Acquire a reference to IDesignerOptionService.
            this.optionService =
                GetService(typeof(IDesignerOptionService)) as IDesignerOptionService;

            // Acquire a reference to IEventBindingService.
            this.eventBindingService =
                GetService(typeof(IEventBindingService)) as IEventBindingService;

            // Acquire a reference to IExtenderListService.
            this.listService =
                GetService(typeof(IExtenderListService)) as IExtenderListService;

            // Acquire a reference to IReferenceService.
            this.referenceService =
                GetService(typeof(IReferenceService)) as IReferenceService;

            // Acquire a reference to ITypeResolutionService.
            this.typeResService = GetService(typeof(ITypeResolutionService))
                                  as ITypeResolutionService;

            // Acquire a reference to IComponentDiscoveryService.
            this.componentDiscoveryService = GetService(typeof(IComponentDiscoveryService))
                                             as IComponentDiscoveryService;

            // Acquire a reference to IToolboxService.
            this.toolboxService = GetService(typeof(IToolboxService)) as IToolboxService;

            // Acquire a reference to UndoEngine.
            this.undoEng = GetService(typeof(UndoEngine)) as UndoEngine;

            if (this.undoEng != null)
            {
                //MessageBox.Show("UndoEngine");
            }
        }
Example #6
0
        public override object EditValue(ITypeDescriptorContext context,
                                         IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService wfes = (IWindowsFormsEditorService)provider.GetService(
                typeof(IWindowsFormsEditorService));

            if (wfes == null || context == null)
            {
                return(null);
            }

            ImageList imageList = null;
            Component component = (Component)context.Instance;

            IExtenderListService extenderListService = (IExtenderListService)component.Site.GetService(typeof(IExtenderListService));

            if (extenderListService != null)
            {
                IExtenderProvider[] extenders = extenderListService.GetExtenderProviders();
                for (int i = 0; i < extenders.Length; i++)
                {
                    if (extenders[i].GetType().FullName == "MenuExtender.MenuExtender")
                    {
                        MenuExtender menuExtender = (MenuExtender)extenders[i];
                        imageList = menuExtender.ImageList;
                    }
                }
            }

            ImageSelector imageSelector = new ImageSelector(imageList, (int)value, wfes);

            wfes.DropDownControl(imageSelector);

            int imageIndex = -1;

            if (imageSelector.SelectedItems.Count != 0)
            {
                try
                {
                    imageIndex = (int)Convert.ToInt32(imageSelector.SelectedItems[0].Text);
                }
                catch
                {
                    imageIndex = -1;
                }
            }
            return(imageIndex);
        }
Example #7
0
        public override void PaintValue(PaintValueEventArgs pe)
        {
            int imageIndex = -1;

            if (pe.Value != null)
            {
                try
                {
                    imageIndex = (int)Convert.ToUInt16(pe.Value.ToString());
                }
                catch
                {
                    imageIndex = -1;
                }
            }

            if (pe.Context.Instance == null || imageIndex < 0)
            {
                return;
            }

            ImageList imageList = null;
            Component component = (Component)pe.Context.Instance;

            IExtenderListService extenderListService = (IExtenderListService)component.Site.GetService(typeof(IExtenderListService));

            if (extenderListService != null)
            {
                IExtenderProvider[] extenders = extenderListService.GetExtenderProviders();
                for (int i = 0; i < extenders.Length; i++)
                {
                    if (extenders[i].GetType().FullName == "MenuItemRenderer.MenuItemRenderer")
                    {
                        MenuItemRender menuExtender = (MenuItemRender)extenders[i];
                        imageList = menuExtender.ImageList;
                    }
                }
            }
            if (imageList == null ||
                imageList.Images.Empty ||
                imageIndex >= imageList.Images.Count)
            {
                return;
            }

            pe.Graphics.DrawImage(imageList.Images[imageIndex], pe.Bounds);
        }
        private static bool SetGenerateMemberProperty(
         IExtenderListService service,
         IComponent component,
         bool value)
        {
            IExtenderProvider provider = null;
            IExtenderProvider[] providers = service.GetExtenderProviders();
            foreach (IExtenderProvider item in providers)
            {
                if (item.GetType().FullName ==
                       "System.ComponentModel.Design.Serialization.CodeDomDesignerLoader+ModifiersExtenderProvider")
                {
                    provider = item;
                    break;
                }
            }

            if (provider == null) return false;

            MethodInfo methodInfo =
               provider.GetType().GetMethod(
                  "SetGenerateMember", BindingFlags.Public |
                                       BindingFlags.Instance);

            if (methodInfo != null)
            {
                methodInfo.Invoke(
                   provider, new object[]
                            {
                               component,
                               value
                            });
                return true;
            }

            return false;
        }
Example #9
0
		// We need these services to be present, but we cache references for efficiency
		// Whenever new designer host loaded etc, must reinitialise the services
		public void InitialiseServices ()
		{
			//unregister old event handlers
			if (selectionService != null)
				selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged);

			//update references
			extenderListService = parentServices.GetService (typeof (IExtenderListService)) as IExtenderListService;
			selectionService = parentServices.GetService (typeof (ISelectionService)) as ISelectionService;
			changeService = parentServices.GetService (typeof (IComponentChangeService)) as IComponentChangeService;
			typeDescriptorFilterService = parentServices.GetService (typeof (ITypeDescriptorFilterService)) as ITypeDescriptorFilterService;

			//register event handlers
			if (selectionService != null)
				selectionService.SelectionChanged += new EventHandler (selectionService_SelectionChanged);
			if (changeService != null) {
				changeService.ComponentAdded += new ComponentEventHandler (changeService_ComponentAdded);
				changeService.ComponentRemoved += new ComponentEventHandler (changeService_ComponentRemoved);
				changeService.ComponentRename += new ComponentRenameEventHandler (changeService_ComponentRename);
				changeService.ComponentChanged += new ComponentChangedEventHandler (changeService_updateValues);
				/*TODO: should we also monitor these?
				changeService.ComponentAdding
				changeService.ComponentChanging
				changeService.ComponentRemoving
				*/
			}

			//get existing components for combo list
			IDesignerHost host = parentServices.GetService (typeof (IDesignerHost)) as IDesignerHost;
			if (host != null)
				foreach (IComponent comp in host.Container.Components)
					changeService_ComponentAdded(host.Container, new ComponentEventArgs (comp));
		}
Example #10
0
        private void x391093a02bb10339()
        {
            IExtenderListService service = (IExtenderListService)this.GetService(typeof(IExtenderListService));

            if (false)
            {
                int num;
                if ((uint)num >= 0U)
                {
                    return;
                }
            }
            else
            {
                goto label_15;
            }
label_2:
            MethodInfo method;

            if (method == null)
            {
                if (true)
                {
                    return;
                }
                goto label_15;
            }
            else
            {
                goto label_9;
            }
label_8:
            if (true)
            {
                goto label_2;
            }
label_9:
            IExtenderProvider extenderProvider;

            method.Invoke((object)extenderProvider, new object[2]
            {
                (object)this.Component,
                (object)false
            });
            int index;

            if ((uint)index >= 0U)
            {
                return;
            }
            goto label_8;
label_15:
            IExtenderProvider[] extenderProviders = service.GetExtenderProviders();
            index = 0;
            if ((uint)index > uint.MaxValue)
            {
                return;
            }
            for (; index < extenderProviders.Length; ++index)
            {
                extenderProvider = extenderProviders[index];
                while (extenderProvider.GetType().FullName == "System.ComponentModel.Design.Serialization.CodeDomDesignerLoader+ModifiersExtenderProvider")
                {
                    method = extenderProvider.GetType().GetMethod("SetGenerateMember", BindingFlags.Instance | BindingFlags.Public);
                    if ((uint)index + (uint)index >= 0U)
                    {
                        goto label_8;
                    }
                }
            }
        }