示例#1
0
 private void downloadFinised(object source, double downloadFinished)
 {
     server.logout(userData, filesData);
     this.filesData = JsonConvert.SerializeObject(this.getFiles(config.path));
     server.login(userData, filesData);
     Dispatcher.BeginInvoke(new ThreadStart(() => progress(downloadFinished)));
 }
示例#2
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            User user = new User();

            if (config == null)
            {
                MessageBox.Show("Config is invalid, Enter new values.");
            }
            if (config == null || checkBox.IsChecked == false)
            {
                config          = new Config();
                config.name     = textBox.Text;
                config.password = passwordBox.Password;
                config.port     = PORT_IN;
                config.ip       = getIPAddress();
                if (this.path == null || this.path == "")
                {
                    MessageBox.Show("You must enter a path.");
                    return;
                }
                config.path = this.path;
            }
            user.name        = config.name;
            user.password    = config.password;
            user.ip          = config.ip;
            user.port        = config.port;
            user.isAvailable = true;
            this.userData    = JsonConvert.SerializeObject(user);
            this.filesData   = JsonConvert.SerializeObject(this.getFiles(config.path));
            string answer = server.login(userData, filesData);

            if (answer != "User login.")
            {
                MessageBox.Show(answer);
            }
            else
            {
                using (StreamWriter file = System.IO.File.CreateText(@FILE_NAME))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, config);
                }
                Page2 page2 = new Page2(config, userData, filesData, this);
                this.Content = page2;
                //MessageBox.Show(answer);
            }
        }