private string QueryProfileName(string profileName) { var f = new InputBoxWindow(); f.IsValidInput = ViewModel.ProfilenameIsValid; f.QuestionText = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow", "EnterProfileName", "Please enter profile name:"); if (profileName != null) { f.InputText = profileName; } else { f.InputText = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow", "NewProfile", "New Profile"); } f.Title = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow", "ProfileName", "Profile name"); if (f.ShowDialog() != true) { return(null); } return(f.InputText); }
public Result <InteractionEvents.CollectionDocumentsCreated> AddFileToDatabase(DatabaseReference database) { var dialog = new OpenFileDialog { Filter = "All files|*.*", Multiselect = false }; if (dialog.ShowDialog() != true) { return(Result.Fail <InteractionEvents.CollectionDocumentsCreated>("FILE_OPEN_CANCELED")); } try { if (InputBoxWindow.ShowDialog("New file id:", "Enter new file id", Path.GetFileName(dialog.FileName), out string id) == true) { var file = database.AddFile(id, dialog.FileName); var documentsCreated = new InteractionEvents.CollectionDocumentsCreated(file.Collection, new [] { file }); return(Result.Ok(documentsCreated)); } } catch (Exception exc) { ErrorInteraction("Failed to upload file:" + Environment.NewLine + exc.Message); } return(Result.Fail <InteractionEvents.CollectionDocumentsCreated>("FILE_OPEN_FAIL")); }
public Task <Result <CollectionDocumentChangeEventArgs> > AddFileToDatabase(DatabaseReference database) { var dialog = new OpenFileDialog { Filter = "All files|*.*", Multiselect = false }; if (dialog.ShowDialog() != true) { return(Task.FromResult(Result.Fail <CollectionDocumentChangeEventArgs>("FILE_OPEN_CANCELED"))); } try { if (InputBoxWindow.ShowDialog("New file id:", "Enter new file id", Path.GetFileName(dialog.FileName), out string id) == true) { var file = database.AddFile(id, dialog.FileName); var documentsCreated = new CollectionDocumentChangeEventArgs(ReferenceNodeChangeAction.Add, new [] { file }, file.Collection); _eventAggregator.PublishOnUIThread(documentsCreated); return(Task.FromResult(Result.Ok(documentsCreated))); } } catch (Exception exc) { _applicationInteraction.ShowError(exc, "Failed to upload file:" + Environment.NewLine + exc.Message, "Database error"); } return(Task.FromResult(Result.Fail <CollectionDocumentChangeEventArgs>("FILE_OPEN_FAIL"))); }
private void AddFileToDatabase(DatabaseReference database) { var dialog = new OpenFileDialog() { Filter = "All files|*.*", Multiselect = false }; if (dialog.ShowDialog() != true) { return; } try { if (InputBoxWindow.ShowDialog("New file id:", "Enter new file id", Path.GetFileName(dialog.FileName), out string id) == true) { var file = database.AddFile(id, dialog.FileName); SelectedCollection = database.Collections.First(a => a.Name == "_files"); ListCollectionData.SelectedItem = file; ListCollectionData.ScrollIntoView(ListCollectionData.SelectedItem); } } catch (Exception exc) { MessageBox.Show( "Failed to upload file:" + Environment.NewLine + exc.Message, "Database error", MessageBoxButton.OK, MessageBoxImage.Error ); } }
public Result AddFileToDatabase(DatabaseReference database) { var dialog = new OpenFileDialog { Filter = "All files|*.*", Multiselect = false }; if (dialog.ShowDialog() != true) { return(Result.Fail("FILE_OPEN_CANCELED")); } try { if (InputBoxWindow.ShowDialog("New file id:", "Enter new file id", Path.GetFileName(dialog.FileName), out string id) == true) { var file = database.AddFile(id, dialog.FileName); Store.Current.SelectCollection(database.Collections.First(a => a.Name == "_files")); Store.Current.SelectDocument(file); return(Result.Ok()); } } catch (Exception exc) { ErrorInteraction("Failed to upload file:" + Environment.NewLine + exc.Message); } return(Result.Fail("FILE_OPEN_FAIL")); }
private void btnShotClockSet_Click(object sender, RoutedEventArgs e) { var ibw = new InputBoxWindow( "Enter the shot clock left:", SQLiteIO.GetSetting("LastShotClockSet", "0.0"), "NBA Stats Tracker"); if (ibw.ShowDialog() == false) { return; } var shotClock = _shotClock; try { shotClock = ConvertTimeStringToDouble(InputBoxWindow.UserInput); } catch { return; } _shotClock = shotClock; updateShotClockIndication(_shotClock); SQLiteIO.SetSetting("LastShotClockSet", InputBoxWindow.UserInput); }
public Task <Maybe <string> > ShowInputDialog(string message, string caption = "", string predefined = "", Func <string, Result> validationFunc = null) { var completionSource = new TaskCompletionSource <Maybe <string> >(); completionSource.SetResult( InputBoxWindow.ShowDialog(message, caption, predefined, validationFunc, out var inputText) == true ? inputText : Maybe <string> .None); return(completionSource.Task); }
public static string Show(string prompt, string caption, bool filterInput = false) { string returnString = string.Empty; InputBoxWindow inputBoxWindow = new InputBoxWindow(prompt, caption, filterInput); inputBoxWindow.ShowDialog(); returnString = inputBoxWindow.UserInput; return(returnString); }
public void RenameSelectedCollection() { try { if (InputBoxWindow.ShowDialog("New name:", "Enter new collection name", Store.Current.SelectedCollection.Name, out string name) == true) { Store.Current.SelectedDatabase.RenameCollection(Store.Current.SelectedCollection.Name, name); } } catch (Exception exc) { ErrorInteraction("Failed to rename collection:" + Environment.NewLine + exc.Message); } }
public void AddCollectionToSelectedDatabase() { try { if (InputBoxWindow.ShowDialog("New collection name:", "Enter new collection name", "", out string name) == true) { Store.Current.SelectedDatabase.AddCollection(name); } } catch (Exception exc) { ErrorInteraction("Failed to add new collection:" + Environment.NewLine + exc.Message); } }
private string RequestPrinternameFromUser(string questionText, string printerName) { var w = new InputBoxWindow(); w.IsValidInput = ValidatePrinterName; w.QuestionText = questionText; w.InputText = printerName; if (w.ShowDialog() != true) { return(null); } return(w.InputText); }
private string QueryLicenseKey() { var inputBoxWindow = new InputBoxWindow(); inputBoxWindow.Title = _translator.GetTranslation("pdfforge.PDFCreator.Shared.Views.UserControls.LicenseTab", "EnterLicenseKeyButton.Text", "Enter new License Key"); inputBoxWindow.QuestionText = _translator.GetTranslation("pdfforge.PDFCreator.Shared.ViewModels.UserControls.LicenseTabViewModel", "EnterLicenseKeyText", "Please enter your License key:"); inputBoxWindow.InputText = LicenseKey; inputBoxWindow.IsValidInput = ValidateLicenseKey; if (inputBoxWindow.ShowDialog() != true) { return(null); } return(inputBoxWindow.InputText); }
public void OpenDatabase(string path) { if (Databases.FirstOrDefault(a => a.Location == path) != null) { return; } if (!File.Exists(path)) { MessageBox.Show( "Cannot open database, file not found.", "File not found", MessageBoxButton.OK, MessageBoxImage.Error); return; } string password = null; if (DatabaseReference.IsDbPasswordProtected(path)) { if (InputBoxWindow.ShowDialog("Database is password protected, enter password:"******"Database password.", "", out password) != true) { return; } } if (PathDefinitions.RecentFiles.Contains(path)) { PathDefinitions.RecentFiles.Remove(path); } PathDefinitions.RecentFiles.Insert(0, path); try { Databases.Add(new DatabaseReference(path, password)); } catch (Exception e) { MessageBox.Show("Failed to open database:" + Environment.NewLine + e.Message, "Database Error", MessageBoxButton.OK, MessageBoxImage.Error); logger.Error(e, "Failed to process update: "); return; } }
/// <summary>Handles the Click event of the btnAdd control. Allows the user to add a new item.</summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="RoutedEventArgs" /> instance containing the event data. /// </param> private void btnAdd_Click(object sender, RoutedEventArgs e) { var ibw = new InputBoxWindow("Enter the name for the new conference:"); if (ibw.ShowDialog() == true) { var name = InputBoxWindow.UserInput.Replace(':', '-'); if (MainWindow.Conferences.Any(conference => conference.Name == name)) { MessageBox.Show("There's already a conference with the name " + name + "."); return; } var usedIDs = new List <int>(); MainWindow.Conferences.ForEach(conference => usedIDs.Add(conference.ID)); var i = 0; while (usedIDs.Contains(i)) { i++; } MainWindow.Conferences.Add(new Conference { ID = i, Name = name }); var db = new SQLiteDatabase(MainWindow.CurrentDB); db.Insert("Conferences", new Dictionary <string, string> { { "ID", i.ToString() }, { "Name", name } }); lstData.ItemsSource = null; lstData.ItemsSource = MainWindow.Conferences; var confToEdit = new Conference(); foreach (Conference item in lstData.Items) { if (item.Name == name) { confToEdit = item; break; } } showEditConferenceWindow(confToEdit); } }
private void AdminButton_Click(object sender, RoutedEventArgs e) { // если мы уже в режиме Администратора, то выходим из него if (IsAdminMode) { IsAdminMode = false; } else { // создаем окно для ввода пароля var InputBox = new InputBoxWindow("Введите пароль Администратора"); // и показываем его как диалог (модально) if ((bool)InputBox.ShowDialog()) { // если нажали кнопку "Ok", то включаем режим, если пароль введен верно IsAdminMode = InputBox.InputText == "0000"; } } }
private void RenameCollectionCommand_Executed(object sender, ExecutedRoutedEventArgs e) { try { if (InputBoxWindow.ShowDialog("New name:", "Enter new colletion name", SelectedCollection.Name, out string name) == true) { SelectedDatabase.RenameCollection(SelectedCollection.Name, name); } } catch (Exception exc) { MessageBox.Show( "Failed to rename collection:" + Environment.NewLine + exc.Message, "Database error", MessageBoxButton.OK, MessageBoxImage.Error ); } }
public void OpenDatabase(string path) { if (Store.Current.IsDatabaseOpen(path)) { return; } if (!File.Exists(path)) { ErrorInteraction("Cannot open database, file not found.", "File not found"); return; } string password = null; if (DatabaseReference.IsDbPasswordProtected(path)) { if (InputBoxWindow.ShowDialog("Database is password protected, enter password:"******"Database password.", "", out password) != true) { return; } } if (PathDefinitions.RecentFiles.Contains(path)) { PathDefinitions.RecentFiles.Remove(path); } PathDefinitions.RecentFiles.Insert(0, path); try { Store.Current.AddDatabase(new DatabaseReference(path, password)); } catch (Exception e) { Logger.Error(e, "Failed to process update: "); ErrorInteraction("Failed to open database:" + Environment.NewLine + e.Message); } }
public Task <Result <CollectionReference> > AddCollection(DatabaseReference database) { try { if (InputBoxWindow.ShowDialog("New collection name:", "Enter new collection name", "", out string name) == true) { var collectionReference = database.AddCollection(name); return(Task.FromResult(Result.Ok(collectionReference))); } return(Task.FromResult(Result.Ok <CollectionReference>(null))); } catch (Exception exc) { var message = "Failed to add new collection:" + Environment.NewLine + exc.Message; _applicationInteraction.ShowError(exc, message, "Database error"); return(Task.FromResult(Result.Fail <CollectionReference>(message))); } }
public Result <bool> AddCollection(DatabaseReference database) { try { if (InputBoxWindow.ShowDialog("New collection name:", "Enter new collection name", "", out string name) == true) { database.AddCollection(name); return(Result.Ok(true)); } return(Result.Ok(false)); } catch (Exception exc) { var message = "Failed to add new collection:" + Environment.NewLine + exc.Message; ErrorInteraction(message); return(Result.Fail <bool>(message)); } }
public Result <bool> RenameCollection(CollectionReference collection) { try { var currentName = collection.Name; if (InputBoxWindow.ShowDialog("New name:", "Enter new collection name", currentName, out string name) == true) { collection.Database.RenameCollection(currentName, name); return(Result.Ok(true)); } return(Result.Ok(false)); } catch (Exception exc) { var message = "Failed to rename collection:" + Environment.NewLine + exc.Message; ErrorInteraction(message); return(Result.Fail <bool>(message)); } }
public Result RenameCollection(CollectionReference collection) { try { var currentName = collection.Name; if (InputBoxWindow.ShowDialog("New name:", "Enter new collection name", currentName, out string name) == true) { collection.Database.RenameCollection(currentName, name); return(Result.Ok(true)); } return(Result.Fail(Fails.Canceled)); } catch (Exception exc) { var message = "Failed to rename collection:" + Environment.NewLine + exc.Message; _viewInteractionResolver.ShowError(exc, message, "Database error"); return(Result.Fail(message)); } }
public async Task OpenDatabase(string path, string password = "") { if (Store.Current.IsDatabaseOpen(path)) { return; } if (!File.Exists(path)) { _applicationInteraction.ShowError("Cannot open database, file not found.", "File not found"); return; } try { if (DatabaseReference.IsDbPasswordProtected(path) && InputBoxWindow.ShowDialog("Database is password protected, enter password:"******"Database password.", password, out password) != true) { return; } Store.Current.AddDatabase(new DatabaseReference(path, password)); PathDefinitions.InsertRecentFile(path); } catch (LiteException liteException) { await OpenDatabaseExceptionHandler(liteException, path, password); } catch (NotSupportedException notSupportedException) { _applicationInteraction.ShowError(notSupportedException, "Failed to open database [NotSupportedException]:" + Environment.NewLine + notSupportedException.Message); } catch (Exception e) { Logger.Error(e, "Failed to open database: "); _applicationInteraction.ShowError(e, "Failed to open database [Exception]:" + Environment.NewLine + e.Message); } }
private void btnTimeLeftSet_Click(object sender, RoutedEventArgs e) { var ibw = new InputBoxWindow("Enter the time left:", SQLiteIO.GetSetting("LastTimeLeftSet", "0:00"), "NBA Stats Tracker"); if (ibw.ShowDialog() == false) { return; } var timeLeft = _timeLeft; try { timeLeft = ConvertTimeStringToDouble(InputBoxWindow.UserInput); } catch { return; } _timeLeft = timeLeft; updateTimeLeftIndication(_timeLeft); SQLiteIO.SetSetting("LastTimeLeftSet", InputBoxWindow.UserInput); }
private void NewFieldMenuItem_Click(object sender, RoutedEventArgs e) { if (InputBoxWindow.ShowDialog("Enter name of new field.", "New field name:", "", out var fieldName) != true) { return; } if (currentDocument.Keys.Contains(fieldName)) { MessageBox.Show(string.Format("Field \"{0}\" already exists!", fieldName), "", MessageBoxButton.OK, MessageBoxImage.Error); return; } var menuItem = sender as MenuItem; BsonValue newValue; switch (menuItem.Header as string) { case "String": newValue = new BsonValue(string.Empty); break; case "Boolean": newValue = new BsonValue(false); break; case "Double": newValue = new BsonValue((double)0); break; case "Int32": newValue = new BsonValue(0); break; case "Int64": newValue = new BsonValue((long)0); break; case "DateTime": newValue = new BsonValue(DateTime.MinValue); break; case "Array": newValue = new BsonArray(); break; case "Document": newValue = new BsonDocument(); break; default: throw new Exception("Uknown value type."); } currentDocument.Add(fieldName, newValue); var newField = NewField(fieldName, false); customControls.Add(newField); newField.EditControl.Focus(); ItemsField_SizeChanged(ListItems, null); ListItems.ScrollIntoView(newField); }