Ejemplo n.º 1
0
        private void FocusNextDirectory()
        {
            if (SelectedFolderPath == null)
            {
                return;
            }

            var folders = Owner.NotesViewControl.ListFolder().ToList();

            var idx = folders.IndexOf(SelectedFolderPath);

            if (idx == -1)
            {
                return;
            }

            folders = folders.Skip(idx + 1).Concat(folders.Take(idx)).ToList();

            if (HierarchicalBaseWrapper.IsSpecialOrRoot(SelectedFolderPath))
            {
                var found = folders.FirstOrDefault(HierarchicalBaseWrapper.IsSpecialOrRoot);
                if (found != null)
                {
                    SelectedFolderPath = found;
                }
            }
            else
            {
                var found = folders.FirstOrDefault(p => !HierarchicalBaseWrapper.IsSpecialOrRoot(p) && p.IsDirectSubPathOf(SelectedFolderPath.ParentPath(), true));
                if (found != null)
                {
                    SelectedFolderPath = found;
                }
            }
        }
Ejemplo n.º 2
0
        private void FocusDirectoryLevelDown()
        {
            if (SelectedFolderPath == null)
            {
                return;
            }

            var folders = Owner.NotesViewControl.ListFolder().ToList();

            if (HierarchicalBaseWrapper.IsSpecial(SelectedFolderPath))
            {
                var found = folders.FirstOrDefault(p => !HierarchicalBaseWrapper.IsSpecial(p));
                if (found != null)
                {
                    SelectedFolderPath = found;
                }
                return;
            }
            else
            {
                var found = folders.FirstOrDefault(p => p.IsDirectSubPathOf(SelectedFolderPath, true));
                if (found != null)
                {
                    SelectedFolderPath = found;
                }
            }
        }
Ejemplo n.º 3
0
        public void ChangePath()
        {
            if (SelectedNote == null)
            {
                return;
            }
            if (!Settings.UseHierarchicalNoteStructure)
            {
                return;
            }
            if (Settings.IsReadOnlyMode)
            {
                return;
            }
            if (SelectedNote.IsLocked)
            {
                return;
            }

            FolderPopupListView.Items.Clear();

            foreach (var folder in MainWindow.Instance.NotesViewControl.ListFolder())
            {
                if (HierarchicalBaseWrapper.IsSpecial(folder) && !folder.IsRoot())
                {
                    continue;
                }
                FolderPopupListView.Items.Add(folder);
            }

            FolderPopupListView.SelectedItem = SelectedNote.Path;

            FolderPopup.IsOpen = true;
        }
        private void DeleteFolder()
        {
            try
            {
                var fp = SelectedFolderPath;

                if (fp == null || HierarchicalBaseWrapper.IsSpecial(fp))
                {
                    return;
                }

                var delNotes = Repository.Notes.Where(n => n.Path.IsPathOrSubPath(fp)).ToList();

                if (MessageBox.Show(Owner, $"Do you really want to delete this folder together with {delNotes.Count} contained notes?", "Delete folder?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                {
                    return;
                }

                foreach (var note in delNotes)
                {
                    Repository.DeleteNote(note, true);
                }

                Owner.NotesViewControl.DeleteFolder(fp);

                SelectedNote = Owner.NotesViewControl.EnumerateVisibleNotes().FirstOrDefault() ?? Repository.Notes.FirstOrDefault();
            }
            catch (Exception e)
            {
                App.Logger.Error("Main", "Could not delete folder", e);
                ExceptionDialog.Show(Owner, "Could not delete folder", e, string.Empty);
            }
        }
        private void MoveFolderDown()
        {
            if (Settings.SortHierarchyFoldersByName)
            {
                return;
            }

            var path = SelectedFolderPath;

            if (HierarchicalBaseWrapper.IsSpecial(path))
            {
                return;
            }

            Owner.NotesViewControl.MoveFolder(path, +1);
        }
Ejemplo n.º 6
0
        private void FocusDirectoryLevelUp()
        {
            if (SelectedFolderPath == null)
            {
                return;
            }
            if (SelectedFolderPath.IsRoot())
            {
                return;
            }
            if (HierarchicalBaseWrapper.IsSpecial(SelectedFolderPath))
            {
                return;
            }

            SelectedFolderPath = SelectedFolderPath.ParentPath();
        }
        private void RenameFolder()
        {
            try
            {
                var oldPath = SelectedFolderPath;
                if (HierarchicalBaseWrapper.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 || HierarchicalBaseWrapper.IsSpecial(currentPath))
            {
                currentPath = DirectoryPath.Root();
            }

            var path = currentPath.SubDir(foldercomponent);

            Owner.NotesViewControl.AddFolder(path);
        }
Ejemplo n.º 9
0
 private void SelectedFolderPathChanged()
 {
     if (Settings != null && Settings.RememberLastSelectedNote)
     {
         Settings.LastSelectedNote   = SelectedNote?.UniqueName;
         Settings.LastSelectedFolder = SelectedFolderPath ?? DirectoryPath.Root();
     }
     if (!string.IsNullOrEmpty(SearchText) && (Settings != null && Settings.ClearSearchOnFolderClick) && !(SelectedFolderPath == null || HierarchicalBaseWrapper.IsSpecial(SelectedFolderPath)))
     {
         SearchText = "";                 // clear serach on subfolder click
     }
     RequestSettingsSave();
 }