MainWindow.xaml.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Reflection;
  2. using System.Text;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Data;
  6. using System.Windows.Documents;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Imaging;
  10. using System.Windows.Navigation;
  11. using System.Windows.Shapes;
  12. namespace ArchivesCenter3
  13. {
  14. /// <summary>
  15. /// Interaction logic for MainWindow.xaml
  16. /// </summary>
  17. public partial class MainWindow : Window
  18. {
  19. public MainWindow()
  20. {
  21. InitializeComponent();
  22. updateinfo();
  23. Version version = Assembly.GetExecutingAssembly().GetName().Version;
  24. versionTextBlock.Text = $"版本号:{version.Major}.{version.Minor}.{version.Build}";
  25. }
  26. private void updateinfo()
  27. {
  28. welcomeText.Text = "欢迎!" + Settings1.Default.Username + " ";
  29. WelcomeTitle.Text = Settings1.Default.WelcomeTitle;
  30. DatabaseName.Text = Settings1.Default.DatabaseName;
  31. DatabaseSubtitle.Text = Settings1.Default.DatabaseSubtitle;
  32. UsernameCu.Text = Settings1.Default.Username;
  33. WelcomeTitleCu.Text = Settings1.Default.WelcomeTitle;
  34. DatabaseNameCu.Text = Settings1.Default.DatabaseName;
  35. DatabaseSubtitleCu.Text = Settings1.Default.DatabaseSubtitle;
  36. PasswordCu.Text = Settings1.Default.Password;
  37. DatabaseNameBox.Text = null;
  38. DatabaseSubtitleBox.Text = null;
  39. WelcomeTitleBox.Text = null;
  40. UsernameBox.Text = null;
  41. PasswordBox.Text = null;
  42. }
  43. private void Button_Click(object sender, RoutedEventArgs e)
  44. {
  45. if (!string.IsNullOrEmpty(DatabaseNameBox.Text))
  46. Settings1.Default.DatabaseName = DatabaseNameBox.Text;
  47. if (!string.IsNullOrEmpty(DatabaseSubtitleBox.Text))
  48. Settings1.Default.DatabaseSubtitle = DatabaseSubtitleBox.Text;
  49. if (!string.IsNullOrEmpty(WelcomeTitleBox.Text))
  50. Settings1.Default.WelcomeTitle = WelcomeTitleBox.Text;
  51. if (!string.IsNullOrEmpty(UsernameBox.Text))
  52. Settings1.Default.Username = UsernameBox.Text;
  53. if (!string.IsNullOrEmpty(PasswordBox.Text))
  54. Settings1.Default.Password = PasswordBox.Text;
  55. Settings1.Default.Save();
  56. updateinfo();
  57. }
  58. private void TextChanged(object sender, TextChangedEventArgs e)
  59. {
  60. bool allTextBoxesEmpty = string.IsNullOrWhiteSpace(DatabaseNameBox.Text) &&
  61. string.IsNullOrWhiteSpace(DatabaseSubtitleBox.Text) &&
  62. string.IsNullOrWhiteSpace(WelcomeTitleBox.Text) &&
  63. string.IsNullOrWhiteSpace(UsernameBox.Text) &&
  64. string.IsNullOrWhiteSpace(PasswordBox.Text);
  65. settingSaveButton0.IsEnabled = !allTextBoxesEmpty;
  66. settingSaveButton1.IsEnabled = !allTextBoxesEmpty;
  67. }
  68. }
  69. }