Inheritance: StateManagedItem
Example #1
0
        internal void AddItem(Type type, BorderLayoutRegion region)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                PanelBase item = (PanelBase)host.CreateComponent(type);

                if (item != null)
                {
                    InitializeItem(item, region);
                    IComponentChangeService changeService =
                        (IComponentChangeService)GetService(typeof(IComponentChangeService));

                    try
                    {
                        changeService.OnComponentChanging(region, TypeDescriptor.GetProperties(region)["Items"]);
                        region.Items.Clear();
                        region.Items.Add(item);
                    }
                    finally
                    {
                        changeService.OnComponentChanged(region, TypeDescriptor.GetProperties(region)["Items"], null,
                                                         null);
                    }
                }
                this.Tag.SetDirty(true);
                this.UpdateDesignTimeHtml();
            }
        }
Example #2
0
        internal void ResetRegion(RegionPosition region)
        {
            switch (region)
            {
            case RegionPosition.North:
                this.north = null;
                break;

            case RegionPosition.South:
                this.south = null;
                break;

            case RegionPosition.East:
                this.east = null;
                break;

            case RegionPosition.West:
                this.west = null;
                break;

            case RegionPosition.Center:
                this.center = null;
                break;

            default:
                throw new ArgumentOutOfRangeException("region");
            }
        }
Example #3
0
        public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content)
        {
            if (content == null)
            {
                return;
            }

            IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                string[] parameters = region.Name.Split('_');

                if (parameters.Length == 3 && parameters[0] == "Body")
                {
                    BorderLayoutRegion layoutRegion = GetLayoutRegionByName(parameters[1]);

                    if (layoutRegion != null && layoutRegion.Items.Count > 0)
                    {
                        IContent contentPanel = null;
                        int      activeIndex  = int.Parse(parameters[2]);

                        if (layoutRegion.Items[0] is Panel)
                        {
                            contentPanel = layoutRegion.Items[0] as Panel;
                        }
                        else if (layoutRegion.Items[0] is TabPanel)
                        {
                            TabPanel tabPanel = layoutRegion.Items[0] as TabPanel;

                            if (activeIndex < tabPanel.Items.Count)
                            {
                                contentPanel = tabPanel.Items[activeIndex] as IContent;
                            }
                        }

                        if (contentPanel == null)
                        {
                            return;
                        }

                        ITemplate template = ControlParser.ParseTemplate(host, content);
                        TypeDescriptor.GetProperties(contentPanel)["Body"].SetValue(
                            contentPanel, template);
                        contentPanel.Content = template;

                        this.Tag.SetDirty(true);
                    }
                }
            }
        }
Example #4
0
        public override string GetEditableDesignerRegionContent(EditableDesignerRegion region)
        {
            IDesignerHost host = (IDesignerHost)this.Component.Site.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                string[] parameters = region.Name.Split('_');

                if (parameters.Length == 3 && parameters[0] == "Body")
                {
                    BorderLayoutRegion layoutRegion = this.GetLayoutRegionByName(parameters[1]);

                    if (layoutRegion != null && layoutRegion.Items.Count > 0)
                    {
                        int      activeIndex  = int.Parse(parameters[2]);
                        IContent contentPanel = null;

                        if (layoutRegion.Items[0] is Panel)
                        {
                            contentPanel = layoutRegion.Items[0] as Panel;
                        }
                        else if (layoutRegion.Items[0] is TabPanel)
                        {
                            TabPanel tabPanel = layoutRegion.Items[0] as TabPanel;

                            if (activeIndex < tabPanel.Items.Count)
                            {
                                contentPanel = tabPanel.Items[activeIndex] as IContent;
                            }
                        }

                        if (contentPanel == null)
                        {
                            return("");
                        }

                        ITemplate contentTemplate = contentPanel.Content;

                        if (contentTemplate != null)
                        {
                            return(ControlPersister.PersistTemplate(contentTemplate, host));
                        }
                    }
                }
            }

            return("");
        }
Example #5
0
        private static void CollapsePanel(BorderLayoutRegion region, bool collapse)
        {
            Component panel = region.Items[0];

            PropertyDescriptor collapsed = TypeDescriptor.GetProperties(panel)["Collapsed"];

            if (collapsed != null)
            {
                collapsed.SetValue(panel, collapse);

                if (ReflectionUtils.IsTypeOf(panel, typeof(PanelBase), false))
                {
                    ((PanelBase)panel).Collapsed = collapse;
                }
            }
        }
Example #6
0
        private Control BuildRegion(BorderLayoutRegion region, Unit width, Unit height)
        {
            if (!this.SchemeMode && region.Items.Count > 0)
            {
                Component item = region.Items[0];

                if (ReflectionUtils.IsTypeOf(item, typeof(PanelBase), false))
                {
                    this.AddIcon(((PanelBase)item).Icon);
                }


                PanelBaseDesigner designer;

                if (ReflectionUtils.IsTypeOf(item, typeof(Panel), false))
                {
                    designer = new PanelDesigner();
                }
                else if (ReflectionUtils.IsTypeOf(item, typeof(TabPanel), false))
                {
                    designer = new TabPanelDesigner();
                }
                else
                {
                    return(BuildStub(region, height, width, true));
                }

                designer.Width = width;

                if (region == this.layout.North || region == this.layout.South)
                {
                    designer.Height = height;
                }
                designer.Layout       = LayoutType.Border;
                designer.BorderRegion = region;

                designer.CurrentDesigner = this.CurrentDesigner;
                designer.Initialize(item);

                return(new LiteralControl(designer.GetDesignTimeHtml(this.designerRegions)));
            }
            else
            {
                return(BuildStub(region, height, width, false));
            }
        }
Example #7
0
        private void InitializeItem(PanelBase item, BorderLayoutRegion region)
        {
            region.Split       = true;
            region.Collapsible = item is Panel;
            item.Title         = region.Region.ToString();
            switch (region.Region)
            {
            case RegionPosition.North:
            case RegionPosition.South:
                item.Height = Unit.Pixel(150);
                break;

            case RegionPosition.East:
            case RegionPosition.West:
                item.Width = Unit.Pixel(175);
                break;

            case RegionPosition.Center:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (item is TabPanel)
            {
                TabPanel tabPanel = item as TabPanel;

                Panel tab = new Panel();
                tab.Title = "Tab 1";
                tabPanel.Items.Add(tab);

                tab       = new Panel();
                tab.Title = "Tab 2";
                tabPanel.Items.Add(tab);

                tab       = new Panel();
                tab.Title = "Tab 3";
                tabPanel.Items.Add(tab);

                tabPanel.ActiveTabIndex = 0;

                region.Collapsible = false;
            }
        }
Example #8
0
        private Control BuildCollapsedRegion(BorderLayoutRegion region)
        {
            string template =
                "<div class=\"x-layout-collapsed x-layout-collapsed-{0}\" style=\"position: static; visibility:visible;{1}\"><a {2}><div class=\"x-tool x-tool-expand-{0}\"></div></a></div>";
            string style;

            if (region.Region == RegionPosition.North || region.Region == RegionPosition.South)
            {
                style = "height:22px;width:auto;";
            }
            else
            {
                style = "height:100%;width:22px;";
            }

            LiteralControl res =
                new LiteralControl(
                    string.Format(template, region.Region.ToString().ToLower(), style,
                                  GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.Expand)));

            this.AddEmptyRegion();

            return(res);
        }
Example #9
0
 /// <summary>
 ///
 /// </summary>
 public BorderLayoutRegion.Builder BorderLayoutRegion(BorderLayoutRegion component)
 {
     return(new BorderLayoutRegion.Builder(component));
 }
Example #10
0
 internal void ResetRegion(RegionPosition region)
 {
     switch (region)
     {
         case RegionPosition.North:
             this.north = null;
             break;
         case RegionPosition.South:
             this.south = null;
             break;
         case RegionPosition.East:
             this.east = null;
             break;
         case RegionPosition.West:
             this.west = null;
             break;
         case RegionPosition.Center:
             this.center = null;
             break;
         default:
             throw new ArgumentOutOfRangeException("region");
     }
 }
Example #11
0
        private void InitializeItem(PanelBase item, BorderLayoutRegion region)
        {
            region.Split = true;
            region.Collapsible = item is Panel;
            item.Title = region.Region.ToString();
            switch (region.Region)
            {
                case RegionPosition.North:
                case RegionPosition.South:
                    item.Height = Unit.Pixel(150);
                    break;
                case RegionPosition.East:
                case RegionPosition.West:
                    item.Width = Unit.Pixel(175);
                    break;
                case RegionPosition.Center:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (item is TabPanel)
            {
                TabPanel tabPanel = item as TabPanel;

                Panel tab = new Panel();
                tab.Title = "Tab 1";
                tabPanel.Items.Add(tab);

                tab = new Panel();
                tab.Title = "Tab 2";
                tabPanel.Items.Add(tab);

                tab = new Panel();
                tab.Title = "Tab 3";
                tabPanel.Items.Add(tab);

                tabPanel.ActiveTabIndex = 0;

                region.Collapsible = false;
            }
        }
Example #12
0
        internal void AddItem(Type type, BorderLayoutRegion region)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {

                PanelBase item = (PanelBase)host.CreateComponent(type);

                if (item != null)
                {
                    InitializeItem(item, region);
                    IComponentChangeService changeService =
                        (IComponentChangeService)GetService(typeof(IComponentChangeService));

                    try
                    {
                        changeService.OnComponentChanging(region, TypeDescriptor.GetProperties(region)["Items"]);
                        region.Items.Clear();
                        region.Items.Add(item);
                    }
                    finally
                    {
                        changeService.OnComponentChanged(region, TypeDescriptor.GetProperties(region)["Items"], null,
                                                         null);
                    }
                }
                this.Tag.SetDirty(true);
                this.UpdateDesignTimeHtml();
            }
        }
Example #13
0
 internal void AddTabPanel(BorderLayoutRegion region)
 {
     this.AddItem(typeof(TabPanel), region);
 }
Example #14
0
        private static void CollapsePanel(BorderLayoutRegion region, bool collapse)
        {
            Component panel = region.Items[0];

            PropertyDescriptor collapsed = TypeDescriptor.GetProperties(panel)["Collapsed"];

            if (collapsed != null)
            {
                collapsed.SetValue(panel, collapse);

                if (ReflectionUtils.IsTypeOf(panel, typeof(PanelBase), false))
                {
                    ((PanelBase)panel).Collapsed = collapse;
                }
            }
        }
Example #15
0
        private Control BuildStub(BorderLayoutRegion region, Unit height, Unit width, bool buildUnsupported)
        {
            StringBuilder sb = new StringBuilder(256);
            sb.AppendFormat(this.beginStub, region.Items.Count == 0 ? disabledColor : activeColor);

            string startRegionTemplate, emptyRegionTemplate;

            startRegionTemplate = this.startRegion;

            if (region.Region == RegionPosition.North || region.Region == RegionPosition.South)
            {
                emptyRegionTemplate = this.emptyNorthSouthRegion;
            }
            else
            {
                emptyRegionTemplate = this.emptyWestEastRegion;
            }

            sb.AppendFormat(startRegionTemplate, region.Region);

            if (!buildUnsupported)
            {
                if (region.Items.Count == 0)
                {
                    sb.AppendFormat(emptyRegionTemplate,
                                    GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.AddPanel),
                                    GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.AddTabPanel));
                }
                else
                {
                    if (region.Region != RegionPosition.Center)
                    {
                        sb.AppendFormat(this.existsRegion,
                                        GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.ClearRegion));
                    }
                    else
                    {
                        if (region.Items[0] is Panel)
                        {
                            sb.AppendFormat(this.changeToTabPanel,
                                        GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.ChangeToTabPanel));
                        }
                        else if (region.Items[0] is TabPanel)
                        {
                            sb.AppendFormat(this.changeToPanel,
                                        GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.ChangeToPanel));
                        }
                    }
                }

                if (region.Region == RegionPosition.Center && this.SchemeMode)
                {
                    sb.AppendFormat(this.turnOffScheme,
                                    GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.TurnOffScheme));
                }
            }
            else
            {
                sb.Append("Unsupported Design-Time Control");
            }

            sb.Append(this.endRegion);

            sb.Append(this.endStub);

            return new LiteralControl(sb.ToString());
        }
Example #16
0
        private Control BuildRegion(BorderLayoutRegion region, Unit width, Unit height)
        {
            if (!this.SchemeMode && region.Items.Count > 0)
            {
                Component item = region.Items[0];

                if (ReflectionUtils.IsTypeOf(item, typeof(PanelBase), false))
                {
                    this.AddIcon(((PanelBase)item).Icon); 
                }
                
                
                PanelBaseDesigner designer;

                if (ReflectionUtils.IsTypeOf(item, typeof(Panel), false))
                {
                    designer = new PanelDesigner();
                }
                else if (ReflectionUtils.IsTypeOf(item, typeof(TabPanel), false))
                {
                    designer = new TabPanelDesigner();
                }
                else
                {
                    return BuildStub(region, height, width, true);
                }

                designer.Width = width;

                if (region == this.layout.North || region == this.layout.South)
                {
                    designer.Height = height;
                }
                designer.Layout = LayoutType.Border;
                designer.BorderRegion = region;

                designer.CurrentDesigner = this.CurrentDesigner;
                designer.Initialize(item);

                return new LiteralControl(designer.GetDesignTimeHtml(this.designerRegions));
            }
            else
            {
                return BuildStub(region, height, width, false);
            }
        }
Example #17
0
        private Control BuildCollapsedRegion(BorderLayoutRegion region)
        {
            string template =
                    "<div class=\"x-layout-collapsed x-layout-collapsed-{0}\" style=\"position: static; visibility:visible;{1}\"><a {2}><div class=\"x-tool x-tool-expand-{0}\"></div></a></div>";
            string style;

            if (region.Region == RegionPosition.North || region.Region == RegionPosition.South)
            {
                style = "height:22px;width:auto;";

            }
            else
            {
                style = "height:100%;width:22px;";
            }

            LiteralControl res =
                new LiteralControl(
                    string.Format(template, region.Region.ToString().ToLower(), style,
                                  GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.Expand)));

            this.AddEmptyRegion();

            return res;
        }
Example #18
0
        private Control BuildStub(BorderLayoutRegion region, Unit height, Unit width, bool buildUnsupported)
        {
            StringBuilder sb = new StringBuilder(256);

            sb.AppendFormat(this.beginStub, region.Items.Count == 0 ? disabledColor : activeColor);

            string startRegionTemplate, emptyRegionTemplate;

            startRegionTemplate = this.startRegion;

            if (region.Region == RegionPosition.North || region.Region == RegionPosition.South)
            {
                emptyRegionTemplate = this.emptyNorthSouthRegion;
            }
            else
            {
                emptyRegionTemplate = this.emptyWestEastRegion;
            }

            sb.AppendFormat(startRegionTemplate, region.Region);

            if (!buildUnsupported)
            {
                if (region.Items.Count == 0)
                {
                    sb.AppendFormat(emptyRegionTemplate,
                                    GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.AddPanel),
                                    GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.AddTabPanel));
                }
                else
                {
                    if (region.Region != RegionPosition.Center)
                    {
                        sb.AppendFormat(this.existsRegion,
                                        GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.ClearRegion));
                    }
                    else
                    {
                        if (region.Items[0] is Panel)
                        {
                            sb.AppendFormat(this.changeToTabPanel,
                                            GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.ChangeToTabPanel));
                        }
                        else if (region.Items[0] is TabPanel)
                        {
                            sb.AppendFormat(this.changeToPanel,
                                            GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.ChangeToPanel));
                        }
                    }
                }

                if (region.Region == RegionPosition.Center && this.SchemeMode)
                {
                    sb.AppendFormat(this.turnOffScheme,
                                    GetDesignerRegionAttribute(region.Region, BorderLayoutClickAction.TurnOffScheme));
                }
            }
            else
            {
                sb.Append("Unsupported Design-Time Control");
            }

            sb.Append(this.endRegion);

            sb.Append(this.endStub);

            return(new LiteralControl(sb.ToString()));
        }
Example #19
0
 internal void AddTabPanel(BorderLayoutRegion region)
 {
     this.AddItem(typeof(TabPanel), region);
 }
Example #20
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);
        }