コード例 #1
0
 private void Login_Click(object sender, RoutedEventArgs e)
 {
     if (user.Text == "" || pass.Password == "")
     {
         MessageBox.Show("id or password can't be empty");
     }
     else
     {
         //SocketClientOut.accountEstablish();
         SocketClientOut.connectionEstablish();
         SocketClientOut.privatePort();
         SocketClientOut.sendActionRequest(Encoding.ASCII.GetBytes("login"));
         SocketClientOut.sendIdAndPassword(Encoding.ASCII.GetBytes(user.Text), Encoding.ASCII.GetBytes(pass.Password));
         var access = SocketClientOut.receiveAccess();
         if (Encoding.ASCII.GetString(access) == "granted")
         {
             var  st = Encoding.ASCII.GetString(SocketClientOut.receiveAccess());
             User x  = JsonConvert.DeserializeObject <User>(st);
             st       = Encoding.ASCII.GetString(SocketClientOut.receiveAccess());
             allSongs = JsonConvert.DeserializeObject <Playlist>(st);
             AfterLogin b = new AfterLogin(x);
             Reset();
             this.Hide();
             b.Show();
         }
         else if (Encoding.ASCII.GetString(access) == "denied")
         {
             InvalidLogin.Visibility = Visibility.Visible;
         }
     }
 }
コード例 #2
0
        private void Login_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                var msg     = "Incorrect Username or Password!";
                int counter = 0;
                foreach (var x in everyUser.Users)
                {
                    if (user.Text == x.mUsername && pass.Password == x.mPassword)
                    {
                        AfterLogin b = new AfterLogin(x);
                        counter++;
                        Reset();
                        this.Hide();
                        b.Show();
                        break;
                    }
                }

                if (counter == 0)
                {
                    InvalidLogin.Visibility = Visibility.Visible;
                    //MessageBox.Show(msg);
                }
            }
        }
コード例 #3
0
        private void Login_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (user.Text == "" || pass.Password == "")
                {
                    MessageBox.Show("id or password can't be empty");
                }
                else
                {
                    //SocketClientOut.accountEstablish();
                    SocketClientOut.connectionEstablish();
                    SocketClientOut.privatePort();
                    SocketClientOut.sendActionRequest(Encoding.ASCII.GetBytes("login"));
                    SocketClientOut.sendIdAndPassword(Encoding.ASCII.GetBytes(user.Text), Encoding.ASCII.GetBytes(pass.Password));
                    var access = SocketClientOut.receiveAccess();
                    if (Encoding.ASCII.GetString(access) == "granted")
                    {
                        var  st = Encoding.ASCII.GetString(SocketClientOut.receiveAccess());
                        User x  = JsonConvert.DeserializeObject <User>(st);
                        st       = Encoding.ASCII.GetString(SocketClientOut.receiveAccess());
                        allSongs = JsonConvert.DeserializeObject <Playlist>(st);
                        AfterLogin b = new AfterLogin(x);
                        Reset();
                        this.Hide();
                        b.Show();
                    }
                    else if (Encoding.ASCII.GetString(access) == "denied")
                    {
                        InvalidLogin.Visibility = Visibility.Visible;
                    }
                }

                /*
                 * var msg = "Incorrect Username or Password!";
                 * int counter = 0;
                 * foreach (var x in everyUser.Users)
                 * {
                 *
                 *  if (user.Text == x.mUsername && pass.Password == x.mPassword)
                 *  {
                 *      AfterLogin b = new AfterLogin(x);
                 *      counter++;
                 *      Reset();
                 *      this.Hide();
                 *      b.Show();
                 *      break;
                 *  }
                 *
                 * }
                 *
                 * if (counter == 0)
                 * {
                 *  InvalidLogin.Visibility = Visibility.Visible;
                 *  //MessageBox.Show(msg);
                 * }
                 */
            }
        }
コード例 #4
0
        private void OpenAddingPlayList(object sender, RoutedEventArgs e)
        {
            afterLoginWindow = this;
            Create b = new Create();

            this.Hide();
            b.Show();
        }
コード例 #5
0
        private void Button_Profile(object sender, RoutedEventArgs e)
        {
            afterLoginWindow = this;
            Profile b = new Profile();

            this.Hide();
            b.Show();
        }
コード例 #6
0
        public AfterLogin(User x)
        {
            ListofListBox    = new List <System.Windows.Controls.ListBox>();
            afterLoginWindow = this;
            var newBox = new System.Windows.Controls.ListBox();


            objectUser    = new User();
            mediaFileList = new List <Song>();
            InitializeComponent();
            username.Content = x.mUsername;
            ax =
                winsFormHost.Child as AxWMPLib.AxWindowsMediaPlayer;
            objectUser     = x;
            profile.Source = new BitmapImage(new Uri("pack://application:,,,/Images/" + x.mUsername + ".png"));

            /*
             * DirectoryInfo dir = new DirectoryInfo(mediaFolder);
             *
             * foreach (FileInfo file in dir.GetFiles("*.*", SearchOption.AllDirectories))
             * {
             *  if (file.Extension == ".mp3" || file.Extension == ".mp4")
             *      mediaFileList.Add(file.Name);
             * }
             */
            foreach (var b in LoginScreen.allSongs.mSongs)
            {
                mediaFileList.Add(b);
            }

            /*if (mediaFileList != null)
            *  {
            *   newBox.ItemsSource = mediaFileList;
            *   ax.URL = mediaFolder + "\\" + mediaFileList[0];
            *  }
            *  var newstackPanel = new StackPanel { Name = "NewExpanderStackPanel" };
            *  newstackPanel.Children.Add(newBox);
            *  Expander exp = new Expander();
            *  exp.Content = newstackPanel;
            *  exp.Header = "Available Songs";
            *  exp.Foreground = Brushes.LightGray;
            *  allPlaylist.Children.Add(exp);
            *  newBox.Background = Brushes.Black;
            *  newBox.Foreground = Brushes.LightGray;
            *  foreach (var b in objectUser.mPlaylists)
            *  {
            *   Expander exp1 = new Expander();
            *   var newStack = new StackPanel { Name = "NewExpanderStackPanel" };
            *   var newListBox = new System.Windows.Controls.ListBox();
            *   newListBox.Background = Brushes.Black;
            *   newListBox.Foreground = Brushes.LightGray;
            *   var newMediaFileList = new List<string>();
            *   foreach (var d in b.mSongs)
            *       newMediaFileList.Add(d.mArtist + "-" + d.mTitle + d.mExtension);
            *   newListBox.ItemsSource = newMediaFileList;
            *   newStack.Children.Add(newListBox);
            *   exp1.Content = newStack;
            *   exp1.Header = b.mName;
            *   exp1.Foreground = Brushes.LightGray;
            *   allPlaylist.Children.Add(exp1);
            *
            *  }
            *  AllPLaylist = allPlaylist;*/
            AllPLaylist = new StackPanel();
            reloadPlaylists();
        }