Example #1
0
        public override string GetEditableDesignerRegionContent(EditableDesignerRegion region)
        {
            if (region == null)
            {
                throw new ArgumentNullException("region");
            }

            string regionName = region.Name;

            Debug.Assert(regionName[0] == 'c' || regionName[0] == 'h', "Expected regionName to start with c or h, not " + regionName);

            // is it a content template or a header?
            //
            bool content = regionName[0] == 'c';

            regionName = regionName.Substring(1);

            TabPanel activeTab = (TabPanel)TabContainer.FindControl(regionName);

            Debug.Assert(activeTab != null, "Couldn't find tab " + regionName);

            return(GetTabContent(activeTab, content));
        }
Example #2
0
        private void OnAddTabPanel()
        {
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                TabContainer tc = TabContainer;

                using (DesignerTransaction dt = host.CreateTransaction("Add new TabPanel"))
                {
                    TabPanel tp = (TabPanel)host.CreateComponent(typeof(TabPanel));

                    if (tp != null)
                    {
                        // set up the inital state
                        //
                        tp.ID         = GetUniqueName(typeof(TabPanel), tc);
                        tp.HeaderText = tp.ID;
                        IComponentChangeService changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

                        try
                        {
                            changeService.OnComponentChanging(tc, TypeDescriptor.GetProperties(tc)["Tabs"]);
                            tc.Tabs.Add(tp);
                        }
                        finally
                        {
                            changeService.OnComponentChanged(tc, TypeDescriptor.GetProperties(tc)["Tabs"], tc.Tabs, tc.Tabs);
                        }
                        TypeDescriptor.GetProperties(tc)["ActiveTab"].SetValue(tc, tp);
                        CurrentTabID = tp.ID;
                    }
                    dt.Commit();
                }
            }
        }
 /// <summary>
 /// Helper method to save the value of a template.  This sets up all the right Undo state.
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="host"></param>
 /// <param name="template"></param>
 /// <param name="propertyName"></param>
 private static void PersistTemplate(TabPanel panel, IDesignerHost host, ITemplate template, string propertyName)
 {
     PropertyDescriptor descriptor = TypeDescriptor.GetProperties(panel)[propertyName];
     using (DesignerTransaction transaction = host.CreateTransaction("SetEditableDesignerRegionContent"))
     {
         descriptor.SetValue(panel, template);
         transaction.Commit();
     }
 }
 private static void PersistTemplateContent(TabPanel panel, IDesignerHost host, string content, string propertyName)
 {
     ITemplate template = ControlParser.ParseTemplate(host, content);
     PersistTemplate(panel, host, template, propertyName);
 }
 /// <summary>
 /// Get the content for a given tab or header
 /// </summary>
 /// <param name="tab">The tab to search</param>
 /// <param name="content">True for ContentTemplate, otherwise it'll do HeaderTemplate</param>
 /// <returns></returns>
 private string GetTabContent(TabPanel tab, bool content)            
 {
     if (tab != null)
     {
         if (content && tab.ContentTemplate != null)
         {
             return GetTemplateContent(tab.ContentTemplate, "_content");
         }
         else if (!content)
         {
             if (tab.HeaderTemplate != null)
             {
                 return GetTemplateContent(tab.HeaderTemplate, "_header");
             }                    
             return tab.HeaderText;
         }
     }
     return "";
 }
Example #6
0
        private static void PersistTemplateContent(TabPanel panel, IDesignerHost host, string content, string propertyName)
        {
            ITemplate template = ControlParser.ParseTemplate(host, content);

            PersistTemplate(panel, host, template, propertyName);
        }