示例#1
0
        /// <summary>
        /// Login to Ge.tt.
        /// </summary>
        private async void button_GettLogin_Click(object sender, EventArgs e)
        {
            try
            {
                UseWaitCursor = true;

                await _gettUser.LoginAsync(Properties.Settings.Default.ApiKey, Properties.Settings.Default.Email, Properties.Settings.Default.Password);

                // Setup Live API ?
                if (!string.IsNullOrEmpty(Properties.Settings.Default.LiveSessionId))
                {
                    try
                    {
                        // Startup Live API
                        _gettLive = _gettUser.GetLive();
                        _gettLive.LiveFileEvent += lfe => Invoke(new Action(() => listBox_LiveEvents.Items.Add(string.Format("{0}: Type:{1} - Share:{2} - FileName:{3}", lfe.Timestamp, lfe.Type, lfe.ShareName, lfe.FileName))));
                        _gettLive.Start(Properties.Settings.Default.LiveSessionId, true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(@"Failed to connect to Live API on Ge.tt" + Environment.NewLine + @"Exception of type " + ex.GetType() + Environment.NewLine + ex.Message);
                    }
                }
                else
                {
                    label3.Visible             = false;
                    listBox_LiveEvents.Visible = false;
                    listBox_Shares.Size        = listBox_Files.Size;
                }

                button_RefreshShares.PerformClick();
            }
            catch (Exception ex)
            {
                label_GettMe.Text      = @"Not loggedin.";
                label_UserStorage.Text = @"Storage...";
                listBox_Shares.Items.Clear();
                listBox_Files.Items.Clear();

                MessageBox.Show(@"Failed to login on Ge.tt, check apiKey, email or password" + Environment.NewLine + @"Exception of type " + ex.GetType() + Environment.NewLine + ex.Message);
            }
            finally
            {
                UseWaitCursor = false;
            }
        }