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 btnAccept_Click(object sender, EventArgs e) { if (cbTheme.SelectedItem == null || cbTransparency.SelectedItem == null || cbFonts.SelectedItem == null) { MessageBox.Show(this.ParentForm, "Please make sure to select a valid theme, transparency, and font before saving.", "Unable to save", MessageBoxButtons.OK); return; } Logger.LogDebug($"Theme: {cbTheme.SelectedValue}, ManagedColor: {btnColor.SelectedColor}, Font: {cbFonts.SelectedItem} Transparency: {cbTransparency.SelectedValue}"); ZAMsettings.BeginCachedConfiguration(); ZAMsettings.Settings.Appearance.ThemeSetting = ((KeyValuePair <ThemeType, string>)cbTheme.SelectedItem).Key; ZAMsettings.Settings.Appearance.TransparencySetting = ((KeyValuePair <TransparencyType, string>)cbTransparency.SelectedItem).Key; ZAMsettings.Settings.Appearance.ManagedColor = btnColor.SelectedColor; ZAMsettings.Settings.Appearance.FontFamily = cbFonts.SelectedItem.ToString(); ZAMsettings.Settings.Appearance.FontSize = (float)nudFontSize.Value; ZAMsettings.Settings.Appearance.IsFontBold = cbBold.Checked; ZAMsettings.Settings.Appearance.IsFontItalic = cbItalic.Checked; ZAMsettings.CommitCachedConfiguration(); ZAMappearance cs = ZAMsettings.Settings.Appearance; ColorsAndFontChangedEventArgs args = new(cs.ThemeSetting, cs.TransparencySetting, cs.ManagedColor, cs.FontFamily, cs.FontSize, cs.IsFontBold, cs.IsFontItalic); // The MainForm listens for this event so it can refresh all colors this.OnColorsAndFontChanged(args); this.sfToolTip.Show("Configuration saved.", Cursor.Position, 2000); }
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; ZAMsettings.OnSystemConfigChanged(this, new EventArgs()); } }
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; ZAMsettings.OnSplitsConfigChanged(this, new EventArgs()); // show recalculated splits this.SystemSettings_LoadFields(); } } else if (this.EditingSplitSettings) { errorOccurred = (errorOccurred || ValidateSystemSettings(this.dgvSplits)); if (!errorOccurred) { ZAMsettings.CommitCachedConfiguration(); EditingSplitSettings = false; ZAMsettings.OnSplitsConfigChanged(this, new EventArgs()); this.SystemSettings_LoadFields(); } } }
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; } } }
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(tbEmailAddr)); //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; } } }