コード例 #1
0
        public void Execute()
        {
            logger.WriteLine("SortCommand.Execute()");

            var result = DialogResult.None;

            using (var dialog = new SortDialog())
            {
                result = dialog.ShowDialog(owner);
                dialog.Focus();

                result    = dialog.DialogResult;
                scope     = dialog.Scope;
                sorting   = dialog.Soring;
                direction = dialog.Direction;
                pinNotes  = dialog.PinNotes;
            }

            if (result == DialogResult.OK)
            {
                logger.WriteLine($"- sort scope [{scope}]");
                logger.WriteLine($"- sort sorting[{sorting}]");
                logger.WriteLine($"- sort direction [{direction}]");

                using (var manager = new ApplicationManager())
                {
                    XElement root;

                    if (scope == HierarchyScope.hsPages)
                    {
                        // get just the current section with all pages as child elements
                        root = manager.CurrentSection();
                        root = SortPages(root, sorting, direction);
                    }
                    else
                    {
                        root = manager.GetHierarchy(scope);

                        if (scope == HierarchyScope.hsNotebooks)
                        {
                            // notebooks is a simple flat list
                            root = SortNotebooks(root, sorting, direction);
                        }
                        else
                        {
                            // sections will include all sections for the current notebook
                            root = SortSections(root, sorting, direction, pinNotes);
                        }
                    }

                    if (root != null)
                    {
                        manager.UpdateHierarchy(root);
                    }
                }
            }
        }
コード例 #2
0
ファイル: SortCommand.cs プロジェクト: osman1963/OneMore
        public override void Execute(params object[] args)
        {
            OneNote.Scope         scope;
            SortDialog.Sortings   sorting;
            SortDialog.Directions direction;
            bool pinNotes;

            using (var dialog = new SortDialog())
            {
                if (dialog.ShowDialog(owner) != DialogResult.OK)
                {
                    return;
                }

                scope     = dialog.Scope;
                sorting   = dialog.Soring;
                direction = dialog.Direction;
                pinNotes  = dialog.PinNotes;
            }

            logger.WriteLine($"sort scope:{scope} sorting:{sorting} direction:{direction}");

            switch (scope)
            {
            case OneNote.Scope.Pages:
                SortPages(sorting, direction);
                break;

            case OneNote.Scope.Sections:
                SortSections(sorting, direction, pinNotes);
                break;

            case OneNote.Scope.Notebooks:
                SortNotebooks(sorting, direction);
                break;
            }
        }