Exemple #1
0
        internal static Selection SelectAll(EditingContext context, bool local)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            ModelService requiredService = context.Services.GetRequiredService <ModelService>();
            Selection    s                = context.Items.GetValue <Selection>();
            Selection    selection        = new Selection();
            ModelItem    primarySelection = s.PrimarySelection;

            if (local && primarySelection != null)
            {
                if (!SelectionImplementation.IsMultiSelection(s) && primarySelection.Content != (ModelProperty)null)
                {
                    selection = SelectionImplementation.SelectContent(primarySelection);
                    if (selection.PrimarySelection == null && primarySelection.Parent != null)
                    {
                        selection = SelectionImplementation.SelectContent(primarySelection.Parent);
                    }
                }
                else if (SelectionImplementation.AreSiblings(s))
                {
                    selection = SelectionImplementation.SelectContent(primarySelection.Parent);
                }
            }
            if (selection.PrimarySelection == null)
            {
                selection = new Selection(SelectionImplementation.EnumerateContents(requiredService.Root));
            }
            context.Items.SetValue((ContextItem)selection);
            return(selection);
        }
Exemple #2
0
        internal static Selection SelectParent(EditingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            ModelService requiredService = context.Services.GetRequiredService <ModelService>();
            Selection    s                = context.Items.GetValue <Selection>();
            Selection    selection        = new Selection();
            ModelItem    primarySelection = s.PrimarySelection;

            if (SelectionImplementation.AreSiblings(s))
            {
                selection = new Selection(new ModelItem[1]
                {
                    primarySelection.Parent
                });
            }
            if (selection.PrimarySelection == null)
            {
                selection = new Selection(new ModelItem[1]
                {
                    requiredService.Root
                });
            }
            context.Items.SetValue((ContextItem)selection);
            return(selection);
        }