Inheritance: System.Windows.Controls.Button
Example #1
0
 private void CreateCustomAuth() {
     gridscrolllist.Children.Clear();
     if (MeCore.Config.SavedAuths.Count != 0)
     {
         short i = 0;
         foreach (var item in MeCore.Config.SavedAuths)
         {
             ButtonMenu butcustomauth = new ButtonMenu();
             butcustomauth.Content = item.Value.DisplayName;
             butcustomauth.MenuImage = new BitmapImage(new Uri(item.Value.AuthType.Equals("Yggdrasil") ? "Resources/mojang.png" : (item.Value.AuthType.Equals("Offline") ? "Resources/offline.png" : "Resources/others.png"), UriKind.Relative));
             butcustomauth.FontSize = 16;
             //butcustomauth.Margin = new Thickness(0, 60 * i, -17, 0);
             butcustomauth.Width = 465;
             butcustomauth.Height = 60;
             butcustomauth.Background = new SolidColorBrush(Colors.Transparent);
             butcustomauth.VerticalAlignment = VerticalAlignment.Top;
             butcustomauth.Style = (Style)Resources["ButtonMeListSolid"];
             butcustomauth.ListType = true;
             butcustomauth.Click += AuthButton_Click;
             gridscrolllist.Children.Add(butcustomauth);
             i++;
         }
     }
         ButtonMenu butcreateauth = new ButtonMenu();
         butcreateauth.Name = "butCreateAuth";
         butcreateauth.Content = "Create new account";
         butcreateauth.MenuImage = new BitmapImage(new Uri("Resources/others.png", UriKind.Relative));
         butcreateauth.FontSize = 16;
         //butcustomauth.Margin = new Thickness(0, 60 * i, -17, 0);
         butcreateauth.Width = 465;
         butcreateauth.Height = 60;
         butcreateauth.Background = new SolidColorBrush(Colors.Transparent);
         butcreateauth.VerticalAlignment = VerticalAlignment.Top;
         butcreateauth.Style = (Style)Resources["ButtonMeListSolid"];
         butcreateauth.ListType = true;
         butcreateauth.Click += delegate (object sender, RoutedEventArgs e) {
             if (e.Source is ButtonMenu)
             {
                 ACLogin ac = new ACLogin(true);
                 ac.ShowDialog();
                 if (ac.info != null && ac.auth != null)
                 {
                     MeCore.Config.SavedAuths.Add(ac.info.DisplayName, new SavedAuth { AuthType = ac.auth.Type, DisplayName = ac.info.DisplayName, AccessToken = ac.info.Session.ToString(), UUID = ac.info.UUID.ToString(), Properies = ac.info.Prop, UserType = ac.info.UserType });
                     MeCore.Config.Save();
                     CreateCustomAuth();
                 }
             }
         };
         gridscrolllist.Children.Add(butcreateauth);
 }
Example #2
0
 private void CreateCustomAuth()
 {
     if (MeCore.Config.Server.Auths.Count != 0)
     {
         short i = 0;
         foreach (var item in MeCore.Config.Server.Auths)
         {
             ++i;
             Grid gridCustomAuth = new Grid();
             gridCustomAuth.Visibility = Visibility.Collapsed;
             Label lbltitie = new Label();
             lbltitie.SetLocalizedContent("Login");
             lbltitie.FontSize = 21.333;
             lbltitie.Margin = new Thickness(10, 10, 0, 0);
             lbltitie.HorizontalAlignment = HorizontalAlignment.Left;
             lbltitie.VerticalAlignment = VerticalAlignment.Top;
             gridCustomAuth.Children.Add(lbltitie);
             Label lblune = new Label();
             lblune.SetLocalizedContent("UNEM");
             lblune.FontSize = 16;
             lblune.Margin = new Thickness(10, 45, 0, 0);
             lblune.HorizontalAlignment = HorizontalAlignment.Left;
             lblune.VerticalAlignment = VerticalAlignment.Top;
             gridCustomAuth.Children.Add(lblune);
             TextBox txtboxune = new TextBox();
             txtboxune.Text = "";
             txtboxune.FontSize = 18.667;
             txtboxune.Margin = new Thickness(10, 75, 10, 0);
             txtboxune.Height = 30;
             txtboxune.HorizontalAlignment = HorizontalAlignment.Stretch;
             txtboxune.VerticalAlignment = VerticalAlignment.Top;
             txtboxune.TextWrapping = TextWrapping.Wrap;
             gridCustomAuth.Children.Add(txtboxune);
             Label lblpw = new Label();
             lblpw.SetLocalizedContent("PW");
             lblpw.FontSize = 16;
             lblpw.Margin = new Thickness(10, 105, 0, 0);
             lblpw.HorizontalAlignment = HorizontalAlignment.Left;
             lblpw.VerticalAlignment = VerticalAlignment.Top;
             gridCustomAuth.Children.Add(lblpw);
             PasswordBox pwbox = new PasswordBox();
             pwbox.Password = "";
             pwbox.FontSize = 18.667;
             pwbox.Margin = new Thickness(10, 135, 10, 0);
             pwbox.Height = 30;
             pwbox.HorizontalAlignment = HorizontalAlignment.Stretch;
             pwbox.VerticalAlignment = VerticalAlignment.Top;
             gridCustomAuth.Children.Add(pwbox);
             Button butback = new Button();
             butback.SetLocalizedContent("Back");
             butback.FontSize = 16;
             butback.Margin = new Thickness(0, 0, 10, 10);
             butback.Width = 202; butback.Height = 32;
             butback.HorizontalAlignment = HorizontalAlignment.Right;
             butback.VerticalAlignment = VerticalAlignment.Bottom;
             butback.BorderThickness = new Thickness(2);
             butback.Style = (Style)Resources["NormalButton"];
             butback.Click += delegate (object sender, RoutedEventArgs e) {
                 gridCustomAuth.Visibility = Visibility.Collapsed;
                 gridMenu.Visibility = Visibility.Visible;
             };
             gridCustomAuth.Children.Add(butback);
             Button butlogin = new Button();
             butlogin.SetLocalizedContent("Login");
             butlogin.FontSize = 16;
             butlogin.Margin = new Thickness(0, 0, 217, 10);
             butlogin.Width = 202; butlogin.Height = 32;
             butlogin.HorizontalAlignment = HorizontalAlignment.Right;
             butlogin.VerticalAlignment = VerticalAlignment.Bottom;
             butlogin.BorderThickness = new Thickness(2);
             butlogin.Style = (Style)Resources["NormalButton"];
             butlogin.Click += delegate (object sender, RoutedEventArgs e) {
                 auth = new Launch.Login.YggdrasilLoginAuth(txtboxune.Text, pwbox.Password,new Launch.Login.YggdrasilHelper(item.Url));
                 if (requiredPreLogin)
                 {
                     info = auth.Login();
                     auth = !string.IsNullOrWhiteSpace(info.ErrorMsg) ? null : new Launch.Login.YggdrasilRefreshAuth(info.Session, new Launch.Login.YggdrasilHelper(item.Url));
                 }
                 Close();
             };
             gridCustomAuth.Children.Add(butlogin);
             gridMain.Children.Add(gridCustomAuth);
             ButtonMenu butcustomauth = new ButtonMenu();
             butcustomauth.Content = string.Format(Lang.LangManager.GetLangFromResource("Online"), item.Name);
             butcustomauth.MenuImage = new BitmapImage(new Uri("pack://application:,,,/Resources/others.png"));
             butcustomauth.FontSize = 16;
             butcustomauth.Margin = new Thickness(0, 60 * (i + 1), -17, 0);
             butcustomauth.Height = 60;
             butcustomauth.Background = new SolidColorBrush(Colors.White);
             butcustomauth.VerticalAlignment = VerticalAlignment.Top;
             butcustomauth.Style = (Style)Resources["ButtonMeListSolid"];
             butcustomauth.ListType = true;
             butcustomauth.Click += delegate (object sender, RoutedEventArgs e) {
                 gridMenu.Visibility = Visibility.Collapsed;
                 gridCustomAuth.Visibility = Visibility.Visible;
             };
             gridscrolllist.Children.Add(butcustomauth);
         }
     }
 }