public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { IDesignerHost service = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); if (service != null) { if (region.Name == "Content") { Tab tab = CurrentControl.Tabs[CurrentControl.ActiveTabIndex]; Control[] parsedControls = ControlParser.ParseControls(service, content); tab.Items.Clear(); for (int i = 0, length = parsedControls.Length; i < length; i++) { ControlBase c = parsedControls[i] as ControlBase; if (c != null) { tab.Items.Add(c); } } //CurrentControl.Tabs[CurrentControl.ActiveTabIndex] = ControlParser.ParseControls(service, content)[0] as Tab; } } }
private Control ParseControlAndSources(ref int i, ref List <PsdLayerExtractor.Layer> layers, ControlParser pa) { var layer = layers[i]; if (!layer.canLoadLayer) { return(null); } var control = null as Control; var list = new List <Control>(); for (; i < layers.Count; ++i) { layer = layers[i]; if (!layer.canLoadLayer) { continue; } pa = new ControlParser(pa.srcFileDirPath, layer); if (list.Count > 0 && list[0].name != pa.name) { i--; break; } var source = null as Control; if (layer.isContainer) { source = new Control(pa); this.ParseImple(source, pa.srcFileDirPath, layer.children); } else { source = new Control(pa); } if (list.Find(s => s.fullName == pa.fullName) != null) { i--; break; } list.Add(source); } if (list.Count > 0) { control = list.Find((a) => a.command.Contains(".normal") || a.command.Contains(".bg")); if (control == null) { list.Sort((a, b) => string.Compare(a.command, b.command)); control = list[0]; } control.sources = list; } return(control); }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { IDesignerHost service = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); if (service != null) { Control[] parsedControls = ControlParser.ParseControls(service, content); if (region.Name == "Items") { CurrentControl.Items.Clear(); for (int i = 0; i < parsedControls.Length; i++) { ControlBase c = parsedControls[i] as ControlBase; if (c != null) { CurrentControl.Items.Add(c); } } } else if (region.Name == "Toolbars") { CurrentControl.Toolbars.Clear(); for (int i = 0; i < parsedControls.Length; i++) { Toolbar c = parsedControls[i] as Toolbar; if (c != null) { CurrentControl.Toolbars.Add(c); } } } } }
public ITemplate ConvertToTemplate() { ITemplate template = null; ITemplate template2 = this.GetTemplate(this.ViewControl); if (template2 != null) { return(template2); } this._designer.ViewControlCreated = false; Hashtable data = new Hashtable(1); data.Add("ConvertToTemplate", true); this.ViewControl.SetDesignModeState(data); this._designer.GetDesignTimeHtml(); Control defaultTemplateContents = this.GetDefaultTemplateContents(); this.SetFailureTextStyle(defaultTemplateContents); this.ConvertPersistedControlsToLiteralControls(defaultTemplateContents); StringWriter writer = new StringWriter(CultureInfo.CurrentCulture); HtmlTextWriter writer2 = new HtmlTextWriter(writer); defaultTemplateContents.RenderControl(writer2); template = ControlParser.ParseTemplate(this._designerHost, writer.ToString()); Hashtable hashtable2 = new Hashtable(1); hashtable2.Add("ConvertToTemplate", false); this.ViewControl.SetDesignModeState(hashtable2); return(template); }
// Create a template from the content string and put it // in the selected view. Called by the designer host public override void SetEditableDesignerRegionContent(EditableDesignerRegion Region, string content) { if (content == null) { return; } // Get a reference to the designer host System.ComponentModel.Design.IDesignerHost host = (System.ComponentModel.Design.IDesignerHost)(Component.Site.GetService(typeof(System.ComponentModel.Design.IDesignerHost))); if (host != null) { // Create a template from the content string ITemplate template = ControlParser.ParseTemplate(host, content); if (template != null) { switch (Region.Name) { case "FirstPanel": Control.FirstPanel = template; break; case "SecondPanel": Control.SecondPanel = template; break; } } } }
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 == 2 && parameters[0] == "Body") { int index = int.Parse(parameters[1]); if (this.tabPanelControl != null && this.tabPanelControl.Items.Count > 0) { PanelBase tab = this.tabPanelControl.Items[index] as PanelBase; if (tab != null && tab is IContent) { ITemplate template = ControlParser.ParseTemplate(host, content); ((IContent)tab).Content = template; } this.Tag.SetDirty(true); } } } }
// Create a template from the content string and // put it in the selected view. public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { if (content == null) { return; } // Get a reference to the designer host IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { // Create a template from the content string ITemplate template = ControlParser.ParseTemplate(host, content); // Determine which region should get the template // Either 'Content0' or 'Content1' if (region.Name.EndsWith("0")) { myControl.View1 = template; } else if (region.Name.EndsWith("1")) { myControl.View2 = template; } } }
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 == 2 && parameters[0] == "Body") { int index = int.Parse(parameters[1]); if (this.layout.Items.Count > 0) { ContentPanel panel = this.layout.Items[index] as ContentPanel; if (panel != null) { ITemplate template = ControlParser.ParseTemplate(host, content); panel.Body = template; } Tag.SetDirty(true); } } } }
/// <summary> /// SkinFileProcessor class constructor. /// </summary> /// <remarks> /// This constructor parses a memory based skin /// </remarks> public SkinFileProcessor(string ControlKey, string ControlSrc) { m_ControlList.Add(ControlKey, ControlSrc); // Instantiate the control parser with the list of skin objects m_ControlFactory = new ControlParser(m_ControlList); }
public static ControlParser Instance() { if (mInstance == null) { mInstance = new ControlParser(); } return mInstance; }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(base.Component)[region.Name]; IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); ITemplate template = ControlParser.ParseTemplate(service, content); using (DesignerTransaction transaction = service.CreateTransaction("SetEditableDesignerRegionContent")) { descriptor.SetValue(base.Component, template); transaction.Commit(); } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { if (content == null) { return; } IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { ITemplate template = ControlParser.ParseTemplate(host, content); if (template == null) { this.viewPort.Content = template; this.viewPort.ContentContainer.Controls.Clear(); this.ChangeService(); return; } Control control = ControlParser.ParseControl(host, content); if (control is Layout) { bool needRefresh = this.viewPort.LayoutControl == null; this.viewPort.Content = template; this.viewPort.ContentContainer.Controls.Clear(); this.viewPort.ContentContainer.Controls.Add(control); if (needRefresh) { this.ChangeService(); } } else { /* * NOTE: We need to call ChangeService for clear content template if user drop not layout * But if control have ActionList then after drop this ActionList will be shown * If we call ChangeService at this moment than VS will crash because trying show * ActionList not exists control * * Need find solution for fixed it */ // this.ChangeService(); } } }
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); } } } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { ITemplate template = ControlParser.ParseTemplate(host, content); if (template != null) { _Control.Content = template; } } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { if (content == null) { return; } IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { ITemplate template = ControlParser.ParseTemplate(host, content); ((ContentPanel)this.Control).Body = template; } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { LoginViewDesignerRegion region2 = region as LoginViewDesignerRegion; if (region2 != null) { IDesignerHost service = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); ITemplate template = ControlParser.ParseTemplate(service, content); using (DesignerTransaction transaction = service.CreateTransaction("SetEditableDesignerRegionContent")) { region2.PropertyDescriptor.SetValue(region2.Object, template); transaction.Commit(); } region2.Template = template; } }
internal static ITemplate GetTemplate(DataBoundControl control, string templateContent) { try { IDesignerHost service = (IDesignerHost)control.Site.GetService(typeof(IDesignerHost)); if ((templateContent != null) && (templateContent.Length > 0)) { return(ControlParser.ParseTemplate(service, templateContent, null)); } return(null); } catch (Exception) { return(null); } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { IDesignerHost service = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); if (service != null) { int rowIndex = Convert.ToInt32(region.Properties["RowIndex"]); Control[] parsedControls = ControlParser.ParseControls(service, content); FormRow row = CurrentControl.Rows[rowIndex]; row.Items.Clear(); for (int i = 0, length = parsedControls.Length; i < length; i++) { ControlBase c = parsedControls[i] as ControlBase; if (c != null) { row.Items.Add(c); } } #region old code //int rowIndex = Convert.ToInt32(region.Properties["RowIndex"]); ////int columnIndex = Convert.ToInt32(region.Properties["ColumnIndex"]); //// 首先从字符串中把所有的 <td style='width:50%;'></td> 中的字符串抽取出来 //content = GetControlsString(content); //Control[] parsedControls = ControlParser.ParseControls(service, content); //CurrentControl.Rows[rowIndex].Controls.Clear(); //CurrentControl.Rows[rowIndex].Items.Clear(); //for (int i = 0, length = parsedControls.Length; i < length; i++) //{ // ControlBase c = parsedControls[i] as ControlBase; // if (c != null) // { // CurrentControl.Rows[rowIndex].Items.Add(c); // } //} #endregion } }
private void ParseImple(Control container, string srcFileDirPath, List <PsdLayerExtractor.Layer> layers) { for (var i = 0; i < layers.Count; ++i) { var layer = layers[i]; if (!layer.canLoadLayer) { continue; } var pa = new ControlParser(srcFileDirPath, layer); var control = this.ParseControlAndSources(ref i, ref layers, pa); if (control != null) { container.children.Add(control); } } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { IDesignerHost service = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); if (service != null) { Control[] parsedControls = ControlParser.ParseControls(service, content); CurrentControl.Controls.Clear(); for (int i = 0, length = parsedControls.Length; i < length; i++) { Control c = parsedControls[i] as Control; if (c != null) { CurrentControl.Controls.Add(c); } } } }
/// <summary> /// 设置设计态的内容 /// </summary> /// <param name="region"></param> /// <param name="content"></param> /// <remarks> /// 设置设计态的内容 /// </remarks> public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { if (content == null) { return; } IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { ITemplate template = ControlParser.ParseTemplate(host, content); if (template != null) { if (this.currentRegion == 0) { this.deluxeGrid.GridPagerTemplate = template; } } } }
// Displays a textbox form to receive an HTML // string that represents a control, and creates // a toolbox item for the control, if not already // present in the selected toolbox category. private void loadPersistedControl() { // Display a StringInputForm to obtain a persisted control string. StringInputForm inputForm = new StringInputForm(); if (inputForm.ShowDialog() != DialogResult.OK) { return; } if (inputForm.TBox.Text.Length < 2) { return; } // Obtain an IDesignerHost for the design-mode document. IDesignerHost host = (IDesignerHost) this.Component.Site.GetService(typeof(IDesignerHost)); //<Snippet2> // Create a Web control from the HTML markup. System.Web.UI.Control ctrl = ControlParser.ParseControl(host, inputForm.TBox.Text.Trim()); //</Snippet2> // Create a Web control toolbox item for the type of the control System.Web.UI.Design.WebControlToolboxItem item = new System.Web.UI.Design.WebControlToolboxItem(ctrl.GetType()); // Add the Web control toolbox item to the toolbox IToolboxService toolService = (IToolboxService) this.Component.Site.GetService(typeof(IToolboxService)); if (toolService != null) { toolService.AddToolboxItem(item); } else { throw new Exception("IToolboxService was not found."); } }
public override void SetEditableDesignerRegionContent(System.Web.UI.Design.EditableDesignerRegion Region, string content) { if (content == null) { return; } // Get a reference to the designer host IDesignerHost host = (IDesignerHost)(Component.Site.GetService(typeof(IDesignerHost))); if (host != null) { // Create a template from the content string ITemplate template = ControlParser.ParseTemplate(host, content); if (template != null) { // Determine which region should get the template Control.ContentTemplate = template; } } }
private bool ConvertToStaticTemplateChangeCallback(object context) { string templateText = null; string staticItemFormatString = this._menu.StaticItemFormatString; if ((staticItemFormatString != null) && (staticItemFormatString.Length != 0)) { templateText = "<%# Eval(\"Text\", \"" + staticItemFormatString + "\") %>"; } else { templateText = "<%# Eval(\"Text\") %>"; } IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { this._menu.StaticItemTemplate = ControlParser.ParseTemplate(service, templateText); } return(true); }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { var lvRegion = region as ReorderListDesignerRegion; if (lvRegion == null) { return; } var host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); Debug.Assert(host != null, "IDesignerHost is null."); var template = ControlParser.ParseTemplate(host, content); using (var transaction = host.CreateTransaction("SetEditableDesignerRegionContent")) { lvRegion.PropertyDescriptor.SetValue(lvRegion.Object, template); transaction.Commit(); } lvRegion.Template = template; }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { var region2 = region as EntityRightsViewDesignerRegion; if (region2 == null) { return; } var service = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); var template = ControlParser.ParseTemplate(service, content); using (var transaction = service.CreateTransaction("SetEditableDesignerRegionContent")) { region2.PropertyDescriptor.SetValue(region2.Object, template); transaction.Commit(); } region2.Template = template; }
public SkinFileProcessor(string SkinPath, string SkinRoot, string SkinName) { this.Message += SkinController.FormatMessage(INITIALIZE_PROCESSOR, SkinRoot + " :: " + SkinName, 0, false); m_SkinRoot = SkinRoot; m_SkinPath = SkinPath; m_SkinName = SkinName; string FileName = this.SkinPath + this.SkinRoot + "\\" + this.SkinName + "\\" + SkinRoot.Substring(0, SkinRoot.Length - 1) + ".xml"; if (File.Exists(FileName)) { try { this.SkinAttributes.Load(FileName); this.Message += SkinController.FormatMessage(PACKAGE_LOAD, Path.GetFileName(FileName), 2, false); } catch (Exception ex) { this.Message += SkinController.FormatMessage(string.Format(PACKAGE_LOAD_ERROR, ex.Message), Path.GetFileName(FileName), 2, true); } } string Token; foreach (SkinControlInfo objSkinControl in SkinControlController.GetSkinControls().Values) { Token = objSkinControl.ControlKey.ToUpper(); if (m_ControlList.ContainsKey(Token)) { this.Message += SkinController.FormatMessage(string.Format(DUPLICATE_ERROR, objSkinControl.ControlKey.ToString().ToUpper()), string.Format(DUPLICATE_DETAIL, (string)m_ControlList[Token], objSkinControl.ControlSrc.ToString()), 2, true); } else { this.Message += SkinController.FormatMessage(string.Format(LOAD_SKIN_TOKEN, objSkinControl.ControlKey.ToString().ToUpper()), objSkinControl.ControlSrc.ToString(), 2, false); m_ControlList.Add(Token, objSkinControl.ControlSrc); } } m_ControlFactory = new ControlParser(m_ControlList); m_ObjectFactory = new ObjectParser(m_ControlList); }
public override void SetEditableDesignerRegionContent (EditableDesignerRegion region, string content) { int regionIndex = Int32.Parse(region.Name.Substring(7)); if (content == null) { if (regionIndex == 0) { myControl.View1 = null; } else if (regionIndex == 1) { myControl.View2 = null; } return; } IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { ITemplate template = ControlParser.ParseTemplate(host, content); if (template != null) { if (regionIndex == 0) { myControl.View1 = template; } else if (regionIndex == 1) { myControl.View2 = template; } } } }
public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { string str = content; try { IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); Control[] controlArray = ControlParser.ParseControls(service, content); str = string.Empty; foreach (Control control in controlArray) { LiteralControl control2 = control as LiteralControl; if (control2 != null) { str = str + control2.Text; } } } catch { } TypeDescriptor.GetProperties(base.Component)["Text"].SetValue(base.Component, str); }
public override Control GetPreviewControl(Control runtimeControl) { Control previewControl = base.GetPreviewControl(runtimeControl); if (previewControl != null) { IDesignerHost service = (IDesignerHost)runtimeControl.Site.GetService(typeof(IDesignerHost)); DataList list = previewControl as DataList; if ((list == null) || (service == null)) { return(previewControl); } TemplateBuilder itemTemplate = list.ItemTemplate as TemplateBuilder; if (((itemTemplate != null) && (itemTemplate.Text.Length == 0)) || (list.ItemTemplate == null)) { string templateText = "####"; list.ItemTemplate = ControlParser.ParseTemplate(service, templateText); list.ItemStyle.HorizontalAlign = HorizontalAlign.Center; } list.HorizontalAlign = HorizontalAlign.Center; list.Width = new Unit(80.0, UnitType.Percentage); } return(previewControl); }
public override Control GetPreviewControl(Control runtimeControl) { Control previewControl = base.GetPreviewControl(runtimeControl); if (previewControl != null) { IDesignerHost service = (IDesignerHost)runtimeControl.Site.GetService(typeof(IDesignerHost)); FormView view = previewControl as FormView; if ((view == null) || (service == null)) { return(previewControl); } TemplateBuilder itemTemplate = view.ItemTemplate as TemplateBuilder; if (((itemTemplate != null) && (itemTemplate.Text.Length == 0)) || (view.ItemTemplate == null)) { string templateText = "#### ####<br/>#### ####<br/>#### ####<br/>#### ####"; view.ItemTemplate = ControlParser.ParseTemplate(service, templateText); view.RowStyle.HorizontalAlign = HorizontalAlign.Center; } view.HorizontalAlign = HorizontalAlign.Center; view.Width = new Unit(80.0, UnitType.Percentage); } return(previewControl); }
/// <summary> /// SkinFileProcessor class constructor. /// </summary> /// <param name="SkinPath">File path to the portals upload directory.</param> /// <param name="SkinRoot">Specifies type of skin (Skins or Containers)</param> /// <param name="SkinName">Name of folder in which skin will reside (Zip file name)</param> /// <remarks> /// The constructor primes the file processor with path information and /// control data that should only be retrieved once. It checks for the /// existentce of a skin level attribute file and read it in, if found. /// It also sorts through the complete list of controls and creates /// a hashtable which contains only the skin objects and their source paths. /// These are recognized by their ControlKey's which are formatted like /// tokens ("[TOKEN]"). The hashtable is required for speed as it will be /// processed for each token found in the source file by the Control Parser. /// </remarks> public SkinFileProcessor( string SkinPath, string SkinRoot, string SkinName ) { this.Message += SkinController.FormatMessage( INITIALIZE_PROCESSOR, SkinRoot + " :: " + SkinName, 0, false ); // Save path information for future use m_SkinRoot = SkinRoot; m_SkinPath = SkinPath; m_SkinName = SkinName; // Check for and read skin package level attribute information file string FileName = this.SkinPath + this.SkinRoot + "\\" + this.SkinName + "\\" + SkinRoot.Substring( 0, SkinRoot.Length - 1 ) + ".xml"; if( File.Exists( FileName ) ) { try { this.SkinAttributes.Load( FileName ); this.Message += SkinController.FormatMessage( PACKAGE_LOAD, Path.GetFileName( FileName ), 2, false ); } catch( Exception ex ) { // could not load XML file this.Message += SkinController.FormatMessage( string.Format( PACKAGE_LOAD_ERROR, ex.Message ), Path.GetFileName( FileName ), 2, true ); } } // Retrieve a list of available controls ModuleControlController objModuleControls = new ModuleControlController(); ArrayList arrModuleControls = objModuleControls.GetModuleControls( Null.NullInteger ); // Look at every control string Token; int i; ModuleControlInfo objModuleControl; for( i = 0; i <= arrModuleControls.Count - 1; i++ ) { objModuleControl = (ModuleControlInfo)arrModuleControls[i]; // If the control is a skin object, save the key and source in the hash table if( objModuleControl.ControlType == SecurityAccessLevel.SkinObject ) { Token = objModuleControl.ControlKey.ToUpper(); // If the control is already in the hash table if( m_ControlList.ContainsKey( Token ) ) { // Record an error message and skip it this.Message += SkinController.FormatMessage( string.Format( DUPLICATE_ERROR, objModuleControl.ControlKey.ToString().ToUpper() ), string.Format( DUPLICATE_DETAIL, ( (string)m_ControlList[Token] ), objModuleControl.ControlSrc.ToString() ), 2, true ); } else { // Add it this.Message += SkinController.FormatMessage( string.Format( LOAD_SKIN_TOKEN, objModuleControl.ControlKey.ToString().ToUpper() ), objModuleControl.ControlSrc.ToString(), 2, false ); m_ControlList.Add( Token, objModuleControl.ControlSrc ); } } } // Instantiate the control parser with the list of skin objects m_ControlFactory = new ControlParser( m_ControlList ); }
/// ----------------------------------------------------------------------------- /// <summary> /// SkinFileProcessor class constructor. /// </summary> /// <param name="SkinPath">File path to the portals upload directory.</param> /// <param name="SkinRoot">Specifies type of skin (Skins or Containers)</param> /// <param name="SkinName">Name of folder in which skin will reside (Zip file name)</param> /// <remarks> /// The constructor primes the file processor with path information and /// control data that should only be retrieved once. It checks for the /// existentce of a skin level attribute file and read it in, if found. /// It also sorts through the complete list of controls and creates /// a hashtable which contains only the skin objects and their source paths. /// These are recognized by their ControlKey's which are formatted like /// tokens ("[TOKEN]"). The hashtable is required for speed as it will be /// processed for each token found in the source file by the Control Parser. /// </remarks> /// <history> /// [willhsc] 3/3/2004 Created /// </history> /// ----------------------------------------------------------------------------- public SkinFileProcessor(string SkinPath, string SkinRoot, string SkinName) { Message += SkinController.FormatMessage(INITIALIZE_PROCESSOR, SkinRoot + " :: " + SkinName, 0, false); //Save path information for future use m_SkinRoot = SkinRoot; m_SkinPath = SkinPath; m_SkinName = SkinName; //Check for and read skin package level attribute information file string FileName = this.SkinPath + this.SkinRoot + "\\" + this.SkinName + "\\" + SkinRoot.Substring(0, SkinRoot.Length - 1) + ".xml"; if (File.Exists(FileName)) { try { SkinAttributes.Load(FileName); Message += SkinController.FormatMessage(PACKAGE_LOAD, Path.GetFileName(FileName), 2, false); } catch (Exception ex) { //could not load XML file Logger.Error(ex); Message += SkinController.FormatMessage(string.Format(PACKAGE_LOAD_ERROR, ex.Message), Path.GetFileName(FileName), 2, true); } } //Look at every control string Token; foreach (SkinControlInfo objSkinControl in SkinControlController.GetSkinControls().Values) { Token = objSkinControl.ControlKey.ToUpper(); //If the control is already in the hash table if (m_ControlList.ContainsKey(Token)) { Message += SkinController.FormatMessage(string.Format(DUPLICATE_ERROR, objSkinControl.ControlKey.ToUpper()), string.Format(DUPLICATE_DETAIL, m_ControlList[Token], objSkinControl.ControlSrc), 2, true); } else { //Add it Message += SkinController.FormatMessage(string.Format(LOAD_SKIN_TOKEN, objSkinControl.ControlKey.ToUpper()), objSkinControl.ControlSrc, 2, false); m_ControlList.Add(Token, objSkinControl.ControlSrc); } } //Instantiate the control parser with the list of skin objects m_ControlFactory = new ControlParser(m_ControlList); //Instantiate the object parser with the list of skin objects m_ObjectFactory = new ObjectParser(m_ControlList); }
public Control() { this.pa = new ControlParser(); }
private Control ParseControlAndSources(ref int i, ref List<PsdLayerExtractor.Layer> layers, ControlParser pa) { var layer = layers[i]; if (!layer.canLoadLayer) return null; var control = null as Control; var list = new List<Control>(); for (; i<layers.Count; ++i) { layer = layers[i]; if (!layer.canLoadLayer) continue; pa = new ControlParser(pa.srcFileDirPath, layer); if (list.Count > 0 && list[0].name != pa.name) { i--; break; } var source = null as Control; if (layer.isContainer) { source = new Control(pa); this.ParseImple(source, pa.srcFileDirPath, layer.children); } else { source = new Control(pa); } if (list.Find(s => s.fullName == pa.fullName) != null) { i--; break; } list.Add(source); } if (list.Count > 0) { control = list.Find((a) => a.command.Contains(".normal") || a.command.Contains(".bg")); if (control == null) { list.Sort((a, b) => string.Compare(a.command, b.command)); control = list[0]; } control.sources = list; } return control; }
public SkinFileProcessor(string ControlKey, string ControlSrc) { m_ControlList.Add(ControlKey, ControlSrc); m_ControlFactory = new ControlParser(m_ControlList); m_ObjectFactory = new ObjectParser(m_ControlList); }
/// ----------------------------------------------------------------------------- /// <summary> /// SkinFileProcessor class constructor. /// </summary> /// <remarks> /// This constructor parses a memory based skin /// </remarks> /// <history> /// [cnurse] 3/21/2005 Created /// </history> /// ----------------------------------------------------------------------------- public SkinFileProcessor(string ControlKey, string ControlSrc) { m_ControlList.Add(ControlKey, ControlSrc); //Instantiate the control parser with the list of skin objects m_ControlFactory = new ControlParser(m_ControlList); //Instantiate the object parser with the list of skin objects m_ObjectFactory = new ObjectParser(m_ControlList); }
public Control(ControlParser pa) { this.pa = pa; }
private void ParseImple(Control container, string srcFileDirPath, List<PsdLayerExtractor.Layer> layers) { for ( var i=0; i<layers.Count; ++i) { var layer = layers[i]; if (!layer.canLoadLayer) continue; var pa = new ControlParser(srcFileDirPath, layer); var control = this.ParseControlAndSources(ref i, ref layers, pa); if (control != null) container.children.Add(control); } }