private void NewTheme() { ErrorText = ""; try { if (!GenericInputDialog.ShowInputDialog(Owner, "Filename for new theme", "New Theme (filename)", "MyTheme.xml", out var filename)) { throw new Exception("Aborted by user"); } if (!filename.ToLower().EndsWith(".xml")) { throw new Exception("Filename must end with xml"); } if (Entries.Any(e => e.SourceFilename.ToLower() == filename.ToLower())) { throw new Exception("Filename already exists"); } var newEntry = new ThemeEditorEntry() { OriginalSource = "", SourceFilename = filename, Name = "New Theme", Source = "", }; Entries.Add(newEntry); SelectedEntry = newEntry; } catch (Exception e) { ErrorText = e.ToString(); } }
private void AddRootFolder() { if (!GenericInputDialog.ShowInputDialog(Owner, "Insert the name for the new folder", "Folder name", "", out var foldercomponent)) { return; } if (string.IsNullOrWhiteSpace(foldercomponent)) { return; } var path = DirectoryPath.Create(Enumerable.Repeat(foldercomponent, 1)); Owner.NotesViewControl.AddFolder(path); }
private void InsertMaillink() { if (SelectedNote == null) { return; } if (!GenericInputDialog.ShowInputDialog(Owner, "Insert mail address", "Email address", "", out var url)) { return; } if (string.IsNullOrWhiteSpace(url)) { return; } url = "mailto:" + url; Owner.NoteEdit.ReplaceSelection(url); Owner.FocusScintilla(); }
private void RenameFolder() { try { var oldPath = SelectedFolderPath; if (HierachicalBaseWrapper.IsSpecial(oldPath)) { return; } if (!GenericInputDialog.ShowInputDialog(Owner, "Insert the name for the folder", "Folder name", oldPath.GetLastComponent(), out var newFolderName)) { return; } var newPath = oldPath.ParentPath().SubDir(newFolderName); if (newPath.EqualsWithCase(oldPath)) { return; } Owner.NotesViewControl.AddFolder(newPath); foreach (INote n in Repository.Notes.ToList()) { if (n.Path.IsPathOrSubPath(oldPath)) { n.Path = n.Path.Replace(oldPath, newPath); } } Owner.NotesViewControl.AddFolder(newPath); } catch (Exception e) { App.Logger.Error("Main", "Could not rename folder", e); ExceptionDialog.Show(Owner, "Could not rename folder", e, string.Empty); } }
private void AddSubFolder() { if (!GenericInputDialog.ShowInputDialog(Owner, "Insert the name for the new subfolder", "Folder name", "", out var foldercomponent)) { return; } if (string.IsNullOrWhiteSpace(foldercomponent)) { return; } var currentPath = SelectedFolderPath; if (currentPath == null || HierachicalBaseWrapper.IsSpecial(currentPath)) { currentPath = DirectoryPath.Root(); } var path = currentPath.SubDir(foldercomponent); Owner.NotesViewControl.AddFolder(path); }
private void InsertHyperlink() { if (SelectedNote == null) { return; } if (!GenericInputDialog.ShowInputDialog(Owner, "Insert website address", "Hyperlink location", "", out var url)) { return; } if (string.IsNullOrWhiteSpace(url)) { return; } if (!(url.ToLower().StartsWith("http://") || url.ToLower().StartsWith("https://"))) { url = "https://" + url; } Owner.NoteEdit.ReplaceSelection(url); Owner.FocusScintilla(); }