private void createBtn_Click(object sender, RoutedEventArgs e) { if (canMake()) { Controler.NewProjectControler npc = new Controler.NewProjectControler(nameBox.Text); } else { error.Content = "Invalid project name"; } this.Close(); }
private void nameBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { String txt = nameBox.Text; if (e.Key == Key.Space && (txt.Equals("") || txt[txt.Length - 1].Equals(' '))) { e.Handled = true; } if (e.Key == Key.Enter) { if (canMake()) { Controler.NewProjectControler npc = new Controler.NewProjectControler(nameBox.Text); } else { error.Content = "Invalid project name"; } this.Close(); return; } else if ((System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift) && char.IsDigit((char)KeyInterop.VirtualKeyFromKey(e.Key))) { error.Content = "Invalid name character"; nameBox.BorderBrush = System.Windows.Media.Brushes.Red; e.Handled = true; } else { BrushConverter bc = new BrushConverter(); nameBox.BorderBrush = (System.Windows.Media.Brush)bc.ConvertFrom("#C7DFFC"); if (error.Content.Equals("Invalid name character")) { error.Content = ""; } } }