예제 #1
0
        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);
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
 public override void Initialize(System.ComponentModel.IComponent component)
 {
     base.Initialize(component);
     this.SetViewFlags(ViewFlags.TemplateEditing, true);
     this.tabPanelControl = (TabPanel)component;
 }