/// <summary> /// Mac-specific implementation. /// </summary> /// <param name="sender">Sender of the event.</param> partial void OnDoubleClick(NSObject sender) { var selectedItemPaths = sender as NSArray; if (selectedItemPaths != null) { var mouseLocation = NSEvent.CurrentMouseLocation; // if multiple items selected, get the one that was double-clicked var outline = View.FindChild <MenuOutlineView>(); var rect = outline.Window.ConvertRectFromScreen(new CGRect(mouseLocation.X, mouseLocation.Y, 0, 0)); rect = outline.ConvertRectFromView(rect, null); var row = outline.GetRow(new CGPoint(rect.X, rect.Y)); if (row >= 0) { var item = outline.ItemAtRow(row) as NSTreeNode; if (item.IsLeaf && DownloadCommandGroup.DownloadAndPlayCommand.CanExecute(LtoFlashViewModel)) { // Should this be changed to the commented out code below (if it even compiles)? var program = item.RepresentedObject as ProgramViewModel; if (program != null) { DownloadCommandGroup.DownloadAndPlay(LtoFlashViewModel.ActiveLtoFlashDevice.Device, program.ProgramDescription); } // (steveno) IIRC the intent here may be to go to the more generic code from INTV.Shared that tries to cope with multiple // possible actions being available on a double-click. For example, what if you have Intellicart, CC3 and LTO Flash! all // available at the same time? ////var programs = NSArray.FromArray<ProgramDescriptionViewModel>(arrangedObjectsArray); ////var doubleClickedProgram = programs[row]; ////DebugItemChange(doubleClickedProgram.Name); ////View.ViewModel.Model.InvokeProgramFromDescription(doubleClickedProgram.Model); } else { if (outline.IsItemExpanded(item)) { outline.CollapseItem(item); } else if (outline.IsExpandable(item)) { outline.ExpandItem(item); } } } } }
/// <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); }