public BaseSelectorViewModel(IDialogIdentifier dialogIdentifier, IClient client) { OwnerIdentifier = dialogIdentifier; this.client = client; CloseDialogCommand = new DelegateCommand(CloseDialog, IsSelected); }
public NewTaskVM(IDialogIdentifier identifier) { Identifier = identifier; CloseDialogCommand = new DelegateCommand(CloseDialog); AddTaskCommand = new DelegateCommand(AddTask); }
public SelectStaffViewModel(int currentId, IDialogIdentifier dialogIdentifier, IClient client, IDataProvider dataProvider) : base(dialogIdentifier, client) { Items = dataProvider.Staff; SelectedItem = Items.FirstOrDefault(x => x.Id == currentId); }
/// <summary> /// Constructor. /// </summary> public BaseSelectorViewModel(IDialogIdentifier owner, ObservableCollection <T> items, T current) { OwnerIdentifier = owner; Items = items; SelectedItem = items.FirstOrDefault(x => x.Equals(current)); CloseDialogCommand = new DelegateCommand(CloseCommand, () => SelectedItem != null); }
/// <summary> /// Конструктор. /// </summary> public ProgramSettingsViewModel(IContainer container) { OwnerIdentifier = container.ResolveRootDialogIdentifier(); Settings = Settings.Default; CloseDialogCommand = new DelegateCommand(CloseDialog); }
/// <summary> /// Update dialog content. /// </summary> /// <param name="identifier">Dialog identifier.</param> /// <param name="content">New content.</param> public static void UpdateContent(this IDialogIdentifier identifier, object content) { if (!Sessions.ContainsKey(identifier.Identifier)) { return; } Sessions[identifier.Identifier].UpdateContent(content); }
/// <summary> /// Close dialog with parameter. /// </summary> /// <param name="identifier">Dialog identifier.</param> /// <param name="parameter">Parameter.</param> public static void Close(this IDialogIdentifier identifier, object parameter) { if (!Sessions.ContainsKey(identifier.Identifier)) { return; } Sessions[identifier.Identifier].Close(parameter); }
static async Task <object> BaseShowAsync(this IDialogIdentifier identifier, object content, Action openedEvent, Action closedEvent) => await DialogHost.Show(content, identifier.Identifier, (_, e) => { Sessions.Add(identifier.Identifier, e.Session); openedEvent?.Invoke(); }, (_, e) => { Sessions.Remove(identifier.Identifier); closedEvent?.Invoke(); });
async Task <T> Show <T, TViewModel>(object[] args, IDialogIdentifier dialogIdentifier = null) { var vm = container.Resolve <TViewModel>(args: args); var view = viewFactory.GetView(vm); dialogIdentifier = dialogIdentifier ?? this.dialogIdentifier; var res = await dialogIdentifier.ShowAsync <T>(view); return(res); }
/// <summary> /// Конструктор. /// </summary> public NavigationViewModel(IContext context, IDialogManager dialogManager, ISnackbarMessageQueue messageQueue, IContainer container) { this.context = context; this.messageQueue = messageQueue; this.dialogManager = dialogManager; dialogIdentifier = container.ResolveRootDialogIdentifier(); EditCommand = new AsyncCommand <T>(Edit, x => x != null); DeleteCommand = new AsyncCommand <T>(Delete, x => x != null); AddCommand = new AsyncCommand(Add); }
/// <summary> /// Открыть диалог. /// </summary> /// <param name="args">Аргументы для VM.</param> /// <param name="dialogIdentifier">Идентификатор, где будет показан диалог.</param> /// <returns></returns> async Task <T> show <T, VM>(object[] args = null, IDialogIdentifier dialogIdentifier = null) { var vm = container.Resolve <VM>(args: args); var view = viewFactory.GetView(vm); dialogIdentifier = dialogIdentifier ?? this.dialogIdentifier; Logger.Log.Info($"Попытка показать диалог: {{view: {view}, viewmodel: {typeof(VM)}}}"); var res = await dialogIdentifier.ShowAsync <T>(view); return(res); }
async void ShowMessageBox(IDialogIdentifier identifier) { var res = await identifier.ShowMessageBoxAsync("Press any button", MaterialMessageBoxButtons.All); if (res == MaterialMessageBoxButtons.Nothing) //returns "Nothing" when dialog closing (look in CloseAllDialogsCommand). { await identifier.ShowMessageBoxAsync("Aborted!", MaterialMessageBoxButtons.Ok); } else { await identifier.ShowMessageBoxAsync($"You pressed: {res}", MaterialMessageBoxButtons.Ok); } }
/// <summary> /// Конструктор. /// </summary> public WaybillStaffSelectorViewModel(IDialogIdentifier dialogIdentifier, IDataProvider dataProvider) { OwnerIdentifier = dialogIdentifier; var settings = Settings.Default; DispatcherSelector = new BaseSelectorViewModel <Staff>(dialogIdentifier, dataProvider.Staff, settings.lastDispatcher); MedicalSelector = new BaseSelectorViewModel <Staff>(dialogIdentifier, dataProvider.Staff, settings.lastMed); MechanicSelector = new BaseSelectorViewModel <Staff>(dialogIdentifier, dataProvider.Staff, settings.lastMechanic); CloseDialogCommand = new DelegateCommand(CloseDialog, () => DispatcherSelector.CloseDialogCommand.CanExecute(null) && MedicalSelector.CloseDialogCommand.CanExecute(null) && MechanicSelector.CloseDialogCommand.CanExecute(null)); }
/// <summary> /// Конструктор. /// </summary> public BaseEditModeViewModel(T obj, bool isEditMode, IContainer container) { IsEditMode = isEditMode; OwnerIdentifier = container.ResolveRootDialogIdentifier(); if (isEditMode) { EditableObject = (T)obj.Clone(); } else { EditableObject = container.Resolve <T>(); } CloseDialogCommand = new DelegateCommand(CloseDialog, IsObjectValid); }
/// <summary> /// Конструктор. /// </summary> public BaseViewModel(IDialogManager dialogManager, ISnackbarMessageQueue snackbarMessageQueue, IClient client, IDataProvider dataProvider, IContainer container) { dialogIdentifier = container.ResolveRootDialogIdentifier(); this.dialogManager = dialogManager; this.snackbarMessageQueue = snackbarMessageQueue; this.client = client; this.dataProvider = dataProvider; AddCommand = new DelegateCommand(Add); EditCommand = new AsyncCommand <T>(Edit, item => item != null); DeleteCommand = new AsyncCommand <T>(Delete, item => item != null); }
/// <summary> /// Конструктор. /// </summary> public LoginViewModel(IRegionManager regionManager, IClient client, IDataProvider dataProvider, IContainer container) { this.regionManager = regionManager; this.dialogIdentifier = container.ResolveRootDialogIdentifier(); this.client = client; this.dataProvider = dataProvider; TryLoginCommand = new AsyncCommand(TryLogin, IsUserValid); LoginUser = new LoginUser { Login = Settings.Default.lastLogin, Password = Settings.Default.lastPassword }; }
/// <summary> /// Show language selector. /// </summary> /// <returns></returns> public async void ShowLanguageSelector(IDialogIdentifier dialogIdentifier) { var res = await Show <Language, LanguageSelectorViewModel>(args : new[] { dialogIdentifier }, dialogIdentifier); if (res == null) { return; //cancel } Properties.Settings.Default.lang = res; Properties.Settings.Default.Save(); var restart = await dialogIdentifier.ShowMessageBoxAsync(Resources.ChangeLanguageEN_Restart, MaterialMessageBoxButtons.YesNo); if (restart == MaterialMessageBoxButtons.Yes) { ProcessHelper.RestartApp(); } }
public MainWindowViewModel(IRegionManager regionManager, ISnackbarMessageQueue messageQueue, IClient client, IDialogManager dialogManager, IContainer container) { DialogIdentifier = container.ResolveRootDialogIdentifier(); MessageQueue = messageQueue; this.client = client; this.regionManager = regionManager; this.dialogManager = dialogManager; this.client.HubConfigurator.Connected += Client_Reconnected; this.client.HubConfigurator.Disconnected += Client_Disconnected; this.client.HubConfigurator.Reconnected += Client_Reconnected; this.client.HubConfigurator.Reconnecting += Client_Reconnecting; this.client.HubConfigurator.ConnectAsync(); }
/// <summary> /// Show message box. /// </summary> /// <param name="identifier">Dialog identifier.</param> /// <param name="content">Dialog content.</param> /// <param name="buttons">Buttons.</param> /// <returns></returns> public static async Task <MaterialMessageBoxButtons> ShowMessageBoxAsync(this IDialogIdentifier identifier, object content, MaterialMessageBoxButtons buttons) => await identifier.ShowAsync <MaterialMessageBoxButtons>(new MaterialMessageBox(content, buttons));
/// <summary> /// Конструктор. /// </summary> public SemitrailerSelectorViewModel(int currentId, IDialogIdentifier dialogIdentifier, IDataProvider dataProvider) : base(dialogIdentifier, dataProvider.Semitrailers, currentId) { }
public NewKeyVM(IDialogIdentifier identifier) { Identifier = identifier; CloseDialogCommand = new DelegateCommand(CloseDialog); }
/// <summary> /// Show dialog with content. /// </summary> /// <param name="identifier">Dialog identifier.</param> /// <param name="content">Dialog content/</param> /// <param name="openedEvent">Raised when dialog showed.</param> /// <param name="closedEvent">Raised when dialog closed.</param> /// <returns></returns> public static async Task <T> ShowAsync <T>(this IDialogIdentifier identifier, object content, Action openedEvent, Action closedEvent) => (T)await identifier.BaseShowAsync(content, openedEvent, closedEvent);
public DialogManager(IDialogViewFactory viewFactory, IContainer container) { this.viewFactory = viewFactory; dialogIdentifier = container.ResolveRootDialogIdentifier(); this.container = container; }
public NewKeyDialog(IDialogIdentifier identifier) { InitializeComponent(); DataContext = new NewKeyVM(identifier); }
/// <summary> /// Конструктор. /// </summary> public TruckSelectorViewModel(int currentId, IDialogIdentifier dialogIdentifier, IDataProvider dataProvider) : base(dialogIdentifier, dataProvider.Trucks, currentId) { }
/// <summary> /// Show dialog with content. /// </summary> /// <param name="identifier">Dialog identifier.</param> /// <param name="content">Dialog content/</param> /// <param name="openedEvent">Raised when dialog showed.</param> /// <returns></returns> public static async Task <object> ShowAsync(this IDialogIdentifier identifier, object content, Action openedEvent) => await identifier.BaseShowAsync(content, openedEvent, null);
/// <summary> /// Конструктор. /// </summary> public DialogManager(IContainer container, IDialogsFactoryView viewFactory) { this.dialogIdentifier = container.ResolveRootDialogIdentifier(); this.container = container; this.viewFactory = viewFactory; }
public static async Task <T> Show <T>(this IDialogIdentifier identifier, object content) => await Task.FromResult(default(T));
public TestDialog(IDialogIdentifier identifier) { InitializeComponent(); DataContext = new TestDialogVM(identifier); }
/// <summary> /// Constructor. /// </summary> public LanguageSelectorViewModel(IDialogIdentifier dialogIdentifier) : base(dialogIdentifier, new ObservableCollection <Language>(Languages.AllLanguages), Properties.Settings.Default.lang) { }