protected override void OnActivityChanged(ActivityChangedEventArgs e)
 {
     base.OnActivityChanged(e);
     if (e.Member != null)
     {
         if ((e.Member.Name == "ProxyClass") && (base.Activity.Site != null))
         {
             InvokeWebServiceActivity activity = e.Activity as InvokeWebServiceActivity;
             System.Workflow.Activities.Common.PropertyDescriptorUtils.SetPropertyValue(base.Activity.Site, TypeDescriptor.GetProperties(base.Activity)["MethodName"], base.Activity, string.Empty);
             IExtendedUIService service = (IExtendedUIService)base.Activity.Site.GetService(typeof(IExtendedUIService));
             if (service == null)
             {
                 throw new Exception(SR.GetString("General_MissingService", new object[] { typeof(IExtendedUIService).FullName }));
             }
             if (activity.ProxyClass == null)
             {
                 this.url = null;
             }
             else
             {
                 Uri urlForProxyClass = service.GetUrlForProxyClass(activity.ProxyClass);
                 this.url = (urlForProxyClass != null) ? urlForProxyClass.ToString() : string.Empty;
             }
         }
         if (((e.Member.Name == "MethodName") || (e.Member.Name == "TargetWorkflow")) && (e.Activity is InvokeWebServiceActivity))
         {
             (e.Activity as InvokeWebServiceActivity).ParameterBindings.Clear();
         }
         if ((e.Member.Name == "ProxyClass") || (e.Member.Name == "MethodName"))
         {
             TypeDescriptor.Refresh(e.Activity);
         }
     }
 }
        void IDisposable.Dispose()
        {
            WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (view != null)
            {
                if (this.refreshTypesHandler != null)
                {
                    view.Idle -= this.refreshTypesHandler;
                }
                if (this.refreshDesignerActionsHandler != null)
                {
                    view.Idle -= this.refreshDesignerActionsHandler;
                }
                if (this.refreshTasksHandler != null)
                {
                    view.Idle -= this.refreshTasksHandler;
                }
            }
            this.refreshTypesHandler           = null;
            this.refreshDesignerActionsHandler = null;
            this.refreshTasksHandler           = null;
            IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (service != null)
            {
                service.RemoveDesignerActions();
            }
            IPropertyValueUIService service2 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;

            if (service2 != null)
            {
                service2.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments));
            }
            IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (service3 != null)
            {
                service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
            }
            ISelectionService service4 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;

            if (service4 != null)
            {
                service4.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
            }
            ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;

            if (provider != null)
            {
                provider.TypesChanged -= new EventHandler(this.OnTypeSystemTypesChanged);
            }
            IDesignerEventService service5 = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService;

            if (service5 != null)
            {
                service5.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged);
            }
            this.serviceProvider.LoadComplete -= new EventHandler(this.OnDesignerReloaded);
        }
        private void OnChangeTheme(object sender, EventArgs e)
        {
            IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (service != null)
            {
                service.ShowToolsOptions();
            }
        }
Esempio n. 4
0
        private void OnRefreshTasks(object sender, EventArgs e)
        {
            WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (this.refreshTasksHandler != null)
            {
                if (workflowView != null)
                {
                    workflowView.Idle -= this.refreshTasksHandler;
                }
                this.refreshTasksHandler = null;
            }

            ISelectionService  selectionService  = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
            IExtendedUIService extendedUIService = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (selectionService != null && extendedUIService != null)
            {
                extendedUIService.RemoveDesignerActions();

                //Only if the current designer is active designer we add the designer actions to the task list
                IDesignerEventService designerEventService = (IDesignerEventService)this.serviceProvider.GetService(typeof(IDesignerEventService));
                if (designerEventService != null && designerEventService.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost)))
                {
                    foreach (object obj in selectionService.GetSelectedComponents())
                    {
                        ActivityDesigner activityDesigner = null;
                        if (obj is HitTestInfo)
                        {
                            activityDesigner = ((HitTestInfo)obj).AssociatedDesigner;
                        }
                        else if (obj is Activity)
                        {
                            activityDesigner = ActivityDesigner.GetDesigner(obj as Activity);
                        }

                        if (activityDesigner != null)
                        {
                            extendedUIService.AddDesignerActions(new List <DesignerAction>(activityDesigner.DesignerActions).ToArray());
                        }
                    }
                }
            }

            if (workflowView != null)
            {
                workflowView.Invalidate();
            }
        }
        private void OnRefreshTasks(object sender, EventArgs e)
        {
            WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;

            if (this.refreshTasksHandler != null)
            {
                if (view != null)
                {
                    view.Idle -= this.refreshTasksHandler;
                }
                this.refreshTasksHandler = null;
            }
            ISelectionService  service  = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
            IExtendedUIService service2 = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if ((service != null) && (service2 != null))
            {
                service2.RemoveDesignerActions();
                IDesignerEventService service3 = (IDesignerEventService)this.serviceProvider.GetService(typeof(IDesignerEventService));
                if ((service3 != null) && (service3.ActiveDesigner == this.serviceProvider.GetService(typeof(IDesignerHost))))
                {
                    foreach (object obj2 in service.GetSelectedComponents())
                    {
                        ActivityDesigner associatedDesigner = null;
                        if (obj2 is HitTestInfo)
                        {
                            associatedDesigner = ((HitTestInfo)obj2).AssociatedDesigner;
                        }
                        else if (obj2 is Activity)
                        {
                            associatedDesigner = ActivityDesigner.GetDesigner(obj2 as Activity);
                        }
                        if (associatedDesigner != null)
                        {
                            service2.AddDesignerActions(new List <DesignerAction>(associatedDesigner.DesignerActions).ToArray());
                        }
                    }
                }
            }
            if (view != null)
            {
                view.Invalidate();
            }
        }
        public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
        {
            object obj2 = o;

            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            IExtendedUIService service = (IExtendedUIService)serviceProvider.GetService(typeof(IExtendedUIService));

            if ((this.editorService != null) && (service != null))
            {
                Uri         url        = null;
                System.Type proxyClass = null;
                if (DialogResult.OK == service.AddWebReference(out url, out proxyClass))
                {
                    obj2 = (url != null) ? url.ToString() : string.Empty;
                    typeDescriptorContext.PropertyDescriptor.SetValue(typeDescriptorContext.Instance, obj2 as string);
                }
            }
            return(obj2);
        }
        protected override void OnActivityChanged(ActivityChangedEventArgs e)
        {
            base.OnActivityChanged(e);

            if (e.Member != null)
            {
                if (e.Member.Name == "ProxyClass")
                {
                    if (Activity.Site != null)
                    {
                        InvokeWebServiceActivity invokeWebServiceDecl = e.Activity as InvokeWebServiceActivity;
                        PropertyDescriptorUtils.SetPropertyValue(Activity.Site, TypeDescriptor.GetProperties(Activity)["MethodName"], Activity, String.Empty);

                        IExtendedUIService extUIService = (IExtendedUIService)Activity.Site.GetService(typeof(IExtendedUIService));
                        if (extUIService == null)
                        {
                            throw new Exception(SR.GetString(SR.General_MissingService, typeof(IExtendedUIService).FullName));
                        }

                        if (invokeWebServiceDecl.ProxyClass == null)
                        {
                            this.url = null;
                        }
                        else
                        {
                            Uri uri = extUIService.GetUrlForProxyClass(invokeWebServiceDecl.ProxyClass);
                            this.url = (uri != null) ? uri.ToString() : string.Empty;
                        }
                    }
                }

                if ((e.Member.Name == "MethodName" || e.Member.Name == "TargetWorkflow") &&
                    e.Activity is InvokeWebServiceActivity)
                {
                    (e.Activity as InvokeWebServiceActivity).ParameterBindings.Clear();
                }

                if (e.Member.Name == "ProxyClass" || e.Member.Name == "MethodName")
                {
                    TypeDescriptor.Refresh(e.Activity);
                }
            }
        }
        public override IComponent[] CreateComponentsWithUI(IDesignerHost host)
        {
            Uri  url                   = null;
            Type proxyClass            = null;
            IExtendedUIService service = host.GetService(typeof(IExtendedUIService)) as IExtendedUIService;

            if (service != null)
            {
                service.AddWebReference(out url, out proxyClass);
            }
            IComponent[] componentArray = base.CreateComponentsWithUI(host);
            if (componentArray.GetLength(0) > 0)
            {
                InvokeWebServiceActivity activity = componentArray[0] as InvokeWebServiceActivity;
                if (activity != null)
                {
                    activity.ProxyClass = proxyClass;
                }
            }
            return(componentArray);
        }
        protected override void OnActivityChanged(ActivityChangedEventArgs e)
        {
            base.OnActivityChanged(e);

            if (e.Member != null)
            {
                if (e.Member.Name == "InterfaceType")
                {
                    if (Activity.Site != null)
                    {
                        Type interfaceType = e.NewValue as Type;
                        if (interfaceType != null)
                        {
                            new ExternalDataExchangeInterfaceTypeFilterProvider(Activity.Site).CanFilterType(interfaceType, true);
                        }

                        CallExternalMethodActivity invokeActivity = e.Activity as CallExternalMethodActivity;
                        PropertyDescriptorUtils.SetPropertyValue(Activity.Site, TypeDescriptor.GetProperties(Activity)["MethodName"], Activity, String.Empty);

                        IExtendedUIService extUIService = (IExtendedUIService)Activity.Site.GetService(typeof(IExtendedUIService));
                        if (extUIService == null)
                        {
                            throw new Exception(SR.GetString(SR.General_MissingService, typeof(IExtendedUIService).FullName));
                        }
                    }
                }

                if ((e.Member.Name == "MethodName") &&
                    e.Activity is CallExternalMethodActivity)
                {
                    (e.Activity as CallExternalMethodActivity).ParameterBindings.Clear();
                }

                if (e.Member.Name == "InterfaceType" || e.Member.Name == "MethodName" || e.Member.Name == "CorrelationToken")
                {
                    TypeDescriptor.Refresh(e.Activity);
                }
            }
        }
        private void OnMenuPaste(object sender, EventArgs e)
        {
            object primarySelection = this.selectionService.PrimarySelection;
            CompositeActivityDesigner parentDesigner = ActivityDesigner.GetDesigner(primarySelection as Activity) as CompositeActivityDesigner;

            if (parentDesigner == null)
            {
                parentDesigner = ActivityDesigner.GetParentDesigner(primarySelection);
            }
            if ((parentDesigner != null) && parentDesigner.IsEditable)
            {
                IDataObject dataObject = Clipboard.GetDataObject();
                ICollection activities = null;
                try
                {
                    activities = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(this.serviceProvider, dataObject, true);
                }
                catch (Exception exception)
                {
                    if (exception != CheckoutException.Canceled)
                    {
                        throw new Exception(DR.GetString("ActivityInsertError", new object[0]) + "\n" + exception.Message, exception);
                    }
                }
                if (activities == null)
                {
                    throw new InvalidOperationException(DR.GetString("InvalidOperationBadClipboardFormat", new object[0]));
                }
                System.Workflow.ComponentModel.Design.HitTestInfo insertLocation = null;
                if (primarySelection is System.Workflow.ComponentModel.Design.HitTestInfo)
                {
                    insertLocation = (System.Workflow.ComponentModel.Design.HitTestInfo)primarySelection;
                }
                else if (primarySelection is CompositeActivity)
                {
                    insertLocation = new System.Workflow.ComponentModel.Design.HitTestInfo(parentDesigner, HitTestLocations.Designer);
                }
                else if (primarySelection is Activity)
                {
                    Activity                  item     = primarySelection as Activity;
                    CompositeActivity         parent   = item.Parent;
                    CompositeActivityDesigner designer = ActivityDesigner.GetDesigner(parent) as CompositeActivityDesigner;
                    if (designer != null)
                    {
                        insertLocation = new ConnectorHitTestInfo(designer, HitTestLocations.Designer, parent.Activities.IndexOf(item) + 1);
                    }
                }
                List <Activity> list = new List <Activity>(Helpers.GetTopLevelActivities(activities));
                if ((insertLocation == null) || !parentDesigner.CanInsertActivities(insertLocation, list.AsReadOnly()))
                {
                    throw new Exception(SR.GetString("Error_NoPasteSupport"));
                }
                IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService;
                if (service != null)
                {
                    foreach (Activity activity3 in activities)
                    {
                        service.AddAssemblyReference(activity3.GetType().Assembly.GetName());
                    }
                }
                CompositeActivityDesigner.InsertActivities(parentDesigner, insertLocation, list.AsReadOnly(), SR.GetString("PastingActivities"));
                Stream data = dataObject.GetData("CF_WINOEDESIGNERCOMPONENTSSTATE") as Stream;
                if (data != null)
                {
                    Helpers.DeserializeDesignersFromStream(activities, data);
                }
                this.selectionService.SetSelectedComponents(list.ToArray(), SelectionTypes.Replace);
                this.workflowView.EnsureVisible(this.selectionService.PrimarySelection);
            }
        }