public async void Add() { var shell = (IoC.Get <IShell>() as Screen); var name = await Dialogs.ShowInputAsync(shell, "New Playlist", "Please enter a name for the playlist"); //this.events.PublishOnUIThread(new ShowInputDialogEvent("Please enter a name for the playlist", "New Playlist")); if (name != null && name != string.Empty) { Playlist p = new Playlist(MatchManager.Match); p.Name = name; MatchManager.Match.Playlists.Add(p); MatchManager.MatchModified = true; NotifyOfPropertyChange("MatchManager.MatchModified"); double pt = 0; for (int c = 0; c < p.Rallies.Count(); c++) { pt = pt + (p.Rallies[c].End - p.Rallies[c].Start); } double test = pt; this.ActivateItem(new PlaylistItem() { Name = name, Count = p.Rallies.Count(), PlayTime = pt, List = p }); } }
private async void SendMessage() { var msg = await _dialog.ShowInputAsync(this, "Send message to " + SelectedUser.Login, null); if (msg == null) { return; } _hub.Invoke("SendMessage", SelectedUser.ConnectionID, msg); }
private async Task <string> ShowColumnNameInput() { return(await dialogCoordinator .ShowInputAsync(this, "ColumnRed", "Введите название столбца", new MetroDialogSettings() { AffirmativeButtonText = "подтвердить", NegativeButtonText = "отмена", DefaultText = SelectedColumn?.Name })); }
private async void RenameWatchlist() { var newName = await Dialog.ShowInputAsync(this, "Enter new name:", null); if (newName == null) { return; } File.Move(WatchListPath, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Inside MMA\\settings\\watchlists\\" + newName); GetWatchlists(); Name = newName; SelectedWatchlist = Name; }
/// <summary> /// Open the Jenkins hash dialog. /// </summary> private async void DoJenkinsHashCommand() { var strToHash = await _dialogCoordinator.ShowInputAsync(this, "Jenkins Hash", "What would you like to hash?"); if (string.IsNullOrWhiteSpace(strToHash)) { return; } var hash32 = JenkinsHash.GetHash32(strToHash); var hash64 = JenkinsHash.GetHash64(strToHash); await _dialogCoordinator.ShowMessageAsync(this, "Hash Result", $"The 32-bit Jenkins hash of \"{strToHash}\" is 0x{hash32:X8}.\nThe 64-bit Jenkins hash is 0x{hash64:X16}."); }
private async void AddProfileAction() { MetroDialogSettings settings = AppearanceManager.MetroDialog; settings.AffirmativeButtonText = Application.Current.Resources["String_Button_Add"] as string; settings.NegativeButtonText = Application.Current.Resources["String_Button_Cancel"] as string; string name = await dialogCoordinator.ShowInputAsync(this, Application.Current.Resources["String_Header_AddProfile"] as string, Application.Current.Resources["String_EnterNameForProfile"] as string, settings); if (string.IsNullOrEmpty(name)) { return; } string configSubnetmask = ConfigSubnetmaskOrCidr; if (ConfigEnableStaticIPAddress && ConfigSubnetmaskOrCidr.StartsWith("/")) { configSubnetmask = Subnetmask.GetFromCidr(int.Parse(ConfigSubnetmaskOrCidr.TrimStart('/'))).Subnetmask; } NetworkInterfaceProfileInfo profile = new NetworkInterfaceProfileInfo { Name = name, EnableStaticIPAddress = ConfigEnableStaticIPAddress, IPAddress = ConfigIPAddress, Gateway = ConfigGateway, Subnetmask = configSubnetmask, EnableStaticDNS = ConfigEnableStaticDNS, PrimaryDNSServer = ConfigPrimaryDNSServer, SecondaryDNSServer = ConfigSecondaryDNSServer }; NetworkInterfaceProfileManager.AddProfile(profile); }
private async void AddClientAction() { MetroDialogSettings settings = AppearanceManager.MetroDialog; settings.AffirmativeButtonText = Application.Current.Resources["String_Button_Add"] as string; settings.NegativeButtonText = Application.Current.Resources["String_Button_Cancel"] as string; settings.DefaultButtonFocus = MessageDialogResult.Affirmative; string hostname = await dialogCoordinator.ShowInputAsync(this, Application.Current.Resources["String_Header_AddClient"] as string, Application.Current.Resources["String_EnterHostnameForClient"] as string, settings); if (string.IsNullOrEmpty(hostname)) { return; } WakeOnLANClientInfo client = new WakeOnLANClientInfo { Hostname = hostname.ToUpper(), MACAddress = MACAddressHelper.GetDefaultFormat(MACAddress), Broadcast = Broadcast, Port = Port }; WakeOnLANClientManager.AddClient(client); }
//put yourself to sleep private async void SelfSleep() { var time = await Dialog.ShowInputAsync(this, "Set time", "Time:"); if (time != null) { await Hub.Invoke("SleepUser", ClientInfo.InsideLogin, time); } }
public static async Task <string> ProcessUserInputStringArg(string inputArgs, string operationName, IDialogCoordinator dc, object dcContext) { if (!inputArgs.Contains("%sarg")) { return(inputArgs); } var userInput = await dc.ShowInputAsync(dcContext, "Enter argument", $"Please specify argument for the {operationName}:"); if (userInput == null) { return(null); } return(inputArgs.Replace("%sarg", userInput)); }
public async void Execute(CoroutineExecutionContext context) { var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "OK", AnimateShow = true, AnimateHide = false }; IDialogCoordinator coordinator = IoC.Get <IDialogCoordinator>(); var result = await coordinator.ShowInputAsync(context.Target, this.Title, this.Question, mySettings); this.Result = result; var args = new ResultCompletionEventArgs() { WasCancelled = result == string.Empty || result == null }; this.Completed(this, args); }
private async Task ShowFilesDialogsAsync(string droppedFile) { MetroDialogSettings settings = new MetroDialogSettings(); settings.DialogMessageFontSize = 12; settings.DialogTitleFontSize = 12; var file = Path.GetFileNameWithoutExtension(droppedFile); settings.DefaultText = file; var result = await _dialogService.ShowInputAsync(this, droppedFile, @"path & name..eg: MyLayer/MyLayer", settings); if (result != null) { await ImagesFromMovie(result + "," + droppedFile); } var savedName = result + @"/" + result + @"_%04d.png".Trim(' '); var count = _assetRepo.Animation.Animations.Where(x => x.FileName == savedName).Count(); if (count == 0) { _assetRepo.Animation.Animations.Add(new AssetModel.Animations() { Alias = file, ColorKey = "blacksrc", FileName = savedName, PosX = 0, PosY = 0, Repeat = false }); Animations.Refresh(); } }
/// <summary> /// Shows a input dialog /// </summary> /// <param name="title">The title of the dialog</param> /// <param name="message">The message of the dialog</param> /// <returns>The result of the input</returns> protected async Task <string> ShowInput(string title, string message) { var result = await _dialogCoordinator.ShowInputAsync(this, title, message); return(result); }
public async Task <string> ShowInputMessageAsync(object context, string title, string message) { return(await _dialogCoordinator.ShowInputAsync(context, title, message, _confirmDialogSettings)); }
public Task <string> ShowInputAsync(object context, string title, string message, IDialogSettings settings = null) => Instance.ShowInputAsync(context, title, message, settings?.ToMetroDialogSettings());
public static async Task RenameLogViewRoutine(IDialogCoordinator dialogCoordinator, object dialogContext, SourceCache <LogView, string> logViewsSourceCache, LogView logView) { var result = new ServiceOperationResult(); var maxCharLength = 100; var oldLogViewName = logView.Name; var keepPrompting = true; var dialogSettings1 = new MetroDialogSettings() { AffirmativeButtonText = "Rename", DefaultText = oldLogViewName, }; while (keepPrompting) { var newLogViewName = await dialogCoordinator.ShowInputAsync(dialogContext, "Rename Log View", "New name:", dialogSettings1); if (newLogViewName == null) { keepPrompting = false; } else if (string.IsNullOrWhiteSpace(newLogViewName)) { await dialogCoordinator.ShowMessageAsync(dialogContext, "Invalid Log View Name", "The new log view name cannot be null or whitespace."); } else if (newLogViewName.Length > maxCharLength) { await dialogCoordinator.ShowMessageAsync(dialogContext, "Invalid Log View Name", $"The new log view name cannot be greater than {maxCharLength} characters."); dialogSettings1.DefaultText = newLogViewName.Substring(0, maxCharLength); } else if (logViewsSourceCache.Keys.Contains(newLogViewName)) { var dialogSettings2 = new MetroDialogSettings() { AffirmativeButtonText = "Overwrite", NegativeButtonText = "Pick a new name", DefaultButtonFocus = MessageDialogResult.Negative, }; var dialogResult = await dialogCoordinator.ShowMessageAsync(dialogContext, "Log View Already Exists", $"There is already a log view with the name \"{newLogViewName}\". Would you like to overwrite the existing log view?", MessageDialogStyle.AffirmativeAndNegative, dialogSettings2); if (dialogResult == MessageDialogResult.Affirmative) { //Remove the old log view and the log view which will be replaced, rename the log view, and add it back in await Task.Run(() => { try { result.Status = ServiceOperationStatus.Attempting; AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Attempting to rename {typeof(LogView).Name} from \"{oldLogViewName}\" to \"{newLogViewName}\" which will overwrite existing log view with name \"{newLogViewName}\".", LogMessageType.Verbose); logViewsSourceCache.Edit(innerCache => { innerCache.RemoveKey(newLogViewName); innerCache.RemoveKey(oldLogViewName); logView.Name = newLogViewName; logView.IsEdited = true; innerCache.AddOrUpdate(logView); }); result.Status = ServiceOperationStatus.Succeeded; AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Successfully renamed {typeof(LogView).Name} from \"{oldLogViewName}\" to \"{newLogViewName}\".", LogMessageType.Verbose); } catch (Exception ex) { result.Status = ServiceOperationStatus.Failed; result.UserFriendlyErrorMessage = $"{AppInfo.BaseAppInfo.AppName} failed to rename {typeof(LogView).Name} from \"{oldLogViewName}\" to \"{newLogViewName}\"."; result.ErrorMessage = result.UserFriendlyErrorMessage + $" {ex.Message}"; AppInfo.BaseAppInfo.Log.QueueLogMessageAsync(result.ErrorMessage, LogMessageType.Error); } }); if (result.OperationSuceeded) { //Remove old log view from settings result = await SettingsService.RemoveLogViewByName(oldLogViewName); } keepPrompting = false; } } else { //Remove the old log view, rename it, and add it back in await Task.Run(() => { try { result.Status = ServiceOperationStatus.Attempting; AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Attempting to rename {typeof(LogView).Name} from \"{oldLogViewName}\" to \"{newLogViewName}\".", LogMessageType.Verbose); logViewsSourceCache.Edit(innerCache => { innerCache.RemoveKey(oldLogViewName); logView.Name = newLogViewName; logView.IsEdited = true; innerCache.AddOrUpdate(logView); }); result.Status = ServiceOperationStatus.Succeeded; AppInfo.BaseAppInfo.Log.QueueLogMessageAsync($"Successfully renamed {typeof(LogView).Name} from \"{oldLogViewName}\" to \"{newLogViewName}\".", LogMessageType.Verbose); } catch (Exception ex) { result.Status = ServiceOperationStatus.Failed; result.UserFriendlyErrorMessage = $"{AppInfo.BaseAppInfo.AppName} failed to rename {typeof(LogView).Name} from \"{oldLogViewName}\" to \"{newLogViewName}\"."; result.ErrorMessage = result.UserFriendlyErrorMessage + $" {ex.Message}"; AppInfo.BaseAppInfo.Log.QueueLogMessageAsync(result.ErrorMessage, LogMessageType.Error); } }); if (result.OperationSuceeded) { //Remove old log view from settings result = await SettingsService.RemoveLogViewByName(oldLogViewName); } keepPrompting = false; } } if (result.OperationFailed) { await result.ShowUserErrorMessage(dialogCoordinator, dialogContext); } else { await Task.Delay(100); Mediator.NotifyColleagues(MediatorMessages.RequestSetSelectedLogView, logView); } }
public async Task <string> ShowInputString(InputStringDialogOption options) { return(await _dialog.ShowInputAsync(options.Context, options.Title, options.Message, options)); }
public UnderlyingSymbolsViewModel(IDataClient client, IDialogCoordinator dialogCoordinator) { UnderlyingSymbols = new ObservableCollection <UnderlyingSymbolViewModel>(); //Load the symbols Load = ReactiveCommand.CreateFromTask(async _ => { var result = await client.GetUnderlyingSymbols(); if (await result.DisplayErrors(this, dialogCoordinator)) { return(null); } return(result.Result); }); Load.Subscribe(symbols => { if (symbols == null) { return; } foreach (var vm in symbols.Select(x => new UnderlyingSymbolViewModel(x))) { UnderlyingSymbols.Add(vm); } }); //Add Add = ReactiveCommand.CreateFromTask(async _ => { var symbolName = await dialogCoordinator.ShowInputAsync(this, "Symbol Name", "Enter new symbol name"); if (string.IsNullOrEmpty(symbolName)) { return(null); } var newSymbol = new UnderlyingSymbol { Symbol = symbolName, Rule = new ExpirationRule() }; var response = await client.AddUnderlyingSymbol(newSymbol); if (await response.DisplayErrors(this, dialogCoordinator)) { return(null); } return(response.Result); }); Add.Where(x => x != null) .Subscribe(underlyingSymbol => { var vm = new UnderlyingSymbolViewModel(underlyingSymbol); UnderlyingSymbols.Add(vm); SelectedSymbol = vm; }); //Delete var deleteCanExecute = this .WhenAnyValue(x => x.SelectedSymbol) .Select(x => x != null); Delete = ReactiveCommand.CreateFromTask(async _ => { var sureDelete = await dialogCoordinator.ShowMessageAsync(this, "Delete", $"Are you sure you want to delete {SelectedSymbol.Symbol}?", MessageDialogStyle.AffirmativeAndNegative); if (sureDelete == MessageDialogResult.Negative) { return; } var response = await client.DeleteUnderlyingSymbol(SelectedSymbol.Model); if (await response.DisplayErrors(this, dialogCoordinator)) { return; } UnderlyingSymbols.Remove(SelectedSymbol); SelectedSymbol = null; }, deleteCanExecute); //Save var saveCanExecute = this .WhenAnyValue(x => x.SelectedSymbol, x => x.SelectedSymbolHasErrors, (symbol, hasError) => new { symbol, hasError }) .Select(x => x.symbol != null && x.hasError == false); Save = ReactiveCommand.CreateFromTask(async _ => { var response = await client.UpdateUnderlyingSymbol(SelectedSymbol.Model); await response.DisplayErrors(this, dialogCoordinator); }, saveCanExecute); }
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously #endregion #region Message boxes protected virtual Task <string> ShowInputBoxAsync(string message, string title = null) { title = title ?? CommonStrings.ACGeneralLabel; return(_dialogCoordinator.ShowInputAsync(this, title, message)); }
public WizardViewModel(IAppModel appModel, IShell shell, IDialogCoordinator dc, IAppConfig cfg, ITemplates templates) { this.appModel = appModel; this.shell = shell; dialCoord = dc; appConfig = cfg; ColorTheme = appConfig.ColorTheme; Templates = templates.GetBoardTemplates().Result; Columns = new ObservableCollection <Column>(); Rows = new ObservableCollection <Row>(); FillFromTemplateCommand = ReactiveCommand.Create(() => { if (SelectedTemplate == null) { return; } Columns.Clear(); Columns.AddRange(SelectedTemplate.Columns); Rows.Clear(); Rows.AddRange(SelectedTemplate.Rows); }); ClearAllCommand = ReactiveCommand.Create(() => { Columns.Clear(); Rows.Clear(); }); CreateCommand = ReactiveCommand.CreateFromTask(CreateCommandExecute); CancelCommand = ReactiveCommand.Create(this.Close); SelectFolderCommand = ReactiveCommand.Create(() => { var dialog = new FolderBrowserDialog { ShowNewFolderButton = false, SelectedPath = FolderName }; if (dialog.ShowDialog() == DialogResult.OK) { FolderName = dialog.SelectedPath; } }); AddColumnCommand = ReactiveCommand.CreateFromTask(async _ => { var ts = await dialCoord.ShowInputAsync(this, "Info", $"Enter new column name"); if (string.IsNullOrEmpty(ts)) { return; } if (Columns.Any(x => x.Name == ts)) { return; } Columns.Add(new Column { Name = ts }); }); AddRowCommand = ReactiveCommand.CreateFromTask(async _ => { var ts = await dialCoord.ShowInputAsync(this, "Info", $"Enter new row name"); if (string.IsNullOrEmpty(ts)) { return; } if (Rows.Any(x => x.Name == ts)) { return; } Rows.Add(new Row { Name = ts }); }); Title = "Creating new board"; FullTitle = Title; this.WhenAnyValue(x => x.BoardName) .Where(x => !string.IsNullOrWhiteSpace(x) && IsNewFile) .Subscribe(v => FileName = BoardNameToFileName(v)); appConfig.ColorThemeObservable .Subscribe(x => UpdateColorTheme()); }
public async void ShowInputDialog() { await _dialogCoordinator.ShowInputAsync(this, "Input to Screen1ViewModel", "Enter something here...").ContinueWith(t => HandleInputBoxClose(t.Result)); }