Beispiel #1
0
        private int AlterSelections()
        {
            var elements = page.Root.Element(ns + "Outline").Descendants(ns + "T")
                           .Where(e => e.Attributes("selected").Any(a => a.Value == "all"));

            if (elements.IsNullOrEmpty())
            {
                return(0);
            }

            var count    = 0;
            var analyzer = new StyleAnalyzer(page.Root, true);

            foreach (var element in elements)
            {
                analyzer.Clear();
                var style = new Style(analyzer.CollectStyleProperties(element));

                // add .05 to compensate for unpredictable behavior; there are cases where going
                // from 11pt to 12pt actually causes OneNote to calculate 9pt :-(
                style.FontSize = (ParseFontSize(style.FontSize) + delta).ToString("#0") + ".05pt";

                var stylizer = new Stylizer(style);
                stylizer.ApplyStyle(element);
                count++;
            }

            return(count);
        }
Beispiel #2
0
        public void Execute(int selectedIndex)
        {
            using (var manager = new ApplicationManager())
            {
                page = manager.CurrentPage();
                if (page != null)
                {
                    ns       = page.GetNamespaceOfPrefix("one");
                    style    = new StyleProvider().GetStyle(selectedIndex);
                    stylizer = new Stylizer(style);

                    bool success = style.StyleType == StyleType.Character
                                                ? StylizeWords()
                                                : StylizeParagraphs();

                    if (success)
                    {
                        manager.UpdatePageContent(page);
                    }
                }
            }
        }
Beispiel #3
0
 public ApplyStylesCommand() : base()
 {
     // using blank Style just so we have a valid Stylizer
     stylizer = new Stylizer(new Style());
 }