/// <summary> /// Gets a Boolean value indicating of the given command is allowed to execute. /// </summary> /// <param name="command">The command of interest.</param> /// <returns><c>true</c> if the command should be allowed to execute, <c>false</c> otherwise.</returns> protected override bool HandleCanExecuteChangedForCommand(VisualRelayCommand command) { var context = Context; if (command.UniqueId == CancelRomsImportCommand.UniqueId) { context = ProgressIndicatorViewModel; } var canExecute = command.CanExecute(context); if (command.UniqueId == RemoveRomsCommand.UniqueId) { if (canExecute) { NSResponder firstResponder = null; if ((NSApplication.SharedApplication != null) && (NSApplication.SharedApplication.MainWindow != null)) { firstResponder = NSApplication.SharedApplication.MainWindow.FirstResponder; canExecute = firstResponder is NSTableView; if (canExecute) { canExecute = (RomListView != null) && (RomListView.FindChild <NSTableView>() == firstResponder); } command.MenuItem.NativeMenuItem.KeyEquivalent = canExecute ? RemoveRomsCommand.KeyboardShortcutKey : string.Empty; command.MenuItem.NativeMenuItem.KeyEquivalentModifierMask = (NSEventModifierMask)(canExecute ? RemoveRomsCommand.KeyboardShortcutModifiers : OSModifierKeys.None); } } } return(canExecute); }
private OSVisual OSInitializeVisual() { var visual = new RomListView(); visual.DataContext = this; // not sure if this needs to be done... return(visual); }
/// <inheritdoc/> public IEnumerable <ComponentVisual> GetVisuals() { // TODO: This is wrong... ViewModel should not create the visual - it should be the other way around if (_visual == null) { var view = OSInitializeVisual().AsType <RomListView>(); _visual = new System.WeakReference(view); } RomListView romListView = _visual.IsAlive ? _visual.Target as RomListView : null; // ugh... .NET 4.0 doesn't have better Generic version of WeakReference<T> :( var componentVisual = new ComponentVisual(RomListView.Id, romListView, Resources.Strings.RomListSettingsPage_Title); yield return(componentVisual); }
private OSVisual OSInitializeVisual() { var visual = new RomListView(this); return(visual); }