示例#1
0
        public override void Execute(params object[] args)
        {
            var style = CollectStyleFromContext();

            if (style != null)
            {
                Color pageColor;
                using (var one = new OneNote(out var page, out _))
                {
                    pageColor = page.GetPageColor(out _, out _);
                }

                DialogResult result;
                using (var dialog = new StyleDialog(style, pageColor))
                {
                    result = dialog.ShowDialog(owner);
                    if (result == DialogResult.OK)
                    {
                        style = dialog.Style;
                        if (style != null)
                        {
                            new StyleProvider().Save(style);
                            ribbon.Invalidate();
                        }
                    }
                }
            }
        }
示例#2
0
        public override async Task Execute(params object[] args)
        {
            Page  page;
            Color pageColor;

            using (var one = new OneNote(out page, out _))
            {
                pageColor = page.GetPageColor(out _, out _);
            }

            var analyzer = new StyleAnalyzer(page.Root);

            var style = analyzer.CollectFromSelection();

            if (style == null)
            {
                return;
            }

            using (var dialog = new StyleDialog(style, pageColor))
            {
                if (dialog.ShowDialog(owner) == DialogResult.OK)
                {
                    if (dialog.Style != null)
                    {
                        ThemeProvider.Save(dialog.Style);
                        ribbon.Invalidate();
                    }
                }
            }

            await Task.Yield();
        }
示例#3
0
        public override async Task Execute(params object[] args)
        {
            Color pageColor;

            using (var one = new OneNote(out var page, out _))
            {
                pageColor = page.GetPageColor(out _, out var black);
                if (black)
                {
                    // if Office Black theme, translate to softer Black Shadow
                    pageColor = BasicColors.BlackSmoke;
                }
            }

            var theme = new ThemeProvider().Theme;

            using (var dialog = new StyleDialog(theme, pageColor))
            {
                if (dialog.ShowDialog(owner) == DialogResult.OK)
                {
                    ThemeProvider.Save(dialog.Theme);
                    ThemeProvider.RecordTheme(dialog.Theme.Key);

                    ribbon.Invalidate();
                }
            }

            ribbon.Invalidate();

            await Task.Yield();
        }
示例#4
0
        public override async Task Execute(params object[] args)
        {
            Color pageColor;

            using (var one = new OneNote(out var page, out _))
            {
                pageColor = page.GetPageColor(out _, out var black);
                if (black)
                {
                    pageColor = ColorTranslator.FromHtml("#201F1E");
                }
            }

            var provider = new StyleProvider();
            var styles   = provider.GetStyles();

            using (var dialog = new StyleDialog(styles, pageColor))
            {
                if (dialog.ShowDialog(owner) == DialogResult.OK)
                {
                    // save styles to remove deleted items and preserve ordering
                    styles = dialog.GetStyles();
                    StyleProvider.Save(styles);
                    ribbon.Invalidate();
                }
            }

            ribbon.Invalidate();

            await Task.Yield();
        }