protected override void OnClick(DesignerRegionMouseEventArgs e) { string[] parameters = e.Region.Name.Split('_'); string actionName = parameters[0]; FitLayoutClickAction action = (FitLayoutClickAction)Enum.Parse(typeof(FitLayoutClickAction), actionName); switch (action) { case FitLayoutClickAction.AddPanel: AddItem(typeof(Panel)); break; case FitLayoutClickAction.AddTabPanel: AddItem(typeof(TabPanel)); break; case FitLayoutClickAction.Toggle: Panel panel = this.fitLayout.Items[0] as Panel; PropertyDescriptor collapsed = TypeDescriptor.GetProperties(panel)["Collapsed"]; bool value = (bool)collapsed.GetValue(panel); collapsed.SetValue(panel, !value); panel.Collapsed = !value; Tag.SetDirty(true); this.UpdateDesignTimeHtml(); break; case FitLayoutClickAction.ChangeTab: if (parameters.Length < 2) { return; } int tabId = int.Parse(parameters[1]); if (this.fitLayout.Items.Count == 0) { return; } TabPanel tabPanel = this.fitLayout.Items[0] as TabPanel; if (tabPanel == null) { return; } if (tabPanel.ActiveTabIndex != tabId) { IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); try { changeService.OnComponentChanging(this.fitLayout, TypeDescriptor.GetProperties(this.fitLayout)["Items"]); PropertyDescriptor activeTab = TypeDescriptor.GetProperties(tabPanel)["ActiveTabIndex"]; activeTab.SetValue(tabPanel, tabId); tabPanel.ActiveTabIndex = tabId; } finally { changeService.OnComponentChanged(this.fitLayout, TypeDescriptor.GetProperties(this.fitLayout)["Items"], null, null); } Tag.SetDirty(true); this.UpdateDesignTimeHtml(); } break; default: throw new ArgumentOutOfRangeException(); } }
private string GetDesignerRegionAttribute(FitLayoutClickAction action) { designerRegions.Add(new DesignerRegion(this, action.ToString(), false)); return(string.Format("{0}=\"{1}\"", DesignerRegion.DesignerRegionAttributeName, designerRegions.Count - 1)); }
private string GetDesignerRegionAttribute(FitLayoutClickAction action) { designerRegions.Add(new DesignerRegion(this, action.ToString(), false)); return "{0}=\"{1}\"".FormatWith(DesignerRegion.DesignerRegionAttributeName, designerRegions.Count - 1); }