Ejemplo n.º 1
0
        private static ModelItem GetLastChild(ModelItem modelItem, ViewService viewService)
        {
            ModelItem modelItem1 = modelItem;
            bool      flag       = false;

            while (modelItem != null && modelItem.Content != (ModelProperty)null && !flag)
            {
                if (modelItem.Content.IsCollection)
                {
                    if (modelItem.Content.Collection.Count > 0)
                    {
                        modelItem = modelItem.Content.Collection[modelItem.Content.Collection.Count - 1];
                    }
                    else
                    {
                        flag = true;
                    }
                }
                else if (modelItem.Content.IsSet)
                {
                    modelItem = modelItem.Content.Value;
                }
                else
                {
                    flag = true;
                }
                if (modelItem != null && SelectionImplementation.IsSelectable(modelItem) && modelItem.View != (ViewItem)null)
                {
                    modelItem1 = modelItem;
                }
            }
            return(modelItem1);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        private static ModelItem GetFirstChild(ModelItem modelItem, ViewService viewService)
        {
            ModelProperty content = modelItem.Content;

            if (content == (ModelProperty)null)
            {
                return((ModelItem)null);
            }
            ModelItem modelItem1 = (ModelItem)null;

            if (content.IsCollection)
            {
                if (content.Collection.Count == 0)
                {
                    return((ModelItem)null);
                }
                modelItem1 = content.Collection[0];
            }
            else if (content.IsSet)
            {
                modelItem1 = content.Value;
            }
            if (modelItem1 == null || !SelectionImplementation.IsSelectable(modelItem1) || modelItem1.View == (ViewItem)null)
            {
                return((ModelItem)null);
            }
            return(modelItem1);
        }
Ejemplo n.º 4
0
        internal static void SelectPrevious(EditingContext context)
        {
            Selection s = context.Items.GetValue <Selection>();

            if (SelectionImplementation.IsMultiSelection(s))
            {
                SelectionImplementation.SelectParent(context);
            }
            else
            {
                if (s.PrimarySelection == null)
                {
                    return;
                }
                ModelItem   primarySelection = s.PrimarySelection;
                ViewService service          = context.Services.GetService <ViewService>();
                ModelItem   previousSibling  = SelectionImplementation.GetPreviousSibling(primarySelection, service);
                ModelItem   modelItem        = previousSibling != null?SelectionImplementation.GetLastChild(previousSibling, service) : (primarySelection.Parent != null ? primarySelection.Parent : SelectionImplementation.GetLastChild(primarySelection, service));

                if (modelItem == null)
                {
                    return;
                }
                context.Items.SetValue((ContextItem) new Selection(new ModelItem[1]
                {
                    modelItem
                }));
            }
        }
Ejemplo n.º 5
0
        internal static void SelectNext(EditingContext context)
        {
            Selection s = context.Items.GetValue <Selection>();

            if (SelectionImplementation.IsMultiSelection(s))
            {
                SelectionImplementation.SelectParent(context);
            }
            else
            {
                if (s.PrimarySelection == null)
                {
                    return;
                }
                ModelItem   modelItem1 = s.PrimarySelection;
                ViewService service    = context.Services.GetService <ViewService>();
                ModelItem   modelItem2;
                for (modelItem2 = SelectionImplementation.GetFirstChild(s.PrimarySelection, service); modelItem2 == null && modelItem1.Parent != null; modelItem1 = modelItem1.Parent)
                {
                    modelItem2 = SelectionImplementation.GetNextSibling(modelItem1, service);
                }
                if (modelItem2 == null)
                {
                    modelItem2 = modelItem1;
                }
                if (modelItem2 == null)
                {
                    return;
                }
                context.Items.SetValue((ContextItem) new Selection(new ModelItem[1]
                {
                    modelItem2
                }));
            }
        }
Ejemplo n.º 6
0
        private static Selection SelectContent(ModelItem parent)
        {
            Selection selection = new Selection();

            if (parent.Content.IsCollection)
            {
                selection = new Selection((IEnumerable)parent.Content.Collection);
            }
            else if (parent.Content.IsDictionary)
            {
                selection = new Selection((IEnumerable)parent.Content.Dictionary);
            }
            else if (parent.Content.IsSet && SelectionImplementation.IsSelectable(parent) && SelectionImplementation.IsSelectable(parent.Content.Value))
            {
                selection = new Selection(new ModelItem[1]
                {
                    parent.Content.Value
                });
            }
            return(selection);
        }