Пример #1
0
        /// <summary>
        /// Apply the styles to all the controls of the form which have her 'style' property
        /// defined.
        ///
        /// This method is defined as public to be able to call it manually.
        /// * set the path of the styles sheet file via 'StylesSheetFileName' key of the app.config.
        /// * for each control, set the name of the style with the 'SetStyle' property.
        /// * apply the styles in calling the 'ApplyStyles' method
        /// </summary>
        public bool ApplyStyles()
        {
            try
            {
                StylesSheetFileManager.StylesSheetFilename = StylesSheetFilename;
                manager.LoadStylesSheetFile();

                foreach (DictionaryEntry values in propertieValues)
                {
                    Control c = (Control)values.Key;
                    if (c != null)
                    {
                        manager.ApplyStyle(c, (string)values.Value);
                    }
                }
                return(true);
            }
            catch (Exception exc)
            {
                Exception e;
                if (exc is StylesSheetException)
                {
                    e = exc;
                }
                else
                {
                    e = new StylesSheetException(StylesSheetException.ExceptionType.UnexpectedException, exc);
                }

                MessageBox.Show(e.Message, "StylesSheetManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
        /// <summary>
        /// Apply the styles to all the controls of the form which have her 'style' property
        /// defined.
        /// 
        /// This method is defined as public to be able to call it manually.
        /// * set the path of the styles sheet file via 'StylesSheetFileName' key of the app.config.
        /// * for each control, set the name of the style with the 'SetStyle' property.
        /// * apply the styles in calling the 'ApplyStyles' method
        /// </summary>
        public bool ApplyStyles()
        {
            try
            {
                StylesSheetFileManager.StylesSheetFilename = StylesSheetFilename;
                manager.LoadStylesSheetFile();

                foreach (DictionaryEntry values in propertieValues)
                {
                    Control c = (Control)values.Key;
                    if (c != null)
                        manager.ApplyStyle(c, (string)values.Value);
                }
                return true;
            }
            catch (Exception exc)
            {
                Exception e;
                if (exc is StylesSheetException)
                    e = exc;
                else
                    e = new StylesSheetException(StylesSheetException.ExceptionType.UnexpectedException, exc);

                MessageBox.Show(e.Message, "StylesSheetManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }