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(); }
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)); } } }
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(); }