Beispiel #1
0
 public EditProfile(GUIManager manager, UserMainPage mainPage)
 {
     this.manager  = manager;
     this.mainPage = mainPage;
     avatar        = null;
     InitializeComponent();
 }
Beispiel #2
0
        public async Task Login(string username, string password)
        {
            //main.mainFrame.NavigationService.Navigate(new UserMainPage(main));
            //main.statusFrame.NavigationService.Navigate(new Status(main));
            if (await Communication.AuthFunctions.Instance.login(username, password))
            {
                await RefreshProfile();

                Status       status = statusWindow;
                UserMainPage umP    = new UserMainPage(this);
                mainWindow.statusFrame.NavigationService.Navigate(status);
                mainWindow.mainFrame.NavigationService.Navigate(umP);
                isLoggedIn = true;
            }
            else
            {
                MessageBox.Show("Bad Input", "    WARNING    ", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #3
0
        internal async void EditProfile(string username, string password, BitmapImage avatar, UserMainPage mainPage)
        {
            string changedString = "";
            bool   changed       = false;

            if (!password.Equals(""))
            {
                if (await Communication.AuthFunctions.Instance.editPassword(password))
                {
                    changedString += "Password Changed!\n";
                    changed        = true;
                }
            }
            if (!username.Equals(""))
            {
                if (await Communication.AuthFunctions.Instance.editUserName(username))
                {
                    changedString += "Username Changed!\n";
                    changed        = true;
                }
            }
            if (avatar != null)
            {
                byte[]            data;
                JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(avatar));
                using (MemoryStream ms = new MemoryStream())
                {
                    encoder.Save(ms);
                    data = ms.ToArray();
                }

                if (data.Length > 32000)
                {
                    MessageBox.Show("Avatar size too big!");
                }
                else
                {
                    if (await Communication.AuthFunctions.Instance.editAvatar(data))
                    {
                        changedString += "Avatar Changed!\n";
                        changed        = true;
                    }
                }
            }

            if (changed)
            {
                MessageBox.Show(changedString, "Profile Updated", MessageBoxButton.OK, MessageBoxImage.Information);
                await RefreshProfile();

                mainPage.ShowAvatar();
                mainWindow.mainFrame.NavigationService.GoBack();
            }
        }