Example #1
0
        private void btnRemoveProfile_Click(object sender, EventArgs e)
        {
            if (lvUserProfiles.SelectedItems.Count > 0)
            {
                UserProfileListViewItem itemBeingEdited = (UserProfileListViewItem)lvUserProfiles.SelectedItems[0];
                UserProfile             userBeingEdited = itemBeingEdited.UserProfile;

                if (MessageBox.Show(this, $"Delete user ({userBeingEdited.Name}), are you sure?", "Deletion Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        ZAMsettings.BeginCachedConfiguration();

                        ZAMsettings.Settings.DeleteUserProfile(userBeingEdited);

                        ZAMsettings.CommitCachedConfiguration();

                        lvUserProfiles.BeginUpdate();
                        lvUserProfiles.Items.Remove(itemBeingEdited);

                        if (lvUserProfiles.Items.Count > 0)
                        {
                            lvUserProfiles.Items[0].Focused  = true;
                            lvUserProfiles.Items[0].Selected = true;
                        }
                        lvUserProfiles.EndUpdate();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Exception occurred: " + ex.ToString(), "Error deleting User Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbMeasurementSystem));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbManual));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbAutomatic));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbDistanceUom));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbPosition));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbDistance));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbHrs));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbMins));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbSecs));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbDistance));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbTime));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.rbPosition));

            // final validation
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.gbLaps));

            if (!errorOccurred)
            {
                ZAMsettings.CommitCachedConfiguration();
                EditingSystemSettings = false;
            }
        }
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            errorOccurred = (errorOccurred || ValidateSystemSettings(tbWindowPosX));
            errorOccurred = (errorOccurred || ValidateSystemSettings(tbWindowPosY));
            errorOccurred = (errorOccurred || ValidateSystemSettings(cbNetwork));
            errorOccurred = (errorOccurred || ValidateSystemSettings(cbCurrentUser));
            errorOccurred = (errorOccurred || ValidateSystemSettings(ckbAutoStart));

            if (!errorOccurred)
            {
                ZAMsettings.CommitCachedConfiguration();
                EditingSystemSettings = false;
            }
        }
Example #4
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            if (this.EditingSystemSettings)
            {
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.ckbShowSplits));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbSplitDistance));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbSplitUom));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.ckbCalculateGoal));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.dtpGoalTime));
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbGoalDistance));

                if (!errorOccurred)
                {
                    // Wipe out splits and recalculate.  These will be saved in settings.
                    ZAMsettings.Settings.SplitsV2.CalculateDefaultSplits();

                    ZAMsettings.CommitCachedConfiguration();
                    EditingSystemSettings = false;

                    // show recalculated splits
                    this.SystemSettings_LoadFields();
                }
            }
            else if (this.EditingSplitSettings)
            {
                errorOccurred = (errorOccurred || ValidateSystemSettings(this.dgvSplits));

                if (!errorOccurred)
                {
                    ZAMsettings.CommitCachedConfiguration();
                    EditingSplitSettings = false;

                    this.SystemSettings_LoadFields();
                }
            }
        }
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            errorOccurred = (errorOccurred || ValidateSystemSettings(this.ckbShowSplits));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbSplitDistance));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.cbSplitUom));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.ckbCalculateGoal));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbGoalHrs));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbGoalMins));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbGoalSecs));
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.tbGoalDistance));

            // Check to make sure selections / values all make sense
            errorOccurred = (errorOccurred || ValidateSystemSettings(this.lvSplits));

            if (!errorOccurred)
            {
                ZAMsettings.CommitCachedConfiguration();
                EditingSystemSettings = false;

                this.LoadSplitChart();
            }
        }
        private void btnStatsSave_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            // this should not happen
            if (lvCollectors.SelectedItems.Count < 1)
            {
                ZAMsettings.RollbackCachedConfiguration();
                EditingCollectors = false;
                return;
            }

            CollectorListViewItem itemBeingEdited      = (CollectorListViewItem)lvCollectors.SelectedItems[0];
            Collector             collectorBeingEdited = itemBeingEdited.Collector;

            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgHide));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgWatts));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgWkg));

            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgMaxHide));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgMaxWatts));
            errorOccurred = (errorOccurred || ValidateStatistics(rbAvgMaxWkg));

            errorOccurred = (errorOccurred || ValidateStatistics(rbFtpHide));
            errorOccurred = (errorOccurred || ValidateStatistics(rbFtpWatts));
            errorOccurred = (errorOccurred || ValidateStatistics(rbFtpWkg));

            if (!errorOccurred)
            {
                try
                {
                    // Add or Update the Collector dictionary in the configuration.
                    ZAMsettings.Settings.UpsertCollector(collectorBeingEdited);

                    ZAMsettings.CommitCachedConfiguration();

                    lvCollectors.BeginUpdate();

                    // Refresh the fields and the list view
                    Collectors_LoadFields(collectorBeingEdited);
                    itemBeingEdited.Refresh();

                    //CollectorListViewItem lvi = new CollectorListViewItem(collectorBeingEdited);
                    //lvCollectors.Items.Add(lvi);
                    //lvi.Selected = true;

                    //lvCollectors.Items.Remove(itemBeingEdited);

                    lvCollectors.EndUpdate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred: " + ex.ToString(), "Error saving Collector", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    errorOccurred = true;
                }
                finally
                {
                    EditingCollectors = false;
                }
            }
        }
Example #7
0
        private void btnSaveProfile_Click(object sender, EventArgs e)
        {
            bool errorOccurred = false;

            // this should not happen
            if (lvUserProfiles.SelectedItems.Count < 1)
            {
                ZAMsettings.RollbackCachedConfiguration();
                EditingUserProfiles = false;
                return;
            }

            UserProfileListViewItem itemBeingEdited = (UserProfileListViewItem)lvUserProfiles.SelectedItems[0];
            UserProfile             userBeingEdited = itemBeingEdited.UserProfile;

            errorOccurred = (errorOccurred || ValidateUserProfiles(tbName));
            errorOccurred = (errorOccurred || ValidateUserProfiles(ckbDefault));
            errorOccurred = (errorOccurred || ValidateUserProfiles(tbWeight));
            errorOccurred = (errorOccurred || ValidateUserProfiles(rbLbs));
            errorOccurred = (errorOccurred || ValidateUserProfiles(rbKgs));
            errorOccurred = (errorOccurred || ValidateUserProfiles(nPowerThreshold));
            errorOccurred = (errorOccurred || ValidateUserProfiles(clbCollectors));

            if (!errorOccurred)
            {
                try
                {
                    // Add or Update the UserProfile dictionary in the configuration.
                    ZAMsettings.Settings.UpsertUserProfile(userBeingEdited);

                    ZAMsettings.CommitCachedConfiguration();

                    lvUserProfiles.BeginUpdate();

                    // Refresh the fields and the list view
                    UserProfiles_LoadFields(userBeingEdited);
                    itemBeingEdited.Refresh();

                    //UserProfileListViewItem lvi = new UserProfileListViewItem(userBeingEdited);
                    //lvUserProfiles.Items.Add(lvi);
                    //lvi.Selected = true;

                    //lvUserProfiles.Items.Remove(itemBeingEdited);

                    foreach (UserProfileListViewItem item in lvUserProfiles.Items)
                    {
                        bool isDefault = (item.UserProfile.UniqueId == ZAMsettings.Settings.DefaultUserProfile);

                        if (item.UserProfile.Default != isDefault)
                        {
                            item.UserProfile.Default = isDefault;
                            item.Refresh();
                        }
                    }

                    lvUserProfiles.EndUpdate();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception occurred: " + ex.ToString(), "Error saving User Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    errorOccurred = true;
                }
                finally
                {
                    EditingUserProfiles = false;
                }
            }
        }