UserControl1.axaml.cs 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Avalonia;
  2. using Avalonia.Controls;
  3. using Avalonia.Interactivity;
  4. using Avalonia.Markup.Xaml;
  5. using AvaloniaApplication2.ViewModels;
  6. using System;
  7. namespace AvaloniaApplication2.Views;
  8. public partial class UserControl1 : UserControl
  9. {
  10. public UserControl1()
  11. {
  12. InitializeComponent();
  13. void button1_Click(object sender, RoutedEventArgs e)
  14. {
  15. String allowchar = " ";
  16. allowchar = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
  17. allowchar += "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,y,z";
  18. allowchar += "1,2,3,4,5,6,7,8,9,0";
  19. char[] a = { ',' };
  20. String[] ar = allowchar.Split(a);
  21. String pwd = " ";
  22. string temp = " ";
  23. Random r = new Random();
  24. for (int i = 0; i < 6; i++)
  25. {
  26. temp = ar[(r.Next(0, ar.Length))];
  27. pwd += temp;
  28. }
  29. textBox1.Text = pwd;
  30. }
  31. }
  32. }