Esempio n. 1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            this.serviceProvider = serviceProvider;

            object returnValue = value;

            if (context != null && context.PropertyDescriptor is DynamicPropertyDescriptor)
            {
                try
                {
                    using (ActivityBindForm bindDialog = new ActivityBindForm(this.serviceProvider, context))
                    {
                        if (DialogResult.OK == bindDialog.ShowDialog())
                        {
                            //Now that OK has been pressed in the dialog we need to create members if necessary
                            if (bindDialog.CreateNew)
                            {
                                //Emit the field / property as required
                                if (bindDialog.CreateNewProperty)
                                {
                                    List <CustomProperty> properties = CustomActivityDesignerHelper.GetCustomProperties(context);
                                    if (properties != null)
                                    {
                                        properties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, bindDialog.NewMemberName, context.PropertyDescriptor, context.Instance));
                                        CustomActivityDesignerHelper.SetCustomProperties(properties, context);
                                    }
                                }
                                else
                                {
                                    ActivityBindPropertyDescriptor.CreateField(context, bindDialog.Binding, true);
                                }
                            }
                            returnValue = bindDialog.Binding;
                        }
                    }
                }
                catch (Exception e)
                {
                    string message = SR.GetString(SR.Error_CanNotBindProperty, context.PropertyDescriptor.Name);
                    if (!String.IsNullOrEmpty(e.Message))
                    {
                        message += "\n\n" + e.Message;
                    }
                    DesignerHelpers.ShowError(context, message);
                }
            }
            else
            {
                DesignerHelpers.ShowError(this.serviceProvider, SR.GetString(SR.Error_MultipleSelectNotSupportedForBindAndPromote));
            }

            return(returnValue);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            this.serviceProvider = serviceProvider;
            object obj2 = value;

            if ((context != null) && (context.PropertyDescriptor is DynamicPropertyDescriptor))
            {
                try
                {
                    using (ActivityBindForm form = new ActivityBindForm(this.serviceProvider, context))
                    {
                        if (DialogResult.OK != form.ShowDialog())
                        {
                            return(obj2);
                        }
                        if (form.CreateNew)
                        {
                            if (form.CreateNewProperty)
                            {
                                List <CustomProperty> customProperties = CustomActivityDesignerHelper.GetCustomProperties(context);
                                if (customProperties != null)
                                {
                                    customProperties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, form.NewMemberName, context.PropertyDescriptor, context.Instance));
                                    CustomActivityDesignerHelper.SetCustomProperties(customProperties, context);
                                }
                            }
                            else
                            {
                                ActivityBindPropertyDescriptor.CreateField(context, form.Binding, true);
                            }
                        }
                        return(form.Binding);
                    }
                }
                catch (Exception exception)
                {
                    string message = SR.GetString("Error_CanNotBindProperty", new object[] { context.PropertyDescriptor.Name });
                    if (!string.IsNullOrEmpty(exception.Message))
                    {
                        message = message + "\n\n" + exception.Message;
                    }
                    DesignerHelpers.ShowError(context, message);
                }
                return(obj2);
            }
            DesignerHelpers.ShowError(this.serviceProvider, SR.GetString("Error_MultipleSelectNotSupportedForBindAndPromote"));
            return(obj2);
        }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
 {
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     this.serviceProvider = serviceProvider;
     object obj2 = value;
     if ((context != null) && (context.PropertyDescriptor is DynamicPropertyDescriptor))
     {
         try
         {
             using (ActivityBindForm form = new ActivityBindForm(this.serviceProvider, context))
             {
                 if (DialogResult.OK != form.ShowDialog())
                 {
                     return obj2;
                 }
                 if (form.CreateNew)
                 {
                     if (form.CreateNewProperty)
                     {
                         List<CustomProperty> customProperties = CustomActivityDesignerHelper.GetCustomProperties(context);
                         if (customProperties != null)
                         {
                             customProperties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, form.NewMemberName, context.PropertyDescriptor, context.Instance));
                             CustomActivityDesignerHelper.SetCustomProperties(customProperties, context);
                         }
                     }
                     else
                     {
                         ActivityBindPropertyDescriptor.CreateField(context, form.Binding, true);
                     }
                 }
                 return form.Binding;
             }
         }
         catch (Exception exception)
         {
             string message = SR.GetString("Error_CanNotBindProperty", new object[] { context.PropertyDescriptor.Name });
             if (!string.IsNullOrEmpty(exception.Message))
             {
                 message = message + "\n\n" + exception.Message;
             }
             DesignerHelpers.ShowError(context, message);
         }
         return obj2;
     }
     DesignerHelpers.ShowError(this.serviceProvider, SR.GetString("Error_MultipleSelectNotSupportedForBindAndPromote"));
     return obj2;
 }
 public void SelectActivity(Activity activity, List<ActivityBindForm.PathInfo> pathInfoList)
 {
     WorkflowOutlineNode parent = base.GetNode(activity);
     if (parent != null)
     {
         parent.Expand();
         if ((pathInfoList != null) && (pathInfoList.Count > 0))
         {
             for (int i = 0; i < pathInfoList.Count; i++)
             {
                 ActivityBindForm.PathInfo info = pathInfoList[i];
                 ActivityBindForm.MemberActivityBindTreeNode node2 = null;
                 int index = info.Path.IndexOf('[');
                 if (index != -1)
                 {
                     string str = info.Path.Substring(0, index);
                     if ((parent.Text.Equals(str, StringComparison.Ordinal) && (i > 0)) && pathInfoList[i - 1].Path.Equals(str, StringComparison.Ordinal))
                     {
                         parent = parent.Parent as WorkflowOutlineNode;
                     }
                 }
                 foreach (TreeNode node3 in parent.Nodes)
                 {
                     ActivityBindForm.MemberActivityBindTreeNode node4 = node3 as ActivityBindForm.MemberActivityBindTreeNode;
                     if ((node4 != null) && node4.PathInfo.Equals(info))
                     {
                         node2 = node4;
                         break;
                     }
                     if (((node4 != null) && node4.Text.Contains("[")) && info.Path.Contains("["))
                     {
                         string memberNameFromIndexerName = this.GetMemberNameFromIndexerName(info.Path);
                         string b = this.GetMemberNameFromIndexerName(node4.Text);
                         if (string.Equals(memberNameFromIndexerName, b, StringComparison.Ordinal) && this.IsSamePropertyIndexer(info.MemberInfo, node4.PathInfo.MemberInfo))
                         {
                             node2 = node4;
                             node4.PathInfo = info;
                             node4.Text = ActivityBindForm.MemberActivityBindTreeNode.MemberName(info.Path);
                             break;
                         }
                     }
                 }
                 if (node2 == null)
                 {
                     break;
                 }
                 parent = node2;
                 parent.Expand();
             }
         }
         base.TreeView.SelectedNode = parent;
         Timer timer = new Timer();
         timer.Tick += new EventHandler(this.timer_Tick);
         timer.Interval = 50;
         timer.Start();
     }
 }
 private ActivityBindForm.MemberActivityBindTreeNode CreateMemberNode(Activity activity, ActivityBindForm.PathInfo pathInfo)
 {
     ActivityBindForm.MemberActivityBindTreeNode node = new ActivityBindForm.MemberActivityBindTreeNode(activity, pathInfo);
     if (node.MayHaveChildNodes)
     {
         node.Nodes.Add(new ActivityBindForm.DummyActivityBindTreeNode(activity));
     }
     return node;
 }
 public ActivityBindFormWorkflowOutline(IServiceProvider serviceProvider, ActivityBindForm parent) : base(serviceProvider)
 {
     this.parent = parent;
     base.NeedsExpandAll = false;
     base.Expanding += new TreeViewCancelEventHandler(this.treeView1_BeforeExpand);
     base.TreeView.BeforeLabelEdit += new NodeLabelEditEventHandler(this.TreeView_BeforeLabelEdit);
     base.TreeView.AfterLabelEdit += new NodeLabelEditEventHandler(this.TreeView_AfterLabelEdit);
     base.TreeView.LabelEdit = true;
     base.TreeView.KeyDown += new KeyEventHandler(this.TreeView_KeyDown);
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            this.serviceProvider = serviceProvider;

            object returnValue = value;
            if (context != null && context.PropertyDescriptor is DynamicPropertyDescriptor)
            {
                try
                {
                    using (ActivityBindForm bindDialog = new ActivityBindForm(this.serviceProvider, context))
                    {
                        if (DialogResult.OK == bindDialog.ShowDialog())
                        {
                            //Now that OK has been pressed in the dialog we need to create members if necessary
                            if (bindDialog.CreateNew)
                            {
                                //Emit the field / property as required
                                if (bindDialog.CreateNewProperty)
                                {
                                    List<CustomProperty> properties = CustomActivityDesignerHelper.GetCustomProperties(context);
                                    if (properties != null)
                                    {
                                        properties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, bindDialog.NewMemberName, context.PropertyDescriptor, context.Instance));
                                        CustomActivityDesignerHelper.SetCustomProperties(properties, context);
                                    }
                                }
                                else
                                {
                                    ActivityBindPropertyDescriptor.CreateField(context, bindDialog.Binding, true);
                                }
                            }
                            returnValue = bindDialog.Binding;
                        }
                    }
                }
                catch (Exception e)
                {
                    string message = SR.GetString(SR.Error_CanNotBindProperty, context.PropertyDescriptor.Name);
                    if (!String.IsNullOrEmpty(e.Message))
                        message += "\n\n" + e.Message;
                    DesignerHelpers.ShowError(context, message);
                }
            }
            else
            {
                DesignerHelpers.ShowError(this.serviceProvider, SR.GetString(SR.Error_MultipleSelectNotSupportedForBindAndPromote));
            }

            return returnValue;
        }