private void OnComponentChanging(RadialMenuItem parent, IComponentChangeService cc) { if (parent == null) { if (_RadialMenu != null) cc.OnComponentChanging(_RadialMenu, TypeDescriptor.GetProperties(_RadialMenu)["Items"]); else if (_RadialMenuContainer != null) cc.OnComponentChanging(_RadialMenuContainer, TypeDescriptor.GetProperties(_RadialMenuContainer)["SubItems"]); } else cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]); }
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); }
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(); }
void AddParameter(object sender, EventArgs e) { string description = String.Format(DesignSR.Trans_Add, typeof(MyParameter).Name); DesignerTransaction transaction = designerHost.CreateTransaction(description); MyParameter parameter = new MyParameter(); try { PropertyDescriptor property = DevExpress.XtraReports.Native.XRAccessor.GetPropertyDescriptor(report, XRComponentPropertyNames.Parameters); changeServ.OnComponentChanging(report, property); ReportDesigner.AddToContainer(designerHost, parameter); report.Parameters.Add(parameter); changeServ.OnComponentChanged(report, property, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new object[] { parameter }); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { RadItemCollection commandTabCollection = value as RadItemCollection; if (commandTabCollection != null) { IComponentChangeService service = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService)); service.OnComponentChanging(context.Instance, TypeDescriptor.GetProperties(context.Instance)["CommandTabs"]); CommandTabsUITypeEditorForm editorForm = new CommandTabsUITypeEditorForm(provider.GetService(typeof(IDesignerHost)) as IDesignerHost, commandTabCollection); if (editorForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { service.OnComponentChanged(context.Instance, TypeDescriptor.GetProperties(context.Instance)["CommandTabs"], null, null); } } return(value); }
internal void RemoveActiveTab() { if (ActiveTabIndexIsValid) { int oldIndex = this.tabPanelControl.ActiveTabIndex; IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host != null) { using (DesignerTransaction dt = host.CreateTransaction("Remove Active Tab")) { IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); PanelBase activeTab = this.tabPanelControl.Items[this.tabPanelControl.ActiveTabIndex] as PanelBase; try { changeService.OnComponentChanging(this.tabPanelControl, TypeDescriptor.GetProperties(this.tabPanelControl)["Tabs"]); this.tabPanelControl.Items.Remove(activeTab); } finally { changeService.OnComponentChanged(this.tabPanelControl, TypeDescriptor.GetProperties(this.tabPanelControl)["Tabs"], null, null); } activeTab.Dispose(); if (this.tabPanelControl.Items.Count > 0) { PropertyDescriptor activeTabIndex = TypeDescriptor.GetProperties(this.tabPanelControl)["ActiveTabIndex"]; activeTabIndex.SetValue(this.tabPanelControl, Math.Min(oldIndex, this.tabPanelControl.Items.Count - 1)); this.tabPanelControl.ActiveTabIndex = Math.Min(oldIndex, this.tabPanelControl.Items.Count - 1); } UpdateDesignTimeHtml(); dt.Commit(); } this.Tag.SetDirty(true); } } }
internal void DeserializeTo(IServiceProvider serviceProvider, IContainer container) { DesignerSerializationManager manager = new LocalDesignerSerializationManager(this, serviceProvider); using (manager.CreateSession()) { WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager); PropertySegmentSerializationProvider provider = new PropertySegmentSerializationProvider(); serializationManager.AddSerializationProvider(provider); StringReader input = new StringReader(this.serializedXmlString); using (XmlTextReader reader2 = new XmlTextReader(input)) { while (((reader2.NodeType != XmlNodeType.Element) && (reader2.NodeType != XmlNodeType.ProcessingInstruction)) && reader2.Read()) { } IReferenceService service = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService; IComponentChangeService service2 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; for (int i = 0; i < this.memberList.Count; i++) { object reference = service.GetReference(this.parentObjectNameList[i]); if (reference != null) { bool flag = (service2 != null) && (!(reference is IComponent) || (((IComponent)reference).Site == null)); PropertyDescriptor member = this.memberList[i] as PropertyDescriptor; if (flag) { service2.OnComponentChanging(reference, member); } serializationManager.Context.Push(reference); new PropertySegmentSerializer(null).DeserializeObject(serializationManager, reader2); serializationManager.Context.Pop(); if (flag) { service2.OnComponentChanged(reference, member, null, null); } } } } serializationManager.RemoveSerializationProvider(provider); } }
/// <summary> /// Attempts to notify the <see cref="IComponentChangeService"/> via /// <see cref="IComponentChangeService.OnComponentChanging"/>. /// </summary> /// <returns> /// <see langword="true"/> if the component can be changed; otherwise, /// <see langword="false"/>. /// </returns> bool ITypeDescriptorContext.OnComponentChanging() { IComponentChangeService componentChangeService = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (componentChangeService != null) { try { componentChangeService.OnComponentChanging(this.myInstance, this.myPropertyDescriptor); } catch (CheckoutException ex) { if (ex != CheckoutException.Canceled) { throw; } return(false); } } return(true); }
private bool OnComponentChanging() { IComponentChangeService service = (IComponentChangeService)this.activity.Site.GetService(typeof(IComponentChangeService)); if (service != null) { try { service.OnComponentChanging(this.activity, null); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw; } return(false); } } return(true); }
private void DataGridViewDesigner_ComponentRemoving(object sender, ComponentEventArgs e) { DataGridView component = base.Component as DataGridView; if ((e.Component != null) && (e.Component == component.DataSource)) { IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService)); string dataMember = component.DataMember; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component); PropertyDescriptor member = (properties != null) ? properties["DataMember"] : null; if ((service != null) && (member != null)) { service.OnComponentChanging(component, member); } component.DataSource = null; if ((service != null) && (member != null)) { service.OnComponentChanged(component, member, dataMember, ""); } } }
private void MoveTabUp(object sender, EventArgs e) { int current = myControl.TabPages.IndexOf(myControl.SelectedTab); if (myControl.TabPages.Count > 1 & current > 0) { // Setup transaction IDesignerHost myHost = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction myTransaction = default(DesignerTransaction); IComponentChangeService myChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); myTransaction = myHost.CreateTransaction("Move Tab Up"); myChangeService.OnComponentChanging(myControl, null); //Move tab myControl.TabPages.MoveUp(myControl.SelectedTab); // Complete transaction myChangeService.OnComponentChanged(myControl, null, null, null); myTransaction.Commit(); } }
private void AddItem(Type ty) { //Designer vorbereiten IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); IComponentChangeService chan = (IComponentChangeService)GetService(typeof(IComponentChangeService)); //Rückgängig-Aktion anzeigen DesignerTransaction t = host.CreateTransaction("Add Item"); using (t) { //Komponente wird geändert chan.OnComponentChanging(_owner, null); //neue Komponente erstellen IComponent com = host.CreateComponent(ty); //der Entwurfszeitinstanz hinzufügen _owner.Buttons.Add((NuGenMiniBarControl)com); //Änderungen anzeigen chan.OnComponentChanged(_owner, null, null, null); t.Commit(); } }
public bool OnComponentChanging() { IComponentChangeService service = (IComponentChangeService)this.serviceProvider.GetService(typeof(IComponentChangeService)); if (service != null) { try { service.OnComponentChanging(this.instance, this.propDesc); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return(false); } } return(true); }
private void PushChanges() { if (this.Dirty) { IComponentChangeService service = this.host.GetService(typeof(IComponentChangeService)) as IComponentChangeService; PropertyDescriptor member = null; IBindableComponent bindableComponent = this.bindings.BindableComponent; if ((service != null) && (bindableComponent != null)) { member = TypeDescriptor.GetProperties(bindableComponent)["DataBindings"]; if (member != null) { service.OnComponentChanging(bindableComponent, member); } } this.bindings.Clear(); TreeNode node = this.propertiesTreeView.Nodes[0]; for (int i = 0; i < node.Nodes.Count; i++) { BindingTreeNode node2 = node.Nodes[i] as BindingTreeNode; if (node2.Binding != null) { this.bindings.Add(node2.Binding); } } TreeNode node3 = this.propertiesTreeView.Nodes[1]; for (int j = 0; j < node3.Nodes.Count; j++) { BindingTreeNode node4 = node3.Nodes[j] as BindingTreeNode; if (node4.Binding != null) { this.bindings.Add(node4.Binding); } } if (((service != null) && (bindableComponent != null)) && (member != null)) { service.OnComponentChanged(bindableComponent, member, null, null); } } }
internal void SetCustomProperty(CustomPropertyDefinitionCollection properties, string name, ExpressionInfo value, ExpressionInfo defaultValue) { // Fire component changing if (ComponentChangeService != null) { ComponentChangeService.OnComponentChanging(ReportItem, null); } // get property CustomPropertyDefinition property = properties[name]; bool isDefaultValue = defaultValue == value; if (isDefaultValue) { // reset the property value if (property != null) { properties.Remove(property); } } else { // set property value if (property == null) { properties.Add(new CustomPropertyDefinition(name, value)); } else { property.Value = value; } } // Fire component changed if (ComponentChangeService != null) { ComponentChangeService.OnComponentChanged(ReportItem, null, null, null); } }
/// <summary> /// <para> /// Invokes the property builder beginning with the specified page. /// </para> /// </summary> /// <param name='initialPage'> /// The page to begin with. /// </param> protected internal void InvokePropertyBuilder(int initialPage) { IComponentChangeService changeService = null; bool result = false; changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (changeService != null) { try { changeService.OnComponentChanging(_objectList, null); } catch (CheckoutException ex) { if (ex == CheckoutException.Canceled) { return; } throw; } } try { ObjectListComponentEditor compEditor = new ObjectListComponentEditor(initialPage); result = compEditor.EditComponent(_objectList); } finally { if (changeService != null) { changeService.OnComponentChanged(_objectList, null, null, null); if (IMobileWebFormServices != null) { IMobileWebFormServices.ClearUndoStack(); } } } }
/// <summary> /// handy helper method for setting multiple properties. /// </summary> /// <param name="component"></param> /// <param name="properties"></param> /// <param name="host"></param> private void SetProperties(Component component, Dictionary <string, object> properties, IDesignerHost host) { IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService)); foreach (string propname in properties.Keys) { PropertyDescriptor propDescriptor = TypeDescriptor.GetProperties(component)[propname]; if (changeSvc != null) { changeSvc.OnComponentChanging(component, propDescriptor); } if (propDescriptor != null) { propDescriptor.SetValue(component, properties[propname]); } if (changeSvc != null) { changeSvc.OnComponentChanged(component, propDescriptor, null, null); } } }
protected void OnVerbFunky(object sender, EventArgs e) { // Get the associated control. MarqueeLabel lbl = (MarqueeLabel)Control; // Get the IComponentChangeService. IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // Start the transaction. DesignerTransaction tran = host.CreateTransaction("Apply Funky Theme"); changeService.OnComponentChanging(lbl, null); lbl.ForeColor = Color.LimeGreen; lbl.BackColor = Color.Yellow; lbl.Font = new Font(lbl.Font.Name, 48, FontStyle.Bold); changeService.OnComponentChanged(lbl, null, null, null); // Commit the transaction. tran.Commit(); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc == null) { return(value); } using (ComboBoxColumnEditor form = new ComboBoxColumnEditor(value)) { if (edSvc.ShowDialog(form) == DialogResult.OK) { IComponentChangeService iccs = (IComponentChangeService)context.GetService(typeof(IComponentChangeService)); iccs.OnComponentChanging(context.Instance, null); (value as ComboBoxColumnCollection).AddRange(form.NewCollection); iccs.OnComponentChanged(context.Instance, null, null, null); } } return(value); }
private void SynchronizeCollections(DictItemBase before, DictItemBase after, ITypeDescriptorContext context) { // Add all new components (in the 'after' but not the 'before' foreach (KryptonBreadCrumbItem item in after.Values) { if (!before.ContainsKey(item)) { context.Container?.Add(item as IComponent); } } // Delete all old components (in the 'before' but not the 'after' foreach (KryptonBreadCrumbItem item in before.Values) { if (!after.ContainsKey(item)) { DestroyInstance(item); context.Container?.Remove(item as IComponent); } } IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); if (changeService != null) { // Mark components as changed when not added or removed foreach (KryptonBreadCrumbItem item in after.Values) { if (before.ContainsKey(item)) { changeService.OnComponentChanging(item, null); changeService.OnComponentChanged(item, null, null, null); } } } }
internal void ExtenderSetValue(IExtenderProvider provider, object component, object value, PropertyDescriptor notifyDesc) { if (provider != null) { ISite site = MemberDescriptor.GetSite(component); IComponentChangeService service = null; object oldValue = null; if (site != null) { service = (IComponentChangeService)site.GetService(typeof(IComponentChangeService)); } if (service != null) { oldValue = this.ExtenderGetValue(provider, component); try { service.OnComponentChanging(component, notifyDesc); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return; } } provider = (IExtenderProvider)this.GetInvocationTarget(this.componentClass, provider); if (this.SetMethodValue != null) { this.SetMethodValue.Invoke(provider, new object[] { component, value }); if (service != null) { service.OnComponentChanged(component, notifyDesc, oldValue, value); } } } }
public void SetProperty(string propertyName, string transactionName, bool value) { IDesignerHost designerHost = this.m_owner.Component.Site.GetService(typeof(IDesignerHost)) as IDesignerHost; DesignerTransaction designerTransaction = designerHost.CreateTransaction(string.Format(transactionName, value ? "Enable" : "Disable")); try { IComponentChangeService componentChangeService = this.m_owner.Component.Site.GetService(typeof(IComponentChangeService)) as IComponentChangeService; PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(this.m_owner.Component)[propertyName]; componentChangeService.OnComponentChanging(this.m_owner.Component, propertyDescriptor); propertyDescriptor.SetValue(this.m_owner.Component, value); componentChangeService.OnComponentChanged(this.m_owner.Component, propertyDescriptor, null, null); designerTransaction.Commit(); designerTransaction = null; } finally { if (designerTransaction != null) { designerTransaction.Cancel(); } } }
internal virtual void OnPropertyChanged(DispatchID dispid) { try { ISite site = Host.Site; if (site is not null) { IComponentChangeService changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService)); if (changeService is not null) { try { changeService.OnComponentChanging(Host, null); } catch (CheckoutException coEx) { if (coEx == CheckoutException.Canceled) { return; } throw; } // Now notify the change service that the change was successful. // changeService.OnComponentChanged(Host, null, null, null); } } } catch (Exception t) { Debug.Fail(t.ToString()); throw; } }
internal override void OnItemRemoving(object item) { ListView instance = base.Context.Instance as ListView; if (instance != null) { ColumnHeader column = item as ColumnHeader; if (column != null) { IComponentChangeService service = base.GetService(typeof(IComponentChangeService)) as IComponentChangeService; PropertyDescriptor member = null; if (service != null) { member = TypeDescriptor.GetProperties(base.Context.Instance)["Columns"]; service.OnComponentChanging(base.Context.Instance, member); } instance.Columns.Remove(column); if ((service != null) && (member != null)) { service.OnComponentChanged(base.Context.Instance, member, null, null); } } } }
public ComponentChangeDispatcher(IServiceProvider serviceProvider, object component, PropertyDescriptor propertyDescriptor) { this.serviceProvider = serviceProvider; this.component = component; this.property = propertyDescriptor; IComponentChangeService service = serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (service != null) { try { this.newValue = this.oldValue = propertyDescriptor.GetValue(component); propertyDescriptor.AddValueChanged(component, new EventHandler(this.OnValueChanged)); service.OnComponentChanging(component, propertyDescriptor); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } } } }
private void DataGridViewAddColumnDialog_Closed(object sender, EventArgs e) { if (this.persistChangesToDesigner) { try { IComponentChangeService service = (IComponentChangeService)this.liveDataGridView.Site.GetService(iComponentChangeServiceType); if (service == null) { return; } DataGridViewColumn[] dataGridViewColumns = new DataGridViewColumn[this.liveDataGridView.Columns.Count - this.initialDataGridViewColumnsCount]; for (int i = this.initialDataGridViewColumnsCount; i < this.liveDataGridView.Columns.Count; i++) { dataGridViewColumns[i - this.initialDataGridViewColumnsCount] = this.liveDataGridView.Columns[i]; } int initialDataGridViewColumnsCount = this.initialDataGridViewColumnsCount; while (initialDataGridViewColumnsCount < this.liveDataGridView.Columns.Count) { this.liveDataGridView.Columns.RemoveAt(this.initialDataGridViewColumnsCount); } PropertyDescriptor member = TypeDescriptor.GetProperties(this.liveDataGridView)["Columns"]; service.OnComponentChanging(this.liveDataGridView, member); for (int j = 0; j < dataGridViewColumns.Length; j++) { dataGridViewColumns[j].DisplayIndex = -1; } this.liveDataGridView.Columns.AddRange(dataGridViewColumns); service.OnComponentChanged(this.liveDataGridView, member, null, null); } catch (InvalidOperationException) { } } base.DialogResult = DialogResult.OK; }
private void OnAddTabPanel() { IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host != null) { TabContainer tc = TabContainer; using (DesignerTransaction dt = host.CreateTransaction("Add new TabPanel")) { TabPanel tp = (TabPanel)host.CreateComponent(typeof(TabPanel)); if (tp != null) { // set up the inital state // tp.ID = GetUniqueName(typeof(TabPanel), tc); tp.HeaderText = tp.ID; IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); try { changeService.OnComponentChanging(tc, TypeDescriptor.GetProperties(tc)["Tabs"]); tc.Tabs.Add(tp); } finally { changeService.OnComponentChanged(tc, TypeDescriptor.GetProperties(tc)["Tabs"], tc.Tabs, tc.Tabs); } TypeDescriptor.GetProperties(tc)["ActiveTab"].SetValue(tc, tp); CurrentTabID = tp.ID; } dt.Commit(); } } }
internal void AddItem(Type type) { IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); if (host != null) { PanelBase item = (PanelBase)host.CreateComponent(type); if (item != null) { InitializeItem(item); IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); try { changeService.OnComponentChanging(this.fitLayout, TypeDescriptor.GetProperties(this.fitLayout)["Items"]); this.fitLayout.Items.Clear(); this.fitLayout.Items.Add(item); } finally { changeService.OnComponentChanged(this.fitLayout, TypeDescriptor.GetProperties(this.fitLayout)["Items"], null, null); } } this.UpdateDesignTimeHtml(); //this.RaiseComponentChanged(TypeDescriptor.GetProperties(this.fitLayout)["Controls"],null,null); this.Tag.SetDirty(true); //this.Refresh(); } }
private void OnAddLabel(object sender, System.EventArgs e) { if (m_owner == null) { return; } Label label = m_owner.Label; if (label == null) { IDesignerHost h = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction dt = h.CreateTransaction("Add MyLabel"); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); label = (MyLabel)h.CreateComponent(typeof(MyLabel)); label.Text = "БъЬт"; c.OnComponentChanging(m_owner, null); m_owner.Label = label; c.OnComponentChanged(m_owner, null, null, null); dt.Commit(); m_owner.ResetLayout(); } }
internal static void SetValue(IComponent component, string propertyName, object value) { PropertyDescriptor propertyDescriptor = GetPropertyDescriptor(component, propertyName); IComponentChangeService svc = GetChangeService(component); IDesignerHost host = GetDesignerHost(component); DesignerTransaction txn = host.CreateTransaction(); try { svc.OnComponentChanging(component, propertyDescriptor); propertyDescriptor.SetValue(component, value); svc.OnComponentChanged(component, propertyDescriptor, null, null); txn.Commit(); txn = null; } finally { if (txn != null) { txn.Cancel(); } } }
/// <summary> /// Removes the item from listview column header collection /// </summary> internal override void OnItemRemoving(object item) { if (!(Context.Instance is ListView listview)) { return; } if (item is ColumnHeader column) { IComponentChangeService cs = GetService(typeof(IComponentChangeService)) as IComponentChangeService; PropertyDescriptor itemsProp = null; if (cs != null) { itemsProp = TypeDescriptor.GetProperties(Context.Instance)["Columns"]; cs.OnComponentChanging(Context.Instance, itemsProp); } listview.Columns.Remove(column); if (cs != null && itemsProp != null) { cs.OnComponentChanged(Context.Instance, itemsProp, null, null); } } }
private void AddDataControl(System.Type type) { if (m_owner == null) { return; } System.Windows.Forms.Control control = m_owner.Control; if (control != null) { m_owner.Control = null; control.Dispose(); } IDesignerHost h = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction dt = h.CreateTransaction("Add DataControl"); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); control = (System.Windows.Forms.Control)h.CreateComponent(type); c.OnComponentChanging(m_owner, null); m_owner.Control = control; c.OnComponentChanged(m_owner, null, null, null); dt.Commit(); }
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(); } }
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; }
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(); } }
internal static void SaveGridState(DesignerTransaction dt, Grid grid, IComponentChangeService service) { service.OnComponentChanging(grid, null); service.OnComponentChanged(grid, null, null, null); dt.Commit(); }
internal static void GotoPage(Wizard w, IComponentChangeService cc, ISelectionService ss) { if (w == null) return; WizardPageOrderDialog d = new WizardPageOrderDialog(); d.SetWizard(w); d.StartPosition = FormStartPosition.CenterScreen; if (d.ShowDialog() == DialogResult.OK) { string pageName = d.SelectedPageName; if (d.OrderChanged) { if (cc != null) cc.OnComponentChanging(w, TypeDescriptor.GetProperties(w)["WizardPages"]); string[] newOrder = d.OrderedPageNames; w.WizardPages.IgnoreEvents = true; try { WizardPageCollection col = new WizardPageCollection(); w.WizardPages.CopyTo(col); w.WizardPages.Clear(); foreach (string pn in newOrder) w.WizardPages.Add(col[pn]); } finally { w.WizardPages.IgnoreEvents = false; } if (cc != null) cc.OnComponentChanged(w, TypeDescriptor.GetProperties(w)["WizardPages"], null, null); } if (pageName != "") w.SelectedPage = w.WizardPages[pageName]; else if (d.OrderChanged) w.SelectedPageIndex = 0; if (ss != null && (pageName!="" || d.OrderChanged)) ss.SetSelectedComponents(new WizardPage[] { w.SelectedPage }, SelectionTypes.Replace); } d.Dispose(); }
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(); } }
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; }
internal static void ApplyOffice2007InnerPageStyle(WizardPage page, IDesignerHost dh, IComponentChangeService cc) { if (cc != null) cc.OnComponentChanging(page, null); page.BackColor = Color.Transparent; page.Style.Reset(); if (cc != null) cc.OnComponentChanged(page, null, null, null); }
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; }
internal static void ApplyDefaultInnerPageStyle(WizardPage page, IDesignerHost dh, IComponentChangeService cc) { if (cc != null) cc.OnComponentChanging(page, null); page.BackColor = SystemColors.Control; if (!page.InteriorPage) { TypeDescriptor.GetProperties(page.Style)["BackColor"].SetValue(page.Style, Color.White); } if (cc != null) cc.OnComponentChanged(page, null, null, null); }