Пример #1
0
        private void OnListBoxDoubleClick(object sener, EventArgs e)
        {
            IToolboxUser        docDes       = null;
            SelfHostToolboxItem selectedItem = listBox.SelectedItem as SelfHostToolboxItem;

            if (selectedItem == null)
            {
                return;
            }

            this.currentSelection = selectedItem.ComponentType;
            IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost));            //des.ActiveDesigner;

            if (host != null && this.currentSelection != null)
            {
                IDesigner designer = host.GetDesigner(host.RootComponent);
                if (designer is IToolboxUser)
                {
                    docDes = (IToolboxUser)designer;
                }

                if (docDes != null)
                {
                    ToolboxItem c = ToolboxService.GetToolboxItem(this.currentSelection);
                    Debug.Assert(c != null, "Class " + this.currentSelection.FullName + " does not exist");
                    if (c != null && docDes.GetToolSupported(c))
                    {
                        try
                        {
                            docDes.ToolPicked(c);
                        }
                        catch (Exception ex)
                        {
                            IUIService uis = (IUIService)provider.GetService(typeof(IUIService));

                            if (uis != null)
                            {
                                uis.ShowError(ex);
                            }
                            else
                            {
                                MessageBox.Show("Error: " + ex.ToString());
                            }
                        }
                    }
                }
                else
                {
                    object o = Activator.CreateInstance(this.currentSelection);
                    SequentialWorkflowActivity service = host.RootComponent as SequentialWorkflowActivity;
                    service.Activities.Add(o as Activity);
                    host.RootComponent.Site.Container.Add(o as IComponent);
                }
            }
        }
Пример #2
0
        //Start the drag drop when user selects and drags the tool
        private void OnListBoxMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && this.listBox.SelectedItem != null)
            {
                SelfHostToolboxItem selectedItem = listBox.SelectedItem as SelfHostToolboxItem;

                if (selectedItem == null || selectedItem.ComponentType == null)
                {
                    return;
                }

                ToolboxItem     toolboxItem = ToolboxService.GetToolboxItem(selectedItem.ComponentType);
                IDataObject     dataObject  = this.SerializeToolboxItem(toolboxItem) as IDataObject;
                DragDropEffects effects     = DoDragDrop(dataObject, DragDropEffects.Copy | DragDropEffects.Move);
            }
        }
Пример #3
0
        public virtual ToolboxItem GetSelectedToolboxItem()
        {
            ToolboxItem toolClass = null;

            if (this.currentSelection != null)
            {
                try
                {
                    toolClass = ToolboxService.GetToolboxItem(this.currentSelection);
                }
                catch (TypeLoadException)
                {
                }
            }

            return(toolClass);
        }
        public WorkflowDesignerControl()
        {
            InitializeComponent();

            toolbox = new ToolboxService(this);
            this.propertyGridSplitter.Panel1.Controls.Add(toolbox);
            toolbox.Dock      = DockStyle.Fill;
            toolbox.BackColor = BackColor;

            WorkflowTheme.CurrentTheme.ReadOnly = true;

            this.propertyGrid.BackColor             = BackColor;
            this.propertyGrid.Site                  = this;
            this.propertyGrid.PropertyValueChanged += (s, e) =>
            {
                if (e.ChangedItem.PropertyDescriptor.Name == "Name")
                {
                    Save();
                }
            };
        }