private string GetDesignerRegionAttribute(RegionPosition region, BorderLayoutClickAction action) { string name = string.Format("{0}_{1}", region, action); this.designerRegions.Add(new DesignerRegion(this, name, false)); return(string.Format("{0}=\"{1}\"", DesignerRegion.DesignerRegionAttributeName, this.designerRegions.Count - 1)); }
private string GetDesignerRegionAttribute(RegionPosition region, BorderLayoutClickAction action) { string name = "{0}_{1}".FormatWith(region, action); this.designerRegions.Add(new DesignerRegion(this, name, false)); return "{0}=\"{1}\"".FormatWith(DesignerRegion.DesignerRegionAttributeName, this.designerRegions.Count - 1); }
protected override void OnClick(DesignerRegionMouseEventArgs e) { if (e.Region == null) { return; } string[] parameters = e.Region.Name.Split('_'); if (parameters.Length < 2) { return; } BorderLayoutRegion region = GetLayoutRegionByName(parameters[0]); if (region == null) { return; } BorderLayoutClickAction action = (BorderLayoutClickAction)Enum.Parse(typeof(BorderLayoutClickAction), parameters[1]); switch (action) { case BorderLayoutClickAction.AddPanel: this.AddPanel(region); break; case BorderLayoutClickAction.AddTabPanel: this.AddTabPanel(region); break; case BorderLayoutClickAction.ClearRegion: this.ClearRegion(region.Region); break; case BorderLayoutClickAction.TurnOffScheme: TypeDescriptor.GetProperties(this.layout)["SchemeMode"].SetValue(this.layout, false); //this.Refresh(); break; case BorderLayoutClickAction.ChangeTab: int tabId = int.Parse(parameters[2]); if (region.Items.Count == 0) { return; } TabPanel tabPanel = region.Items[0] as TabPanel; if (tabPanel == null) { return; } if (tabPanel.ActiveTabIndex != tabId) { PropertyDescriptor activeTab = TypeDescriptor.GetProperties(tabPanel)["ActiveTabIndex"]; activeTab.SetValue(tabPanel, tabId); tabPanel.ActiveTabIndex = tabId; } break; case BorderLayoutClickAction.ChangeToPanel: this.AddPanel(region); break; case BorderLayoutClickAction.ChangeToTabPanel: this.AddTabPanel(region); break; case BorderLayoutClickAction.Collapse: CollapsePanel(region, true); break; case BorderLayoutClickAction.Expand: CollapsePanel(region, false); break; default: throw new ArgumentOutOfRangeException(); } this.Tag.SetDirty(true); this.UpdateDesignTimeHtml(); //base.OnClick(e); }