private void ActivityBindForm_Load(object sender, EventArgs e)
 {
     this.Text = string.Format(CultureInfo.CurrentCulture, this.ActivityBindDialogTitleFormat, new object[] { this.context.PropertyDescriptor.Name });
     if (this.context.PropertyDescriptor is DynamicPropertyDescriptor)
     {
         this.boundType = PropertyDescriptorUtils.GetBaseType(this.context.PropertyDescriptor, PropertyDescriptorUtils.GetComponent(this.context), this.serviceProvider);
     }
     if (this.boundType != null)
     {
         ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
         if (provider != null)
         {
             System.Type type = provider.GetType(this.boundType.FullName, false);
             this.boundType = (type != null) ? type : this.boundType;
         }
     }
     this.workflowOutline = new ActivityBindFormWorkflowOutline(this.serviceProvider, this);
     this.dummyPanel.BorderStyle = BorderStyle.None;
     this.dummyPanel.SuspendLayout();
     this.dummyPanel.Controls.Add(this.workflowOutline);
     this.workflowOutline.Location = new Point(3, 3);
     this.workflowOutline.Size = new Size(0xc7, 0x15f);
     this.workflowOutline.Dock = DockStyle.Fill;
     this.dummyPanel.ResumeLayout(false);
     this.workflowOutline.AddMemberKindImages(this.memberTypes);
     this.workflowOutline.ReloadWorkflowOutline();
     this.workflowOutline.ExpandRootNode();
     Activity component = PropertyDescriptorUtils.GetComponent(this.context) as Activity;
     if (component == null)
     {
         IReferenceService service = this.context.GetService(typeof(IReferenceService)) as IReferenceService;
         if (service != null)
         {
             component = service.GetComponent(this.context.Instance) as Activity;
         }
     }
     ActivityBind bind = this.context.PropertyDescriptor.GetValue(this.context.Instance) as ActivityBind;
     if ((component != null) && (bind != null))
     {
         Activity activity = Helpers.ParseActivity(Helpers.GetRootActivity(component), bind.Name);
         if (activity != null)
         {
             this.workflowOutline.SelectActivity(activity, this.ParseStringPath(this.GetActivityType(activity), bind.Path));
         }
     }
     if (this.properties != null)
     {
         List<string> list = new List<string>();
         foreach (CustomProperty property in this.properties)
         {
             list.Add(property.Name);
         }
         this.memberNameTextBox.Text = DesignerHelpers.GenerateUniqueIdentifier(this.serviceProvider, component.Name + "_" + this.context.PropertyDescriptor.Name, list.ToArray());
     }
     this.newMemberHelpTextBox.Lines = string.Format(CultureInfo.CurrentCulture, this.CreateNewMemberHelpFormat, new object[] { this.GetSimpleTypeFullName(this.boundType) }).Split(new char[] { '\n' });
 }
        private void ActivityBindForm_Load(object sender, EventArgs e)
        {
            this.Text = string.Format(CultureInfo.CurrentCulture, ActivityBindDialogTitleFormat, context.PropertyDescriptor.Name);


            if (this.context.PropertyDescriptor is DynamicPropertyDescriptor)
                this.boundType = PropertyDescriptorUtils.GetBaseType(this.context.PropertyDescriptor, PropertyDescriptorUtils.GetComponent(context), serviceProvider);

            if (this.boundType != null)
            {
                //lets get the same type through the type provider (otherwise this type may mismatch with the one obtained from the design time types)
                ITypeProvider typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider;
                if (typeProvider != null)
                {
                    Type designTimeType = typeProvider.GetType(this.boundType.FullName, false);
                    this.boundType = (designTimeType != null) ? designTimeType : this.boundType;
                }
            }

            //create outline control
            this.workflowOutline = new ActivityBindFormWorkflowOutline(this.serviceProvider, this);
            this.dummyPanel.BorderStyle = BorderStyle.None;
            this.dummyPanel.SuspendLayout();
            this.dummyPanel.Controls.Add(this.workflowOutline);
            this.workflowOutline.Location = new Point(3, 3);
            this.workflowOutline.Size = new Size(199, 351);
            this.workflowOutline.Dock = DockStyle.Fill;
            this.dummyPanel.ResumeLayout(false);

            this.workflowOutline.AddMemberKindImages(this.memberTypes);

            //make the outline view load initial state
            this.workflowOutline.ReloadWorkflowOutline();

            //expand just the root node
            this.workflowOutline.ExpandRootNode();

            //now we need to select the activity/path which was previously set
            //NOTE: we would have to expand all nodes on the way to make doc outline control populate their children
            Activity activity = PropertyDescriptorUtils.GetComponent(context) as Activity;
            if (activity == null)
            {
                IReferenceService rs = this.context.GetService(typeof(IReferenceService)) as IReferenceService;
                if (rs != null)
                    activity = rs.GetComponent(this.context.Instance) as Activity;
            }

            ActivityBind previousBinding = context.PropertyDescriptor.GetValue(context.Instance) as ActivityBind;
            if (activity != null && previousBinding != null)
            {
                Activity previousBindActivity = Helpers.ParseActivity(Helpers.GetRootActivity(activity), previousBinding.Name);
                if (previousBindActivity != null)
                    this.workflowOutline.SelectActivity(previousBindActivity, ParseStringPath(GetActivityType(previousBindActivity), previousBinding.Path));
            }

            if (this.properties != null)
            {
                List<String> customPropertyNames = new List<String>();
                foreach (CustomProperty customProperty in this.properties)
                    customPropertyNames.Add(customProperty.Name);

                // set default name
                this.memberNameTextBox.Text = DesignerHelpers.GenerateUniqueIdentifier(this.serviceProvider, activity.Name + "_" + context.PropertyDescriptor.Name, customPropertyNames.ToArray());
            }

            this.newMemberHelpTextBox.Lines = string.Format(CultureInfo.CurrentCulture, CreateNewMemberHelpFormat, GetSimpleTypeFullName(this.boundType)).Split(new char[] { '\n' });
        }