コード例 #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            GenericCollection <WizardStep> steps = (GenericCollection <WizardStep>)value;
            WizardControl owner     = (WizardControl)steps.Owner;
            IDesignerHost container = (IDesignerHost)context.Container;
            int           count     = steps.Count;
            object        obj2      = base.EditValue(context, provider, value);

            if (steps.Count >= count)
            {
                return(obj2);
            }
            SelectWizard(owner, container);
            return(obj2);
        }
コード例 #2
0
        ///<summary>
        ///Initializes the designer with the specified component.
        ///</summary>
        ///
        ///<param name="component">The <see cref="T:System.ComponentModel.IComponent"></see> to associate with the designer. </param>
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            AutoResizeHandles = true;
            ISelectionService service = (ISelectionService)GetService(typeof(ISelectionService));

            if (service != null)
            {
                service.SelectionChanged += OnSelectionChanged;
            }
            WizardControl control = (WizardControl)Control;

            wizardDesignerActionList = new WizardDesignerActionList(control);
            actionListCollection.Add(wizardDesignerActionList);
            control.CurrentStepIndexChanged += CurrentStepIndexChanged;
            control.WizardSteps.Inserted    += RefreshComponent;
        }
コード例 #3
0
        protected internal virtual void RemoveStep()
        {
            IDesignerHost service = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (WizardControl == null || service == null)
            {
                return;
            }
            if (MessageBox.Show(WizardControl.FindForm(), "Are you sure you want to remove the step?", "Remove Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                WizardStep step = WizardControl.WizardSteps[WizardControl.CurrentStepIndex];
                WizardControl.WizardSteps.Remove(step);
                service.DestroyComponent(step);
                step.Dispose();
            }
            SelectWizard();
        }
コード例 #4
0
        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ISelectionService service = (ISelectionService)GetService(typeof(ISelectionService));

            if (service == null)
            {
                return;
            }
            isSelected = false;
            ICollection selectedComponents = service.GetSelectedComponents();

            if (selectedComponents == null)
            {
                return;
            }
            WizardControl control    = (WizardControl)Control;
            IEnumerator   enumerator = selectedComponents.GetEnumerator();

            if (enumerator == null)
            {
                return;
            }
            try
            {
                while (enumerator.MoveNext())
                {
                    object current = enumerator.Current;
                    if (current == control)
                    {
                        isSelected = true;
                        break;
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
コード例 #5
0
        ///<summary>
        ///Called when a drag-and-drop operation enters the control designer view.
        ///</summary>
        ///
        ///<param name="de">A <see cref="T:System.Windows.Forms.DragEventArgs"></see> that provides data for the event. </param>
        protected override void OnDragEnter(DragEventArgs de)
        {
            WizardControl control = (WizardControl)Control;

            if (control.WizardSteps.Count <= 0)
            {
                base.OnDragEnter(de);
                return;
            }
            WizardStep step            = control.WizardSteps[control.CurrentStepIndex];
            Point      pt              = step.PointToClient(new Point(de.X, de.Y));
            Rectangle  clientRectangle = step.ClientRectangle;

            if (!clientRectangle.Contains(pt))
            {
                base.OnDragEnter(de);
                return;
            }
            GetWizardStepDesigner(step).OnDragEnterInternal(de);
            forwardOnDrag = true;
        }
コード例 #6
0
        ///<summary>
        ///Called when a drag-and-drop object is dragged over the control designer view.
        ///</summary>
        ///
        ///<param name="de">A <see cref="T:System.Windows.Forms.DragEventArgs"></see> that provides data for the event. </param>
        protected override void OnDragOver(DragEventArgs de)
        {
            WizardControl control = Control as WizardControl;

            if (control == null || control.WizardSteps.Count <= 0)
            {
                de.Effect = DragDropEffects.None;
                return;
            }
            WizardStep         step = control.WizardSteps[control.CurrentStepIndex];
            Point              pt   = step.PointToClient(new Point(de.X, de.Y));
            WizardStepDesigner wizardStepDesigner = GetWizardStepDesigner(step);
            Rectangle          clientRectangle    = step.ClientRectangle;

            if (!clientRectangle.Contains(pt))
            {
                if (!forwardOnDrag)
                {
                    de.Effect = DragDropEffects.None;
                    return;
                }
                forwardOnDrag = false;
                wizardStepDesigner.OnDragLeaveInternal(EventArgs.Empty);
                base.OnDragEnter(de);
                return;
            }
            else
            {
                if (!forwardOnDrag)
                {
                    base.OnDragLeave(EventArgs.Empty);
                    wizardStepDesigner.OnDragEnterInternal(de);
                    forwardOnDrag = true;
                    return;
                }
                wizardStepDesigner.OnDragOverInternal(de);
                return;
            }
        }
コード例 #7
0
        private WizardStepDesigner GetDesigner()
        {
            WizardControl      control   = Control as WizardControl;
            WizardStep         component = null;
            IDesignerHost      service   = null;
            WizardStepDesigner designer  = null;

            if (control != null && control.WizardSteps.Count >= 0)
            {
                component = control.WizardSteps[control.CurrentStepIndex];
                service   = (IDesignerHost)GetService(typeof(IDesignerHost));
                designer  = null;
            }
            if (service == null)
            {
                return(designer);
            }
            if (component == null)
            {
                return(designer);
            }
            designer = (WizardStepDesigner)service.GetDesigner(component);
            return(designer);
        }
コード例 #8
0
        protected internal virtual void RemoveAllSteps()
        {
            IDesignerHost service = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (WizardControl == null || service == null)
            {
                return;
            }
            if (MessageBox.Show(WizardControl.FindForm(), "Are you sure you want to remove all the steps?", "Remove Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            WizardStep[] array = new WizardStep[WizardControl.WizardSteps.Count];
            ((ICollection)WizardControl.WizardSteps).CopyTo(array, 0);
            WizardControl.WizardSteps.Clear();
            WizardStep[] stepArray2 = array;
            for (int index = 0; index < stepArray2.Length; index++)
            {
                WizardStep component = stepArray2[index];
                service.DestroyComponent(component);
                index++;
            }
            SelectWizard();
        }