Exemplo n.º 1
0
        public void UpdateExpansions(NSOutlineView outlineView)
        {
            this.isExpanding = true;

            if (!String.IsNullOrWhiteSpace(this.dataSource.DataContext.FilterText))
            {
                outlineView.ExpandItem(null, true);
            }
            else
            {
                foreach (IGrouping <string, EditorViewModel> g in this.dataSource.DataContext.ArrangedEditors)
                {
                    NSObject item;
                    if (!this.dataSource.TryGetFacade(g, out item))
                    {
                        continue;
                    }

                    if (this.dataSource.DataContext.GetIsExpanded(g.Key))
                    {
                        outlineView.ExpandItem(item);
                    }
                    else
                    {
                        outlineView.CollapseItem(item);
                    }
                }
            }
            this.isExpanding = false;
        }
Exemplo n.º 2
0
            void UpdateStructure(ITreeNode newRoot)
            {
                void Rebind(NSNodeItem item, ITreeNode newNode)
                {
                    nodeToItem.Remove(item.Node);
                    item.Node           = newNode;
                    nodeToItem[newNode] = item;
                }

                void DeleteDescendantsFromMap(NSNodeItem item)
                {
                    item.Children.ForEach(c =>
                    {
                        Debug.Assert(nodeToItem.Remove(c.Node));
                        DeleteDescendantsFromMap(c);
                    });
                }

                var edits = TreeEdit.GetTreeEdits(rootItem.Node, newRoot);

                Rebind(rootItem, newRoot);

                foreach (var e in edits)
                {
                    var node = nodeToItem[e.Node];
                    switch (e.Type)
                    {
                    case TreeEdit.EditType.Insert:
                        var insertedNode = CreateItem(e.NewChild);
                        node.Children.Insert(e.ChildIndex, insertedNode);
                        treeView.InsertItems(new NSIndexSet(e.ChildIndex), ToObject(node), NSTableViewAnimation.None);
                        break;

                    case TreeEdit.EditType.Delete:
                        var deletedNode = node.Children[e.ChildIndex];
                        node.Children.RemoveAt(e.ChildIndex);
                        Debug.Assert(deletedNode == nodeToItem[e.OldChild]);
                        nodeToItem.Remove(e.OldChild);
                        treeView.RemoveItems(new NSIndexSet(e.ChildIndex), ToObject(node), NSTableViewAnimation.None);
                        DeleteDescendantsFromMap(deletedNode);
                        break;

                    case TreeEdit.EditType.Reuse:
                        treeView.ReloadItem(ToObject(node));
                        Rebind(nodeToItem[e.OldChild], e.NewChild);
                        break;

                    case TreeEdit.EditType.Expand:
                        treeView.ExpandItem(ToObject(node), expandChildren: false);
                        break;

                    case TreeEdit.EditType.Collapse:
                        treeView.CollapseItem(ToObject(node), collapseChildren: false);
                        break;
                    }
                }
            }
        private void EnsureOpenOrClose(NSOutlineView outline, NSObjectFacade item, bool open)
        {
            if (open)
            {
                outline.ExpandItem(item);
            }
            else
            {
                outline.CollapseItem(item);
            }

            NSView view = GetViewForItem(outline, item, makeIfNeccessary: true);

            if (view.Subviews[0] is NSButton expander)
            {
                expander.State = (open) ? NSCellStateValue.On : NSCellStateValue.Off;
            }
        }
Exemplo n.º 4
0
        public void Execute(NSOutlineView treeView, bool playingDelayedOps)
        {
            switch (Type)
            {
            case NodeOpType.ExpandAll:
                treeView.ExpandItem(Target, true);
                break;

            case NodeOpType.Collapse:
                treeView.CollapseItem(Target, false);
                break;

            case NodeOpType.InvalidateNodeView:
                if (!playingDelayedOps)
                {
                    treeView.NeedsDisplay = true;
                }
                break;
            }
        }
Exemplo n.º 5
0
            void UpdateStructure(ITreeNode newRoot)
            {
                void Rebind(NSNodeItem item, ITreeNode newNode)
                {
                    nodeToItem.Remove(item.Node);
                    item.Node           = newNode;
                    nodeToItem[newNode] = item;
                }

                void DeleteDescendantsFromMap(NSNodeItem item)
                {
                    item.Children.ForEach(c =>
                    {
                        Debug.Assert(nodeToItem.Remove(c.Node));
                        DeleteDescendantsFromMap(c);
                    });
                }

                var edits = TreeEdit.GetTreeEdits(rootItem.Node, newRoot, new TreeEdit.Options
                {
                    TemporariltyExpandParentToInitChildren = true
                });

                Rebind(rootItem, newRoot);

                foreach (var e in edits)
                {
                    var node = nodeToItem[e.Node];
                    switch (e.Type)
                    {
                    case TreeEdit.EditType.Insert:
                        var insertedNode = CreateItem(e.NewChild);
                        node.Children.Insert(e.ChildIndex, insertedNode);
                        using (var set = new NSIndexSet(e.ChildIndex))
                            treeView.InsertItems(set, ToObject(node), NSTableViewAnimation.None);
                        break;

                    case TreeEdit.EditType.Delete:
                        var deletedNode = node.Children[e.ChildIndex];
                        node.Children.RemoveAt(e.ChildIndex);
                        Debug.Assert(deletedNode == nodeToItem[e.OldChild]);
                        nodeToItem.Remove(e.OldChild);
                        using (var set = new NSIndexSet(e.ChildIndex))
                            treeView.RemoveItems(set, ToObject(node), NSTableViewAnimation.None);
                        DeleteDescendantsFromMap(deletedNode);
                        break;

                    case TreeEdit.EditType.Reuse:
                        var viewItem = nodeToItem [e.OldChild];
                        Rebind(viewItem, e.NewChild);
                        treeView.ReloadItem(ToObject(viewItem), reloadChildren: false);
                        if (owner.OnUpdateRowView != null)
                        {
                            var rowIdx  = treeView.RowForItem(ToObject(viewItem));
                            var rowView = rowIdx >= 0 ? treeView.GetRowView(rowIdx, makeIfNecessary: false) : null;
                            if (rowView != null)
                            {
                                owner.OnUpdateRowView(rowView, (Node)e.NewChild);
                            }
                        }
                        break;

                    case TreeEdit.EditType.Expand:
                        treeView.ExpandItem(ToObject(node), expandChildren: false);
                        break;

                    case TreeEdit.EditType.Collapse:
                        treeView.CollapseItem(ToObject(node), collapseChildren: false);
                        break;
                    }
                }
            }
Exemplo n.º 6
0
            /// <inheritdoc />
            public override bool ShouldEditTableColumn(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
            {
                DebugDelegatePrint("***************** SHOULD EDIT CALLED");
                var canEdit = MenuLayoutCommandGroup.EditLongNameCommand.CanExecute(ViewModel.HostPCMenuLayout);

                if (canEdit)
                {
                    var treeNode = item as NSTreeNode;
                    EditingColumn = (EditableOutlineViewColumn)outlineView.TableColumns().ToList().IndexOf(tableColumn);
                    var    editingObject = treeNode.RepresentedObject as FileNodeViewModel;
                    string initialValue  = null;
                    int    maxLength     = -1;
                    switch (EditingColumn)
                    {
                    case EditableOutlineViewColumn.LongName:
                        canEdit      = true;
                        initialValue = editingObject.LongName;
                        maxLength    = INTV.LtoFlash.Model.FileSystemConstants.MaxLongNameLength;
                        break;

                    case EditableOutlineViewColumn.ShortName:
                        canEdit      = true;
                        initialValue = editingObject.ShortName;
                        maxLength    = INTV.LtoFlash.Model.FileSystemConstants.MaxShortNameLength;
                        break;

                    default:
                        ErrorReporting.ReportError("Unsupported edit column");
                        break;
                    }
                    if (InPlaceEditor == null)
                    {
                        InPlaceEditor = new TextCellInPlaceEditor(outlineView);
                    }
                    InPlaceEditor.EditingObject    = editingObject;
                    InPlaceEditor.InitialValue     = initialValue;
                    InPlaceEditor.MaxLength        = maxLength;
                    InPlaceEditor.IsValidCharacter = (c) => INTV.Core.Model.Grom.Characters.Contains(c);
                    InPlaceEditor.EditorClosed    += InPlaceEditor_EditorClosed;
                    InPlaceEditor.BeginEdit();
                }
                else if ((SingleInstanceApplication.Current.LastKeyPressed == TextCellInPlaceEditor.ReturnKey) && (SingleInstanceApplication.Current.LastKeyPressedTimestamp != ReturnKeyTimestamp))
                {
                    // return was pressed -- do we need to check for <enter> vs. <return> (on laptops, Fn+return)?
                    ReturnKeyTimestamp = SingleInstanceApplication.Current.LastKeyPressedTimestamp;
                    if (!outlineView.IsExpandable(item) && DownloadCommandGroup.DownloadAndPlayCommand.CanExecute(ViewModel))
                    {
                        var program = ViewModel.HostPCMenuLayout.CurrentSelection as ProgramViewModel;
                        if ((program != null) && DownloadCommandGroup.DownloadAndPlayCommand.CanExecute(ViewModel))
                        {
                            DownloadCommandGroup.DownloadAndPlay(ViewModel.ActiveLtoFlashDevice.Device, program.ProgramDescription);
                        }
                    }
                    else
                    {
                        // On a directory. If so, toggle state.
                        if (outlineView.IsItemExpanded(item))
                        {
                            outlineView.CollapseItem(item);
                        }
                        else
                        {
                            outlineView.ExpandItem(item);
                        }
                    }
                }
                return(canEdit);
            }