Inheritance: ContainerBase, IIcon, IXPostBackDataHandler
Exemple #1
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;
            }
        }
Exemple #2
0
        public void RemovePanel()
        {
            int oldIndex = this.layout.ExpandedPanelIndex;

            if (this.layout.ExpandedPanelIndex > -1)
            {
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                if (host != null)
                {
                    using (DesignerTransaction dt = host.CreateTransaction("Remove Panel"))
                    {
                        IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
                        PanelBase panel = this.layout.Items[oldIndex] as PanelBase;

                        try
                        {
                            changeService.OnComponentChanging(this.layout, TypeDescriptor.GetProperties(this.layout)["Items"]);
                            this.layout.Items.Remove(panel);

                            if (this.layout.Items.Count > 0)
                            {
                                PanelBase activeItem =
                                    this.layout.Items[Math.Min(oldIndex, this.layout.Items.Count - 1)] as PanelBase;

                                this.ExpandItem(activeItem);
                            }
                        }
                        finally
                        {
                            changeService.OnComponentChanged(this.layout, TypeDescriptor.GetProperties(this.layout)["Items"], null, null);
                        }

                        panel.Dispose();

                        this.UpdateDesignTimeHtml();
                        dt.Commit();
                    }
                    this.Tag.SetDirty(true);
                }
            }
        }
Exemple #3
0
        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);
                }
            }
        }
Exemple #4
0
        private void InitializeItem(PanelBase item)
        {
            item.Title = "Title";

            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;
            }
        }
Exemple #5
0
        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();
            }
        }
Exemple #6
0
        public override string XGetDesignTimeHtml(DesignerRegionCollection regions)
        {
            StringBuilder sb = new StringBuilder(256);

            designerRegions = regions;

            EditableDesignerRegion editableDesignerRegion = new EditableDesignerRegion(CurrentDesigner, "Body_" + this.layout.ExpandedPanelIndex);

            designerRegions.Add(editableDesignerRegion);

            sb.AppendFormat("<div style='width:100%;height:100%;margins:0px;padding-addToStart:0px;padding-right:0px;padding-left:0px;padding-bottom:{0}px;'>", 23 * this.layout.Items.Count);

            bool wasExpaned = false;

            for (int i = 0; i < this.layout.Items.Count; i++)
            {
                PanelBase item = this.layout.Items[i] as PanelBase;

                this.AddIcon(item.Icon);

                sb.Append("<div class='x-panel ");

                if (!item.Border)
                {
                    sb.Append("x-panel-noborder ");
                }

                if (item.Collapsed || wasExpaned)
                {
                    SetCollapsed(item, true);
                    sb.Append("x-panel-collapsed");
                }
                else
                {
                    wasExpaned = true;
                }

                sb.Append("' style='width:auto;'>");

                sb.AppendFormat("<a href='#' {0}><div class='x-panel-header ", GetDesignerRegionAttribute(i));

                if (!item.Border)
                {
                    sb.Append("x-panel-header-noborder ");
                }

                sb.Append("x-accordion-hd'>");

                sb.Append("<div class='x-tool x-tool-toggle'></div>");

                string iconCls = item.IconCls;

                if (iconCls.IsNotEmpty())
                {
                    string s =
                        this.GetWebResourceUrl(
                            "Ext.Net.Build.Ext.Net.extjs.resources.images.default.s.gif");
                    sb.AppendFormat("<img class='x-panel-inline-icon {0}'src='{1}'/>", iconCls, s);
                }

                sb.AppendFormat("<span class='x-panel-header-text' style='text-decoration:none;'>{0}</span>", item.Title.IsEmpty() ? "&nbsp;" : item.Title);

                sb.Append("</div></a>");

                if (!item.Collapsed)
                {
                    sb.AppendFormat(@"<div class='x-panel-bwrap' style='DISPLAY: block; LEFT: auto; VISIBILITY: visible; POSITION: static; TOP: auto'>
                                    <div class='x-panel-body {0}' style='width:auto;height:100%;padding:0px;margins:0px;' {1}></div>
                                    </div>", item.Border ? "" : "x-panel-body-noborder", GetEditableDesignerRegionAttribute());
                }

                sb.Append("</div>");
            }

            sb.Append("</div>");

            return(sb.ToString() + this.GetIconStyleBlock());
        }
        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;
            }
        }
Exemple #8
0
        private void AddTab(InsertMode mode)
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                PanelBase tab = (PanelBase)host.CreateComponent(typeof(PanelBase));

                if (tab != null)
                {
                    //this.tabPanelControl.EnsureTabs();

                    IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

                    try
                    {
                        changeService.OnComponentChanging(this.tabPanelControl, TypeDescriptor.GetProperties(this.tabPanelControl)["Tabs"]);

                        switch (mode)
                        {
                        case InsertMode.Begin:
                            this.tabPanelControl.Items.Insert(0, tab);
                            break;

                        case InsertMode.End:
                            this.tabPanelControl.Items.Add(tab);
                            break;

                        case InsertMode.AfterActive:
                            if (ActiveTabIndexIsValid)
                            {
                                this.tabPanelControl.Items.Insert(this.tabPanelControl.ActiveTabIndex + 1, tab);
                            }
                            else
                            {
                                this.tabPanelControl.Items.Add(tab);
                            }
                            break;

                        default:
                            throw new ArgumentOutOfRangeException("mode");
                        }
                    }
                    finally
                    {
                        changeService.OnComponentChanged(this.tabPanelControl, TypeDescriptor.GetProperties(this.tabPanelControl)["Tabs"], null, null);
                    }
                    PropertyDescriptor activeTab = TypeDescriptor.GetProperties(this.tabPanelControl)["ActiveTabIndex"];

                    int newActiveTab;

                    switch (mode)
                    {
                    case InsertMode.Begin:
                        newActiveTab = 0;
                        break;

                    case InsertMode.End:
                        newActiveTab = this.tabPanelControl.Items.Count - 1;
                        break;

                    case InsertMode.AfterActive:
                        if (ActiveTabIndexIsValid)
                        {
                            newActiveTab = this.tabPanelControl.ActiveTabIndex + 1;
                        }
                        else
                        {
                            newActiveTab = this.tabPanelControl.Items.Count - 1;
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("mode");
                    }

                    activeTab.SetValue(this.tabPanelControl, newActiveTab);
                    this.tabPanelControl.ActiveTabIndex = newActiveTab;
                }

                this.UpdateDesignTimeHtml();

                this.Tag.SetDirty(true);
            }
        }
Exemple #9
0
        private HtmlGenericControl BuildTabs(TabPosition position)
        {
            HtmlGenericControl header = new HtmlGenericControl("div");
            StringBuilder      headerClass;

            if (position == TabPosition.Top)
            {
                headerClass = new StringBuilder("x-tab-panel-header");
            }
            else
            {
                headerClass = new StringBuilder("x-tab-panel-footer");
            }

            if (!this.tabPanelControl.Border)
            {
                if (position == TabPosition.Top)
                {
                    headerClass.Append(" x-tab-panel-header-noborder");
                }
                else
                {
                    headerClass.Append(" x-tab-panel-footer-noborder");
                }
            }

            if (this.tabPanelControl.Plain && position == TabPosition.Top)
            {
                headerClass.Append(" x-tab-panel-header-plain");
            }

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                headerClass.Append(" x-tab-scrolling");
            }

            header.Attributes["class"] = headerClass.ToString();

            double headerWidth = 0;

            if (this.tabPanelControl.Width != Unit.Empty)
            {
                headerWidth           = this.tabPanelControl.Width.Value - (this.tabPanelControl.Border ? 2 : 0);
                header.Style["width"] = "{0}px".FormatWith(headerWidth.ToString());
            }
            else
            {
                header.Style["width"] = "auto";
            }

            //header.Style["MozUserSelect"] = "none";
            //header.Style["KhtmlUserSelect"] = "none";

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                HtmlGenericControl scrollRight = new HtmlGenericControl("div");
                scrollRight.Attributes["class"] = "x-tab-scroller-right x-unselectable";
                //scrollRight.Style["MozUserSelect"] = "none";
                //scrollRight.Style["KhtmlUserSelect"] = "none";
                int h = 22 - (this.tabPanelControl.Plain ? 1 : 0);

                //foreach (Tab tab in tabPanelControl.Items)
                //{
                //    if (tab.Closable)
                //    {
                //        if (ActiveTabIndexIsValid && this.tabPanelControl.Items[this.tabPanelControl.ActiveTabIndex].Closable)
                //        {
                //            h--;
                //        }
                //        break;
                //    }
                //}

                scrollRight.Style["height"] = h + "px";
                header.Controls.Add(scrollRight);

                HtmlGenericControl scrollLeft = new HtmlGenericControl("div");
                scrollLeft.Attributes["class"] = "x-tab-scroller-left x-unselectable";
                //scrollLeft.Style["MozUserSelect"] = "none";
                //scrollLeft.Style["KhtmlUserSelect"] = "none";
                scrollLeft.Style["height"] = h + "px";
                header.Controls.Add(scrollLeft);
            }

            HtmlGenericControl stripWrap = new HtmlGenericControl("div");

            stripWrap.Attributes["class"] = "x-tab-strip-wrap";
            stripWrap.Style["width"]      = "auto";

            if (this.tabPanelControl.EnableTabScroll && position == TabPosition.Top)
            {
                if (this.tabPanelControl.Width != Unit.Empty)
                {
                    stripWrap.Style["width"] = "{0}px".FormatWith((headerWidth - 36).ToString());
                }
            }

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            if (position == TabPosition.Top)
            {
                ul.Attributes["class"] = "x-tab-strip x-tab-strip-top";
            }
            else
            {
                ul.Attributes["class"] = "x-tab-strip x-tab-strip-bottom";
            }

            //ul.Style["width"] = "100%";
            ul.Style["width"]  = "auto! important";
            ul.Style["height"] = "21px";

            int activeIndex = tabPanelControl.ActiveTabIndex;

            for (int i = 0; i < tabPanelControl.Items.Count; i++)
            {
                PanelBase tabControl = this.tabPanelControl.Items[i] as PanelBase;

                this.AddIcon(tabControl.Icon);

                bool IsActive          = i == activeIndex;
                HtmlGenericControl tab = new HtmlGenericControl("li");

                //tab.Style["height"] = "100%";

                StringBuilder tabClass = new StringBuilder();

                if (tabControl.Closable)
                {
                    tabClass.Append("x-tab-strip-closable");
                }

                if (tabControl.Disabled)
                {
                    tabClass.Append(" x-item-disabled");
                }

                if (tabControl.IconClsProxy.IsNotEmpty())
                {
                    tabClass.Append(" x-tab-with-icon");
                }

                if (IsActive)
                {
                    tabClass.Append(" x-tab-strip-active");
                }

                tab.Attributes["class"] = tabClass.ToString();

                HtmlAnchor tabRight = new HtmlAnchor();
                tabRight.Attributes["class"] = "x-tab-right";

                designerRegions.Add(new DesignerRegion(CurrentDesigner, this.BuildChangeTabSignature(i), false));
                tabRight.Attributes[DesignerRegion.DesignerRegionAttributeName] = (designerRegions.Count - 1).ToString();

                HtmlGenericControl tabLeft = new HtmlGenericControl("em");
                tabLeft.Attributes["class"] = "x-tab-left";

                HtmlGenericControl stripInner = new HtmlGenericControl("span");
                stripInner.Attributes["class"] = "x-tab-strip-inner";

                HtmlGenericControl stripText = new HtmlGenericControl("span");

                if (tabControl.IconClsProxy.IsNotEmpty())
                {
                    stripText.Attributes["class"] = "x-tab-strip-text {0}".FormatWith(tabControl.IconClsProxy);
                }
                else
                {
                    stripText.Attributes["class"] = "x-tab-strip-text";
                }

                stripText.InnerHtml = tabControl.Title.IsEmpty() ? "&nbsp;" : tabControl.Title;

                if (tabControl.Closable)
                {
                    HtmlGenericControl stripClose = new HtmlGenericControl("a");
                    stripClose.Attributes["class"] = "x-tab-strip-close";
                    stripClose.Style["position"]   = "none";
                    //tab.Controls.Add(stripClose);
                    stripText.Controls.Add(stripClose);
                }

                stripInner.Controls.Add(stripText);
                tabLeft.Controls.Add(stripInner);
                tabRight.Controls.Add(tabLeft);
                tab.Controls.Add(tabRight);
                ul.Controls.Add(tab);
            }


            HtmlGenericControl edge = new HtmlGenericControl("li");

            edge.Attributes["class"] = "x-tab-edge";
            ul.Controls.Add(edge);

            HtmlGenericControl clear = new HtmlGenericControl("div");

            clear.Attributes["class"] = "x-clear";
            ul.Controls.Add(clear);

            stripWrap.Controls.Add(ul);
            header.Controls.Add(stripWrap);

            HtmlGenericControl stripSpacer = new HtmlGenericControl("div");

            stripSpacer.Attributes["class"] = "x-tab-strip-spacer";
            header.Controls.Add(stripSpacer);

            return(header);
        }
Exemple #10
0
        private void InitializeItem(PanelBase item)
        {
            item.Title = "Title";

            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;
            }
        }
Exemple #11
0
        public override string XGetDesignTimeHtml(DesignerRegionCollection regions)
        {
            StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);

            this.htmlWriter = new HtmlTextWriter(writer);

            designerRegions = regions;

            StringBuilder sb = new StringBuilder(256);

            if (this.fitLayout.Items.Count == 0)
            {
                sb.Append(begin);

                object[] prms = new object[]
                {
                    this.GetWebResourceUrl("Ext.Net.Build.Ext.Net.icons.add.png"),
                    this.GetDesignerRegionAttribute(FitLayoutClickAction.AddPanel),
                    this.GetDesignerRegionAttribute(FitLayoutClickAction.AddTabPanel)
                };

                sb.AppendFormat(content, prms);
                sb.Append(end);
            }
            else
            {
                PanelBase         item = this.fitLayout.Items[0] as PanelBase;
                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(unsupported);
                }

                designer.Width = Unit.Percentage(100);

                designer.Layout = LayoutType.Fit;

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

                int addBottomMargins = 27;// +(this.fitLayout.Items[0] is TabPanel ? 2 : 0);

                if (item.Collapsible && item.Collapsed && item is Panel)
                {
                    addBottomMargins = 0;
                }

                sb.AppendFormat("<div style='width:100%;height:auto;margins:0;padding-bottom:{0}px;'>",
                                addBottomMargins);
                sb.AppendFormat(designer.GetDesignTimeHtml(designerRegions));
                sb.Append(this.GetIconStyleBlock() + "</div>");
            }

            return(sb.ToString());
        }
Exemple #12
0
        private void ExpandItem(PanelBase item)
        {
            foreach (PanelBase panel in this.layout.Items)
            {
                if (!panel.Collapsed)
                {
                    TypeDescriptor.GetProperties(panel)["Collapsed"].SetValue(panel, true);
                    panel.Collapsed = true;
                }
            }

            TypeDescriptor.GetProperties(item)["Collapsed"].SetValue(item, false);
            item.Collapsed = false;
        }
Exemple #13
0
 private static void SetCollapsed(PanelBase item, bool collapse)
 {
     PropertyDescriptor collapsed = TypeDescriptor.GetProperties(item)["Collapsed"];
     collapsed.SetValue(item, collapse);
     item.Collapsed = collapse;
 }