示例#1
0
        /// <summary>
        /// Adds the default print styles.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <remarks>Documented by Dev02, 2008-01-21</remarks>
        public static void AddDefaultPrintStyles(Style style, System.Resources.ResourceManager ResourceManager)
        {
            StyleInfo info = new StyleInfo();
            info.resourceManager = ResourceManager;
            info.Path = @"System\Print\default.xsl";
            string infoname = ResourceManager.GetString("PRINT_STYLE_PRINTALL");
            info.Name = string.IsNullOrEmpty(infoname) ? "Print All" : infoname;
            info.ResourceID = "PRINT_STYLE_PRINTALL";

            if (!ContainsStyle(style.PrintStyles, info))
                style.PrintStyles.Add(info);

            info = new StyleInfo();
            info.resourceManager = ResourceManager;
            info.Path = @"System\Print\withoutMedia.xsl";
            infoname = ResourceManager.GetString("PRINT_STYLE_WITHOUTMEDIA");
            info.Name = string.IsNullOrEmpty(infoname) ? "Print without Media" : infoname;
            info.ResourceID = "PRINT_STYLE_WITHOUTMEDIA";

            if (!ContainsStyle(style.PrintStyles, info))
                style.PrintStyles.Add(info);
        }
示例#2
0
        /// <summary>
        /// Completes the styles paths, adds the default styles if necessary, adds the resourceManager for using localizable style names.
        /// </summary>
        /// <param name="stylesheetPath">The stylesheet path.</param>
        /// <param name="style">The style.</param>
        /// <remarks>Documented by Dev02, 2008-01-21</remarks>
        private static void CheckStyles(string stylesheetPath, Style style, System.Resources.ResourceManager resourceManager)
        {
            AddDefaultPrintStyles(style, resourceManager);

            List<StyleInfo> invalidStyles = new List<StyleInfo>();
            foreach (StyleInfo styleinfo in style.PrintStyles)
            {
                styleinfo.Path = Path.Combine(stylesheetPath, styleinfo.Path);
                styleinfo.resourceManager = resourceManager;

                if (!File.Exists(styleinfo.Path))
                    invalidStyles.Add(styleinfo);
            }

            //remove invalid styles
            foreach (StyleInfo styleinfo in invalidStyles)
                style.PrintStyles.Remove(styleinfo);
        }
示例#3
0
        /// <summary>
        /// Initializes arrayList new instance of the <see cref="styleHandler"/> class.
        /// </summary>
        /// <param name="stylesPath">The styles path.</param>
        /// <param name="appdataFolderDesigns">The appdata folder designs.</param>
        /// <remarks>Documented by Dev05, 2007-08-10</remarks>
        public StyleHandler(string stylesPath, string appdataFolderDesigns, System.Resources.ResourceManager resourceManager, bool runFromStick)
        {
            //get resource strings
            this.ResourceManager = resourceManager;

            string styleExtension = resourceManager.GetString("STYLE_STYLE_EXTENSION");
            m_styleExtension = string.IsNullOrEmpty(styleExtension) ? ".style" : styleExtension;

            string defaultStyleName = resourceManager.GetString("STYLE_DEFAULT_STYLENAME");
            m_defaultStyleName = string.IsNullOrEmpty(defaultStyleName) ? "Default" : defaultStyleName;

            if (runFromStick)
            {
                string[] files = null;
                //add own skins
                if (Directory.Exists(stylesPath))
                {
                    files = Directory.GetFiles(stylesPath, "*" + m_styleExtension);
                    AddStyles(stylesPath, files);
                }
                //add already installed skins
                if (Directory.Exists(appdataFolderDesigns))
                {
                    files = Directory.GetFiles(appdataFolderDesigns, "*" + m_styleExtension);
                    AddStyles(appdataFolderDesigns, files);
                }

                StylesPath = stylesPath;
            }
            else
            {
                //create default skin folder
                if (!Directory.Exists(appdataFolderDesigns))
                    Directory.CreateDirectory(appdataFolderDesigns);

                StylesPath = appdataFolderDesigns;
            #if !DEBUG
            if (!Directory.Exists(appdataFolderDesigns + @"\System"))
            #endif
                {
                    Directory.CreateDirectory(appdataFolderDesigns);
                    if (Directory.Exists(stylesPath))
                        CopyFolder(stylesPath, appdataFolderDesigns);
                }
                string[] files = Directory.GetFiles(appdataFolderDesigns, "*" + m_styleExtension);
                AddStyles(appdataFolderDesigns, files);
                if (Directory.Exists(stylesPath))
                {
                    files = Directory.GetFiles(stylesPath, "*" + m_styleExtension);
                    AddStyles(stylesPath, files);
                }
            }

            //add empty default style (as fallback)
            if (!Styles.ContainsKey(m_defaultStyleName))
            {
                Style defaultStyle = new Style();
                CheckStyles(stylesPath, defaultStyle, ResourceManager);
                defaultStyle.AnswerStylesheetPath = Path.Combine(appdataFolderDesigns, defaultStyle.AnswerStylesheetPath);
                defaultStyle.QuestionStylesheetPath = Path.Combine(appdataFolderDesigns, defaultStyle.QuestionStylesheetPath);
                defaultStyle.StylePath = Path.Combine(appdataFolderDesigns, defaultStyle.StylePath);
                Styles.Add(m_defaultStyleName, defaultStyle);
            }
        }