public static object DoInTransaction(IDesignerHost theHost, string theTransactionName, TransactionAwareParammedMethod theMethod, object theParam)
 {
     DesignerTransaction transaction = null;
     object obj2 = null;
     try
     {
         transaction = theHost.CreateTransaction(theTransactionName);
         obj2 = theMethod(theHost, theParam);
     }
     catch (CheckoutException exception)
     {
         if (exception != CheckoutException.Canceled)
         {
             throw exception;
         }
     }
     catch
     {
         if (transaction != null)
         {
             transaction.Cancel();
             transaction = null;
         }
         throw;
     }
     finally
     {
         if (transaction != null)
         {
             transaction.Commit();
         }
     }
     return obj2;
 }
예제 #2
0
        /// <summary>
        /// Event handler for the "Add Page" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void AddPage(IDesignerHost dh, MultiPanel panel)
        {
            DesignerTransaction dt = dh.CreateTransaction("Added new page");

            // Gets a free name
            int i = 1;
            while (panel.Controls.Cast<Control>().Any(x => x.Name == "Page" + i))
            {
                i++;
            }
            string name = "Page" + i;

            // Creates the page
            MultiPanelPage newPage = dh.CreateComponent(typeof(MultiPanelPage), name) as MultiPanelPage;
            if (newPage != null)
            {
                newPage.Text = name;
                panel.Controls.Add(newPage);

                // Update selection
                panel.SelectedPage = newPage;
            }

            dt.Commit();
        }
        /// <summary>
        /// Event handler for the "Select X page" handler.
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        private static void SelectPage(IDesignerHost dh, MultiPanel panel, MultiPanelPage page)
        {
            DesignerTransaction dt = dh.CreateTransaction("Selected page");
            MultiPanelPage oldSelectedPage = panel.SelectedPage;

            panel.SelectedPage = page;
            dt.Commit();
        }
예제 #4
0
		public SmartTagTransactions(string transactionname,DesignerActionList list,Control ctrl)
		{
			
			this.actionList = list;
			this.ctrl = ctrl;
			host = (IDesignerHost)this.actionList.GetService(typeof(IDesignerHost));
			this.transaction = host.CreateTransaction(transactionname);
			changeService = (IComponentChangeService)this.actionList.GetService(typeof(IComponentChangeService));
			changeService.OnComponentChanging(ctrl,null);                                                      
		}
예제 #5
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void RemovePage(IDesignerHost dh, MultiPanel panel)
        {
            MultiPanelPage page = panel.SelectedPage;
            if (page == null)
                return;

            DesignerTransaction dt = dh.CreateTransaction("Removed page");

            panel.Controls.Remove(page);
            dh.DestroyComponent(page);

            panel.SelectedPage = panel.Controls.Count > 0 ? (MultiPanelPage)panel.Controls[0] : null;

            dt.Commit();
        }
예제 #6
0
 // container coordinates (primary selection's)
 //
 public void DragBegin()
 {
     // Console.WriteLine ("DragBegin");
     if (_transaction == null)
     {
         IDesignerHost host = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
         _transaction = host.CreateTransaction("Move " +
                                               (this.SelectionService.SelectionCount == 1? ((IComponent)this.SelectionService.PrimarySelection).Site.Name : "controls"));
     }
     _dragging  = true;
     _firstMove = true;
     if (this.SelectionService.PrimarySelection != null)
     {
         ((Control)this.SelectionService.PrimarySelection).DoDragDrop(new ControlDataObject((Control)this.SelectionService.PrimarySelection), DragDropEffects.All);
     }
 }
예제 #7
0
        public void RemoveTabHandler(object sender, EventArgs e)
        {
            ThemeTabControl tabcontrol = (ThemeTabControl)base.Component;

            if (tabcontrol == null || tabcontrol.TabPages.Count == 0)
            {
                return;
            }

            MemberDescriptor controlsdescriptor = TypeDescriptor.GetProperties(base.Component)["Controls"];
            ThemeTab         tab  = tabcontrol.SelectedTab;
            IDesignerHost    host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host == null)
            {
                return;
            }

            DesignerTransaction transaction = null;

            try
            {
                try
                {
                    transaction = host.CreateTransaction("Remove Tab");
                    base.RaiseComponentChanging(controlsdescriptor);
                }
                catch (CheckoutException ex)
                {
                    if (ex != CheckoutException.Canceled)
                    {
                        throw ex;
                    }

                    return;
                }
                host.DestroyComponent(tab);
                base.RaiseComponentChanged(controlsdescriptor, null, null);
            }
            finally
            {
                if (transaction != null)
                {
                    transaction.Commit();
                }
            }
        }
예제 #8
0
        ///
        ///
        ///      This is called in response to a verb to remove a tab.  It removes
        ///      the current tab.
        ///
        private void OnRemove(object sender, EventArgs eevent)
        {
            TabControl tc = (TabControl)Component;

            // if the control is null, or there are not tab pages, get out!...
            //
            if (tc == null || tc.TabPages.Count == 0)
            {
                return;
            }

            // member is OK to be null...
            //
            MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Controls"];

            TabPage tp = tc.SelectedTab;

            // destroy the page
            //
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                DesignerTransaction t = null;
                try {
                    try {
                        t = host.CreateTransaction(SR.GetString(SR.TabControlRemoveTab, ((IComponent)tp).Site.Name, Component.Site.Name));
                        RaiseComponentChanging(member);
                    } catch (CheckoutException ex) {
                        if (ex == CheckoutException.Canceled)
                        {
                            return;
                        }
                        throw ex;
                    }

                    host.DestroyComponent(tp);

                    RaiseComponentChanged(member, null, null);
                } finally {
                    if (t != null)
                    {
                        t.Commit();
                    }
                }
            }
        }
        private void UpdateZOrder(ActivityDesigner activityDesigner, ZOrder zorder)
        {
            IDesignerHost       service     = base.GetService(typeof(IDesignerHost)) as IDesignerHost;
            DesignerTransaction transaction = null;

            if (service != null)
            {
                transaction = service.CreateTransaction(DR.GetString("ZOrderUndoDescription", new object[] { activityDesigner.Text }));
            }
            try
            {
                bool flag = false;
                CompositeActivityDesigner parentDesigner = this;
                ActivityDesigner          designer2      = activityDesigner;
                while ((parentDesigner != null) && (designer2 != null))
                {
                    if (parentDesigner is FreeformActivityDesigner)
                    {
                        ReadOnlyCollection <ActivityDesigner> containedDesigners = parentDesigner.ContainedDesigners;
                        if ((containedDesigners.Count > 1) && (containedDesigners[(zorder == ZOrder.Background) ? 0 : (containedDesigners.Count - 1)] != designer2))
                        {
                            int connector = (zorder == ZOrder.Background) ? 0 : containedDesigners.Count;
                            parentDesigner.MoveActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, connector), new List <Activity>(new Activity[] { designer2.Activity }).AsReadOnly());
                            flag = true;
                        }
                    }
                    designer2      = parentDesigner;
                    parentDesigner = parentDesigner.ParentDesigner;
                }
                if (flag)
                {
                    base.Invalidate();
                }
                if (transaction != null)
                {
                    transaction.Commit();
                }
            }
            catch (Exception exception)
            {
                if (transaction != null)
                {
                    transaction.Cancel();
                }
                throw exception;
            }
        }
예제 #10
0
        void ExecutePaste(object sender, EventArgs e)
        {
            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                IDesignerSerializationService dss = (IDesignerSerializationService)this.GetService(typeof(IDesignerSerializationService));
                if (dss != null)
                {
                    object v = System.Windows.Forms.Clipboard.GetData("DesignObject");
                    if (v != null)
                    {
                        ICollection cc = dss.Deserialize(v);
                        if (cc != null)
                        {
                            using (DesignerTransaction trans = host.CreateTransaction("Paste"))
                            {
                                foreach (object x in cc)
                                {
                                    if (x is IComponent)
                                    {
                                        host.Container.Add((IComponent)x);
                                        if (x is Control)
                                        {
                                            if (host.RootComponent is Control)
                                            {
                                                ((Control)host.RootComponent).Controls.Add((Control)x);
                                                ((Control)x).Location = new Point(((Control)x).Left + 10, ((Control)x).Top + 10);
                                            }
                                        }
                                        //notify
                                    }
                                }
                                ISelectionService selSvc = (ISelectionService)GetService(typeof(ISelectionService));
                                if (selSvc != null)
                                {
                                    selSvc.SetSelectedComponents(cc, SelectionTypes.Replace);
                                }
                                trans.Commit();
                                enableUndoMenu();
                            }
                        }
                    }
                }
            }
        }
예제 #11
0
        private void OnAddButton(object sender, EventArgs e)
        {
            StatusItem              item = new StatusItem();
            IDesignerHost           h    = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction     dt   = null;
            IComponentChangeService c    = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            //Add a new button to the collection
            dt   = h.CreateTransaction("Add Status Item");
            item = (StatusItem)h.CreateComponent(typeof(StatusItem));
            c.OnComponentChanging(Parent, null);
            Parent.Items.Add(item);
            c.OnComponentChanged(Parent, null, null, null);
            dt.Commit();

            Parent.DrawItems();
        }
예제 #12
0
        /// <summary>
        /// Called when the designer
        /// is initialized, so the designer can set default values for properties of the component.
        /// </summary>
        public override void InitializeNewComponent(IDictionary defaultValues)
        {
            base.InitializeNewComponent(defaultValues);

            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            Debug.Assert(host != null, "host != null");

            IComponent hostComponent = host.RootComponent;

            Debug.Assert(hostComponent != null, "hostComponent != null");
            Debug.Assert(hostComponent is Form, "hostComponent is Form");

            Form hostForm = (Form)hostComponent;

            DesignerTransaction transaction = host.CreateTransaction("Host initialization");

            Button okButton = (Button)host.CreateComponent(
                typeof(Button),
                this.GetName(this.dialogBlock, "okButton", 0)
                );

            Button cancelButton = (Button)host.CreateComponent(
                typeof(Button),
                this.GetName(this.dialogBlock, "cancelButton", 0)
                );

            okButton.Text     = "&Ok";
            cancelButton.Text = "&Cancel";

            cancelButton.Left = this.dialogBlock.Right - cancelButton.Width - OFFSET;
            okButton.Left     = cancelButton.Left - okButton.Width - OFFSET;

            this.InitializeDialogButton(okButton);
            this.InitializeDialogButton(cancelButton);

            Debug.Assert(this.dialogBlock != null, "this.dialogBlock != null");

            this.dialogBlock.Controls.Add(okButton);
            this.dialogBlock.Controls.Add(cancelButton);

            hostForm.AcceptButton = okButton;
            hostForm.CancelButton = cancelButton;

            transaction.Commit();
        }
        private void OnMoveRight(object sender, EventArgs e)
        {
            int index = toolButton.Parent.Controls.GetChildIndex(toolButton);

            if (index > 0)
            {
                IDesignerHost           host        = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                IComponentChangeService service     = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
                DesignerTransaction     transaction = host.CreateTransaction("Move Left");
                service.OnComponentChanging(toolButton.Parent, TypeDescriptor.GetProperties(toolButton.Parent)["Controls"]);
                toolButton.Parent.Controls.SetChildIndex(toolButton, index - 1);
                service.OnComponentChanged(toolButton.Parent, TypeDescriptor.GetProperties(toolButton.Parent)["Controls"], null, null);
                transaction.Commit();

                toolButton.Parent.Invalidate();
            }
        }
        private void OnMoveDown(object sender, EventArgs e)
        {
            int index = tabPage.Parent.Controls.GetChildIndex(tabPage);

            if (index < tabPage.Parent.Controls.Count - 1)
            {
                IDesignerHost           host        = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                IComponentChangeService service     = (IComponentChangeService)this.GetService(typeof(IComponentChangeService));
                DesignerTransaction     transaction = host.CreateTransaction("Move Down");
                service.OnComponentChanging(tabPage.Parent, TypeDescriptor.GetProperties(tabPage.Parent)["Controls"]);
                tabPage.Parent.Controls.SetChildIndex(tabPage, index + 1);
                service.OnComponentChanged(tabPage.Parent, TypeDescriptor.GetProperties(tabPage.Parent)["Controls"], null, null);
                transaction.Commit();

                tabPage.Parent.Invalidate();
            }
        }
        /// <summary>
        /// </summary>
        protected void CreateTabPage <TPage>() where TPage : NuGenTabPage, new()
        {
            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            Debug.Assert(host != null, "host != null");

            if (host != null)
            {
                DesignerTransaction transaction = null;

                try
                {
                    try
                    {
                        transaction = host.CreateTransaction("NuGenTabControl.AddTabPage");
                    }
                    catch (CheckoutException e)
                    {
                        if (e != CheckoutException.Canceled)
                        {
                            throw;
                        }

                        return;
                    }

                    TPage tabPage = (TPage)host.CreateComponent(typeof(TPage));
                    _tabControl.TabPages.Add(tabPage);

                    PropertyDescriptor textDescriptor = TypeDescriptor.GetProperties(tabPage)["Text"];

                    if (textDescriptor != null)
                    {
                        textDescriptor.SetValue(tabPage, ctrlProps.Resources.BlankText);
                    }
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Event handler for the "Select MultiPanel" verb.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="ea">
        /// Some <see cref="EventArgs"/>.
        /// </param>
        private void OnSelectManager(object sender, EventArgs ea)
        {
            IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (dh != null)
            {
                DesignerTransaction dt = dh.CreateTransaction("Select MultiPanel");

                if (this.HostControl.Parent != null)
                {
                    this.SelectionService.SetSelectedComponents(new Component[] { this.HostControl.Parent });
                }

                dt.Commit();

                dt.Cancel();
            }
        }
예제 #17
0
        /// <summary>
        /// 使控件大小相等
        /// </summary>
        public void HorizVertSpaceMakeEqual()
        {
            IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (host == null)
            {
                return;
            }

            //启用设计器事务
            using (DesignerTransaction transaction = host.CreateTransaction("HorizVertSpaceMakeEqual"))
            {
                HorizSpaceMakeEqual();
                VertSpaceMakeEqual();

                transaction.Commit();
            }
        }
        /// <summary>
        /// Event handler for the "Add Page" verb.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// Some <see cref="EventArgs"/>.
        /// </param>
        private void AddPage(object sender, EventArgs e)
        {
            IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (dh != null)
            {
                DesignerTransaction dt        = dh.CreateTransaction("Added new page");
                MultiPanelPage      before    = _mpanel.SelectedPage;
                string         name           = GetNewPageName();
                MultiPanelPage multiPanelPage = dh.CreateComponent(typeof(MultiPanelPage), name) as MultiPanelPage;
                multiPanelPage.Text = name;
                _mpanel.Controls.Add(multiPanelPage);
                _mpanel.SelectedPage = multiPanelPage;
                RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedPage"]);
                RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedPage"], before, multiPanelPage);
                dt.Commit();
            }
        }
예제 #19
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void RemovePage(IDesignerHost dh, MultiPanel panel)
        {
            MultiPanelPage page = panel.SelectedPage;

            if (page == null)
            {
                return;
            }

            DesignerTransaction dt = dh.CreateTransaction("Removed page");

            panel.Controls.Remove(page);
            dh.DestroyComponent(page);

            panel.SelectedPage = panel.Controls.Count > 0 ? (MultiPanelPage)panel.Controls[0] : null;

            dt.Commit();
        }
예제 #20
0
        /// <summary>
        /// Add a new tab and set selection.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void OnAddTab(object sender, EventArgs e)
        {
            // Begin transaction
            IDesignerHost       host        = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
            DesignerTransaction transaction = host.CreateTransaction("Add tab");

            // Create new tab
            WhidbeyTabPage tab = host.CreateComponent(typeof(WhidbeyTabPage)) as WhidbeyTabPage;

            m_oChangeSvc.OnComponentChanging(m_oControl, null);
            m_oControl.TabPages.Add(tab);
            m_oChangeSvc.OnComponentChanged(m_oControl, null, null, null);

            // End transaction
            transaction.Commit();

            m_oControl.SelectedTab = tab;
        }
예제 #21
0
 private void StartDragEvent(string toolName)
 {
     if (toolName != null)
     {
         ToolboxItem toolboxItem = Toolbox.toolboxItemDictionary[toolName];
         if (this.mouseClicks == 1)
         {
             DataObject data = this.SerializeToolboxItem(toolboxItem) as DataObject;
             base.DoDragDrop(data, DragDropEffects.Copy);
             DetailsTemplatesSurface.SortControls(this.designSurface.TemplateTab.SelectedTab, false);
             this.mouseClicks = 0;
             return;
         }
         if (this.mouseClicks == 2)
         {
             IDesignerHost     designerHost     = (IDesignerHost)this.designSurface.GetService(typeof(IDesignerHost));
             ISelectionService selectionService = (designerHost == null) ? null : (designerHost.GetService(typeof(ISelectionService)) as ISelectionService);
             if (selectionService != null)
             {
                 DesignerTransaction designerTransaction = null;
                 try
                 {
                     designerTransaction = designerHost.CreateTransaction(toolboxItem.TypeName + this.designSurface.TemplateTab.Site.Name);
                     Hashtable hashtable = new Hashtable();
                     hashtable["Parent"] = this.designSurface.TemplateTab.SelectedTab;
                     ICollection collection = toolboxItem.CreateComponents(designerHost, hashtable);
                     if (collection != null && collection.Count > 0)
                     {
                         selectionService.SetSelectedComponents(collection, SelectionTypes.Replace);
                     }
                 }
                 finally
                 {
                     if (designerTransaction != null)
                     {
                         designerTransaction.Commit();
                     }
                 }
                 DetailsTemplatesSurface.SortControls(this.designSurface.TemplateTab.SelectedTab, false);
             }
             this.mouseClicks = 0;
         }
     }
 }
예제 #22
0
        internal void RemovePageFromWizard(WizardPage page)
        {
            IDesignerHost           h = DesignerHost;
            IComponentChangeService c = ComponentChangeService;

            if (h == null || c == null)
            {
                throw new ArgumentException("Both IDesignerHost and IComponentChangeService arguments cannot be null.");
            }

            if (Control == null || !Control.Pages.Contains(page))
            {
                return;
            }

            DesignerTransaction dt = null;

            try
            {
                dt = h.CreateTransaction("Remove Wizard Page");

                MemberDescriptor member = TypeDescriptor.GetProperties(Control)["Pages"];
                base.RaiseComponentChanging(member);

                if (page.Owner != null)
                {
                    page.Owner.Pages.Remove(page);
                    h.DestroyComponent(page);
                }
                else
                {
                    page.Dispose();
                }
                base.RaiseComponentChanged(member, null, null);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Commit();
                }
            }
            RefreshDesigner();
        }
예제 #23
0
        private void OnRemove(object sender, EventArgs eevent)
        {
            HorizontalTabs tabs = (HorizontalTabs)base.Component;

            if ((tabs == null) || (tabs.Tabs.Count == 0))
            {
                return;
            }
            MemberDescriptor descriptor1 = TypeDescriptor.GetProperties(base.Component)["Controls"];
            HorizontalTab    page1       = tabs.SelectedTab;
            IDesignerHost    host1       = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host1 == null)
            {
                return;
            }
            DesignerTransaction transaction1 = null;

            try
            {
                try
                {
                    transaction1 = host1.CreateTransaction("RemoveTabTransaction");
                    base.RaiseComponentChanging(descriptor1);
                }
                catch (CheckoutException exception1)
                {
                    if (exception1 != CheckoutException.Canceled)
                    {
                        throw exception1;
                    }
                    return;
                }
                host1.DestroyComponent(page1);
                base.RaiseComponentChanged(descriptor1, null, null);
            }
            finally
            {
                if (transaction1 != null)
                {
                    transaction1.Commit();
                }
            }
        }
        /*
         * AddTabPage
         */

        public void AddTabPage()
        {
            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                DesignerTransaction transaction = null;

                try
                {
                    try
                    {
                        transaction = host.CreateTransaction("NuGenTabControl.AddTabPage");
                    }
                    catch (CheckoutException e)
                    {
                        if (e != CheckoutException.Canceled)
                        {
                            throw e;
                        }

                        return;
                    }

                    NuGenTabPage tabPage = (NuGenTabPage)host.CreateComponent(typeof(NuGenTabPage));
                    _tabControl.TabPages.Add(tabPage);


                    PropertyDescriptor textDescriptor = TypeDescriptor.GetProperties(tabPage)["Text"];

                    if (textDescriptor != null)
                    {
                        textDescriptor.SetValue(tabPage, Resources.BlankText);
                    }
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
예제 #25
0
        /// <summary>
        /// Создание всех элементов для данного типа поля таблицы БД.
        /// </summary>
        public void CreateControl(DBFormItemBase item, string name)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction transaction = host.CreateTransaction("AddControl");

            item.DBForm = this;
            item.BaseNavBarItem = (NavBarItem)HostComponent.CreateComponent(host, typeof(NavBarItem), string.Format("{0}NavBarItem", name));
            item.BaseNavBarItem.AppearancePressed.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
            item.BaseNavBarItem.AppearancePressed.ForeColor = System.Drawing.Color.Red;
            item.BaseNavBarItem.AppearancePressed.Options.UseFont = true;
            item.BaseNavBarItem.AppearancePressed.Options.UseForeColor = true;

            BaseNavBarControl.Items.Add(item.BaseNavBarItem);
            BaseNavBarGroup.ItemLinks.Add(new NavBarItemLink(item.BaseNavBarItem));
            BaseNavBarGroup.SelectedLinkIndex = -1;
            item.UpdateAll();

            transaction.Commit();
        }
        private DesignerTransaction CreateTransaction(object obj, string description)
        {
            IComponent component = obj as IComponent;

            if (component == null || component.Site == null)
            {
                return(null);
            }
            IDesignerHost designerHost = (IDesignerHost)component.Site.GetService(typeof(IDesignerHost));

            if (designerHost == null)
            {
                return(null);
            }
            DesignerTransaction result = designerHost.CreateTransaction(description);

            ((IComponentChangeService)component.Site.GetService(typeof(IComponentChangeService)))?.OnComponentChanging(component, this);
            return(result);
        }
예제 #27
0
        private void Set1031Default(object sender, System.EventArgs e)
        {
            if (null == _panel)
            {
                return;
            }

            IDesignerHost           host    = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService service = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            if (null != host && null != service)
            {
                DesignerTransaction transaction = host.CreateTransaction("Set1031Default");
                service.OnComponentChanging(_panel, null);
                _panel.Localization.Set1031Default(sender, e);
                service.OnComponentChanged(_panel, null, null, null);
                transaction.Commit();
            }
        }
        private void OnAddPanel(object sender, EventArgs e)
        {
            CCTabControl            tabCtl             = Control as CCTabControl;
            IDesignerHost           _designerHost      = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService componentChangeSvc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            DesignerTransaction _designerTransaction = _designerHost.CreateTransaction("Add Panel");

            Control panel = _designerHost.CreateComponent(tabCtl.GetDefaultPageType()) as Control;

            panel.Text = panel.Name;
            if (panel != null)
            {
                componentChangeSvc.OnComponentChanging(Control, null);
                Control.Controls.Add(panel);
                componentChangeSvc.OnComponentChanged(Control, null, null, null);
            }
            _designerTransaction.Commit();
        }
예제 #29
0
        internal void InsertPageIntoWizard(bool add)
        {
            IDesignerHost           h   = this.DesignerHost;
            IComponentChangeService c   = this.ComponentChangeService;
            WizardControl           wiz = this.Control as WizardControl;

            if (h == null || c == null)
            {
                throw new ArgumentNullException("Both IDesignerHost and IComponentChangeService arguments cannot be null.");
            }

            DesignerTransaction dt = null;

            try
            {
                dt = h.CreateTransaction("Insert Wizard Page");
                WizardPage       page   = (WizardPage)h.CreateComponent(typeof(WizardPage));
                MemberDescriptor member = TypeDescriptor.GetProperties(wiz)["Pages"];
                base.RaiseComponentChanging(member);
                //c.OnComponentChanging(wiz, null);

                //Add a new page to the collection
                if (wiz.Pages.Count == 0 || add)
                {
                    wiz.Pages.Add(page);
                }
                else
                {
                    wiz.Pages.Insert(wiz.SelectedPageIndex, page);
                }

                //c.OnComponentChanged(wiz, null, null, null);
                base.RaiseComponentChanged(member, null, null);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Commit();
                }
            }
            RefreshDesigner();
        }
예제 #30
0
		private void handleAddPage(object sender, EventArgs e)
		{
			Wizard wiz = this.Control as Wizard;

			IDesignerHost h  = (IDesignerHost) GetService(typeof(IDesignerHost));
			IComponentChangeService c = (IComponentChangeService) GetService(typeof (IComponentChangeService));

			DesignerTransaction dt = h.CreateTransaction("Add Page");
			WizardPage page = (WizardPage) h.CreateComponent(typeof(WizardPage));
			c.OnComponentChanging(wiz, null);
    
			//Add a new page to the collection
			wiz.Pages.Add(page);
			wiz.Controls.Add(page);
			wiz.ActivatePage(page);

			c.OnComponentChanged(wiz, null, null, null);
			dt.Commit();
		}	
예제 #31
0
        protected virtual void MoveTab(TabPanel from, TabPanel to)
        {
            if (!(this.Control is TabView))
            {
                return;
            }

            if (from == null || to == null ||
                !this.Control.Controls.Contains(from) ||
                !this.Control.Controls.Contains(to))
            {
                return;
            }

            IDesignerHost designerHost = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            TabView       tabView      = this.Control as TabView;

            if (designerHost == null)
            {
                return;
            }

            using (DesignerTransaction transaction = designerHost.CreateTransaction($"Add tab to \"{tabView.Name}\""))
            {
                try
                {
                    PropertyDescriptor controlsProperty = TypeDescriptor.GetProperties(tabView)[nameof(tabView.Controls)];

                    this.RaiseComponentChanging(controlsProperty);
                    this.Control.Controls.SetChildIndex(from, Control.Controls.GetChildIndex(to));
                    this.RaiseComponentChanged(controlsProperty, null, null);

                    tabView.UpdateLayout();
                    tabView.Refresh();
                    transaction.Commit();
                }
                catch
                {
                    transaction.Cancel();
                }
            }
        }
예제 #32
0
        private void OnRemoveTabPanel()
        {
            TabContainer tc = TabContainer;

            if (tc.ActiveTab != null)
            {
                int oldIndex = tc.ActiveTabIndex;

                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                if (host != null)
                {
                    using (DesignerTransaction dt = host.CreateTransaction("Remove TabPanel"))
                    {
                        TabPanel activeTab = tc.ActiveTab;

                        IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

                        try
                        {
                            changeService.OnComponentChanging(tc, TypeDescriptor.GetProperties(tc)["Tabs"]);
                            tc.Tabs.Remove(activeTab);
                        }
                        finally
                        {
                            changeService.OnComponentChanged(tc, TypeDescriptor.GetProperties(tc)["Tabs"], tc.Tabs, tc.Tabs);
                        }

                        activeTab.Dispose();

                        if (tc.Tabs.Count > 0)
                        {
                            TypeDescriptor.GetProperties(tc)["ActiveTabIndex"].SetValue(tc, Math.Min(oldIndex, tc.Tabs.Count - 1));
                        }


                        UpdateDesignTimeHtml();
                        dt.Commit();
                    }
                }
            }
        }
        void ExecuteDel(object sender, EventArgs e)
        {
            if (VobState.GetMainPropertyGridFocus != null)
            {
                if (VobState.GetMainPropertyGridFocus())
                {
                    if (VobState.SendDeleteToMainPropertyGridTextEditor != null)
                    {
                        VobState.SendDeleteToMainPropertyGridTextEditor(this, EventArgs.Empty);
                    }
                    return;
                }
            }
            ISelectionService ss = (ISelectionService)this.GetService(typeof(ISelectionService));

            if (ss != null)
            {
                ICollection cc = ss.GetSelectedComponents();
                if (cc != null)
                {
                    IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                    if (host != null)
                    {
                        using (DesignerTransaction trans = host.CreateTransaction("Delete " + cc.Count + " component(s)"))
                        {
                            foreach (object v in cc)
                            {
                                if (v is System.ComponentModel.IComponent)
                                {
                                    if (v != host.RootComponent)
                                    {
                                        host.DestroyComponent((System.ComponentModel.IComponent)v);
                                    }
                                }
                            }
                            trans.Commit();
                            enableUndoMenu();
                        }
                    }
                }
            }
        }
예제 #34
0
        public void RemovePanel()
        {
            int oldIndex = this.layout.ExpandedPanelIndex;

            if (this.layout.ExpandedPanelIndex > -1)
            {
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                if (host != null)
                {
                    using (DesignerTransaction dt = host.CreateTransaction("Remove Panel"))
                    {
                        IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
                        PanelBase panel = this.layout.Items[oldIndex] as PanelBase;

                        try
                        {
                            changeService.OnComponentChanging(this.layout, TypeDescriptor.GetProperties(this.layout)["Items"]);
                            this.layout.Items.Remove(panel);

                            if (this.layout.Items.Count > 0)
                            {
                                PanelBase activeItem =
                                    this.layout.Items[Math.Min(oldIndex, this.layout.Items.Count - 1)] as PanelBase;

                                this.ExpandItem(activeItem);
                            }
                        }
                        finally
                        {
                            changeService.OnComponentChanged(this.layout, TypeDescriptor.GetProperties(this.layout)["Items"], null, null);
                        }

                        panel.Dispose();

                        this.UpdateDesignTimeHtml();
                        dt.Commit();
                    }
                    this.Tag.SetDirty(true);
                }
            }
        }
        public static object DoInTransaction(
            IDesignerHost theHost,
            string theTransactionName,
            TransactionAwareParammedMethod theMethod,
            object theParam)
        {
            DesignerTransaction aTran = null;
            object aRetVal            = null;

            try
            {
                aTran = theHost.CreateTransaction(theTransactionName);

                aRetVal = theMethod(theHost, theParam); // do the task polymorphically
            }
            catch (CheckoutException theEx)             // something has gone wrong with transaction creation
            {
                if (theEx != CheckoutException.Canceled)
                {
                    throw theEx;
                }
            }
            catch
            {
                if (aTran != null)
                {
                    aTran.Cancel();
                    aTran = null;                       // the transaction won't commit in the finally block
                }

                throw;
            }
            finally
            {
                if (aTran != null)
                {
                    aTran.Commit();
                }
            }

            return(aRetVal);
        }
예제 #36
0
        public static object DoInTransaction(
            IDesignerHost host,
            string transactionName,
            TransactionMethod transactionMethod,
            object parameter)
        {
            DesignerTransaction transaction = null;
            object RetVal = null;

            try
            {
                // Create a new designer transaction.
                transaction = host.CreateTransaction(transactionName);

                // Do the task polymorphically.
                RetVal = transactionMethod(host, parameter);
            }
            catch (CheckoutException ex)	// something has gone wrong with transaction creation.
            {
                if (ex != CheckoutException.Canceled)
                    throw ex;
            }
            catch
            {
                if (transaction != null)
                {
                    transaction.Cancel();
                    transaction = null;	// the transaction won't commit in the finally block.
                }

                throw;
            }
            finally
            {
                if (transaction != null)
                    transaction.Commit();
            }

            return RetVal;
        }
예제 #37
0
        public static object DoInTransaction(
			IDesignerHost theHost,
			string theTransactionName,
			TransactionAwareParammedMethod theMethod,
			object theParam)
        {
            DesignerTransaction aTran = null;
            object aRetVal = null;

            try
            {
                aTran = theHost.CreateTransaction(theTransactionName);

                aRetVal = theMethod(theHost, theParam);      // do the task polymorphically
            }
            catch (CheckoutException theEx)	// something has gone wrong with transaction creation
            {
                if (theEx != CheckoutException.Canceled)
                    throw theEx;
            }
            catch
            {
                if (aTran != null)
                {
                    aTran.Cancel();
                    aTran = null;	// the transaction won't commit in the finally block
                }

                throw;
            }
            finally
            {
                if (aTran != null)
                    aTran.Commit();
            }

            return aRetVal;
        }
예제 #38
0
        private static object TransactionInfo(string TransactionName, IDesignerHost DesignerHost, Func<IDesignerHost, object, object> TransactionFunction)
        {
            object Value = null;
            DesignerTransaction Transaction = null;
            try
            {
                if (DesignerHost != null)
                {
                    Transaction = DesignerHost.CreateTransaction(TransactionName);
                    Value = TransactionFunction.Invoke(DesignerHost, null);
                }
            }
            catch (Exception Ex)
            {
                Ex.ToString();

                if (Transaction != null)
                {
                    Transaction.Cancel();
                    Transaction = null;
                }
            }
            finally
            {
                if (Transaction != null)
                {
                    Transaction.Commit();
                }
            }

            return Value;
        }
 protected override IComponent[] CreateComponentsCore(IDesignerHost host)
 {
     IComponent[] sourceArray = base.CreateComponentsCore(host);
     Control component = null;
     ControlDesigner parent = null;
     TabStrip strip = null;
     IComponentChangeService service = (IComponentChangeService) host.GetService(typeof(IComponentChangeService));
     if ((sourceArray.Length > 0) && (sourceArray[0] is TabStrip))
     {
         strip = sourceArray[0] as TabStrip;
         ITreeDesigner designer2 = host.GetDesigner(strip) as ITreeDesigner;
         parent = designer2.Parent as ControlDesigner;
         if (parent != null)
         {
             component = parent.Control;
         }
     }
     if (host != null)
     {
         TabPageSwitcher switcher = null;
         DesignerTransaction transaction = null;
         try
         {
             try
             {
                 transaction = host.CreateTransaction("add tabswitcher");
             }
             catch (CheckoutException exception)
             {
                 if (exception != CheckoutException.Canceled)
                 {
                     throw exception;
                 }
                 return sourceArray;
             }
             MemberDescriptor member = TypeDescriptor.GetProperties(parent)["Controls"];
             switcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;
             if (service != null)
             {
                 service.OnComponentChanging(component, member);
                 service.OnComponentChanged(component, member, null, null);
             }
             Dictionary<string, object> properties = new Dictionary<string, object>();
             properties["Location"] = new Point(strip.Left, strip.Bottom + 3);
             properties["TabStrip"] = strip;
             this.SetProperties(switcher, properties, host);
         }
         finally
         {
             if (transaction != null)
             {
                 transaction.Commit();
             }
         }
         if (switcher != null)
         {
             IComponent[] destinationArray = new IComponent[sourceArray.Length + 1];
             Array.Copy(sourceArray, destinationArray, sourceArray.Length);
             destinationArray[destinationArray.Length - 1] = switcher;
             return destinationArray;
         }
     }
     return sourceArray;
 }
예제 #40
0
        internal static void AddGridColumn(ref Grid grid, ref IDesignerHost designerhost,
            ref IComponentChangeService componentChangeService,
            ref DesignerTransaction dt, ColumnTemplates template)
        {
            if (template == ColumnTemplates.None)
                return;
            dt = designerhost.CreateTransaction(string.Format("Configure WebGrid as {0}", template));

            switch (template)
            {
                case ColumnTemplates.SelectRowColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "SelectColumn";
                        systemcolumn.Grid = grid;
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.SelectColumn;
                        systemcolumn.DisplayIndex = 5;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.EditRowColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "EditColumn";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Edit row";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.EditColumn;
                        systemcolumn.DisplayIndex = 7;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.CopyRowColumnn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "CopyColumn";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Copy row";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.CopyColumn;
                        systemcolumn.DisplayIndex = 2;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.UpdateGridRecordColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "UpdateRecord";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Update record";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.UpdateGridRecordColumn;
                        systemcolumn.DisplayIndex = 9;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.UpdateGridRecordsColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "UpdateRecords";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Update all";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.UpdateGridRecordsColumn;
                        systemcolumn.DisplayIndex = 9;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.DeleteRowColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "DeleteRow";
                        systemcolumn.Html = "Delete row";
                        systemcolumn.Grid = grid;
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.DeleteColumn;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.HtmlEditorColumn:
                    {
                        Text htmlColumn = (Text) designerhost.CreateComponent(typeof (Text));
                        htmlColumn.ColumnId = "HtmlColumn";
                        htmlColumn.Title = "Html column";
                        htmlColumn.Grid = grid;
                        htmlColumn.IsHtml = true;
                        htmlColumn.WidthEditableColumn = Unit.Percentage(90);
                        htmlColumn.HeightEditableColumn = Unit.Pixel(300);
                        htmlColumn.Visibility = Visibility.Detail;
                        htmlColumn.Required = true;
                        grid.Columns.Add(htmlColumn);
                    }
                    break;
                case ColumnTemplates.EmailValidColumn:
                    {
                        Text emailcolumn = (Text) designerhost.CreateComponent(typeof (Text));
                        emailcolumn.ColumnId = "Emailcolumn";
                        emailcolumn.Title = "E-mail address";
                        emailcolumn.Grid = grid;
                        emailcolumn.Visibility = Visibility.Both;
                        emailcolumn.DisplayIndex = grid.Columns.Count*10;
                        emailcolumn.Required = true;
                        grid.Columns.Add(emailcolumn);
                    }
                    break;
            }
             WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
        }
예제 #41
0
        internal static void ConfigureGrid(ref Grid grid, ref IDesignerHost designerhost,
            ref IComponentChangeService componentChangeService,
            ref DesignerTransaction dt, GridTemplate template)
        {
            if (template == GridTemplate.None)
                return;

            switch (template)
            {
                case GridTemplate.ProductCatalog:
                    {
                        dt = designerhost.CreateTransaction(string.Format("Configure WebGrid as {0}", template));

                        grid.RecordsPerRow = 3;
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Product catalog";
                        grid.DefaultVisibility = Visibility.None;
                        grid.DisplayView = DisplayView.Grid;
                        grid.Columns.Clear();

                        Text producttitle = (Text) designerhost.CreateComponent(typeof (Text));
                        producttitle.ColumnId = "productTitle";
                        producttitle.Grid = grid;
                        producttitle.Title = "Title";
                        producttitle.Visibility = Visibility.Both;
                        producttitle.DisplayIndex = 10;

                        grid.Columns.Add(producttitle);

                        File productImageGrid = (File) designerhost.CreateComponent(typeof (File));
                        productImageGrid.ColumnId = "productImageGrid";
                        productImageGrid.Grid = grid;
                        productImageGrid.Title = "Grid image";
                        productImageGrid.HideDetailTitle = true;
                        productImageGrid.NewRowInGrid = true;
                        productImageGrid.Visibility = Visibility.Grid;
                        productImageGrid.DisplayIndex = 20;

                        grid.Columns.Add(productImageGrid);

                        File productImageEdit = (File) designerhost.CreateComponent(typeof (File));
                        productImageEdit.ColumnId = "productImageEdit";
                        productImageEdit.Title = "Edit image";
                        productImageEdit.Grid = grid;
                        productImageEdit.HideDetailTitle = true;
                        productImageEdit.NewRowInGrid = true;
                        productImageEdit.Visibility = Visibility.Detail;
                        productImageEdit.DisplayIndex = 20;

                        grid.Columns.Add(productImageEdit);

                        Text productGridDescription = (Text) designerhost.CreateComponent(typeof (Text));
                        productGridDescription.ColumnId = "productGridDescription";
                        productGridDescription.Title = "Grid description";
                        productGridDescription.Grid = grid;
                        productGridDescription.HideDetailTitle = true;
                        productGridDescription.Visibility = Visibility.Grid;
                        productGridDescription.IsHtml = true;
                        productGridDescription.DisplayIndex = 30;

                        grid.Columns.Add(productGridDescription);

                        Text productEditDescription = (Text) designerhost.CreateComponent(typeof (Text));
                        productEditDescription.ColumnId = "productGridDescription";
                        productEditDescription.Grid = grid;
                        productEditDescription.Title = "Edit description";
                        productEditDescription.HideDetailTitle = true;
                        productEditDescription.IsHtml = true;
                        productEditDescription.Visibility = Visibility.Detail;
                        productEditDescription.DisplayIndex = 30;

                        grid.Columns.Add(productEditDescription);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.UserRegistration:
                    {
                        grid.Width = Unit.Pixel(500);
                        grid.Title = "User login";
                        grid.DefaultVisibility = Visibility.None;
                        grid.DisplayView = DisplayView.Detail;
                        grid.AllowCancel = false;
                        grid.AllowUpdate = true;
                        grid.RecordsPerRow = 1;

                        grid.Columns.Clear();

                        Text userloginID = (Text) designerhost.CreateComponent(typeof (Text));
                        userloginID.ColumnId = "LoginID";
                        userloginID.Title = "Login ID";
                        userloginID.Grid = grid;
                        userloginID.HideDetailTitle = true;
                        userloginID.Visibility = Visibility.Detail;
                        userloginID.DisplayIndex = 10;
                        userloginID.Required = true;
                        grid.Columns.Add(userloginID);

                        Text userpassword = (Text) designerhost.CreateComponent(typeof (Text));
                        userpassword.ColumnId = "LoginPassword";
                        userpassword.Title = "Login password";
                        userpassword.Grid = grid;
                        userpassword.IsPassword = true;
                        userpassword.Visibility = Visibility.Detail;
                        userpassword.DisplayIndex = 20;
                        userpassword.ValidExpression = "[RepeatPassword] != [LoginPassword]";
                        userpassword.Required = true;
                        userpassword.MinSize = 5;
                        userpassword.MaxSize = 15;
                        userpassword.SystemMessage = "Your passwords did not match.";

                        grid.Columns.Add(userpassword);

                        Text repeatuserpassword = (Text) designerhost.CreateComponent(typeof (Text));
                        repeatuserpassword.ColumnId = "RepeatPassword";
                        repeatuserpassword.Title = "Repeat password";
                        repeatuserpassword.NewRowInDetail = false;
                        repeatuserpassword.Grid = grid;
                        repeatuserpassword.IsPassword = true;
                        repeatuserpassword.Visibility = Visibility.Detail;
                        repeatuserpassword.DisplayIndex = 30;
                        repeatuserpassword.MinSize = 5;
                        repeatuserpassword.MaxSize = 15;
                        repeatuserpassword.Required = true;

                        grid.Columns.Add(repeatuserpassword);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.RowSummary:
                    {
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Row summary";
                        grid.DefaultVisibility = Visibility.None;
                        grid.RecordsPerRow = 1;
                        grid.DisplayView = DisplayView.Grid;

                        grid.Columns.Clear();

                        Decimal productprice = (Decimal) designerhost.CreateComponent(typeof (Decimal));
                        productprice.ColumnId = "Price";
                        productprice.Title = "Price";
                        productprice.Grid = grid;
                        productprice.Visibility = Visibility.Both;
                        productprice.DisplayIndex = 10;

                        grid.Columns.Add(productprice);

                        Number productQuantity = (Number) designerhost.CreateComponent(typeof (Number));
                        productQuantity.ColumnId = "Quantity";
                        productQuantity.Title = "Quantity";
                        productQuantity.Grid = grid;
                        productQuantity.Visibility = Visibility.Both;
                        productQuantity.DisplayIndex = 20;

                        grid.Columns.Add(productQuantity);

                        Decimal productSubSum = (Decimal) designerhost.CreateComponent(typeof (Decimal));
                        productSubSum.ColumnId = "Total";
                        productSubSum.Title = "Sub total";
                        productSubSum.Grid = grid;
                        productSubSum.Visibility = Visibility.Grid;
                        productSubSum.DisplayIndex = 30;
                        productSubSum.DisplayTotalSummary = true;
                        productSubSum.Sum = "[Quantity]*[Price]";
                        grid.Columns.Add(productSubSum);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.DocumentDatabase:
                    {
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Document database";
                        grid.DefaultVisibility = Visibility.None;
                        grid.RecordsPerRow = 1;
                        grid.DisplayView = DisplayView.Grid;

                        grid.Columns.Clear();

                        Text documenttitle = (Text) designerhost.CreateComponent(typeof (Text));
                        documenttitle.ColumnId = "TitleDocument";
                        documenttitle.Title = "Title";
                        documenttitle.Grid = grid;
                        documenttitle.Visibility = Visibility.Both;
                        documenttitle.DisplayIndex = 10;
                        documenttitle.Required = true;

                        grid.Columns.Add(documenttitle);

                        Text htmldocument = (Text) designerhost.CreateComponent(typeof (Text));
                        htmldocument.ColumnId = "htmlDocument";
                        htmldocument.Title = "Document";
                        htmldocument.Grid = grid;
                        htmldocument.IsHtml = true;
                        htmldocument.WidthEditableColumn = Unit.Percentage(90);
                        htmldocument.HeightEditableColumn = Unit.Pixel(300);
                        htmldocument.Visibility = Visibility.Detail;
                        htmldocument.DisplayIndex = 20;
                        htmldocument.Required = true;

                        grid.Columns.Add(htmldocument);

                        File fileattachment = (File) designerhost.CreateComponent(typeof (File));
                        fileattachment.ColumnId = "FileAttachment";
                        fileattachment.Title = "File Attachment";
                        fileattachment.Grid = grid;
                        fileattachment.Visibility = Visibility.Both;
                        fileattachment.DisplayIndex = 30;
                        fileattachment.Required = false;

                        grid.Columns.Add(fileattachment);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
            }
        }
 private void ReParentControls(Control newParent, ArrayList controls, string transactionName, IDesignerHost host)
 {
     using (DesignerTransaction transaction = host.CreateTransaction(transactionName))
     {
         IComponentChangeService service = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
         PropertyDescriptor member = TypeDescriptor.GetProperties(newParent)["Controls"];
         PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(newParent)["Location"];
         Point empty = Point.Empty;
         if (descriptor2 != null)
         {
             empty = (Point) descriptor2.GetValue(newParent);
         }
         if (service != null)
         {
             service.OnComponentChanging(newParent, member);
         }
         foreach (object obj2 in controls)
         {
             Control component = obj2 as Control;
             Control parent = component.Parent;
             Point point2 = Point.Empty;
             InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(component)[typeof(InheritanceAttribute)];
             if ((attribute == null) || (attribute != InheritanceAttribute.InheritedReadOnly))
             {
                 PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(component)["Location"];
                 if (descriptor3 != null)
                 {
                     point2 = (Point) descriptor3.GetValue(component);
                 }
                 if (parent != null)
                 {
                     if (service != null)
                     {
                         service.OnComponentChanging(parent, member);
                     }
                     parent.Controls.Remove(component);
                 }
                 newParent.Controls.Add(component);
                 Point point3 = Point.Empty;
                 if (parent != null)
                 {
                     if (parent.Controls.Contains(newParent))
                     {
                         point3 = new Point(point2.X - empty.X, point2.Y - empty.Y);
                     }
                     else
                     {
                         Point point4 = (Point) descriptor3.GetValue(parent);
                         point3 = new Point(point2.X + point4.X, point2.Y + point4.Y);
                     }
                 }
                 descriptor3.SetValue(component, point3);
                 if ((service != null) && (parent != null))
                 {
                     service.OnComponentChanged(parent, member, null, null);
                 }
             }
         }
         if (service != null)
         {
             service.OnComponentChanged(newParent, member, null, null);
         }
         transaction.Commit();
     }
 }
예제 #43
0
        internal static PageSliderPage CreatePage(PageSlider parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            PageSliderPage page = null;
            try
            {
                page = dh.CreateComponent(typeof(PageSliderPage)) as PageSliderPage;

                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["Controls"]);
                parent.Controls.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["Controls"], null, null);

                if (ss != null)
                    ss.SetSelectedComponents(new PageSliderPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPage"].SetValue(parent, page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }
예제 #44
0
        protected override IComponent[] CreateComponentsCore(IDesignerHost host)
        {
            IComponent[] components = base.CreateComponentsCore(host);

            Control parentControl = null;
            ControlDesigner parentControlDesigner = null;
            TabStrip tabStrip = null;
            IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            // fish out the parent we're adding the TabStrip to.
            if (components.Length > 0 && components[0] is TabStrip) {
                tabStrip = components[0] as TabStrip;

                ITreeDesigner tabStripDesigner = host.GetDesigner(tabStrip) as ITreeDesigner;
                parentControlDesigner = tabStripDesigner.Parent as ControlDesigner;
                if (parentControlDesigner != null) {
                    parentControl = parentControlDesigner.Control;
                }
            }

            // Create a ControlSwitcher on the same parent.

            if (host != null) {
                TabPageSwitcher controlSwitcher = null;

                DesignerTransaction t = null;
                try {
                    try {
                        t = host.CreateTransaction("add tabswitcher");
                    }
                    catch (CheckoutException ex) {
                        if (ex == CheckoutException.Canceled) {
                            return components;
                        }
                        throw ex;
                    }
                    MemberDescriptor controlsMember = TypeDescriptor.GetProperties(parentControlDesigner)["Controls"];
                    controlSwitcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;

                    if (changeSvc != null) {
                        changeSvc.OnComponentChanging(parentControl, controlsMember);
                        changeSvc.OnComponentChanged(parentControl, controlsMember, null, null);
                    }

                    Dictionary<string, object> propertyValues = new Dictionary<string, object>();
                    propertyValues["Location"] = new Point(tabStrip.Left, tabStrip.Bottom + 3);
                    propertyValues["TabStrip"] = tabStrip;

                    SetProperties(controlSwitcher, propertyValues, host);

                }
                finally {
                    if (t != null)
                        t.Commit();
                }

                if (controlSwitcher != null) {
                    IComponent[] newComponents = new IComponent[components.Length + 1];
                    Array.Copy(components, newComponents, components.Length);
                    newComponents[newComponents.Length - 1] = controlSwitcher;
                    return newComponents;
                }

            }

            return components;
        }
예제 #45
0
        internal static WizardPage CreatePage(Wizard parent, bool innerPage, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss, eWizardStyle wizardStyle)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            WizardPage page=null;
            try
            {
                page = dh.CreateComponent(typeof(WizardPage)) as WizardPage;
				
				page.AntiAlias=false;
                page.InteriorPage = innerPage;
                if (innerPage)
                {
                    page.PageTitle = "< Wizard step title >";
                    page.PageDescription = "< Wizard step description >";
                }
                if (wizardStyle == eWizardStyle.Default)
                    ApplyDefaultInnerPageStyle(page, dh, cc);
                else if (wizardStyle == eWizardStyle.Office2007)
                    ApplyOffice2007InnerPageStyle(page, dh, cc);
                //else
                //{
                //    TypeDescriptor.GetProperties(page.Style)["BackColor"].SetValue(page.Style, Color.White);
                //}

                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["WizardPages"]);
                parent.WizardPages.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["WizardPages"], null, null);

                if (ss != null)
                    ss.SetSelectedComponents(new WizardPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPageIndex"].SetValue(parent, parent.WizardPages.IndexOf(page));
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }
예제 #46
0
        internal static WizardPage CreateWelcomePage(Wizard parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss, eWizardStyle style)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            WizardPage page = null;
            try
            {
                page = dh.CreateComponent(typeof(WizardPage)) as WizardPage;

                if(style == eWizardStyle.Default)
                    ApplyDefaultWelcomePageStyle(page, null, null);
                else
                    ApplyOffice2007WelcomePageStyle(page, null, null);
                //TypeDescriptor.GetProperties(page)["InteriorPage"].SetValue(page, false);
                //TypeDescriptor.GetProperties(page)["BackColor"].SetValue(page, Color.White);
                //TypeDescriptor.GetProperties(page)["CanvasColor"].SetValue(page, Color.White);
                //TypeDescriptor.GetProperties(page.Style)["BackColor"].SetValue(page.Style, Color.White);
                //TypeDescriptor.GetProperties(page.Style)["BackgroundImage"].SetValue(page.Style, GetWelcomeImage(false));
                //TypeDescriptor.GetProperties(page.Style)["BackgroundImagePosition"].SetValue(page.Style, eStyleBackgroundImage.TopLeft);
                page.Size = new Size(534, 289);

                // Load labels onto the page, first Welcome to the Wizard...
                System.Windows.Forms.Label label = dh.CreateComponent(typeof(System.Windows.Forms.Label)) as System.Windows.Forms.Label;
                page.Controls.Add(label);
                label.Location = new Point(210, 18);
                label.Text = "Welcome to the <Wizard Name> Wizard";
                label.BackColor = Color.Transparent;
                try
                {
                    label.Font = new Font("Tahoma", 16);
                    TypeDescriptor.GetProperties(label)["AutoSize"].SetValue(label, false);
                }
                catch { }
                label.Size = new Size(310, 66);
                label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

                // Wizard description label...
                label = dh.CreateComponent(typeof(System.Windows.Forms.Label)) as System.Windows.Forms.Label;
                page.Controls.Add(label);
                label.Location = new Point(210, 100);
                label.Text = "This wizard will guide you through the <Enter Process Name>.\r\n\r\n<Enter brief description of the process wizard is covering.>";
                label.BackColor = Color.Transparent;
                try
                {
                    TypeDescriptor.GetProperties(label)["AutoSize"].SetValue(label, false);
                }
                catch { }
                label.Size = new Size(309, 157);
                label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;

                // Click Next to Continue label...
                label = dh.CreateComponent(typeof(System.Windows.Forms.Label)) as System.Windows.Forms.Label;
                page.Controls.Add(label);
                label.Location = new Point(210, 266);
                label.Text = "To continue, click Next.";
                label.Size = new Size(120, 13);
                label.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
                label.BackColor = Color.Transparent;
                
                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["WizardPages"]);
                parent.WizardPages.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["WizardPages"], null, null);


                if (ss != null)
                    ss.SetSelectedComponents(new WizardPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPageIndex"].SetValue(parent, parent.WizardPages.IndexOf(page));
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }
예제 #47
0
 internal static void ApplyDefaultWelcomePageStyle(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
 {
     DesignerTransaction dt = null;
     if (dh != null) dt = dh.CreateTransaction();
     
     try
     {
         page.BackColor = Color.White;
         page.Style.BackColorBlend.Clear();
         TypeDescriptor.GetProperties(page)["InteriorPage"].SetValue(page, false);
         TypeDescriptor.GetProperties(page)["BackColor"].SetValue(page, Color.White);
         TypeDescriptor.GetProperties(page)["CanvasColor"].SetValue(page, Color.White);
         TypeDescriptor.GetProperties(page.Style)["BackColor"].SetValue(page.Style, Color.White);
         TypeDescriptor.GetProperties(page.Style)["BackColor2"].SetValue(page.Style, Color.Empty);
         TypeDescriptor.GetProperties(page.Style)["BackgroundImage"].SetValue(page.Style, LoadWizardImage(eWizardImages.WelcomeDefault));
         TypeDescriptor.GetProperties(page.Style)["BackgroundImagePosition"].SetValue(page.Style, eStyleBackgroundImage.TopLeft);
     }
     catch
     {
         dt.Cancel();
         throw;
     }
     finally
     {
         if (dt != null && !dt.Canceled)
             dt.Commit();
     }
 }
예제 #48
0
        internal static void DeletePage(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
        {
            if (page == null || !(page.Parent is Wizard))
                return;

            Wizard w = page.Parent as Wizard;

            DesignerTransaction dt = dh.CreateTransaction();

            try
            {
                if (cc != null)
                    cc.OnComponentChanging(w, TypeDescriptor.GetProperties(w)["WizardPages"]);

                w.WizardPages.Remove(page);

                if (cc != null)
                    cc.OnComponentChanged(w, TypeDescriptor.GetProperties(w)["WizardPages"], null, null);

                dh.DestroyComponent(page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }
        }
예제 #49
0
        internal static void DeletePage(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
        {
            if (page == null || !(page.Parent is PageSlider))
                return;

            PageSlider slider = (PageSlider)page.Parent;

            DesignerTransaction dt = dh.CreateTransaction("Deleting page");

            try
            {
                if (cc != null)
                    cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);

                slider.Controls.Remove(page);

                if (cc != null)
                    cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);

                dh.DestroyComponent(page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }
        }
 /// <summary>
 /// Helper method to save the value of a template.  This sets up all the right Undo state.
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="host"></param>
 /// <param name="template"></param>
 /// <param name="propertyName"></param>
 private static void PersistTemplate(TabPanel panel, IDesignerHost host, ITemplate template, string propertyName)
 {
     PropertyDescriptor descriptor = TypeDescriptor.GetProperties(panel)[propertyName];
     using (DesignerTransaction transaction = host.CreateTransaction("SetEditableDesignerRegionContent"))
     {
         descriptor.SetValue(panel, template);
         transaction.Commit();
     }
 }
        // Helper method to save the value of a template.  This sets up all the right Undo state.
        static void PersistTemplate(TabPanel panel, IDesignerHost host, ITemplate template, string propertyName) {
            using(var transaction = host.CreateTransaction("SetEditableDesignerRegionContent")) {
                var propertyInfo = panel.GetType().GetProperty(propertyName);
                if(propertyInfo == null)
                    return;

                propertyInfo.SetValue(panel, template, null);
                transaction.Commit();
            }
        }
예제 #52
0
        internal static void ApplyOffice2007WelcomePageStyle(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
        {
            DesignerTransaction dt = null;
            if (dh != null) dt = dh.CreateTransaction();
            
            try
            {
                if (cc != null) cc.OnComponentChanging(page, null);
                page.BackColor = Color.Transparent;
                page.Style.Reset();
                //page.BackColor = ColorScheme.GetColor(0xBBDBF7);
                //page.CanvasColor = page.BackColor;
                //page.Style.BackColor = Color.Empty;
                //page.Style.BackColor2 = Color.Empty;
                //page.Style.BackColorBlend.Clear();
                //page.Style.BackColorBlend.AddRange(new BackgroundColorBlend[] {
                //new BackgroundColorBlend(ColorScheme.GetColor(0xBBDBF7), 0f),
                //new BackgroundColorBlend(ColorScheme.GetColor(0xBBDBF7), .3f),
                //new BackgroundColorBlend(ColorScheme.GetColor(0xF3F9FE), .9f),
                //new BackgroundColorBlend(ColorScheme.GetColor(0xFEFFFF), 1f)});
                //page.Style.BackColorGradientAngle = 90;
                //page.Style.BackgroundImage = GetWelcomeImage(eWizardImages.BackgroundOffice2007);
                //page.Style.BackgroundImagePosition = eStyleBackgroundImage.TopLeft;

                if (cc != null) cc.OnComponentChanged(page, null, null, null);
            }
            catch
            {
                dt.Cancel();
                throw;
            }
            finally
            {
                if (dt != null && !dt.Canceled)
                    dt.Commit();
            }
        }