private void ChooseEmail() { IIOService ioService = EasyIoc.IocContainer.Default.Resolve <IIOService>(); string mailsPath = ConfigurationManager.AppSettings["MailTemplatesPath"]; string filePath = ioService.OpenFileDialog(mailsPath, "html", "html files (*.html)|*.html"); try { if (!string.IsNullOrWhiteSpace(filePath)) { string html = File.ReadAllText(filePath); if (!string.IsNullOrWhiteSpace(html)) { html = html.Replace("\t", string.Empty).Replace(Environment.NewLine, string.Empty); // Remove cid:[tag] with tag related filename Regex pattern = new Regex(@"img src=""(?<cid>cid\:\w+)"""); EmailContent = pattern.ReplaceGroup(html, "cid", ReplaceCid); } } } catch (Exception ex) { Logger.Exception(ex); } }
public void FileOpen() { var path = _ioService.OpenFileDialog(); if (string.IsNullOrEmpty(path)) { return; } EditorTabViewModel tab; if (Items.SingleOrDefault(t => t.FullPath.Equals(path, StringComparison.OrdinalIgnoreCase)) is EditorTabViewModel item) { tab = item; } else { _logger.LogInformation("Opening file '{fullPath}'", path); var sw = Stopwatch.StartNew(); var textReader = _ioService.OpenTextFile(path); tab = _editorTabFactory(); tab.FullPath = path; tab.Map = _mapFactory.FromText(textReader); _logger.LogInformation("{action} took {ms} ms", "Opening", sw.ElapsedMilliseconds); Items.Add(tab); if (Items.Count == 1) { NotifyOfPropertyChange(nameof(HasOpenTabs)); } } ActivateItem(tab); }