protected async override void OnNavigatedTo(NavigationEventArgs e) { deckName = NavigationContext.QueryString["deck"]; cardName = NavigationContext.QueryString["card"]; var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("decks", CreationCollisionOption.OpenIfExists); var stream = await(await(await folder.GetFolderAsync(deckName)).GetFileAsync(cardName)).OpenStreamForReadAsync(); using (StreamReader reader = new StreamReader(stream)) { string s = await reader.ReadToEndAsync(); FlashCard f = JsonConvert.DeserializeObject <FlashCard>(s); panel.DataContext = f; foreach (var v in f.Definitions) { PhoneTextBox box = new PhoneTextBox(); box.Style = this.Resources["temp"] as Style; box.Text = v; box.TextWrapping = TextWrapping.Wrap; boxes.Add(box); list.Children.Add(box); } } }
public override void Login(LoginConfig config) { var prompt = new CustomMessageBox { Caption = config.Title, Message = config.Message, LeftButtonContent = config.OkText, RightButtonContent = config.CancelText }; var txtUser = new PhoneTextBox { PlaceholderText = config.LoginPlaceholder, Text = config.LoginValue ?? String.Empty }; var txtPass = new PhonePasswordBox { PlaceholderText = config.PasswordPlaceholder }; var stack = new StackPanel(); stack.Children.Add(txtUser); stack.Children.Add(txtPass); prompt.Content = stack; prompt.Dismissed += (sender, args) => config.OnResult(new LoginResult( txtUser.Text, txtPass.Password, args.Result == CustomMessageBoxResult.LeftButton )); this.Dispatch(prompt.Show); }
public Task <InputResponse> InputAsync(string message, string placeholder = null, string title = null, string okButton = "OK", string cancelButton = "Cancel", string initialText = null) { var textBox = new PhoneTextBox { Hint = placeholder }; var box = new Microsoft.Phone.Controls.CustomMessageBox() { Caption = title, Message = message, LeftButtonContent = okButton, RightButtonContent = cancelButton, Content = textBox }; var response = new TaskCompletionSource <InputResponse>(); box.Dismissed += (sender, args) => response.TrySetResult(new InputResponse() { Ok = args.Result == CustomMessageBoxResult.LeftButton, Text = textBox.Text }); box.Show(); return(response.Task); }
// // Sprawdza czy podane pola textowe są nie puste - w tym przypadku zwraca true. // private bool CheckTextBox(PhoneTextBox textBox1, PhoneTextBox textBox2) { /* * CEL: * Sprawdza czy podane pola textowe są nie puste. * Jeśli pola są wypełnione to zwraca true. * Jeśli pola są puste to zwracane jest false. * * PARAMETRY: * textBox1:PhoneTextBox - sprawdzane pole tekstowe * textBox2:PhoneTextBox - sprawdzane pole tekstowe * * WARTOŚĆ ZWRACANE: * bool - zależy od tego czy pola są wypełnione czy puste */ bool checkedPositive = false; // Sprawdz czy pola są nie puste if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0) { // Jeśli pola są wypełnione to ustaw true checkedPositive = true; } // Zwróć wartość return(checkedPositive); }
private void AddComment_Click(object sender, RoutedEventArgs e) { StackPanel sp = new StackPanel(); var Comment = new PhoneTextBox(); Comment.Hint = "Enter your comment here"; Comment.AcceptsReturn = true; sp.Children.Add(Comment); CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Add Comment", Message = "Add a comment to this customer", Content = sp, LeftButtonContent = "Submit", RightButtonContent = "Cancel" }; messageBox.Dismissed += async(s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: await api.AddCommentToCustomer(Customer.Email, Comment.Text); await this.InitializeCustomer(); MessageBox.Show("Comment added sucessfully"); break; } }; messageBox.Show(); }
public override IDisposable Login(LoginConfig config) { var prompt = new CustomMessageBox { Caption = config.Title, Message = config.Message, LeftButtonContent = config.OkText, RightButtonContent = config.CancelText }; var txtUser = new PhoneTextBox { Text = config.LoginValue ?? String.Empty }; var txtPass = new PasswordBox(); var stack = new StackPanel(); stack.Children.Add(txtUser); stack.Children.Add(txtPass); prompt.Content = stack; prompt.Dismissed += (sender, args) => config.OnAction(new LoginResult( args.Result == CustomMessageBoxResult.LeftButton, txtUser.Text, txtPass.Password )); return(this.DispatchWithDispose(prompt.Show, prompt.Dismiss)); }
private void AddNote_Click(object sender, RoutedEventArgs e) { StackPanel sp = new StackPanel(); var NoteText = new PhoneTextBox(); var ShowUser = new CheckBox(); ShowUser.Content = "Show to user"; NoteText.AcceptsReturn = true; sp.Children.Add(NoteText); sp.Children.Add(ShowUser); CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Add Note to Order", Message = "Add some notes to this order", Content = sp, LeftButtonContent = "Submit", RightButtonContent = "Cancel" }; messageBox.Dismissed += async(s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: api.NewOrderNote(Order.OrderID, NoteText.Text, Convert.ToBoolean(ShowUser.IsChecked)); MessageBox.Show("Note added sucessfuly"); break; } }; messageBox.Show(); }
/// <summary> /// Deletes contact information in the list and ListBox. /// </summary> private void RemoveContact() { var selectedIndex = AllContactsListBox.SelectedIndex; if (selectedIndex == -1) { MessageBox.Show("Select a contact from the list", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; //TODO: если после if-else нет никакой общей логики, тогда в if можно написать return, а else с лишней вложенностью убрать (+) } DialogResult result = MessageBox.Show("Do you really want to remove this contact?", "Remove contact", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { var selectedContact = _contacts[selectedIndex]; _project.Contacts.Remove(selectedContact); AllContactsListBox.Items.RemoveAt(selectedIndex); SurnameTextBox.Clear(); NameTextBox.Clear(); PhoneTextBox.Clear(); EmailTextBox.Clear(); VkIDTextBox.Clear(); SaveToFile(); } SortingFoundContacts(); }
private bool ValidateForm() { if (!Regex.Match(TitleTextBox.Text, @"^\D{1,50}$").Success) { MessageBox.Show("Title must consist of at least 1 character and not exceed 50 characters!"); TitleTextBox.Focus(); return(false); } if (!Regex.Match(ContactTextBox.Text, @"^\D{1,50}$").Success) { MessageBox.Show("Contact person must consist of at least 1 character and not exceed 50 characters!"); ContactTextBox.Focus(); return(false); } if (!Regex.Match(PhoneTextBox.Text, @"^\d{10}$").Success) { MessageBox.Show("Phone number must consist of 10 digits!"); PhoneTextBox.Focus(); return(false); } if (!Regex.Match(AddressTextBox.Text, @"^(Вул\.\s\D{1,40}\,\s\d{1,3})$").Success) { MessageBox.Show("Address must consist of at least 1 character and not exceed 50 characters!"); AddressTextBox.Focus(); return(false); } return(true); }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(PhoneTextBox.Text) && !string.IsNullOrEmpty(NameTextBox.Text) && !string.IsNullOrEmpty(PasswordBox.Password) && !string.IsNullOrEmpty(ConfirmPasswordBox.Password)) { if (PasswordBox.Password == ConfirmPasswordBox.Password) { if (!service.SignUpEmployee(NameTextBox.Text, PhoneTextBox.Text, PasswordBox.Password, "default", out string message, out Employee user)) { Close(); } else { PhoneTextBox.Clear(); NameTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); } } else { MessageBox.Show("Passwords in to fields should be equal"); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); PasswordBox.Focus(); } }
private async void AddToWish_Click(object sender, EventArgs e) { var attributes = await HasAttributes(SelectedProduct.Id); if (!attributes) { StackPanel s = new StackPanel(); PhoneTextBox Quantity = new PhoneTextBox(); InputScope scope = new InputScope(); InputScopeName number = new InputScopeName(); number.NameValue = InputScopeNameValue.Number; scope.Names.Add(number); Quantity.Hint = "Quantity"; Quantity.InputScope = scope; s.Children.Add(Quantity); CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Select Quantity", Message = "Select how many " + SelectedProduct.Name + " do you want?", LeftButtonContent = "Add To Wishlist", Content = s, RightButtonContent = "Cancel" }; messageBox.Show(); messageBox.Dismissed += async(s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: var Customer = await api.GetCustomersByEmail(Helper.CurrentCustomer()); if (Quantity.Text == "") { Quantity.Text = "1"; } var AddResult = await api.AddToCart(Customer.First().Email, SelectedProduct.Id, Int32.Parse(Quantity.Text), new String[] { "" }, ShoppingCartType.Wishlist); if (AddResult) { CustomMessageBox SuccessToast = new CustomMessageBox() { Caption = "Added Successfully", Message = "The product was added to your wishlist sucessfuly", LeftButtonContent = "Dismiss" }; SuccessToast.Show(); await Task.Delay(2000); SuccessToast.Dismiss(); } break; } }; } else { NavigationService.Navigate(new Uri("/Pages/ProductDetails.xaml?ProdId=" + SelectedProduct.Id, UriKind.Relative)); } }
public override void Prompt(PromptConfig config) { var prompt = new CustomMessageBox { Caption = config.Title, Message = config.Message, LeftButtonContent = config.OkText, RightButtonContent = config.CancelText }; var password = new PasswordBox(); var inputScope = this.GetInputScope(config.InputType); var txt = new PhoneTextBox { PlaceholderText = config.Placeholder, InputScope = inputScope }; var isSecure = config.InputType == InputType.Password; if (isSecure) { prompt.Content = password; } else { prompt.Content = txt; } prompt.Dismissed += (sender, args) => config.OnResult(new PromptResult { Ok = args.Result == CustomMessageBoxResult.LeftButton, Text = isSecure ? password.Password : txt.Text.Trim() }); this.Dispatch(prompt.Show); }
private void EmailTextBoxKeyDown_Handler(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { PhoneTextBox.Select(PhoneTextBox.Text.Length, 0); } }
// if enter is pressed in name box, make user select phone number box private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r')// adds to list if "enter" key is pressed { //addToList(); PhoneTextBox.Select(); } }
void ClearMethod() { NameTextBox.Clear(); AgeTextBox.Clear(); AddressTextBox.Clear(); PhoneTextBox.Clear(); HistoryTextBox.Clear(); }
protected override void OnViewAttached(object view, object context) { base.OnViewAttached(view, context); var control = view as NewStatusPageView; textbox = control.Text; textbox.GotFocus += Textbox_GotFocus; }
private static void tbIntegration_TextChanged(object sender, TextChangedEventArgs e) { PhoneTextBox tb = sender as PhoneTextBox; Grid grid = tb.Parent as Grid; string name = ((grid.Children[0] as Grid).Children[0] as CheckBox).Content.ToString(); int? mark = string.IsNullOrEmpty(tb.Text) ? (int?)null : Convert.ToInt32(tb.Text); Lessons.SingleOrDefault(x => x.Name == name).Integration.Mark = mark; }
private void ClearForm() { NameTextBox.Clear(); EmailTextBox.Clear(); PhoneTextBox.Clear(); AddressTextBox.Clear(); Products.Clear(); TotalTextBox.Text = "0"; }
private void refresh() { NameTextBox.Clear(); ProjectComboBox.SelectedIndex = 0; PhoneTextBox.Clear(); passwordTextBox.Clear(); confrimPWTextBox.Clear(); CommentTextBox.Clear(); bindingDateGridView(null); }
private void EditGoal_Click(object sender, RoutedEventArgs e) { Button bt = (Button)sender; bt.Visibility = System.Windows.Visibility.Collapsed; PhoneTextBox ptb = (PhoneTextBox)FindName(bt.Name.Replace("Edit", "Add")); ptb.Visibility = System.Windows.Visibility.Visible; ptb.Focus(); }
private void AfficherCarte(PhoneTextBox myTextBox, Microsoft.Phone.Maps.Controls.Map myMap) { GeocodeQuery query = new GeocodeQuery() { GeoCoordinate = new GeoCoordinate(0, 0), SearchTerm = myTextBox.Text }; query.QueryCompleted += query_QueryCompleted; query.QueryAsync(); }
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { SelectedItem = (string)comboBox.SelectedItem; try { MySqlConnection connection = new MySqlConnection("Datasource=localhost;port=3306;username=root;password="******"SELECT * FROM bookstore.customers WHERE first = \"{name[0]}\" AND last = \"{name[1]}\""; connection.Open(); MySqlCommand command = new MySqlCommand(query, connection); MySqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { firstTextBox.Text = reader["first"].ToString(); lastTextBox.Text = reader["last"].ToString(); addressTextBox.Text = reader["address"].ToString(); cityTextBox.Text = reader["city"].ToString(); stateTextBox.Text = reader["state"].ToString(); zipTextBox.Text = reader["zip"].ToString(); emailTextBox.Text = reader["email"].ToString(); PhoneTextBox.Text = reader["phone"].ToString(); tempfirst = reader["first"].ToString(); templast = reader["last"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message); //clear form firstTextBox.Clear(); lastTextBox.Clear(); addressTextBox.Clear(); cityTextBox.Clear(); stateTextBox.Clear(); zipTextBox.Clear(); PhoneTextBox.Clear(); //emailTextBox.Clear(); } finally { connection.Close(); } comboBox.Focus(); }
private void Filter_Click(object sender, EventArgs e) { StackPanel s = new StackPanel(); var Min = new PhoneTextBox(); var Max = new PhoneTextBox(); Min.Hint = "Minimum Price"; Max.Hint = "Maximum Price"; s.Children.Add(Min); s.Children.Add(Max); CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Filter by", Message = "Select the minimum and maximum prices, leave in blank to disable limit", LeftButtonContent = "Submit", Content = s, RightButtonContent = "Cancel" }; messageBox.Show(); messageBox.Dismissed += async(s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: var Count = 0; foreach (PivotItem pivot in CategoryPivot.Items) { var Listbox = Helper.FindFirstElementInVisualTree <ListBox>(pivot); Listbox.Items.Clear(); if (Listbox.ItemTemplate.Equals(Application.Current.Resources["ProductCategoryTemplate"] as DataTemplate)) { var Prods = await api.CategoryProductsSortedFiltered(Categories[Count].Id, false, true, ProductSortingEnum.Position, Decimal.Parse(Max.Text), Decimal.Parse(Min.Text)); foreach (ProductDTO p in Prods) { Listbox.Items.Add(new MainPage.ProductData { Id = p.Id, Description = p.Description, Image = Helper.ConvertToBitmapImage(p.Image.First()), ProductName = p.Name, Value = p.Price.ToString("0.0#") + " " + Currency }); } } Count++; } break; } }; }
public override IDisposable Prompt(PromptConfig config) { var prompt = new CustomMessageBox { Caption = config.Title, Message = config.Message, LeftButtonContent = config.OkText }; if (config.IsCancellable) { prompt.RightButtonContent = config.CancelText; } var password = new PasswordBox(); var inputScope = this.GetInputScope(config.InputType); var txt = new PhoneTextBox { InputScope = inputScope }; if (config.Text != null) { txt.Text = config.Text; } var isSecure = (config.InputType == InputType.NumericPassword || config.InputType == InputType.Password); if (isSecure) { prompt.Content = password; } else { prompt.Content = txt; } prompt.Dismissed += (sender, args) => { var ok = args.Result == CustomMessageBoxResult.LeftButton; var text = isSecure ? password.Password : txt.Text.Trim(); config.OnResult(new PromptResult(ok, text)); }; return(this.DispatchWithDispose(prompt.Show, prompt.Dismiss)); }
private StackPanel GetAddBlockPanel() { var margin = new Thickness(0, 0, 0, 20); const double fontSize = 30; _addBlockPanel = new StackPanel(); var lastTimeValue = _timeSlider != null?_timeSlider.GetTimeValue() : DefaultTime; var label = new TextBlock { Text = AppResources.IntervalAddLabel, Margin = margin, TextWrapping = TextWrapping.Wrap, FontSize = fontSize }; _tbxLabel = new PhoneTextBox { Height = 72, Width = 456, HorizontalAlignment = HorizontalAlignment.Left, TextWrapping = TextWrapping.Wrap, Hint = "Block n°" + (_viewModel.Blocks.Count + 1) }; var tbkTemps = new TextBlock { Text = AppResources.IntervalAddTime, Margin = margin, TextWrapping = TextWrapping.Wrap, FontSize = fontSize }; _timeSlider = new TimeLabeledRadialSlider { TextFontSize = 90, }; _timeSlider.SetTimeValue(lastTimeValue); _addBlockPanel.Children.Add(label); _addBlockPanel.Children.Add(_tbxLabel); _addBlockPanel.Children.Add(tbkTemps); _addBlockPanel.Children.Add(_timeSlider); return(_addBlockPanel); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); var view = (TxEntry)Element; if (view.IsPassword) { _passwordBox = (PasswordBox)Control.Children.FirstOrDefault(c => c is PasswordBox); } else { _phoneTextBox = (PhoneTextBox)Control.Children.FirstOrDefault(c => c is PhoneTextBox); } this.SetFont(view); this.SetXAlign(view); this.SetMaxLength(view); this.SetPlaceholderTextColor(view); }
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { var tbx = new PhoneTextBox() { Hint = "Titre", Margin = new Thickness(0, 14, 0, -2) }; var uc = new TimeLabeledRadialSlider(); TiltEffect.SetIsTiltEnabled(tbx, true); var messageBox = new CustomMessageBox() { Caption = "Donnez un titre à ce temps", Content = uc, LeftButtonContent = "ok", RightButtonContent = "annuler", IsFullScreen = false }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: var b = (Button)sender; b.Content = uc.GetTimeValue().ToString(); //var saved = _chronometerStore.SaveNew(tbx.Text, _stopWatch.Elapsed); //var message = saved ? "Le temps a été enregistré." : "Une erreur est survenue."; //Popup(message); // confirmation break; case CustomMessageBoxResult.RightButton: case CustomMessageBoxResult.None: default: break; } }; messageBox.Show(); //*/ }
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { SelectedItem = (string)comboBox.SelectedItem; try { //access books string BookJSON = File.ReadAllText(path); JObject json = JObject.Parse(BookJSON); JObject CustoTarget = (JObject)json[SelectedItem]; string custo_target = CustoTarget.ToString(); CustomerList foundCusto = new CustomerList(); Newtonsoft.Json.JsonConvert.PopulateObject(custo_target, foundCusto); firstTextBox.Text = foundCusto.first; lastTextBox.Text = foundCusto.last; addressTextBox.Text = foundCusto.address; cityTextBox.Text = foundCusto.city; stateTextBox.Text = foundCusto.state; zipTextBox.Text = foundCusto.zip; PhoneTextBox.Text = foundCusto.phone; emailTextBox.Text = foundCusto.email; tempfirst = foundCusto.first; templast = foundCusto.last; } catch { //clear form firstTextBox.Clear(); lastTextBox.Clear(); addressTextBox.Clear(); cityTextBox.Clear(); stateTextBox.Clear(); zipTextBox.Clear(); PhoneTextBox.Clear(); //emailTextBox.Clear(); } comboBox.Focus(); }
/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); var view = (ExtendedEntry)Element; //Because Xamarin EntryRenderer switches the type of control we need to find the right one if (view.IsPassword) { _thisPasswordBox = (PasswordBox)Control.Children.FirstOrDefault(c => c is PasswordBox); } else { _thisPhoneTextBox = (PhoneTextBox)Control.Children.FirstOrDefault(c => c is PhoneTextBox); } SetFont(view); SetTextAlignment(view); SetBorder(view); SetPlaceholderTextColor(view); }
public static void AddRepositoryPropmt() { PhoneTextBox textbox1 = new PhoneTextBox(); textbox1.Hint = AppResources.Url; CustomMessageBox messageBox = new CustomMessageBox() { Message = AppResources.AddRepository, Content = textbox1, LeftButtonContent = AppResources.OK, IsLeftButtonEnabled = false, RightButtonContent = AppResources.Cancel, IsRightButtonEnabled = true }; textbox1.TextChanged += (s, ev) => { messageBox.IsLeftButtonEnabled = !string.IsNullOrWhiteSpace(textbox1.Text); }; messageBox.Dismissed += async(s, ev) => { if (ev.Result == CustomMessageBoxResult.LeftButton) { try { Uri uri = new Uri(textbox1.Text, UriKind.Absolute); App.ViewModel.Repositories.Add(textbox1.Text); await App.ViewModel.EmoticonList.UpdateRepositories(); } catch (UriFormatException) { MessageBox.Show(AppResources.UrlError); } } }; messageBox.Show(); textbox1.Focus(); }