public DialogManager(
			ContentControl parent,
			Dispatcher dispatcher)
        {
            _dispatcher = dispatcher;
            _dialogHost = new DialogLayeringHelper(parent);
        }
示例#2
0
        public static DialogManager Init(IDialogHost dialogHost, IDialogCoordinator dialogCoordinator, bool initDefaultInteractionsHandlers)
        {
            MainDialogManager = new DialogManager(dialogHost, dialogCoordinator);
            if (initDefaultInteractionsHandlers)
            {
                Interactions.SimpleMessage.RegisterHandler(async interaction =>
                {
                    var result = await MainDialogManager.ShowMessageAsync(interaction.Input.Title, interaction.Input.Message);
                    if (result == MessageDialogResult.Affirmative)
                    {
                        interaction.SetOutput(InteractionResult.OK);
                    }
                    else
                    {
                        interaction.SetOutput(InteractionResult.Cancel);
                    }
                });
                Interactions.CriticalError.RegisterHandler(async interaction =>
                {
                    await MainDialogManager.RaiseCriticalErrorAsync(interaction.Input.Message);
                    interaction.SetOutput(InteractionResult.OK);
                });


                //Interactions.SimpleMessage.Subscribe(async input => await MainDialogManager.ShowMessageAsync(input.Title, input.Message));
                //Interactions.LongTimeOperationStarter.Subscribe(async input => await MainDialogManager.ShowDefaultProgressAsync(input.Title, input.Message));
                //Interactions.LongTimeOperationFinisher.Subscribe(async _ => await MainDialogManager.HideDefaultProgressAsync());
                //Interactions.CriticalError.Subscribe(async input => await MainDialogManager.RaiseCriticalErrorAsync(input.Message));
                Interactions.Confirmation.RegisterHandler(async interaction =>
                {
                    var result = await MainDialogManager.ShowConfirmationAsync(
                        interaction.Input.Title,
                        interaction.Input.Message,
                        interaction.Input.YesString,
                        interaction.Input.NoString);
                    if (result)
                    {
                        interaction.SetOutput(InteractionResult.Yes);
                    }
                    else
                    {
                        interaction.SetOutput(InteractionResult.No);
                    }
                });

                Interactions.LongTimeOperationStarter.RegisterHandler(async interaction =>
                {
                    await MainDialogManager.ShowDefaultProgressAsync(interaction.Input.Title, interaction.Input.Message);
                    interaction.SetOutput(InteractionResult.OK);
                });
                Interactions.LongTimeOperationFinisher.RegisterHandler(async interaction =>
                {
                    await MainDialogManager.HideDefaultProgressAsync();
                    interaction.SetOutput(InteractionResult.OK);
                });
            }


            return(MainDialogManager);
        }
示例#3
0
 protected DialogDataEditViewModel(IDialogHost dialogHost, ILoadingPresenter loadingPresenter, IDataRepository dataRepository) : base(dialogHost)
 {
     Apply            = new RelayCommand(ExecuteApply, CanApply);
     Cancel           = new RelayCommand(ExecuteCancel);
     DataRepository   = dataRepository;
     LoadingPresenter = loadingPresenter;
 }
示例#4
0
        public static IProgressDialog CreateProgressDialog(IDialogHost dialogHost, DialogMode dialogMode, Dispatcher dispatcher)
        {
            IProgressDialog dialog = null;

            dispatcher.Invoke(new Action(() => dialog = new WaitProgressDialog(dialogHost, dialogMode, false, dispatcher)), DispatcherPriority.DataBind);
            return(dialog);
        }
示例#5
0
        public ClientsPageViewModel(IClientsService clientsService, IResidencesService residencesService, ISnackbarMessageQueue snackbarMessageQueue, IDialogHost dialogHost, Hotel hotel)
        {
            _clientsService       = clientsService;
            _residencesService    = residencesService;
            _snackbarMessageQueue = snackbarMessageQueue;
            _hotel      = hotel;
            _dialogHost = dialogHost;


            Clients = new ObservableCollection <Client>(_clientsService.Get());

            ClientsViews        = (CollectionView)CollectionViewSource.GetDefaultView(Clients);
            ClientsViews.Filter = ClientsFilter;


            FilteredFields = new Dictionary <string, string>(Client.Fields)
            {
                { AnyFieldFilterValue, "Любое поле" }
            };
            SelectedFilterField = AnyFieldFilterValue;
            IsContainsFilter    = true;

            SortedFields = new Dictionary <string, string>(Client.Fields)
            {
                { NoSortingSortValue, "Не сортировать" }
            };
            SelectedSortField = NoSortingSortValue;
            IsAscendingSort   = true;
        }
 public DialogOrderEditViewModel(IDialogHost dialogHost, ILoadingPresenter loadingPresenter, IDataRepository dataRepository)
     : base(dialogHost, loadingPresenter, dataRepository)
 {
     AddProduct        = new RelayCommand <IProduct>(ExecuteAddProduct, CanAddProduct);
     IncrementQuantity = new RelayCommand <ProductQuantityViewModel>(ExecuteIncrementQuantity);
     DecrementQuantity = new RelayCommand <ProductQuantityViewModel>(ExecuteDecrementQuantity);
 }
示例#7
0
        public PersonsPageViewModel(IPersonsService personsService, IDialogHost dialogHost)
        {
            _personsService = personsService;
            _dialogHost     = dialogHost;

            Persons = new ObservableCollection <Person>(_personsService.Get());


            PersonsViews        = (CollectionView)CollectionViewSource.GetDefaultView(Persons);
            PersonsViews.Filter = PersonsFilter;

            FilteredFields = new Dictionary <string, string>(Person.Fields)
            {
                { AnyFieldFilterValue, "Любое поле" }
            };
            SelectedFilterField = AnyFieldFilterValue;
            IsContainsFilter    = true;

            SortedFields = new Dictionary <string, string>(Person.Fields)
            {
                { NoSortingSortValue, "Не сортировать" }
            };
            SelectedSortField = NoSortingSortValue;
            IsAscendingSort   = true;
        }
 public AddGame(IDialogHost host)
 {
     InitializeComponent();
     _host = host;
     App.DataMan.UnSelectPlatforms();
     PlatformSelector.ItemsSource = App.DataMan.Emulators;
 }
示例#9
0
        public WorkersPageViewModel(IWorkersService workersService, IDialogHost dialogHost)
        {
            _workersService = workersService;
            _dialogHost     = dialogHost;


            Workers = new ObservableCollection <Worker>(_workersService.Get());

            WorkersViews        = (CollectionView)CollectionViewSource.GetDefaultView(Workers);
            WorkersViews.Filter = WorkersFilter;

            FilteredFields = new Dictionary <string, string>(Worker.Fields)
            {
                { AnyFieldFilterValue, "Любое поле" }
            };
            SelectedFilterField = AnyFieldFilterValue;
            IsContainsFilter    = true;

            SortedFields = new Dictionary <string, string>(Worker.Fields)
            {
                { NoSortingSortValue, "Не сортировать" }
            };
            SelectedSortField = NoSortingSortValue;
            IsAscendingSort   = true;

            IsExcludeLaidOffWorkers = false;
        }
        public WeeklySchedulesPageViewModel(ISchedulesService schedulesService, IDialogHost dialogHost)
        {
            _schedulesService = schedulesService;
            _dialogHost       = dialogHost;


            WeeklySchedules = new ObservableCollection <WeeklySchedule>(_schedulesService.Get());
        }
示例#11
0
        public ResidencesPageViewModel(IResidencesService residencesService, IDialogHost dialogHost, Hotel hotel)
        {
            _residencesService = residencesService;
            _dialogHost        = dialogHost;
            _hotel             = hotel;

            Residences = new ObservableCollection <Residence>(_residencesService.Get());
        }
 public StartWithDialog(IDialogHost host)
 {
     InitializeComponent();
     _host = host;
     EmuStarter.DataContext = this;
     StartCommand           = new RelayCommand(o => { Start(o); }, o => true);
     EmuStarter.ItemsSource = App.DataMan.Emulators;
 }
 protected static void DisplayErrorMessage(IDialogHost dialogHost, string errorMessage)
 {
     if (dialogHost == null)
     {
         throw new ArgumentNullException("dialogHost");
     }
     dialogHost.ShowErrorMessage(errorMessage, null);
 }
		public CustomContentDialog(
			IDialogHost dialogHost, 
			DialogMode dialogMode,
			object content,
			Dispatcher dispatcher)
			: base(dialogHost, dialogMode, dispatcher)
		{
			SetContent(content);
		}
示例#15
0
 public CustomContentDialog(
     IDialogHost dialogHost,
     DialogMode dialogMode,
     object content,
     Dispatcher dispatcher)
     : base(dialogHost, dialogMode, dispatcher)
 {
     SetContent(content);
 }
        public HotelRoomsPageViewModel(IHotelRoomsService hotelRoomsService, IDialogHost dialogHost)
        {
            _hotelRoomsService = hotelRoomsService;
            _dialogHost        = dialogHost;

            HotelRooms = new ObservableCollection <HotelRoom>(_hotelRoomsService.Get());

            HotelRoomsViews = (CollectionView)CollectionViewSource.GetDefaultView(HotelRooms);
        }
示例#17
0
 public static async Task ShowMessageDialog(this IDialogHost host, string message, string title = null)
 {
     var vm = new MessageDialogViewModel()
     {
         Title   = title,
         Message = message
     };
     await host.ShowDialog(vm);
 }
		private WaitProgressDialog(
			IDialogHost dialogHost,
			DialogMode dialogMode,
			bool showWaitAnimation,
			Dispatcher dispatcher)
			: base(dialogHost, dialogMode, dispatcher)
		{
			_waitProgressDialogControl = new WaitProgressDialogControl(showWaitAnimation);
			SetContent(_waitProgressDialogControl);
		}
示例#19
0
 private WaitProgressDialog(
     IDialogHost dialogHost,
     DialogMode dialogMode,
     bool showWaitAnimation,
     Dispatcher dispatcher)
     : base(dialogHost, dialogMode, dispatcher)
 {
     _waitProgressDialogControl = new WaitProgressDialogControl(showWaitAnimation);
     SetContent(_waitProgressDialogControl);
 }
示例#20
0
        public static async Task <bool> ShowConfirmationDialog(this IDialogHost host, string message, string title = null)
        {
            var vm = new ConfirmDialogViewModel()
            {
                Title   = title,
                Message = message
            };

            return(await host.ShowDialog(vm));
        }
示例#21
0
        bool IInvokeCommand.Invoke(IDialogHost dialogHost)
        {
            if (!Enabled)
            {
                return(false);
            }

            var args = new DialogUICommandInvokedArgs(dialogHost, this);

            return(OnInvoked(args));
        }
示例#22
0
        public void RegisterHost(IDialogHost host)
        {
            VerifyAccess();

            if (_host != null)
            {
                throw new InvalidOperationException("Dialog host is already registered");
            }

            _host = host ?? throw new ArgumentNullException(nameof(host));
        }
示例#23
0
 public UnityLiveTemplatesOptionsPage(Lifetime lifetime,
                                      UnityScopeCategoryUIProvider uiProvider,
                                      OptionsPageContext optionsPageContext,
                                      OptionsSettingsSmartContext optionsSettingsSmartContext,
                                      StoredTemplatesProvider storedTemplatesProvider,
                                      ScopeCategoryManager scopeCategoryManager,
                                      IDialogHost dialogHost,
                                      TemplatesUIFactory uiFactory, IconHostBase iconHostBase)
     : base(lifetime, uiProvider, optionsPageContext, optionsSettingsSmartContext, storedTemplatesProvider, scopeCategoryManager,
            uiFactory, iconHostBase, dialogHost, "CSHARP")
 {
 }
示例#24
0
        /// <summary>Initializes a new instance of DialogButton.</summary>
        /// <param name="command">The associated UI command.</param>
        /// <param name="dialogHost">The assoicated dialog host.</param>
        internal DialogButton(IUICommand command, IDialogHost dialogHost)
        {
            if (command == null) throw new ArgumentNullException("command");
            if (dialogHost == null) throw new ArgumentNullException("dialogHost");
            Debug.Assert(command is IHasDialogResult);
            Debug.Assert(command is INotifyPropertyChanged);
            Debug.Assert(command is IInvokeCommand);

            _command = command;
            _dialogHost = dialogHost;
            ((INotifyPropertyChanged) _command).PropertyChanged += CommandPropertyChanged;
        }
		public static IProgressDialog CreateProgressDialog(
			IDialogHost dialogHost,
			DialogMode dialogMode,
			Dispatcher dispatcher)
		{
			IProgressDialog dialog = null;
			dispatcher.Invoke(
				new Action(() => dialog = new WaitProgressDialog(
					dialogHost, dialogMode, false, dispatcher)),
				DispatcherPriority.DataBind);
			return dialog;
		}
示例#26
0
        public MainViewModel(ISnackbarMessageQueue snackbarMessageQueue, IDataService dataService, IDialogHost dialogHost)
        {
            SnackbarMessageQueue = snackbarMessageQueue;
            _dataService         = dataService;
            _dialogHost          = dialogHost;

            _dataService.Initialize();

            Hotel = _dataService.Hotel.Get();

            HamburgerMenuSelectedOptionsIndex = -1;

            SelectedClient = ClientsPageViewModel.Clients.First();
        }
        public static IWaitDialog CreateWaitDialog(
            IDialogHost dialogHost,
            DialogMode dialogMode,
            Dispatcher dispatcher,
            bool isIndeterminate)
        {
            IWaitDialog dialog = null;

            dispatcher.Invoke(
                new Action(() => dialog = new WaitProgressDialog(
                               dialogHost, dialogMode, isIndeterminate, dispatcher)),
                DispatcherPriority.DataBind);
            return(dialog);
        }
示例#28
0
        protected DialogBase(
            IDialogHost dialogHost,
            DialogMode dialogMode,
            Dispatcher dispatcher,
            System.Windows.MessageBoxImage image = MessageBoxImage.None)
        {
            this.dialogHost    = dialogHost;
            this.dispatcher    = dispatcher;
            this.Mode          = dialogMode;
            this.Image         = image;
            this.CloseBehavior = DialogCloseBehavior.AutoCloseOnButtonClick;

            this.OkText     = Strings.OK_Button_Label;
            this.CancelText = Strings.Cancel_Button_Label;
            this.YesText    = Strings.Yes_Button_Label;
            this.NoText     = Strings.No_Button_Label;

            switch (dialogMode)
            {
            case DialogMode.None:
                break;

            case DialogMode.Ok:
                this.CanOk = true;
                break;

            case DialogMode.Cancel:
                this.CanCancel = true;
                break;

            case DialogMode.OkCancel:
                this.CanOk     = true;
                this.CanCancel = true;
                break;

            case DialogMode.YesNo:
                this.CanYes = true;
                this.CanNo  = true;
                break;

            case DialogMode.YesNoCancel:
                this.CanYes    = true;
                this.CanNo     = true;
                this.CanCancel = true;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(dialogMode));
            }
        }
        private WaitProgressDialog(
            IDialogHost dialogHost,
            DialogMode dialogMode,
            bool isIndeterminate,
            Dispatcher dispatcher,
            System.Windows.MessageBoxImage image = MessageBoxImage.None)
            : base(dialogHost, dialogMode, dispatcher, image)
        {
            this.HorizontalDialogAlignment = HorizontalAlignment.Center;
            this.VerticalDialogAlignment   = VerticalAlignment.Center;

            this.waitProgressDialogControl = new WaitProgressDialogControl(isIndeterminate);
            this.SetContent(this.waitProgressDialogControl);
        }
        public CustomContentDialog(
            IDialogHost dialogHost,
            DialogMode dialogMode,
            object content,
            Dispatcher dispatcher)
            : base(dialogHost, dialogMode, dispatcher)
        {
            if (content is System.Windows.Controls.Control control)
            {
                this.HorizontalDialogAlignment = control.HorizontalAlignment;
                this.VerticalDialogAlignment   = control.VerticalAlignment;
            }

            this.SetContent(content);
        }
示例#31
0
 public MessageDialog(IDialogHost dialogHost, DialogMode dialogMode, string message, Dispatcher dispatcher) : base(dialogHost, dialogMode, dispatcher)
 {
     InvokeUICall(() =>
     {
         _messageTextBlock = new TextBlock
         {
             Text = message,
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment   = VerticalAlignment.Center,
             TextWrapping        = TextWrapping.Wrap,
             //Foreground = Ertis.Themes.ThemeManager.GetElementFromResource("ContrastBrush5") as SolidColorBrush
         };
         SetContent(_messageTextBlock);
     });
 }
示例#32
0
        protected DialogBase(
            IDialogHost dialogHost,
            DialogMode dialogMode,
            Dispatcher dispatcher)
        {
            _dialogHost   = dialogHost;
            _dispatcher   = dispatcher;
            Mode          = dialogMode;
            CloseBehavior = DialogCloseBehavior.AutoCloseOnButtonClick;

            OkText     = "Ok";
            CancelText = "Cancel";
            YesText    = "Yes";
            NoText     = "No";

            switch (dialogMode)
            {
            case DialogMode.None:
                break;

            case DialogMode.Ok:
                CanOk = true;
                break;

            case DialogMode.Cancel:
                CanCancel = true;
                break;

            case DialogMode.OkCancel:
                CanOk     = true;
                CanCancel = true;
                break;

            case DialogMode.YesNo:
                CanYes = true;
                CanNo  = true;
                break;

            case DialogMode.YesNoCancel:
                CanYes    = true;
                CanNo     = true;
                CanCancel = true;
                break;

            default:
                throw new ArgumentOutOfRangeException("dialogMode");
            }
        }
示例#33
0
        protected DialogBase(IDialogHost dialogHost, DialogMode dialogMode, Dispatcher dispatcher, bool isCloseButtonVisible = true)
        {
            _dialogHost               = dialogHost;
            _dispatcher               = dispatcher;
            Mode                      = dialogMode;
            CloseBehavior             = DialogCloseBehavior.AutoCloseOnButtonClick;
            this.isCloseButtonVisible = isCloseButtonVisible;

            OkText     = Localization.LocalizationUtility.Convert("Ok");
            CancelText = Localization.LocalizationUtility.Convert("Cancel");
            YesText    = Localization.LocalizationUtility.Convert("Yes");
            NoText     = Localization.LocalizationUtility.Convert("No");

            switch (dialogMode)
            {
            case DialogMode.None:
                break;

            case DialogMode.Ok:
                CanOk = true;
                break;

            case DialogMode.Cancel:
                CanCancel = true;
                break;

            case DialogMode.OkCancel:
                CanOk     = true;
                CanCancel = true;
                break;

            case DialogMode.YesNo:
                CanYes = true;
                CanNo  = true;
                break;

            case DialogMode.YesNoCancel:
                CanYes    = true;
                CanNo     = true;
                CanCancel = true;
                break;

            default:
                throw new ArgumentOutOfRangeException("dialogMode");
            }
        }
        ShowPasswordInputDialog(
            this IDialogHost host,
            string message         = null,
            string title           = null,
            string initialPassword = null
            )
        {
            var vm = new PasswordInputDialogViewModel()
            {
                Title    = title ?? "Password input",
                Message  = message ?? "Type your password.",
                Password = initialPassword,
            };
            var result = await host.ShowDialog(vm);

            return(result, vm.Password);
        }
示例#35
0
        /// <summary>Initializes a new instance of DialogButton.</summary>
        /// <param name="command">The associated UI command.</param>
        /// <param name="dialogHost">The assoicated dialog host.</param>
        internal DialogButton(IUICommand command, IDialogHost dialogHost)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (dialogHost == null)
            {
                throw new ArgumentNullException("dialogHost");
            }
            Debug.Assert(command is IHasDialogResult);
            Debug.Assert(command is INotifyPropertyChanged);
            Debug.Assert(command is IInvokeCommand);

            _command    = command;
            _dialogHost = dialogHost;
            ((INotifyPropertyChanged)_command).PropertyChanged += CommandPropertyChanged;
        }
示例#36
0
		protected DialogBase(
			IDialogHost dialogHost,
			DialogMode dialogMode,
			Dispatcher dispatcher)
		{
			_dialogHost = dialogHost;
			_dispatcher = dispatcher;
			Mode = dialogMode;
			CloseBehavior = DialogCloseBehavior.AutoCloseOnButtonClick;

			OkText = "Ok";
			CancelText = "Cancel";
			YesText = "Yes";
			NoText = "No";

			switch (dialogMode)
			{
				case DialogMode.None:
					break;
				case DialogMode.Ok:
					CanOk = true;
					break;
				case DialogMode.Cancel:
					CanCancel = true;
					break;
				case DialogMode.OkCancel:
					CanOk = true;
					CanCancel = true;
					break;
				case DialogMode.YesNo:
					CanYes = true;
					CanNo = true;
					break;
				case DialogMode.YesNoCancel:
					CanYes = true;
					CanNo = true;
					CanCancel = true;
					break;
				default:
					throw new ArgumentOutOfRangeException("dialogMode");
			}

		}
示例#37
0
        public MessageDialog(
			IDialogHost dialogHost, 
			DialogMode dialogMode,
			string message,
			Dispatcher dispatcher)
            : base(dialogHost, dialogMode, dispatcher)
        {
            InvokeUICall(() =>
                {
                    _messageTextBlock = new TextBlock
                    {
                        Text = message,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment = VerticalAlignment.Center,
                        TextWrapping = TextWrapping.Wrap,
                    };
                    SetContent(_messageTextBlock);
                });
        }
示例#38
0
        protected static void DisplayErrorMessage(IDialogHost dialogHost, string errorMessage)
        {
            if (dialogHost == null)
            {
                throw new ArgumentNullException("dialogHost");
            }

            dialogHost.ShowErrorMessage(
                            errorMessage,
                            caption: null);
        }