Пример #1
0
        //============================================================================*
        // OnEditChargeTest()
        //============================================================================*

        private void OnEditChargeTest(object sender, EventArgs e)
        {
            //----------------------------------------------------------------------------*
            // Get the selected charge test
            //----------------------------------------------------------------------------*

            cChargeTest OldChargeTest = (cChargeTest)ChargeTestListView.SelectedItems[0].Tag;

            //----------------------------------------------------------------------------*
            // Start the dialog
            //----------------------------------------------------------------------------*

            cChargeTestForm ChargeTestForm = new cChargeTestForm(OldChargeTest, m_Load, m_DataFiles);

            if (ChargeTestForm.ShowDialog() == DialogResult.OK)
            {
                //----------------------------------------------------------------------------*
                // Get the new Manufacturer Data
                //----------------------------------------------------------------------------*

                cChargeTest ChargeTest = ChargeTestForm.ChargeTest;

                //----------------------------------------------------------------------------*
                // Remove the old charge test and insert the new
                //----------------------------------------------------------------------------*

                m_Charge.TestList.Remove(OldChargeTest);

                m_Charge.TestList.Add(ChargeTest);

                PopulateChargeTestListView();
            }
        }
Пример #2
0
        //============================================================================*
        // OnAddChargeTest()
        //============================================================================*

        private void OnAddChargeTest(object sender, EventArgs e)
        {
            //----------------------------------------------------------------------------*
            // Start the dialog
            //----------------------------------------------------------------------------*

            cChargeTestForm ChargeTestForm = new cChargeTestForm(null, m_Load, m_DataFiles);

            if (ChargeTestForm.ShowDialog() == DialogResult.OK)
            {
                //----------------------------------------------------------------------------*
                // Get the new Manufacturer Data
                //----------------------------------------------------------------------------*

                cChargeTest ChargeTest = ChargeTestForm.ChargeTest;

                m_DataFiles.Preferences.LastChargeTest = ChargeTestForm.ChargeTest;

                //----------------------------------------------------------------------------*
                // See if the Charge already exists
                //----------------------------------------------------------------------------*

                m_Charge.TestList.Add(ChargeTest);

                PopulateChargeTestListView();
            }
        }
Пример #3
0
        //============================================================================*
        // OnOKClicked()
        //============================================================================*

        public void OnOKClicked(object sender, EventArgs args)
        {
            string strTestSource = String.Format("Batch #{0:G} Testing", m_BatchTest.Batch.BatchID);

            foreach (cCharge Charge in m_BatchTest.Batch.Load.ChargeList)
            {
                if (Charge.PowderWeight == m_BatchTest.Batch.PowderWeight)
                {
                    Charge.Favorite = FavoriteLoadRadioButton.Checked;
                    Charge.Reject   = RejectLoadRadioButton.Checked;

                    cChargeTest ChargeTest = null;

                    foreach (cChargeTest CheckChargeTest in Charge.TestList)
                    {
                        if (CheckChargeTest.BatchID == m_BatchTest.Batch.BatchID)
                        {
                            ChargeTest = CheckChargeTest;

                            break;
                        }
                    }

                    if (ChargeTest == null)
                    {
                        ChargeTest = new cChargeTest();

                        Charge.TestList.Add(ChargeTest);
                    }

                    ChargeTest.TestDate = TestDatePicker.Value;
                    ChargeTest.Firearm  = m_BatchTest.Firearm;

                    ChargeTest.Source = strTestSource;

                    ChargeTest.BarrelLength = m_BatchTest.Firearm.BarrelLength;
                    ChargeTest.Twist        = m_BatchTest.Firearm.Twist;

                    ChargeTest.BestGroup      = m_BatchTest.BestGroup;
                    ChargeTest.BestGroupRange = m_BatchTest.BestGroupRange;

                    ChargeTest.MuzzleVelocity = m_BatchTest.MuzzleVelocity;
                    ChargeTest.Pressure       = m_BatchTest.Pressure;

                    ChargeTest.Notes     = m_BatchTest.Notes;
                    ChargeTest.BatchTest = true;
                    ChargeTest.BatchID   = m_BatchTest.Batch.BatchID;
                }
            }

            while (m_BatchTest.TestShotList.Count > 0 && m_BatchTest.NumRounds < m_BatchTest.TestShotList.Count)
            {
                m_BatchTest.TestShotList.RemoveAt(m_BatchTest.TestShotList.Count - 1);
            }
        }
Пример #4
0
        //============================================================================*
        // AddTest()
        //============================================================================*

        public void AddTest(cChargeTest NewChargeTest)
        {
            bool fFound = false;

            foreach (cChargeTest ChargeTest in m_TestList)
            {
                if (ChargeTest.CompareTo(NewChargeTest) == 0)
                {
                    fFound = true;

                    break;
                }
            }

            if (!fFound)
            {
                m_TestList.Add(NewChargeTest);
            }
        }
Пример #5
0
        //============================================================================*
        // Copy() - ChargeTest
        //============================================================================*

        public void Copy(cChargeTest ChargeTest)
        {
            m_TestDate  = ChargeTest.m_TestDate;
            m_strSource = ChargeTest.m_strSource;

            m_Firearm       = ChargeTest.m_Firearm;
            m_dBarrelLength = ChargeTest.m_dBarrelLength;
            m_dTwist        = ChargeTest.m_dTwist;

            m_nMuzzleVelocity = ChargeTest.m_nMuzzleVelocity;
            m_nPressure       = ChargeTest.m_nPressure;

            m_dBestGroup      = ChargeTest.m_dBestGroup;
            m_dBestGroupRange = ChargeTest.m_dBestGroupRange;
            m_strNotes        = ChargeTest.m_strNotes;

            m_fBatchTest = ChargeTest.m_fBatchTest;
            m_nBatchID   = ChargeTest.m_nBatchID;

            m_dPowderWeight = ChargeTest.m_dPowderWeight;
        }
Пример #6
0
        //============================================================================*
        // OnRemoveChargeTest()
        //============================================================================*

        private void OnRemoveChargeTest(object sender, EventArgs e)
        {
            //----------------------------------------------------------------------------*
            // Get the selected charge test
            //----------------------------------------------------------------------------*

            if (ChargeTestListView.SelectedItems.Count > 0)
            {
                cChargeTest ChargeTest = (cChargeTest)ChargeTestListView.SelectedItems[0].Tag;

                if (ChargeTest != null)
                {
                    if (MessageBox.Show("Are you sure you wish to delete the selected test data?", "Deletion Verification", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        m_Charge.TestList.Remove(ChargeTest);

                        PopulateChargeTestListView();
                    }
                }
            }
        }
Пример #7
0
        //============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cChargeTest Test1, cChargeTest Test2)
        {
            if (Test1 == null)
            {
                if (Test2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Test2 == null)
                {
                    return(1);
                }
            }

            return(Test1.CompareTo(Test2));
        }
Пример #8
0
        //============================================================================*
        // cChargeTest() - Copy Constructor
        //============================================================================*

        public cChargeTest(cChargeTest ChargeTest)
        {
            Copy(ChargeTest);
        }
Пример #9
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

        public int CompareTo(cChargeTest ChargeTest)
        {
            if (ChargeTest == null)
            {
                return(1);
            }

            //----------------------------------------------------------------------------*
            // Date
            //----------------------------------------------------------------------------*

            int rc = m_TestDate.CompareTo(ChargeTest.m_TestDate);

            // Sort Latest to Oldest

            if (rc != 0)
            {
                return(rc < 0 ? 1 : -1);
            }

            //----------------------------------------------------------------------------*
            // Source
            //----------------------------------------------------------------------------*

            if (rc == 0)
            {
                rc = m_strSource.ToUpper().CompareTo(ChargeTest.m_strSource.ToUpper());

                //----------------------------------------------------------------------------*
                // Firearm
                //----------------------------------------------------------------------------*

                if (rc == 0)
                {
                    if (m_Firearm != null)
                    {
                        rc = m_Firearm.CompareTo(ChargeTest.m_Firearm);
                    }

                    //----------------------------------------------------------------------------*
                    // Barrel Length
                    //----------------------------------------------------------------------------*

                    if (rc == 0)
                    {
                        rc = m_dBarrelLength.CompareTo(ChargeTest.m_dBarrelLength);

                        //----------------------------------------------------------------------------*
                        // Twist
                        //----------------------------------------------------------------------------*

                        if (rc == 0)
                        {
                            rc = m_dTwist.CompareTo(ChargeTest.m_dTwist);

                            //----------------------------------------------------------------------------*
                            // Muzzle Velocity
                            //----------------------------------------------------------------------------*

                            if (rc == 0)
                            {
                                rc = m_nMuzzleVelocity.CompareTo(ChargeTest.m_nMuzzleVelocity);

                                //----------------------------------------------------------------------------*
                                // Pressure
                                //----------------------------------------------------------------------------*

                                if (rc == 0)
                                {
                                    rc = m_nPressure.CompareTo(ChargeTest.m_nPressure);
                                }
                            }
                        }
                    }
                }
            }

            //----------------------------------------------------------------------------*
            // Return results
            //----------------------------------------------------------------------------*

            return(rc);
        }
Пример #10
0
        //============================================================================*
        // cEvaluationItem() - Constructor
        //============================================================================*

        public cEvaluationItem(cLoad Load, cCharge Charge, cChargeTest ChargeTest)
        {
            m_Load       = Load;
            m_Charge     = Charge;
            m_ChargeTest = ChargeTest;
        }
Пример #11
0
        //============================================================================*
        // UpdateButtons()
        //============================================================================*

        private void UpdateButtons()
        {
            if (m_fViewOnly)
            {
                return;
            }

            bool   fEnableOK  = true;
            string strToolTip = "";
            bool   fDuplicate = false;

            //----------------------------------------------------------------------------*
            // Check PowderWeight
            //----------------------------------------------------------------------------*

            if (!PowderWeightTextBox.ValueOK || m_Charge.PowderWeight == 0.0)
            {
                fEnableOK = false;

                AddChargeTestButton.Enabled = false;
            }
            else
            {
                //----------------------------------------------------------------------------*
                // Check for Duplicate
                //----------------------------------------------------------------------------*

                fDuplicate = false;

                if (PowderWeightTextBox.Value != cDataFiles.StandardToMetric(m_dOriginalCharge, cDataFiles.eDataType.PowderWeight))
                {
                    foreach (cCharge CheckCharge in m_Load.ChargeList)
                    {
                        if (cDataFiles.StandardToMetric(CheckCharge.PowderWeight, cDataFiles.eDataType.PowderWeight) == PowderWeightTextBox.Value)
                        {
                            fDuplicate = true;

                            fEnableOK = false;

                            PowderWeightTextBox.BackColor = Color.LightPink;

                            string strErrorMessage = String.Format("This powder weight, \"{0:F1} {1}\", already exists for this load.  Duplicate charges are not allowed.", PowderWeightTextBox.Value, cDataFiles.MetricString(cDataFiles.eDataType.PowderWeight));

                            strToolTip += strErrorMessage;

                            ErrorMessageLabel.Text = strErrorMessage;

                            break;
                        }
                    }
                }

                if (!fDuplicate)
                {
                    AddChargeTestButton.Enabled = fEnableOK;

                    PowderWeightTextBox.BackColor = SystemColors.Window;

                    //----------------------------------------------------------------------------*
                    // Check if this powder weight can be modified
                    //----------------------------------------------------------------------------

                    if (m_fEditCharge)
                    {
                        int nNumBatches = 0;

                        foreach (cBatch Batch in m_DataFiles.BatchList)
                        {
                            if (Batch.Load.CompareTo(m_Load) == 0)
                            {
                                if (Batch.PowderWeight == Charge.PowderWeight)
                                {
                                    nNumBatches++;
                                }
                            }
                        }

                        if (nNumBatches > 0)
                        {
                            ErrorMessageLabel.Text = String.Format("This powder weight for this load has been used in {0:N0} batch{1} and may not be changed.  Fill Ratio, Favorite, and Reject selections may be changed.", nNumBatches, nNumBatches > 1 ? "es" : "");

                            m_fEditCharge = false;
                        }
                        else
                        {
                            ErrorMessageLabel.Text = "";
                        }
                    }

                    EnableChanges();
                }
            }

            //----------------------------------------------------------------------------*
            // Check Fill Ratio
            //----------------------------------------------------------------------------*

            if (!FillRatioTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            //----------------------------------------------------------------------------*
            // Check ChargeTestListView
            //----------------------------------------------------------------------------

            AddChargeTestButton.Enabled = fEnableOK;

            if (!fEnableOK || fDuplicate || ChargeTestListView.SelectedItems.Count == 0)
            {
                EditChargeTestButton.Enabled   = false;
                RemoveChargeTestButton.Enabled = false;
            }
            else
            {
                if (ChargeTestListView.SelectedItems.Count > 0)
                {
                    cChargeTest ChargeTest = (cChargeTest)ChargeTestListView.SelectedItems[0].Tag;

                    if (!ChargeTest.BatchTest)
                    {
                        EditChargeTestButton.Enabled   = true;
                        RemoveChargeTestButton.Enabled = true;
                    }
                    else
                    {
                        EditChargeTestButton.Enabled   = false;
                        RemoveChargeTestButton.Enabled = false;
                    }
                }
            }

            ChargeOKButton.Enabled = fEnableOK;
        }
Пример #12
0
        //============================================================================*
        // cChargeTestForm() - Constructor
        //============================================================================*

        public cChargeTestForm(cChargeTest ChargeTest, cLoad Load, cDataFiles DataFiles)
        {
            InitializeComponent();

            m_Load      = Load;
            m_DataFiles = DataFiles;

            if (ChargeTest == null)
            {
                if (m_DataFiles.Preferences.LastChargeTest != null)
                {
                    m_ChargeTest = new cChargeTest(m_DataFiles.Preferences.LastChargeTest);

                    m_ChargeTest.TestDate       = DateTime.Today;
                    m_ChargeTest.MuzzleVelocity = 0;
                    m_ChargeTest.Pressure       = 0;
                    m_ChargeTest.BestGroup      = 0.0;
                    m_ChargeTest.BestGroupRange = 0;
                    m_ChargeTest.Notes          = "";
                }
                else
                {
                    m_ChargeTest = new cChargeTest();
                }

                ChargeTestOKButton.Text = "Add";
            }
            else
            {
                m_ChargeTest = new cChargeTest(ChargeTest);

                ChargeTestOKButton.Text = "Update";
            }

            SetClientSizeCore(TestGroupBox.Location.X + TestGroupBox.Width + 10, ChargeTestCancelButton.Location.Y + ChargeTestCancelButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Set Control Event Handlers
            //----------------------------------------------------------------------------*

            SourceComboBox.TextChanged        += OnSourceChanged;
            FirearmCombo.SelectedIndexChanged += OnFirearmSelected;

            BarrelLengthTextBox.TextChanged   += OnBarrelLengthChanged;
            TwistTextBox.TextChanged          += OnTwistChanged;
            MuzzleVelocityTextBox.TextChanged += OnMuzzleVelocityChanged;
            PressureTextBox.TextChanged       += OnPressureChanged;
            BestGroupTextBox.TextChanged      += OnBestGroupChanged;
            BestGroupRangeTextBox.TextChanged += OnBestGroupRangeChanged;
            NotesTextBox.TextChanged          += OnNotesChanged;

            ChargeTestOKButton.Click += OnOKClicked;

            //----------------------------------------------------------------------------*
            // Populate the firearm combo
            //----------------------------------------------------------------------------*

            cControls.PopulateFirearmCombo(FirearmCombo, m_DataFiles, m_ChargeTest.Firearm, m_Load.Caliber, m_Load.FirearmType, true);

            PopulateSourceComboBox();

            //----------------------------------------------------------------------------*
            // Fill in the firearm data
            //----------------------------------------------------------------------------*

            SetInputParameters();

            PopulateChargeTestData();

            //----------------------------------------------------------------------------*
            // Set title and text fields
            //----------------------------------------------------------------------------*

            string strTitle;

            if (ChargeTest == null)
            {
                strTitle = "Add";
            }
            else
            {
                strTitle = "Edit";
            }

            strTitle += " Basic Charge Test";

            Text = strTitle;

            SetStaticToolTips();

            UpdateButtons();

            SetInitialFocus();
        }