示例#1
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();
        }
示例#2
0
        private void SaveTheme(object sender, EventArgs e)
        {
            using (var dialog = new SaveFileDialog())
            {
                dialog.DefaultExt = "xml";
                dialog.Filter     = "Theme files (*.xml)|*.xml|All files (*.*)|*.*";
                dialog.Title      = "Save 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 key = Path.GetFileNameWithoutExtension(dialog.FileName);
                    theme = new Theme(MakeStyles(), key, key, theme.Dark);
                    ThemeProvider.Save(theme, dialog.FileName);

                    Text = string.Format(
                        Resx.StyleDialog_ThemeText,
                        Path.GetFileNameWithoutExtension(dialog.FileName));
                }
            }
        }
示例#3
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();
        }