示例#1
0
        void loadProfile()
        {
            List <RideWithGpsActivityListItem> activities;

            SetStatusProgressThreadSafe(statusBar, "Value", 0);
            SetStatusProgressThreadSafe(statusBar, "Maximum", 3);
            SetStatusTextThreadSafe(statusBar, "Authenticating with RideWithGPS...");

            // Log in to RideWithGPS, display error if failed
            if (!_rwgps.login(_username, _password))
            {
                MessageBox.Show("RideWithGPS: Login Failed");
                this.Close();
            }

            SetControlPropertyThreadSafe(lblProfileName, "Text", _rwgps._profile.display_name);
            SetControlPropertyThreadSafe(lblProfileCity, "Text", _rwgps._profile.profile_area);
            SetControlPropertyThreadSafe(lblMemberSince, "Text", _rwgps._profile.member_since);
            SetControlPropertyThreadSafe(lblDOB, "Text", _rwgps._profile.dob);
            SetControlPropertyThreadSafe(lblTotalElevation, "Text", string.Format("{0:0.00} ft", (_rwgps._profile.total_trip_elevation * 3.2808399)));

            TimeSpan totDur = TimeSpan.FromSeconds(_rwgps._profile.total_trip_duration);

            SetControlPropertyThreadSafe(lblTotalDuration, "Text", string.Format("{0:D2} d {1:D2} h {2:D2} m {3:D2} s", Convert.ToInt32(Math.Floor(totDur.TotalDays)), totDur.Hours, totDur.Minutes, totDur.Seconds));
            SetControlPropertyThreadSafe(lblTotalDistance, "Text", string.Format("{0:0.00} miles", (_rwgps._profile.total_trip_distance * 0.000621371192)));
            SetControlPropertyThreadSafe(lblTotalActivities, "Text", string.Format("{0:0}", _rwgps._profile.total_trip_count));

            SetControlPropertyThreadSafe(pbProfilePhoto, "ImageLocation", _rwgps._profile.profile_photo_url);


            activities = _rwgps.GetActivities(this);


            SetStatusTextThreadSafe(statusBar, "Processing activities, and adding to profile page...");
            for (int a = 0; a < activities.Count; a++)
            {
                TimeSpan ts = TimeSpan.FromSeconds(activities[a].moving_time);

                string[] row =
                {
                    activities[a].id.ToString(),
                    activities[a].departed_at,
                    activities[a].name,
                    activities[a].location_string,
                    string.Format("{0:0.00} miles",            (activities[a].distance / 1000) * 0.621371192),
                    string.Format("{0:D2} h {1:D2} m {2:D2} s",ts.Hours,                                       ts.Minutes,ts.Seconds),
                    string.Format("{0:0.00} mph",              activities[a].avg_speed * 0.621371192),
                    string.Format("{0:0.00} ft",               activities[a].elevation_gain * 3.2808399),
                    //activities[a].avg_power.ToString(),
                    activities[a].created_at
                };
                AddListViewItem(lstActivities, new ListViewItem(row));
                SetControlPropertyThreadSafe(lblTotalActivities, "Text", string.Format("{0}", lstActivities.Items.Count));
            }
            SetStatusTextThreadSafe(statusBar, "Done.");

            ResizeListView(lstActivities);
        }
        void BtnLoginTestClick(object sender, EventArgs e)
        {
            _email    = txtUsername.Text;
            _password = txtPassword.Text;

            if (rwgps.login(txtUsername.Text, txtPassword.Text))
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Login FAILED. FRM. Incorrect username / password perhaps ?");
            }
        }
示例#3
0
        void checkForRideWithGpsDetails()
        {
            SetControlPropertyThreadSafe(tStatusText, "Text", "Checking RideWithGps authentication details...");
            _ridewithgps_email    = loadDbSetting("ridewithgps_email", "");
            _ridewithgps_password = loadDbSetting("ridewithgps_password", "");
            _ridewithgps_token    = loadDbSetting("ridewithgps_token", "");

            try{
                if (_ridewithgps_email != "" && _ridewithgps_password != "")
                {
                    _rwgps = new RideWithGpsAPI();
                    if (_rwgps.login(_ridewithgps_email, _ridewithgps_password))
                    {
                        //EnableMenuItem(menuConnectToRideWithGps, false);
                        //EnableMenuItem(menuViewAccountRideWithGps, true);
                        _ridewithgps_token = _rwgps.getAuthToken();
                    }
                }
            }
            catch {}
        }