Beispiel #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);
                    }
                }
            }
        }
Beispiel #2
0
        private void ShowHierarchy(HierarchyScope scope)
        {
            var element = manager.GetHierarchy(scope);

            if (element != null)
            {
                var xml = element.ToString(SaveOptions.None);
                hierBox.Text = xml;
            }
            else
            {
                hierBox.Text = $"Cannot get hierarchy for {scope.ToString()}";
            }
        }