/// <summary> /// Initializes a new instance of the <see cref="INTV.LtoFlash.View.DeviceInformationPage"/> class. /// </summary> public DeviceInformationPage() { // Don't want to block this due to the dialog being up, which is the default behavior // for dialogs. Save the value and then restore when destroyed. _blockWhenBusy[DeviceCommandGroup.SetDeviceNameCommand] = DeviceCommandGroup.SetDeviceNameCommand.BlockWhenAppIsBusy; _blockWhenBusy[DeviceCommandGroup.SetDeviceOwnerCommand] = DeviceCommandGroup.SetDeviceOwnerCommand.BlockWhenAppIsBusy; foreach (var blockWhenBusy in _blockWhenBusy) { blockWhenBusy.Key.BlockWhenAppIsBusy = false; } this.Build(); _deviceName.TooltipText = DeviceCommandGroup.SetDeviceNameCommand.ToolTipDescription; _nameEditor = new TextCellInPlaceEditor(_deviceName, FileSystemConstants.MaxShortNameLength) { IsValidCharacter = INTV.Core.Model.Grom.Characters.Contains }; _nameEditor.EditorClosed += DeviceNameEditorClosed; _deviceOwner.TooltipText = DeviceCommandGroup.SetDeviceOwnerCommand.ToolTipDescription; _ownerEditor = new TextCellInPlaceEditor(_deviceOwner, FileSystemConstants.MaxLongNameLength) { IsValidCharacter = INTV.Core.Model.Grom.Characters.Contains }; _ownerEditor.EditorClosed += DeviceOwnerEditorClosed; _deviceUniqueId.TooltipText = DeviceCommandGroup.DeviceUniqueIdCommand.ToolTipDescription; CommandManager.RequerySuggested += HandleRequerySuggested; }
/// <inheritdoc/> protected override void OnDestroyed() { foreach (var blockWhenBusy in _blockWhenBusy) { blockWhenBusy.Key.BlockWhenAppIsBusy = blockWhenBusy.Value; } CommandManager.RequerySuggested -= HandleRequerySuggested; _nameEditor.EditorClosed -= DeviceNameEditorClosed; _nameEditor.Dispose(); _nameEditor = null; _ownerEditor.EditorClosed -= DeviceOwnerEditorClosed; _ownerEditor.Dispose(); _ownerEditor = null; base.OnDestroyed(); }
private void InitializeMenuLayout(Gtk.TreeView menuLayout, MenuLayoutViewModel dataContext) { menuLayout.SetValue(IFakeDependencyObjectHelpers.DataContextPropertyName, dataContext); var column = new Gtk.TreeViewColumn(); Gtk.CellRenderer cellRenderer = new Gtk.CellRendererPixbuf(); column.PackStart(cellRenderer, true); column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellImageColumnRenderer <FileNodeViewModel>(l, c, m, i, p => p.Icon)); ////column.Sizing = Gtk.TreeViewColumnSizing.Fixed; ////column.FixedWidth = 20; menuLayout.AppendColumn(column); column = new Gtk.TreeViewColumn() { Title = MenuLayoutViewModel.LongNameHeader }; cellRenderer = new Gtk.CellRendererText(); _longNameEditor = new TextCellInPlaceEditor(menuLayout, column, cellRenderer as Gtk.CellRendererText, FileSystemConstants.MaxLongNameLength) { IsValidCharacter = INTV.Core.Model.Grom.Characters.Contains }; _longNameEditor.EditorClosed += HandleInPlaceEditorClosed; column.PackStart(cellRenderer, true); column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellTextColumnRenderer <FileNodeViewModel>(l, c, m, i, p => p.LongName.SafeString())); column.Sizing = Gtk.TreeViewColumnSizing.Fixed; column.FixedWidth = Properties.Settings.Default.MenuLayoutLongNameColWidth; column.Resizable = true; menuLayout.AppendColumn(column); column = new Gtk.TreeViewColumn() { Title = MenuLayoutViewModel.ShortNameHeader }; cellRenderer = new Gtk.CellRendererText(); _shortNameEditor = new TextCellInPlaceEditor(menuLayout, column, cellRenderer as Gtk.CellRendererText, FileSystemConstants.MaxShortNameLength) { IsValidCharacter = INTV.Core.Model.Grom.Characters.Contains }; _shortNameEditor.EditorClosed += HandleInPlaceEditorClosed; column.PackStart(cellRenderer, true); column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellTextColumnRenderer <FileNodeViewModel>(l, c, m, i, p => p.ShortName.SafeString())); column.Sizing = Gtk.TreeViewColumnSizing.Fixed; column.FixedWidth = Properties.Settings.Default.MenuLayoutShortNameColWidth; column.Resizable = true; menuLayout.AppendColumn(column); column = new Gtk.TreeViewColumn() { Title = MenuLayoutViewModel.ManualHeader }; cellRenderer = new Gtk.CellRendererText(); column.PackStart(cellRenderer, true); column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellTextColumnRenderer <FileNodeViewModel>(l, c, m, i, GetManualColumnStringValue)); column.Sizing = Gtk.TreeViewColumnSizing.Fixed; column.FixedWidth = Properties.Settings.Default.MenuLayoutManualColWidth; column.Resizable = true; menuLayout.AppendColumn(column); column = new Gtk.TreeViewColumn() { Title = MenuLayoutViewModel.SaveDataHeader }; cellRenderer = new Gtk.CellRendererText(); column.PackStart(cellRenderer, true); ////column.SetCellDataFunc(cellRenderer, (l,c,m,i) => VisualHelpers.CellTextColumnRenderer<ProgramDescriptionViewModel>(l,c,m,i, p => p.Name)); ////column.Sizing = Gtk.TreeViewColumnSizing.Fixed; ////column.FixedWidth = Properties.Settings.Default.MenuLayoutSaveDataColWidth; column.Resizable = true; column.Visible = Properties.Settings.Default.ShowAdvancedFeatures; menuLayout.AppendColumn(column); menuLayout.HasTooltip = true; menuLayout.QueryTooltip += HandleMenuLayoutQueryTooltip; var menuLayoutStore = new Gtk.TreeStore(typeof(FileNodeViewModel)); dataContext.SynchronizeToTreeStore(menuLayoutStore); menuLayout.Model = menuLayoutStore; menuLayout.EnableModelDragSource(Gdk.ModifierType.Button1Mask, DragDropSourceEntries, Gdk.DragAction.Move); menuLayout.EnableModelDragDest(DragDropTargetEntries, Gdk.DragAction.Copy | Gdk.DragAction.Move); menuLayout.Selection.Changed += HandleSelectionChanged; dataContext.PropertyChanged += HandleMenuLayoutPropertyChanged; }
/// <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); }