Ejemplo n.º 1
0
        public override OSVisual CreateVisualForCommand(ICommand command)
        {
            OSVisual visual        = OSVisual.Empty;
            var      visualCommand = command as VisualRelayCommand;
            var      window        = INTV.Shared.Utility.SingleInstanceApplication.Instance.MainWindow;

            if (visualCommand != null)
            {
                switch (visualCommand.UniqueId)
                {
                case UniqueNameBase + ".Root":
                    visual = window.FindChild <Gtk.Toolbar>(c => c.Name == "_toolbar");
                    break;

                case UniqueNameBase + ".RootMenu":
                case UniqueNameBase + ".ApplicationMenuCommand":
                    visual = window.FindChild <Gtk.MenuBar>(c => c.Name == "_menubar");
                    break;

                default:
                    visual = base.CreateVisualForCommand(command);
                    break;
                }
            }
            return(visual);
        }
 /// <summary>
 /// Initializes a new instance of ProgressIndicatorViewModel, attaching it to the specified visual.
 /// </summary>
 /// <param name="visual">The visual with which to associate the progress indicator.</param>
 /// <remarks>This is an atypical construction pattern, driven partly by pragmatism and partly
 /// by laziness in getting the different platforms involved. Blame the Mac and me not caring
 /// to revisit every off-the-cuff workaround I created while trying to avoid replicating the
 /// notion of DependencyObject / DependencyPropery and the whole inheritance mechanism.</remarks>
 public ProgressIndicatorViewModel(OSVisual visual)
 {
     DisplayDelay = DefaultDisplayDelay;
     if (!visual.IsEmpty)
     {
         visual.NativeVisual.SetValue(ProgressIndicatorViewModelDataContextProperty, this);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a Boolean value indicating of the given command is allowed to execute.
        /// </summary>
        /// <param name="command">The command of interest.</param>
        /// <param name="visual">The visual with which the command is associated</param>
        /// <returns><c>true</c> if the command should be allowed to execute, <c>false</c> otherwise.</returns>
        protected override bool HandleCanExecuteChangedForCommand(VisualRelayCommand command, OSVisual visual)
        {
            var canExecute = true;

            if ((command.UniqueId == RomListCommandGroup.RemoveRomsCommand.UniqueId) && (visual.NativeVisual is Gtk.MenuItem))
            {
                // for this one, disable the menu item unless the RomListView's tree has focus.
                canExecute = RomListViewModel.ListHasFocus;
            }
            return(canExecute && base.HandleCanExecuteChangedForCommand(command, visual));
        }
Ejemplo n.º 4
0
 private void OSInitializeVisual(OSVisual visual)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a Boolean value indicating of the given command is allowed to execute.
        /// </summary>
        /// <param name="command">The command of interest.</param>
        /// <param name="visual">The visual with which the command is associated</param>
        /// <returns><c>true</c> if the command should be allowed to execute, <c>false</c> otherwise.</returns>
        protected virtual bool HandleCanExecuteChangedForCommand(VisualRelayCommand command, OSVisual visual)
        {
            object dataContext = null;

            if (!visual.IsEmpty)
            {
                dataContext = visual.NativeVisual.GetInheritedValue(IFakeDependencyObjectHelpers.DataContextPropertyName);
            }
            if (dataContext == null)
            {
                dataContext = GetContextForCommand(dataContext, command, Context);
            }
            return(command.CanExecute(dataContext));
        }