示例#1
0
        /// <summary>
        ///		Trata el evento de modificación del documento activo
        /// </summary>
        private void TreatActiveDocumentChanged(Libraries.BauMvvm.Views.Forms.IFormView formView)
        {
            bool treated = false;

            // Si hay un documento activo, añade los menús abrir, nuevo y adicional
            if (formView != null && formView.FormView.ViewModel is Libraries.BauMvvm.ViewModels.Forms.Interfaces.IFormViewModel viewModel &&
                viewModel != null)
            {
                // Añade los menús
                AddMenus(mnuFilesOpen, viewModel.MenuCompositionData.Menus.Select(MenuGroupViewModel.TargetMenuType.MainMenu,
                                                                                  MenuGroupViewModel.TargetMainMenuItemType.FileOpenItems));
                AddMenus(mnuFilesNew, viewModel.MenuCompositionData.Menus.Select(MenuGroupViewModel.TargetMenuType.MainMenu,
                                                                                 MenuGroupViewModel.TargetMainMenuItemType.FileNewItems));
                AddMenusBetween(mnuFiles, mnuFileAdditionalStart, mnuFileAdditionalEnd,
                                viewModel.MenuCompositionData.Menus.Select(MenuGroupViewModel.TargetMenuType.MainMenu,
                                                                           MenuGroupViewModel.TargetMainMenuItemType.FileAdditionalItems));
                // Indica que se han tratado los menús
                treated = true;
            }
            // Si no se han tratado los menús, oculta los sobrantes
            if (!treated)
            {
                mnuFileAdditionalEnd.Visibility = Visibility.Collapsed;
            }
        }
示例#2
0
        /// <summary>
        ///		Comprueba si se puede ejecutar una acción
        /// </summary>
        protected override bool CanExecuteAction(string action, object parameter)
        {
            Libraries.BauMvvm.Views.Forms.IFormView viewModel = GetActiveViewModel();
            bool canExecute = false;

            // Comprueba si se puede ejecutar el comando
            if (viewModel != null)
            {
                switch (action)
                {
                case nameof(CloseCommand):
                case nameof(SaveAllCommand):
                case nameof(CloseAllWindowsCommand):
                case nameof(HelpIndexCommand):
                    canExecute = true;
                    break;

                case nameof(NewCommand):
                    if (viewModel is IPaneViewModel)
                    {
                        canExecute = (viewModel as IPaneViewModel).NewCommand.CanExecute(parameter);
                    }
                    break;

                case nameof(SaveCommand):
                    if (viewModel is IFormViewModel)
                    {
                        canExecute = (viewModel as IFormViewModel).SaveCommand.CanExecute(parameter);
                    }
                    break;

                case nameof(PropertiesCommand):
                    if (viewModel is IPaneViewModel)
                    {
                        canExecute = (viewModel as IPaneViewModel).PropertiesCommand.CanExecute(parameter);
                    }
                    break;

                case nameof(DeleteCommand):
                    if (viewModel is IFormViewModel)
                    {
                        canExecute = (viewModel as IFormViewModel).DeleteCommand.CanExecute(parameter);
                    }
                    break;

                case nameof(RefreshCommand):
                    if (viewModel is IFormViewModel)
                    {
                        canExecute = (viewModel as IFormViewModel).RefreshCommand.CanExecute(parameter);
                    }
                    break;
                }
            }
            // Ejecuta el comando
            return(canExecute);
        }
示例#3
0
        /// <summary>
        ///		Ejecuta una acción
        /// </summary>
        protected override void ExecuteAction(string action, object parameter)
        {
            Libraries.BauMvvm.Views.Forms.IFormView viewModel = GetActiveViewModel();

            if (viewModel != null)
            {
                switch (action)
                {
                case nameof(CloseCommand):
                    Close(SystemControllerEnums.ResultType.Yes);
                    break;

                case nameof(CloseAllWindowsCommand):
                    DockingController.CloseAllDocuments();
                    break;

                case nameof(NewCommand):
                    if (viewModel is IPaneViewModel)
                    {
                        (viewModel as IPaneViewModel).NewCommand.Execute(parameter);
                    }
                    break;

                case nameof(SaveAllCommand):
                    DockingController.SaveAllDocuments();
                    break;

                case nameof(SaveCommand):
                    if (viewModel is IFormViewModel)
                    {
                        (viewModel as IFormViewModel).SaveCommand.Execute(parameter);
                    }
                    break;

                case nameof(DeleteCommand):
                    if (viewModel is IFormViewModel)
                    {
                        (viewModel as IFormViewModel).DeleteCommand.Execute(parameter);
                    }
                    break;

                case nameof(PropertiesCommand):
                    if (viewModel is IPaneViewModel)
                    {
                        (viewModel as IPaneViewModel).PropertiesCommand.Execute(parameter);
                    }
                    break;

                case nameof(RefreshCommand):
                    if (viewModel is IFormViewModel)
                    {
                        (viewModel as IFormViewModel).RefreshCommand.Execute(parameter);
                    }
                    break;

                case nameof(HelpIndexCommand):
                    Globals.HostController.ShowWebBrowser("http://BauPlugStudio.webs-interesantes.es");
                    break;
                }
            }
        }