Пример #1
0
 public void Execute(int selectedIndex)
 {
     using (var style = new StylesProvider().GetStyle(selectedIndex, false))
     {
         using (var manager = new ApplicationManager())
         {
             var page = manager.CurrentPage();
             if (page != null)
             {
                 EvaluatePage(page, style, manager);
             }
         }
     }
 }
Пример #2
0
        private List <IStyleInfo> GetHeadingTemplates()
        {
            var templates = new List <IStyleInfo>();

            // collect Heading quick style defs (h1, h2, h3, ...)

            var quickdefs =
                from e in page.Elements(ns + "QuickStyleDef")
                let n = e.Attribute("name")
                        where (n != null) && (Regex.IsMatch(n.Value, @"h\d"))         // || n.Value.Equals("PageTitle"))
                        select new QuickInfo(e);

            if (quickdefs?.Count() > 0)
            {
                int level = 0;
                foreach (var def in quickdefs)
                {
                    def.Level = level++;
                    templates.Add(def);
                }
            }

            // collect custom heading styles

            var customs = new StylesProvider()
                          .Filter(e => e.Attributes("isHeading").Any(a => a.Value.ToLower()
                                                                     .Equals("True", StringComparison.InvariantCultureIgnoreCase)));

            if (customs?.Count() > 0)
            {
                var level = 0;
                foreach (var custom in customs)
                {
                    templates.Add(new CustomInfo(custom)
                    {
                        Level = level++
                    });
                }
            }

            return(templates);
        }
Пример #3
0
        public void Execute()
        {
            var provider = new StylesProvider();

            var          styles = provider.GetStyles();
            DialogResult result;

            using (var dialog = new StyleDialog(styles))
            {
                result = dialog.ShowDialog(owner);

                if (result == DialogResult.OK)
                {
                    // save styles to remove delete items and preserve ordering
                    styles = dialog.GetStyles();
                    provider.SaveStyles(styles);
                    ribbon.Invalidate();
                }
            }
        }
Пример #4
0
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


        private void loadButton_Click(object sender, EventArgs e)
        {
            using (var dialog = new OpenFileDialog())
            {
                dialog.DefaultExt  = "xml";
                dialog.Filter      = "Theme files (*.xml)|*.xml|All files (*.*)|*.*";
                dialog.Multiselect = false;
                dialog.Title       = "Open Style Theme";
                dialog.ShowHelp    = true;              // stupid, but this is needed to avoid hang

                var path = PathFactory.GetAppDataPath();
                if (Directory.Exists(path))
                {
                    dialog.InitialDirectory = path;
                }
                else
                {
                    dialog.InitialDirectory =
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                }

                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    var styles = new StylesProvider().LoadTheme(dialog.FileName);
                    if (styles?.Count > 0)
                    {
                        LoadStyles(styles);
                    }
                    else
                    {
                        MessageBox.Show(this, "Could not load this theme file?", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Пример #5
0
 public GalleryTileFactory() : base()
 {
     provider = new StylesProvider();
 }