/// <summary>
        /// Gets the theme part.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        /// <remarks>
        /// added: Jes1111 - 2004/08/27
        /// Part of Zen support
        /// </remarks>
        public string GetThemePart(string name)
        {
            if (ThemeParts.ContainsKey(name))
            {
                ThemePart part = (ThemePart)ThemeParts[name];
                return(part.Html);
            }

            else
            {
                return(string.Empty);
            }
        }
예제 #2
0
        /// <summary>
        /// Loads the XML.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <returns>A bool value...</returns>
        private bool LoadXml(string filename)
        {
            XmlTextReader       _xtr = null;
            NameTable           _nt  = new NameTable();
            XmlNamespaceManager _nsm = new XmlNamespaceManager(_nt);

            _nsm.AddNamespace(string.Empty, "http://www.w3.org/1999/xhtml");
            XmlParserContext _context    = new XmlParserContext(_nt, _nsm, string.Empty, XmlSpace.None);
            bool             returnValue = false;

            try
            {
                // Create an XmlTextReader using a FileStream.
                using (Stream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        _xtr = new XmlTextReader(fs, XmlNodeType.Document, _context);
                        _xtr.WhitespaceHandling = WhitespaceHandling.None;
                        ThemeImage _myImage;
                        ThemePart  _myPart = new ThemePart();

                        while (!_xtr.EOF)
                        {
                            if (_xtr.MoveToContent() == XmlNodeType.Element)
                            {
                                switch (_xtr.LocalName)
                                {
                                case "Name":
                                    CurrentTheme.Name = _xtr.ReadString();
                                    break;

                                case "Type":
                                    CurrentTheme.Type = _xtr.ReadString();
                                    break;

                                case "Css":
                                    CurrentTheme.Css = _xtr.ReadString();
                                    break;

                                case "MinimizeColor":
                                    CurrentTheme.MinimizeColor = _xtr.ReadString();
                                    break;

                                case "ThemeImage":
                                    _myImage = new ThemeImage();

                                    while (_xtr.MoveToNextAttribute())
                                    {
                                        switch (_xtr.LocalName)
                                        {
                                        case "Name":
                                            _myImage.Name = _xtr.Value;
                                            break;

                                        case "ImageUrl":
                                            _myImage.ImageUrl = _xtr.Value;
                                            break;

                                        case "Width":
                                            _myImage.Width = double.Parse(_xtr.Value);
                                            break;

                                        case "Height":
                                            _myImage.Height = double.Parse(_xtr.Value);
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                    CurrentTheme.ThemeImages.Add(_myImage.Name, _myImage);
                                    _xtr.MoveToElement();
                                    break;

                                case "ThemePart":
                                    _myPart = new ThemePart();

                                    while (_xtr.MoveToNextAttribute())
                                    {
                                        switch (_xtr.LocalName)
                                        {
                                        case "Name":
                                            _myPart.Name = _xtr.Value;
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                    _xtr.MoveToElement();
                                    break;

                                case "HTML":

                                    if (_myPart.Name.Length != 0)
                                    {
                                        _myPart.Html = _xtr.ReadString();
                                    }
                                    //Moved here on load instead on retrival.
                                    //by Manu
                                    string w = string.Concat(CurrentTheme.WebPath, "/");
                                    _myPart.Html = _myPart.Html.Replace("src='", string.Concat("src='", w));
                                    _myPart.Html = _myPart.Html.Replace("src=\"", string.Concat("src=\"", w));
                                    _myPart.Html =
                                        _myPart.Html.Replace("background='", string.Concat("background='", w));
                                    _myPart.Html =
                                        _myPart.Html.Replace("background=\"", string.Concat("background=\"", w));
                                    CurrentTheme.ThemeParts.Add(_myPart.Name, _myPart);
                                    break;

                                default:
                                    //Debug.WriteLine(" - unwanted");
                                    break;
                                }
                            }
                            _xtr.Read();
                        }
                        returnValue = true;
                    }

                    catch (Exception ex)
                    {
                        ErrorHandler.Publish(LogLevel.Error,
                                             "Failed to Load XML Theme : " + filename + " Message was: " + ex.Message);
                    }

                    finally
                    {
                        fs.Close();
                    }
                }
            }

            catch (Exception ex)
            {
                ErrorHandler.Publish(LogLevel.Error,
                                     "Failed to open XML Theme : " + filename + " Message was: " + ex.Message);
            }
            return(returnValue);
        }