コード例 #1
0
        private void btnStatsCancel_Click(object sender, EventArgs e)
        {
            ZAMsettings.RollbackCachedConfiguration();

            errorProvider.Clear();

            if (lvCollectors.SelectedItems.Count > 0)
            {
                CollectorListViewItem itemBeingEdited = (CollectorListViewItem)lvCollectors.SelectedItems[0];
                Collector             userBeingEdited = itemBeingEdited.Collector;

                // If a newly added row, remove it and select the first one in list
                if (1 == 0)
                {
                    //lvCollectors.Items.Remove(itemBeingEdited);
                    //if (lvCollectors.Items.Count > 0)
                    //{
                    //    lvCollectors.Items[0].Selected = true;
                    //}
                }
                else
                {
                    // Refresh user from rolled back configuration
                    Collector refreshCollector = ZAMsettings.Settings.Collectors[userBeingEdited.Name];
                    Collectors_LoadFields(refreshCollector);

                    // This will clone the Collector so that the listview doesn't have a direct link to the configuration
                    itemBeingEdited.Collector = refreshCollector;
                }
            }
            EditingCollectors = false;
        }
コード例 #2
0
        private void btnCancelProfile_Click(object sender, EventArgs e)
        {
            ZAMsettings.RollbackCachedConfiguration();

            errorProvider.Clear();

            if (lvUserProfiles.SelectedItems.Count > 0)
            {
                UserProfileListViewItem itemBeingEdited = (UserProfileListViewItem)lvUserProfiles.SelectedItems[0];
                UserProfile             userBeingEdited = itemBeingEdited.UserProfile;

                // If a newly added row, remove it and select the first one in list
                if (userBeingEdited.UniqueId.Length == 0)
                {
                    lvUserProfiles.Items.Remove(itemBeingEdited);
                    if (lvUserProfiles.Items.Count > 0)
                    {
                        lvUserProfiles.Items[0].Selected = true;
                        lvUserProfiles.Items[0].Focused  = true;
                    }
                }
                else
                {
                    // Refresh user from rolled back configuration
                    UserProfile refreshUser = ZAMsettings.Settings.UserProfiles[userBeingEdited.UniqueId];
                    UserProfiles_LoadFields(refreshUser);

                    // This will clone the UserProfile so that the listview doesn't have a direct link to the configuration
                    itemBeingEdited.UserProfile = refreshUser;
                }
            }

            EditingUserProfiles = false;
        }
コード例 #3
0
        private void btnCancelSettings_Click(object sender, EventArgs e)
        {
            ZAMsettings.RollbackCachedConfiguration();

            errorProvider.Clear();

            // Reload values from configuration into fields since cancel was pressed
            SystemSettings_LoadFields();

            EditingSystemSettings = false;
        }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
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;
                }
            }
        }