Ejemplo n.º 1
0
        /// <summary>
        /// Validates whether or not the modeling should proceed.
        /// </summary>
        /// <param name="Profile">If the profile is valid, reference to the modeling profile</param>
        /// <returns>true/false depending on whether the model is validated for simulation</returns>
        private bool CanModel(ref GPProjectProfile Profile)
        {
            //
            // Ensure a profile is selected
            if (lvProfilesModeling.SelectedIndices.Count == 0)
            {
                MessageBox.Show("Please select a modeling profile", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //
            // Download the profile from the database
            Profile = new GPProjectProfile();
            Profile.LoadFromDB((int)lvProfilesModeling.SelectedItems[0].Tag);

            //
            // If the project doesn't have training data, don't start the modeling
            if (!(m_Project.DataTrainingID > 0))
            {
                MessageBox.Show("Select a training data set before modeling", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK);
                return(false);
            }

            switch (Profile.ValidateForModeling())
            {
            case GPProjectProfile.Validation.FunctionSet:
                MessageBox.Show("Please select functions for modeling", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK);
                return(false);

            case GPProjectProfile.Validation.Probability:
                MessageBox.Show("Ensure the Population Operators total 100", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private void lvProfiles_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            //
            // If the current profile is dirty, ask the user if they want to save it
            if (m_Profile != null && m_Profile.Dirty)
            {
                if (MessageBox.Show("Current profile has been modified, would you like to save it first?", GPEnums.APPLICATON_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    btnProfileSave_Click(sender, e);
                }
                //
                // Set the dirty flag to false even if the user didn't save, it prevents
                // the code from asking them again.
                m_Profile.Dirty = false;
            }

            //
            // If a modeling session is active, don't enable the Delete button
            if (!btnCancel.Enabled)
            {
                btnProfileDelete.Enabled = e.IsSelected;
            }

            btnProfileSave.Enabled = false;             // Always disable upon new selection
            btnProfileCopy.Enabled = e.IsSelected;
            if (e.IsSelected)
            {
                //
                // Get the selected profile displayed
                int ProfileID = (int)e.Item.Tag;
                m_Profile = new GPProjectProfile();
                m_Profile.LoadFromDB(ProfileID);

                UpdateProfileUI(m_Profile);

                //
                // If this profile is in use, then disable all the tab pages
                // so it can't be modified
                bool InUse = m_Profile.ProfileInUse;
                foreach (TabPage Page in tabProfile.TabPages)
                {
                    foreach (Control Child in Page.Controls)
                    {
                        Child.Enabled = !InUse;
                    }
                }

                //
                // Disable the delete buttons for the ADF, ADL and ADRs
                if (lvADF.SelectedItems.Count == 0)
                {
                    btnADFDelete.Enabled = false;
                }
                if (lvADL.SelectedItems.Count == 0)
                {
                    btnADLDelete.Enabled = false;
                }
                if (lvADR.SelectedItems.Count == 0)
                {
                    btnADRDelete.Enabled = false;
                }
            }
            else
            {
                //
                // Disable the ability to edit the profile
                foreach (TabPage Page in tabProfile.TabPages)
                {
                    foreach (Control Child in Page.Controls)
                    {
                        Child.Enabled = false;
                    }
                }
            }
        }