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) { StyleProvider.Save(GetStyles(), dialog.FileName); } } }
protected override void RegisterStyles() { StyleMapper .If(() => StyleProvider.ModalShow(), () => IsOpen); base.RegisterStyles(); }
private static Style GetStyle() { Style style = null; // use custom Caption style if it exists var styles = new StyleProvider().GetStyles(); if (styles?.Count > 0) { style = styles.FirstOrDefault(s => s.Name.Equals("Caption")); } // otherwise use default style if (style == null) { style = new Style { Color = "#5B9BD5", // close to CornflowerBlue FontSize = "10pt", IsBold = true }; } return(style); }
protected override void RegisterStyles() { StyleMapper .If(() => StyleProvider.ProgressBarValue(Value ?? 0), () => Value != null); base.RegisterStyles(); }
protected void Notify(string message, string icon, int time, bool requireClose, NotifyActionItem[] actions) { var index = Enumerable.Range(0, 10).First(i => Items.All(n => n.Index != i)); if (time == 0) { requireClose = true; } time += 800; var notificationItem = new NotificationItem() { AnimatedX = 0, Icon = StyleProvider.GetImage(icon), Message = message, TimeLeft = time, Time = time, Index = index, RequireClose = requireClose, Actions = actions }; EditorApplication.delayCall += () => { Items.Add(notificationItem); }; Signal <IDebugWindowEvents>(_ => _.RegisterInspectedItem(notificationItem, notificationItem.Message, true)); //Add notification item to the queue }
public async Task Index() { if (!PathEndsInSlash(Request.Path)) { RedirectToPathWithSlash(HttpContext); return; } var basePath = "./files"; await Response.WriteAsync($"<!DOCTYPE html>\n"); await Response.WriteAsync($"<html>\n"); await Response.WriteAsync($"<head>\n"); await Response.WriteAsync($" <meta charset=\"utf-8\">\n"); await Response.WriteAsync($" <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap\"/>\n"); await Response.WriteAsync($" <title>{TitleProvider.Title}</title>\n"); await Response.WriteAsync($"\n"); await Response.WriteAsync($" <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n"); await Response.WriteAsync($"\n"); await Response.WriteAsync($" <link rel=\"icon\" href=\"{FaviconProvider.Favicon}\">\n"); await Response.WriteAsync($"\n"); foreach (var style in StyleProvider.GetAll()) { var path = style.Path.StartsWith("http") || style.Path.StartsWith("/") ? style.Path : Path.Combine(basePath, style.Path).Replace('\\', '/'); await Response.WriteAsync($" <link rel=\"stylesheet\" type=\"text/css\" href=\"{path}\" />\n"); } foreach (var script in ScriptProvider.GetAll()) { var path = script.Path.StartsWith("http") || script.Path.StartsWith("/") ? script.Path : Path.Combine(basePath, script.Path).Replace('\\', '/'); await Response.WriteAsync($" <script src=\"{path}\"></script>\n"); } await Response.WriteAsync($"</head>\n"); await Response.WriteAsync($"<body>\n"); await Response.WriteAsync($" <script type=\"module\">\n"); await Response.WriteAsync($" import Portal from '{Path.Combine(basePath, "portal.js").Replace('\\', '/')}';\n"); await Response.WriteAsync($" import appProvider from '{Path.Combine(basePath, "app-provider.js").Replace('\\', '/')}';\n"); await Response.WriteAsync($" appProvider.getAll().then(apps => new Portal('{TitleProvider.Title}', apps).appendTo(document.body));\n"); await Response.WriteAsync($" </script>\n"); await Response.WriteAsync($"</body>\n"); await Response.WriteAsync($"</html>\n"); }
/// <summary> /// Creates a new instance of a generator. /// </summary> /// <returns>Generator</returns> public ExcelFileGenerator CreateGenerator() { var sharedStringsInterner = new SharedStringsInterner(_defaultCapacity); var styleProvider = new StyleProvider(); var visitors = new IDataProviderVisitor[] { new EnumDataProviderVisitor(), new NumericDataProviderVisitor(string.IsNullOrEmpty(_numberFormat) ? (int?)null : styleProvider.GetColumnStyle(_numberFormat)), new DateTimeDataProviderVisitor(string.IsNullOrEmpty(_dateFormat) ? (int?)null : styleProvider.GetColumnStyle(_dateFormat)), new BooleanDataProviderVisitor(string.IsNullOrEmpty(_booleanFormat) ? (int?)null : styleProvider.GetColumnStyle(_booleanFormat)), new DefaultStringDataProviderVisitor(_throwOnLimit) }; var columnFactory = new ExcelColumnFactory(visitors, styleProvider); return(new ExcelFileGenerator(columnFactory, new WorksheetWriter(_encoder, sharedStringsInterner), new SharedStringsWriter(_encoder, sharedStringsInterner), new StylesWriter(styleProvider), _templateStreamFactory(), _compressionStrategy, _compressionLevel, _propertiesFilter)); }
protected override void RegisterStyles() { StyleMapper .If(() => StyleProvider.ModalBodyMaxHeight(MaxHeight ?? 0), () => MaxHeight != null); base.RegisterStyles(); }
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(); }
private void OnWebBlockLoaded(object sender, RoutedEventArgs e) { var web = (WebBlock)sender; var styleProvider = new StyleProvider(); var isThemeBright = ((Color)Application.Current.Resources[@"WindowBackgroundColor"]).GetBrightness() > 0.4; web.SetJsBridge <SrsFixAcCompatibleApiBridge>(b => { b.StyleProvider = styleProvider; b.IsThemeBright = isThemeBright; }); web.StyleProvider = styleProvider; }
protected ResourceDictionary CreateGlobalStyles(StyleProvider styleProvider) { var resources = new ResourceDictionary { styleProvider.GetStyleForButtons(), styleProvider.GetStyleForLabels(), styleProvider.GetStyleForEntries(), styleProvider.GetStyleForEditors(), styleProvider.GetStyleForSwitches(), styleProvider.GetStyleForPages() }; return(resources); }
public override async Task Execute(params object[] args) { using (var one = new OneNote(out page, out _)) { var styles = new StyleProvider().GetStyles(); if (ApplyStyles(styles)) { ApplyToLists(styles); if (page.GetPageColor(out _, out _).GetBrightness() < 0.5) { ApplyToHyperlinks(); } await one.Update(page); } } }
public StatusBar(UiStateModel uiState, StyleProvider styleProvider) { _uiState = uiState ?? throw new ArgumentNullException(nameof(uiState)); if (styleProvider == null) { throw new ArgumentNullException(nameof(styleProvider)); } // copy down config _barHeight = 26; _fgStyle = styleProvider.GetStyle("StatusBarForegroundStyle"); _bgStyle = styleProvider.GetStyle("StatusBarBackgroundStyle"); _fgTextFormat = new CanvasTextFormat() { VerticalAlignment = CanvasVerticalAlignment.Center, HorizontalAlignment = CanvasHorizontalAlignment.Left, FontWeight = FontWeights.Bold, FontSize = _barHeight * 0.75f }; }
private void LoadTheme(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 StyleProvider().LoadTheme(dialog.FileName); if (styles.Count > 0) { LoadStyles(styles); } else { MessageBox.Show(this, "Could not load this theme file?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
protected virtual void RegisterStyles() { StyleMapper .If(() => Style, () => Style != null) .Add(() => StyleProvider.Visibility(Visibility)); }
private async Task RemoveSpacing() { using (var one = new OneNote(out var page, out var ns)) { logger.StartClock(); var elements = (from e in page.Root.Descendants(page.Namespace + "OE") where e.Elements().Count() == 1 let t = e.Elements().First() where (t != null) && (t.Name.LocalName == "T") && ((e.Attribute("spaceBefore") != null) || (e.Attribute("spaceAfter") != null) || (e.Attribute("spaceBetween") != null)) select e) .ToList(); if (elements != null) { var quickStyles = page.GetQuickStyles() .Where(s => s.StyleType == StyleType.Heading); var customStyles = new StyleProvider().GetStyles() .Where(e => e.StyleType == StyleType.Heading) .ToList(); var modified = false; foreach (var element in elements) { // is this a known Heading style? var attr = element.Attribute("quickStyleIndex"); if (attr != null) { var index = int.Parse(attr.Value, CultureInfo.InvariantCulture); if (quickStyles.Any(s => s.Index == index)) { if (includeHeadings) { modified |= CleanElement(element); } continue; } } // is this a custom Heading style? var style = new Style(element.CollectStyleProperties(true)); if (customStyles.Any(s => s.Equals(style))) { if (includeHeadings) { modified |= CleanElement(element); } continue; } // normal paragraph modified |= CleanElement(element); } logger.WriteTime("removed spacing, now saving..."); if (modified) { await one.Update(page); } } } }
public GunTowerBodySprite(IConfig config, StyleProvider styleProvider) { Style = styleProvider.GetStyle(config.GetString(CfgStyleName)); }
/* * Find consecutive empty lines that need to be collapsed... */ public bool CollapseEmptyLines(Page page, XNamespace ns) { var elements = (from e in page.Root.Descendants(ns + "OE") let t = e.Elements().FirstOrDefault() where (t?.Name.LocalName == "T") && (t.TextValue().Trim().Length == 0) select e) .ToList(); if (elements?.Any() != true) { return(false); } var modified = false; var quickStyles = page.GetQuickStyles() .Where(s => s.StyleType == StyleType.Heading); var customStyles = new StyleProvider().GetStyles() .Where(e => e.StyleType == StyleType.Heading) .ToList(); foreach (var element in elements) { // is this a known Heading style? var attr = element.Attribute("quickStyleIndex"); if (attr != null) { var index = int.Parse(attr.Value, CultureInfo.InvariantCulture); if (quickStyles.Any(s => s.Index == index)) { // remove empty standard heading element.Remove(); modified = true; continue; } } // is this a custom Heading style? var style = new Style(element.CollectStyleProperties(true)); if (customStyles.Any(s => s.Equals(style))) { // remove empty custom heading element.Remove(); modified = true; continue; } // is this an empty paragraph preceded by an empty paragraph? if (element.PreviousNode != null && element.PreviousNode.NodeType == System.Xml.XmlNodeType.Element) { var prev = element.PreviousNode as XElement; if (prev.Name.LocalName == "OE") { var t = prev.Elements().Last(); if (t.Name.LocalName == "T" && t.TextValue().Trim().Length == 0) { // remove consecutive empty line prev.Remove(); modified = true; } } } } return(modified); }