示例#1
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            var res = await NetworkControl.AttemptSignin(UserNameBox.Text, PasswordBox.Password);

            string msg     = "";
            bool   success = false;

            if (res["code"] == "-1")
            {
                msg = "Connection to server appears to be down, please check.";
            }
            else if (res["code"] == "-2")
            {
                msg = "Ughh... The server doesn't seem to be a Know-it Server, please check again.";
            }
            else if (res["code"] == "0")
            {
                msg = res["errMessage"];
            }
            else if (res["code"] == "1")
            {
                msg = "Success!";
            }
            MessageDialog dialog = new MessageDialog(msg);
            await dialog.ShowAsync();

            if (success)
            {
                //go to content page, passing a pair with username as key and password as value as parameter.
            }
        }
示例#2
0
        private async void UserNameBox_LostFocus(object sender, RoutedEventArgs e)
        {
            if (UserNameBox.Text.Length != 0)
            {
                string name = UserNameBox.Text;
                var    res  = await NetworkControl.QueryUserInfo(name);

                UserNameMsg.Text = "";
                if (res["code"] == "0")
                {
                    UserNameMsg.Text = res["errMessage"];
                }
                else if (res["code"] == "1")
                {
                    string imgUrl = res["imageUrl"];

                    Logo.Source = new BitmapImage(new Uri(NetworkControl.GetFullPathUrl(imgUrl), UriKind.Absolute));
                }
            }
        }
示例#3
0
        private async void test()
        {
            var fop = new FileOpenPicker();

            fop.FileTypeFilter.Add(".jpg");
            fop.FileTypeFilter.Add(".jpeg");
            fop.FileTypeFilter.Add(".png");
            fop.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            var file = await fop.PickSingleFileAsync();

            await NetworkControl.PublishPost(UserNameBox.Text, PasswordBox.Password, "ThirdTry", "F*****g Jian Yang!", file);

            await NetworkControl.GiveThumbToPost(UserNameBox.Text, PasswordBox.Password, "2");

            var result = await NetworkControl.GetPostFromID(UserNameBox.Text, PasswordBox.Password, "2");

            if (result["image"] != null)
            {
                string fullPath = NetworkControl.accessName + "/img/" + result["image"];
                Logo.Source = new BitmapImage(new Uri(fullPath, UriKind.Absolute));
                Debug.WriteLine(result["thumbs"]);
            }
        }
示例#4
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder builder = new StringBuilder();

            if (!usernamePattern.IsMatch(UsernameBox.Text))
            {
                builder.Append("Username Invalid!\n");
            }
            if (!passwordPattern.IsMatch(PasswordBox.Password))
            {
                builder.Append("Password Invalid!\n");
            }
            if (PasswordBox.Password != SecondPasswordBox.Password)
            {
                builder.Append("The Two Passwords Don't Match!\n");
            }
            if (!emailPattern.IsMatch(EmailBox.Text))
            {
                builder.Append("Email Invalid!\n");
            }
            if (!phonePattern.IsMatch(PhoneBox.Text))
            {
                builder.Append("Phone Number Invalid!\n");
            }
            if (builder.Length != 0)
            {
                var alert = new MessageDialog(builder.ToString(), "Error!");
                await alert.ShowAsync();
            }
            else
            {
                if (thumbFile == null)
                {
                    thumbFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/jian-yang.png"));
                }
                var res = await NetworkControl.AttemptSignUp(UsernameBox.Text, PasswordBox.Password, SecondPasswordBox.Password,
                                                             PhoneBox.Text, EmailBox.Text, thumbFile);

                string msg     = "";
                bool   success = false;
                if (res["code"] == "-1")
                {
                    msg = "Connection to server appears to be down, please check.";
                }
                else if (res["code"] == "-2")
                {
                    msg = "Ughh... The server doesn't seem to be a Know-it Server, please check again.";
                }
                else if (res["code"] == "0")
                {
                    msg = res["errMessage"];
                }
                else if (res["code"] == "1")
                {
                    msg = "Success!";
                }
                MessageDialog dialog = new MessageDialog(msg);
                await dialog.ShowAsync();

                if (success)
                {
                    //go to content page, passing a pair with username as key and password as value as parameter.
                }
            }
        }