예제 #1
0
        //============================================================================*
        // cOCWForm() - Constructor
        //============================================================================*

        public cOCWForm(cDataFiles DataFiles, rOCW OCW, cBatch Batch)
        {
            InitializeComponent();

            m_DataFiles = DataFiles;
            m_rOCW.Copy(OCW);
            m_Batch = Batch;

            SetClientSizeCore(SettingsGroupBox.Location.X + SettingsGroupBox.Width + 10, FormCancelButton.Location.Y + FormCancelButton.Height + 20);

            MaxNumBatchesTextBox.TextChanged  += OnMaxNumChanged;
            NumRoundsTextBox.TextChanged      += OnNumRoundsChanged;
            StartingWeightTextBox.TextChanged += OnStartWeightChanged;
            IncrementTextBox.TextChanged      += OnIncrementChanged;

            SetStaticToolTips();

            SetInputParameters();

            cBatchForm.SetOCWString(m_DataFiles, OCWLabel, ref m_rOCW, m_Batch);

            PopulateOCWSettings();

            UpdateButtons();

            m_fInitialized = true;
        }
예제 #2
0
        //============================================================================*
        // cBatchLoadListView() - Constructor
        //============================================================================*

        public cBatchLoadListView(cDataFiles DataFiles, cBatch Batch, bool fShowBatchLoad)
            : base(DataFiles, cPreferences.eApplicationListView.BatchLoadListView)
        {
            m_DataFiles      = DataFiles;
            m_Batch          = Batch;
            m_fShowBatchLoad = fShowBatchLoad;

            //----------------------------------------------------------------------------*
            // Set Properties
            //----------------------------------------------------------------------------*

            //----------------------------------------------------------------------------*
            // Event Handlers
            //----------------------------------------------------------------------------*

            //----------------------------------------------------------------------------*
            // Populate Columns and Groups
            //----------------------------------------------------------------------------*

            SortingOrder = m_DataFiles.Preferences.BatchLoadSortOrder;

            SortingColumn = m_DataFiles.Preferences.BatchLoadSortColumn;

            PopulateColumns(m_arColumns);

            //----------------------------------------------------------------------------*
            // Populate Data
            //----------------------------------------------------------------------------*

            Initialized = true;
        }
예제 #3
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public void Copy(cBatchTest BatchTest)
        {
            m_Batch = BatchTest.m_Batch;

            m_TestDate    = BatchTest.m_TestDate;
            m_strLocation = BatchTest.m_strLocation;

            m_Firearm = BatchTest.m_Firearm;

            m_nNumRounds      = BatchTest.m_nNumRounds;
            m_dBestGroup      = BatchTest.m_dBestGroup;
            m_dBestGroupRange = BatchTest.m_dBestGroupRange;
            m_strNotes        = BatchTest.m_strNotes;

            m_TestShotList = new cTestShotList(BatchTest.TestShotList);

            m_nAltitude    = BatchTest.m_nAltitude;
            m_nTemperature = BatchTest.m_nTemperature;
            m_dPressure    = BatchTest.m_dPressure;
            m_dHumidity    = BatchTest.m_dHumidity;

            m_nWindDirection = BatchTest.m_nWindDirection;
            m_nWindSpeed     = BatchTest.m_nWindSpeed;

            m_fSuppressed = BatchTest.m_fSuppressed;
        }
예제 #4
0
        //============================================================================*
        // SetBatchData()
        //============================================================================*

        public void SetBatchData(ListViewItem Item, cBatch Batch)
        {
            Item.SubItems.Clear();

            Item.Text = Batch.BatchIDString;

            Item.Checked = Batch.Checked;

            Item.Group = Groups[(int)Batch.Load.FirearmType];
            Item.Tag   = Batch;

            Item.SubItems.Add(String.IsNullOrEmpty(Batch.UserID) ? "" : Batch.UserID);
            Item.SubItems.Add(Batch.DateLoaded.ToShortDateString());
            Item.SubItems.Add(Batch.BatchTest != null ? "Y" : "");
            Item.SubItems.Add(Batch.Load.Caliber.ToString());
            Item.SubItems.Add(String.Format("{0:N0}", Batch.NumRounds));
            Item.SubItems.Add(Batch.Load.Bullet.ToWeightString());

            bool fCompressed = false;

            foreach (cCharge Charge in Batch.Load.ChargeList)
            {
                if (Charge.PowderWeight == Batch.PowderWeight)
                {
                    if (Charge.FillRatio > 100.0)
                    {
                        fCompressed = true;
                    }

                    break;
                }
            }

            string strPowderWeightFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.PowderWeight);

            if (fCompressed)
            {
                strPowderWeightFormat += "C";
            }

            strPowderWeightFormat += " {1} of {2}";

            Item.SubItems.Add(String.Format(strPowderWeightFormat, cDataFiles.StandardToMetric(Batch.PowderWeight, cDataFiles.eDataType.PowderWeight), cDataFiles.MetricString(cDataFiles.eDataType.PowderWeight), Batch.Load.Powder.ToString()));
            Item.SubItems.Add(Batch.Load.Primer.ToString());
            Item.SubItems.Add(Batch.Load.Case.ToShortString());

            if (Batch.Firearm != null)
            {
                Item.SubItems.Add(Batch.Firearm.ToString());
            }
            else
            {
                Item.SubItems.Add("Any Firearm");
            }
        }
        //============================================================================*
        // cTargetDetailsForm() - Constructor
        //============================================================================*

        public cTargetDetailsForm(cDataFiles DataFiles, cTarget Target)
        {
            InitializeComponent();

            m_DataFiles = DataFiles;
            m_Target    = new cTarget(Target);

            if (m_Target.BatchID != 0)
            {
                m_Batch = m_DataFiles.GetBatchByID(m_Target.BatchID);
            }

            //----------------------------------------------------------------------------*
            // Event Handlers
            //----------------------------------------------------------------------------*

            DatePicker.ValueChanged     += OnDateChanged;
            ShooterTextBox.TextChanged  += OnShooterChanged;
            LocationTextBox.TextChanged += OnLocationChanged;
            EventTextBox.TextChanged    += OnEventChanged;
            NotesTextBox.TextChanged    += OnNotesChanged;

            FirearmCombo.SelectedIndexChanged += OnFirearmChanged;

            //----------------------------------------------------------------------------*
            // Size Dialog and create Sho tList View
            //----------------------------------------------------------------------------*

            SetClientSizeCore(GeneralGroupBox.Location.X + GeneralGroupBox.Width + 10, OKButton.Location.Y + OKButton.Height + 20);

            m_ShotListView = new cTargetShotListView(m_DataFiles, m_Target);

            m_ShotListView.Location = new Point(6, 25);
            m_ShotListView.Size     = new Size(ShotDataGroupBox.Width - 12, ShotDataGroupBox.Height - 31);

            m_ShotListView.TabIndex = 0;

            ShotDataGroupBox.Controls.Add(m_ShotListView);

            //----------------------------------------------------------------------------*
            // Populate Data
            //----------------------------------------------------------------------------*

            PopulateFirearmCombo();

            PopulateDetailData();

            //----------------------------------------------------------------------------*
            // Finish up and exit
            //----------------------------------------------------------------------------*

            m_fInitialized = true;

            UpdateButtons();
        }
예제 #6
0
        //============================================================================*
        // Synch() - Batch
        //============================================================================*

        public bool Synch(cBatch Batch)
        {
            if (m_Batch != null && m_Batch.CompareTo(Batch) == 0)
            {
                m_Batch = Batch;

                return(true);
            }

            return(false);
        }
예제 #7
0
        //============================================================================*
        // cAmmo() - Batch Ammo Constructor
        //============================================================================*

        public cAmmo(cManufacturer BatchManufacturer, cBatch Batch)
            : base(cSupply.eSupplyTypes.Ammo)
        {
            FirearmType             = Batch.Load.FirearmType;
            Manufacturer            = BatchManufacturer;
            m_strPartNumber         = String.Format("Batch {0:G0}", Batch.BatchID);
            m_strType               = Batch.Load.Bullet.ToShortString();
            m_nBatchID              = Batch.BatchID;
            m_Caliber               = Batch.Load.Caliber;
            m_dBulletDiameter       = Batch.Load.Bullet.Diameter;
            m_dBulletWeight         = Batch.Load.Bullet.Weight;
            m_dBallisticCoefficient = Batch.Load.Bullet.BallisticCoefficient;
            m_fReload               = true;
        }
예제 #8
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

        public int CompareTo(Object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            cBatch Batch = (cBatch)obj;

            //----------------------------------------------------------------------------*
            // Batch ID
            //----------------------------------------------------------------------------*

            return(m_nBatchID.CompareTo(Batch.m_nBatchID));
        }
예제 #9
0
        //============================================================================*
        // UpdateBatch()
        //============================================================================*

        public ListViewItem UpdateBatch(cBatch Batch, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder, bool fSelect = false)
        {
            //----------------------------------------------------------------------------*
            // Find the Item
            //----------------------------------------------------------------------------*

            ListViewItem Item = null;

            foreach (ListViewItem CheckItem in Items)
            {
                if ((CheckItem.Tag as cBatch).CompareTo(Batch) == 0)
                {
                    Item = CheckItem;

                    break;
                }
            }

            //----------------------------------------------------------------------------*
            // If the item was not found, add it
            //----------------------------------------------------------------------------*

            if (Item == null)
            {
                return(null);
            }

            //----------------------------------------------------------------------------*
            // Otherwise, update the Item Data
            //----------------------------------------------------------------------------*

            SetBatchData(Item, Batch);

            Item.Selected = fSelect;

            if (SelectedItems.Count > 0)
            {
                SelectedItems[0].EnsureVisible();
            }

            Focus();

            return(Item);
        }
예제 #10
0
        //============================================================================*
        // VerifyBatch()
        //============================================================================*

        public bool VerifyBatch(cBatch Batch, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder)
        {
            //----------------------------------------------------------------------------*
            // Make sure the batch shouldn't be hidden
            //----------------------------------------------------------------------------*

            /*
             *                      if ((m_DataFiles.Preferences.HideUncheckedCalibers && !Batch.Load.Caliber.Checked) ||
             *                              (m_DataFiles.Preferences.HideUncheckedSupplies && !Batch.Load.Bullet.Checked) ||
             *                              (m_DataFiles.Preferences.HideUncheckedSupplies && !Batch.Load.Powder.Checked) ||
             *                              (m_DataFiles.Preferences.HideUncheckedSupplies && !Batch.Load.Primer.Checked) ||
             *                              (m_DataFiles.Preferences.HideUncheckedSupplies && !Batch.Load.Case.Checked) ||
             *                              Batch.Archived)
             *                              return (false);
             */
            //----------------------------------------------------------------------------*
            // Check the filters
            //----------------------------------------------------------------------------*

            if (Batch.Load.FirearmType != eFirearmType)
            {
                return(false);
            }

            if (Caliber != null && Batch.Load.Caliber != Caliber)
            {
                return(false);
            }

            if (Bullet != null && Batch.Load.Bullet != Bullet)
            {
                return(false);
            }

            if (Powder != null && Batch.Load.Powder != Powder)
            {
                return(false);
            }

            return(true);
        }
예제 #11
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public void Copy(cBatch Batch)
        {
            m_nBatchID        = Batch.m_nBatchID;
            m_nOCWBatchID     = Batch.m_nOCWBatchID;
            m_strUserID       = Batch.m_strUserID;
            m_DateLoaded      = new DateTime(Batch.DateLoaded.Ticks);
            m_dPowderWeight   = Batch.m_dPowderWeight;
            m_nNumRounds      = Batch.m_nNumRounds;
            m_nTimesFired     = Batch.m_nTimesFired;
            m_dCOL            = Batch.m_dCOL;
            m_dCBTO           = Batch.m_dCBTO;
            m_dHeadSpace      = Batch.m_dHeadSpace;
            m_dNeckSize       = Batch.m_dNeckSize;
            m_dNeckWall       = Batch.m_dNeckWall;
            m_dCaseTrimLength = Batch.m_dCaseTrimLength;
            m_dBulletDiameter = Batch.m_dBulletDiameter;

            m_fFullLengthSized = Batch.m_fFullLengthSized;
            m_fNeckSized       = Batch.m_fNeckSized;
            m_fExpandedNeck    = Batch.m_fExpandedNeck;

            m_fGasCheck       = Batch.m_fGasCheck;
            m_fNeckTurned     = Batch.m_fNeckTurned;
            m_fAnnealed       = Batch.m_fAnnealed;
            m_fModifiedBullet = Batch.m_fModifiedBullet;

            m_fJumpSet = Batch.m_fJumpSet;
            m_dJump    = Batch.m_dJump;

            m_Firearm = Batch.m_Firearm;

            m_Load = Batch.m_Load;

            m_BatchTestList = new cBatchTestList(Batch.BatchTestList);

            m_fArchive = Batch.m_fArchive;

            m_fTrackInventory = Batch.m_fTrackInventory;
        }
예제 #12
0
        //============================================================================*
        // AddBatch()
        //============================================================================*

        public ListViewItem AddBatch(cBatch Batch, cFirearm.eFireArmType eFireArmType, cCaliber Caliber, cBullet Bullet, cPowder Powder, bool fSelect = false)
        {
            if (!VerifyBatch(Batch, eFireArmType, Caliber, Bullet, Powder))
            {
                return(null);
            }

            //----------------------------------------------------------------------------*
            // Create the ListViewItem
            //----------------------------------------------------------------------------*

            ListViewItem Item = new ListViewItem();

            SetBatchData(Item, Batch);

            //----------------------------------------------------------------------------*
            // Add the item and exit
            //----------------------------------------------------------------------------*

            AddItem(Item, fSelect);

            return(Item);
        }
예제 #13
0
        //============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cBatch Batch1, cBatch Batch2)
        {
            if (Batch1 == null)
            {
                if (Batch2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Batch2 == null)
                {
                    return(1);
                }
            }

            return(Batch1.CompareTo(Batch2));
        }
        //============================================================================*
        // Compare()
        //============================================================================*

        public override int Compare(Object Object1, Object Object2)
        {
            if (Object1 == null)
            {
                if (Object2 == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (Object2 == null)
                {
                    return(1);
                }
            }

            cEvaluationItem Item1 = (cEvaluationItem)(Object1 as ListViewItem).Tag;
            cEvaluationItem Item2 = (cEvaluationItem)(Object2 as ListViewItem).Tag;

            if (Item1 == null)
            {
                if (Item2 == null)
                {
                    return(0);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Item2 == null)
                {
                    return(1);
                }
            }

            //----------------------------------------------------------------------------*
            // Do Special Compares
            //----------------------------------------------------------------------------*

            bool fSpecial = false;
            int  rc       = 0;

            string strPart1 = "";
            string strPart2 = "";

            cBatch Batch1 = null;
            cBatch Batch2 = null;

            switch (SortColumn)
            {
            //----------------------------------------------------------------------------*
            // Batch ID
            //----------------------------------------------------------------------------*

            case 0:
                rc = Item1.ChargeTest.BatchID.CompareTo(Item2.ChargeTest.BatchID);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Caliber
            //----------------------------------------------------------------------------*

            case 1:
                rc = Item1.Load.Caliber.CompareTo(Item2.Load.Caliber);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Bullet
            //----------------------------------------------------------------------------*

            case 2:
                rc = Item1.Load.Bullet.Manufacturer.CompareTo(Item2.Load.Bullet.Manufacturer);

                if (rc == 0)
                {
                    strPart1 = Item1.Load.Bullet.PartNumber;
                    strPart2 = Item2.Load.Bullet.PartNumber;

                    if (strPart1.Length != strPart2.Length)
                    {
                        if (strPart1.Length > strPart2.Length)
                        {
                            string strPad = "";

                            while (strPart1.Length > strPart2.Length + strPad.Length)
                            {
                                strPad += " ";
                            }

                            strPart2 = strPad + strPart2;
                        }
                        else
                        {
                            string strPad = "";

                            while (strPart2.Length > strPart1.Length + strPad.Length)
                            {
                                strPad += " ";
                            }

                            strPart1 = strPad + strPart1;
                        }
                    }


                    rc = strPart1.CompareTo(strPart2);

                    if (rc == 0)
                    {
                        rc = Item1.Load.Powder.CompareTo(Item2.Load.Powder);
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Powder
            //----------------------------------------------------------------------------*

            case 3:
                rc = Item1.Load.Powder.Manufacturer.CompareTo(Item2.Load.Powder.Manufacturer);

                if (rc == 0)
                {
                    strPart1 = Item1.Load.Powder.Type;
                    strPart2 = Item2.Load.Powder.Type;

                    if (strPart1.Length != strPart2.Length)
                    {
                        string strPad = "";

                        if (strPart1.Length < strPart2.Length)
                        {
                            while (strPart1.Length + strPad.Length < strPart2.Length)
                            {
                                strPad += " ";
                            }

                            strPart1 = strPad + strPart1;
                        }
                        else
                        {
                            while (strPart2.Length + strPad.Length < strPart1.Length)
                            {
                                strPad += " ";
                            }

                            strPart2 = strPad + strPart2;
                        }
                    }

                    rc = strPart1.CompareTo(strPart2);

                    if (rc == 0)
                    {
                        rc = Item1.Charge.PowderWeight.CompareTo(Item2.Charge.PowderWeight);
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Charge
            //----------------------------------------------------------------------------*

            case 4:
                rc = Item1.Charge.PowderWeight.CompareTo(Item2.Charge.PowderWeight);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Primer
            //----------------------------------------------------------------------------*

            case 5:
                rc = Item1.Load.Primer.Manufacturer.CompareTo(Item2.Load.Primer.Manufacturer);

                if (rc == 0)
                {
                    strPart1 = Item1.Load.Primer.Model;
                    strPart2 = Item2.Load.Primer.Model;

                    if (strPart1.Length != strPart2.Length)
                    {
                        string strPad = "";

                        if (strPart1.Length < strPart2.Length)
                        {
                            while (strPart1.Length + strPad.Length < strPart2.Length)
                            {
                                strPad += " ";
                            }

                            strPart1 = strPad + strPart1;
                        }
                        else
                        {
                            while (strPart2.Length + strPad.Length < strPart1.Length)
                            {
                                strPad += " ";
                            }

                            strPart2 = strPad + strPart2;
                        }
                    }

                    rc = strPart1.CompareTo(strPart2);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Case
            //----------------------------------------------------------------------------*

            case 6:
                rc = Item1.Load.Case.Manufacturer.CompareTo(Item2.Load.Case.Manufacturer);

                if (rc == 0)
                {
                    rc = Item1.Load.Case.Caliber.CompareTo(Item2.Load.Case.Caliber);
                }

                if (rc == 0)
                {
                    strPart1 = Item1.Load.Case.PartNumber;
                    strPart2 = Item2.Load.Case.PartNumber;

                    if (strPart1.Length != strPart2.Length)
                    {
                        string strPad = "";

                        if (strPart1.Length < strPart2.Length)
                        {
                            while (strPart1.Length + strPad.Length < strPart2.Length)
                            {
                                strPad += " ";
                            }

                            strPart1 = strPad + strPart1;
                        }
                        else
                        {
                            while (strPart2.Length + strPad.Length < strPart1.Length)
                            {
                                strPad += " ";
                            }

                            strPart2 = strPad + strPart2;
                        }
                    }

                    rc = strPart1.CompareTo(strPart2);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Num Rounds
            //----------------------------------------------------------------------------*

            case 7:
                int nItem1 = 0;
                int nItem2 = 0;

                Int32.TryParse((Object1 as ListViewItem).Text, out nItem1);
                Int32.TryParse((Object2 as ListViewItem).Text, out nItem2);

                rc = nItem1.CompareTo(nItem2);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Best Group
            //----------------------------------------------------------------------------*

            case 8:
                rc = Item1.ChargeTest.BestGroup.CompareTo(Item2.ChargeTest.BestGroup);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // MOA
            //----------------------------------------------------------------------------*

            case 9:
                double Group1 = Item1.ChargeTest.BestGroup;
                double Group2 = Item2.ChargeTest.BestGroup;

                Group1 = cDataFiles.MetricToStandard(Group1, cDataFiles.eDataType.GroupSize);
                Group2 = cDataFiles.MetricToStandard(Group2, cDataFiles.eDataType.GroupSize);

                double dRange1 = Item1.ChargeTest.BestGroupRange;
                double dRange2 = Item2.ChargeTest.BestGroupRange;

                if (cPreferences.StaticPreferences.MetricRanges)
                {
                    dRange1 = cConversions.MetersToYards(dRange1);
                    dRange2 = cConversions.MetersToYards(dRange2);
                }

                double dMOA1 = (dRange1 > 0) ? Group1 / ((dRange1 / 100.0) * 1.047) : 0;
                double dMOA2 = (dRange2 > 0) ? Group2 / ((dRange2 / 100.0) * 1.047) : 0;

                rc = dMOA1.CompareTo(dMOA2);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Best Group Range
            //----------------------------------------------------------------------------*

            case 10:
                rc = Item1.ChargeTest.BestGroupRange.CompareTo(Item2.ChargeTest.BestGroupRange);

                fSpecial = true;

                break;

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

            case 11:
                rc = Item1.ChargeTest.MuzzleVelocity.CompareTo(Item2.ChargeTest.MuzzleVelocity);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Max Deviation
            //----------------------------------------------------------------------------*

            case 12:
                Batch1 = m_DataFiles.GetBatchByID(Item1.ChargeTest.BatchID);
                Batch2 = m_DataFiles.GetBatchByID(Item2.ChargeTest.BatchID);

                if (Batch1 == null || Batch1.BatchTest == null || Batch1.BatchTest.TestShotList == null || Batch2 == null || Batch2.BatchTest == null || Batch2.BatchTest.TestShotList == null)
                {
                    rc = 0;
                }
                else
                {
                    rc = Batch1.BatchTest.TestShotList.Statistics.MaxDeviation.CompareTo(Batch2.BatchTest.TestShotList.Statistics.MaxDeviation);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Std Deviation
            //----------------------------------------------------------------------------*

            case 13:
                Batch1 = m_DataFiles.GetBatchByID(Item1.ChargeTest.BatchID);
                Batch2 = m_DataFiles.GetBatchByID(Item2.ChargeTest.BatchID);

                if (Batch1 == null || Batch1.BatchTest == null || Batch1.BatchTest.TestShotList == null || Batch2 == null || Batch2.BatchTest == null || Batch2.BatchTest.TestShotList == null)
                {
                    rc = 0;
                }
                else
                {
                    rc = Batch1.BatchTest.TestShotList.Statistics.StdDev.CompareTo(Batch2.BatchTest.TestShotList.Statistics.StdDev);
                }

                fSpecial = true;

                break;
            }

            if (fSpecial)
            {
                if (SortingOrder == SortOrder.Descending)
                {
                    return(0 - rc);
                }

                return(rc);
            }

            return(base.Compare(Object1, Object2));
        }
예제 #15
0
        //============================================================================*
        // OnMouseClick()
        //============================================================================*

        protected override void OnMouseClick(MouseEventArgs args)
        {
            int nX = args.X;
            int nY = args.Y;

            ListViewItem Item = GetItemAt(nX, nY);

            //----------------------------------------------------------------------------*
            // Find the Column that was clicked
            //----------------------------------------------------------------------------*

            int nColumn  = 0;
            int nColumnX = 0;

            bool fColumnFound = false;

            if (Item != null)
            {
                foreach (ColumnHeader Column in Columns)
                {
                    if (nX >= nColumnX && nX <= nColumnX + Column.Width)
                    {
                        fColumnFound = true;

                        break;
                    }

                    nColumnX += Column.Width;
                    nColumn++;
                }
            }

            if (fColumnFound)
            {
                ColumnHeader Header = Columns[nColumn];

                Graphics g = Graphics.FromHwnd(this.Handle);

                SizeF TextSize = g.MeasureString(Item.SubItems[nColumn].Text, this.Font);

                //----------------------------------------------------------------------------*
                // Website Column
                //----------------------------------------------------------------------------*

                if (Header.Text == "Website")
                {
                    if (Item.SubItems[nColumn].Text.Length > 0)
                    {
                        if (nX - nColumnX < (int)TextSize.Width)
                        {
                            try
                            {
                                System.Diagnostics.Process.Start(Item.SubItems[nColumn].Text);

                                WebsiteVisited(Item);
                            }
                            catch
                            {
                                MessageBox.Show("Invalid Website URL.  Correct the URL and try again.", "Invalid URL", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                return;
                            }
                        }
                    }
                }

                //----------------------------------------------------------------------------*
                // Part Number Column
                //----------------------------------------------------------------------------*

                if (Header.Text == "Part Number" && Item.Text == "Batch Editor")
                {
                    Size BoxSize = CheckBoxRenderer.GetGlyphSize(g, (Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));

                    if ((nColumn == 0 && CheckBoxes && nX > 4 + BoxSize.Width && nX - 4 - BoxSize.Width - nColumnX < (int)TextSize.Width) ||
                        (nColumn == 0 && !CheckBoxes && nX > 4 && nX - nColumnX < (int)TextSize.Width) ||
                        (nColumn != 0 && nX > 4 && nX - nColumnX < (int)TextSize.Width))
                    {
                        string strBatchNumber = Item.SubItems[1].Text;

                        if (strBatchNumber.Length >= 7 && strBatchNumber.Substring(0, 6) == "Batch ")
                        {
                            strBatchNumber = strBatchNumber.Substring(6);
                        }
                        else
                        {
                            strBatchNumber = "";
                        }

                        int nBatchID = 0;

                        Int32.TryParse(strBatchNumber, out nBatchID);

                        if (nBatchID > 0)
                        {
                            cBatch Batch = m_DataFiles.GetBatchByID(nBatchID);

                            if (Batch != null)
                            {
                                cBatchForm BatchForm = new cBatchForm(Batch, m_DataFiles, null, cFirearm.eFireArmType.None, true);

                                BatchForm.ShowDialog();
                            }
                        }
                    }
                }

                //----------------------------------------------------------------------------*
                // Caliber Column
                //----------------------------------------------------------------------------*

                if (Header.Text == "Caliber" || Header.Text == "Primary Caliber")
                {
                    cCaliber Caliber = GetCaliberFromTag(Item);

                    if (Caliber != null && !String.IsNullOrEmpty(Caliber.SAAMIPDF))
                    {
                        Size BoxSize = CheckBoxRenderer.GetGlyphSize(g, (Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));

                        if ((nColumn == 0 && CheckBoxes && nX > 4 + BoxSize.Width && nX - 4 - BoxSize.Width - nColumnX < (int)TextSize.Width) ||
                            (nColumn == 0 && !CheckBoxes && nX > 4 && nX - nColumnX < (int)TextSize.Width) ||
                            (nColumn != 0 && nX > 4 && nX - nColumnX < (int)TextSize.Width))
                        {
                            cCaliber.ShowSAAMIPDF(m_DataFiles, Caliber);
                        }
                    }
                }
            }

            base.OnMouseClick(args);
        }
예제 #16
0
        //============================================================================*
        // cBatchTestForm() - Constructor
        //============================================================================*

        public cBatchTestForm(cBatch Batch, cDataFiles DataFiles, cRWRegistry RWRegistry, bool fViewOnly = false)
        {
            InitializeComponent();

            m_DataFiles  = DataFiles;
            m_RWRegistry = RWRegistry;
            m_fViewOnly  = fViewOnly;

            string strTitle = "";

            if (Batch.BatchTest == null)
            {
                m_BatchTest          = new cBatchTest();
                m_BatchTest.Batch    = Batch;
                m_BatchTest.Firearm  = Batch.Firearm;
                m_BatchTest.TestDate = DateTime.Today;

                m_BatchTest.Temperature        = 59;
                m_BatchTest.Altitude           = 0;
                m_BatchTest.BarometricPressure = 29.92;
                m_BatchTest.Humidity           = 0.78;

                strTitle = "Add";

                BatchTestOKButton.Text        = "Add";
                BatchTestDeleteButton.Enabled = false;
            }
            else
            {
                m_BatchTest = new cBatchTest(Batch.BatchTest);

                if (!m_fViewOnly)
                {
                    strTitle = "Edit";

                    BatchTestOKButton.Text = "Update";
                }
                else
                {
                    BatchTestCancelButton.Text    = "Close";
                    BatchTestDeleteButton.Visible = false;
                    BatchTestOKButton.Visible     = false;

                    int nButtonX = (this.Size.Width / 2) - (BatchTestCancelButton.Width / 2);

                    BatchTestCancelButton.Location = new Point(nButtonX, BatchTestCancelButton.Location.Y);

                    strTitle = "View";
                }
            }

            SetClientSizeCore(BatchDataGroupBox.Location.X + BatchDataGroupBox.Width + 10, BatchTestCancelButton.Location.Y + BatchTestCancelButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Set Title
            //----------------------------------------------------------------------------*

            strTitle += " Batch Test";

            Text = strTitle;

            //----------------------------------------------------------------------------*
            // Event Handlers
            //----------------------------------------------------------------------------*

            if (!m_fViewOnly && !m_BatchTest.Batch.Archived)
            {
                TestDatePicker.TextChanged += OnDateChanged;

                FirearmCombo.SelectedIndexChanged += OnFirearmChanged;

                LocationTextBox.TextChanged += OnLocationTextChanged;

                SuppressedCheckBox.Click += OnSuppressedClicked;

                TemperatureTextBox.TextChanged += OnTemperatureChanged;
                AltitudeTextBox.TextChanged    += OnAltitudeChanged;
                PressureTextBox.TextChanged    += OnBarometricPressureChanged;
                HumidityTextBox.TextChanged    += OnHumidityChanged;

                WindSpeedTextBox.TextChanged     += OnWindSpeedChanged;
                WindDirectionTextBox.TextChanged += OnWindDirectionChanged;

                NumShotsTextBox.TextChanged += OnNumShotsTextChanged;

                BestGroupTextBox.TextChanged += OnBestGroupChanged;

                NotesTextBox.TextChanged += OnNotesChanged;

                BestGroupRangeTextBox.TextChanged += OnBestGroupRangeChanged;

                TargetCalculatorButton.Click += OnTargetCalculatorClicked;

                FavoriteLoadRadioButton.Click += OnFavoriteLoadClicked;
                RejectLoadRadioButton.Click   += OnRejectLoadClicked;

                BatchTestOKButton.Click += OnOKClicked;
            }
            else
            {
                NumShotsTextBox.ReadOnly       = true;
                BestGroupTextBox.ReadOnly      = true;
                BestGroupRangeTextBox.ReadOnly = true;

                NotesTextBox.ReadOnly = true;
            }

            EditShotsButton.Click += OnEditShotsClicked;

            //----------------------------------------------------------------------------*
            // Set Decimals
            //----------------------------------------------------------------------------*

            SetInputParameters();

            //----------------------------------------------------------------------------*
            // Populate Form Data
            //----------------------------------------------------------------------------*

            SetStaticToolTips();

            BatchIDLabel.Text = String.Format("{0:G0}", m_BatchTest.Batch.BatchID);

            if (m_BatchTest.Batch.Archived)
            {
                BatchIDLabel.Text += " - Archived";
            }

            DateLoadedLabel.Text = m_BatchTest.Batch.DateLoaded.ToShortDateString();
            CaliberLabel.Text    = m_BatchTest.Batch.Load.Caliber.ToString();
            LoadLabel.Text       = m_BatchTest.Batch.Load.ToShortString();
            ChargeLabel.Text     = String.Format("{0:F1}", m_BatchTest.Batch.PowderWeight);
            NumRoundsLabel.Text  = String.Format("{0:G0}", m_BatchTest.Batch.NumRounds);

            switch (m_BatchTest.Batch.Load.FirearmType)
            {
            case cFirearm.eFireArmType.Handgun:
                FirearmTypeLabel.Text = "Handgun";
                break;

            case cFirearm.eFireArmType.Rifle:
                FirearmTypeLabel.Text = "Rifle";
                break;

            case cFirearm.eFireArmType.Shotgun:
                FirearmTypeLabel.Text = "Shotgun";
                break;
            }

            PopulateBatchTestData();
            PopulateShotList();

            m_fInitialized = true;

            UpdateButtons();
        }
        //============================================================================*
        // Compare()
        //============================================================================*

        public override int Compare(Object Object1, Object Object2)
        {
            if (Object1 == null)
            {
                if (Object2 == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (Object2 == null)
                {
                    return(1);
                }
            }

            cBatch Batch1 = (cBatch)(Object1 as ListViewItem).Tag;
            cBatch Batch2 = (cBatch)(Object2 as ListViewItem).Tag;

            if (Batch1 == null)
            {
                if (Batch2 == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (Batch2 == null)
                {
                    return(1);
                }
            }

            bool fSpecial = false;
            int  rc       = 0;

            switch (SortColumn)
            {
            //----------------------------------------------------------------------------*
            // Batch ID
            //----------------------------------------------------------------------------*

            case 0:
                rc = Batch1.BatchID.CompareTo(Batch2.BatchID);

                fSpecial = true;

                break;

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

            case 2:
                rc = Batch1.DateLoaded.CompareTo(Batch2.DateLoaded);

                if (rc == 0)
                {
                    rc = Batch1.BatchID.CompareTo(Batch2.BatchID);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // test Data
            //----------------------------------------------------------------------------*

            case 3:
                rc = 0;

                if (Batch1.BatchTest != null)
                {
                    if (Batch2.BatchTest == null)
                    {
                        rc = 1;
                    }
                }
                else
                {
                    if (Batch2.BatchTest != null)
                    {
                        rc = -1;
                    }
                }

                if (rc == 0)
                {
                    rc = Batch1.BatchID.CompareTo(Batch2.BatchID);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Num Rounds
            //----------------------------------------------------------------------------*

            case 5:
                rc = Batch1.NumRounds.CompareTo(Batch2.NumRounds);

                if (rc == 0)
                {
                    rc = Batch1.BatchID.CompareTo(Batch2.BatchID);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Bullet
            //----------------------------------------------------------------------------*

            case 6:
                rc = Batch1.Load.Bullet.CompareTo(Batch2.Load.Bullet);

                if (rc == 0)
                {
                    rc = Batch1.BatchID.CompareTo(Batch2.BatchID);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Powder
            //----------------------------------------------------------------------------*

            case 7:
                rc = Batch1.Load.Powder.CompareTo(Batch2.Load.Powder);

                if (rc == 0)
                {
                    rc = Batch1.PowderWeight.CompareTo(Batch2.PowderWeight);

                    if (rc == 0)
                    {
                        rc = Batch1.BatchID.CompareTo(Batch2.BatchID);
                    }
                }

                fSpecial = true;

                break;
            }

            if (fSpecial)
            {
                if (SortingOrder == SortOrder.Descending)
                {
                    return(0 - rc);
                }

                return(rc);
            }

            return(base.Compare(Object1, Object2));
        }
예제 #18
0
        //============================================================================*
        // SetLoadData()
        //============================================================================*

        public void SetLoadData(cLoad Load)
        {
            //----------------------------------------------------------------------------*
            // Create the format strings
            //----------------------------------------------------------------------------*

            string strChargeFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.PowderWeight);
            string strGroupFormat  = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.GroupSize);

            //----------------------------------------------------------------------------*
            // Loop through the charges
            //----------------------------------------------------------------------------*

            foreach (cCharge Charge in Load.ChargeList)
            {
                //----------------------------------------------------------------------------*
                // Loop through the charge tests
                //----------------------------------------------------------------------------*

                foreach (cChargeTest ChargeTest in Charge.TestList)
                {
                    if (ChargeTest.BatchID == 0 && !m_fFactoryTest)
                    {
                        continue;
                    }

                    //----------------------------------------------------------------------------*
                    // Create the ListViewItem
                    //----------------------------------------------------------------------------*

                    ListViewItem Item = new ListViewItem();

                    //----------------------------------------------------------------------------*
                    // Set the ListViewItem Data
                    //----------------------------------------------------------------------------*

                    Item.Text = (ChargeTest.BatchID != 0) ? String.Format("Batch #{0:G0}", ChargeTest.BatchID) : ChargeTest.Source;

                    Item.Tag = new cEvaluationItem(Load, Charge, ChargeTest);

                    Item.SubItems.Add(Load.Caliber.ToString());
                    Item.SubItems.Add(Load.Bullet.ToString());
                    Item.SubItems.Add(Load.Powder.ToString());
                    Item.SubItems.Add(String.Format(strChargeFormat, cDataFiles.StandardToMetric(Charge.PowderWeight, cDataFiles.eDataType.PowderWeight)));
                    Item.SubItems.Add(Load.Primer.ToShortString());
                    Item.SubItems.Add(Load.Case.ToShortString());

                    cBatch Batch = null;

                    if (ChargeTest.BatchID != 0)
                    {
                        Batch = m_DataFiles.GetBatchByID(ChargeTest.BatchID);
                    }

                    if (Batch == null || Batch.BatchTest == null)
                    {
                        Item.SubItems.Add("-");
                    }
                    else
                    {
                        Item.SubItems.Add(String.Format("{0:G0}", Batch.BatchTest.NumRounds));
                    }

                    if (ChargeTest.BestGroup == 0.0)
                    {
                        Item.SubItems.Add("-");
                    }
                    else
                    {
                        Item.SubItems.Add(String.Format(strGroupFormat, cDataFiles.StandardToMetric(ChargeTest.BestGroup, cDataFiles.eDataType.GroupSize)));
                    }

                    if (ChargeTest.BestGroupRange == 0.0)
                    {
                        Item.SubItems.Add("-");
                        Item.SubItems.Add("-");
                    }
                    else
                    {
                        Item.SubItems.Add(String.Format("{0:F3}", ChargeTest.BestGroup / ((double)((double)ChargeTest.BestGroupRange / 100.0) * 1.047)));
                        Item.SubItems.Add(String.Format("{0:N0}", cDataFiles.StandardToMetric(ChargeTest.BestGroupRange, cDataFiles.eDataType.Range)));
                    }

                    if (ChargeTest.MuzzleVelocity == 0)
                    {
                        Item.SubItems.Add("-");
                    }
                    else
                    {
                        Item.SubItems.Add(String.Format("{0:N0}", cDataFiles.StandardToMetric(ChargeTest.MuzzleVelocity, cDataFiles.eDataType.Velocity)));
                    }

                    if (Batch == null || Batch.BatchTest == null || Batch.BatchTest.TestShotList == null)
                    {
                        Item.SubItems.Add("-");
                        Item.SubItems.Add("-");
                    }
                    else
                    {
                        cTestStatistics Statistics = new cTestStatistics(Batch.BatchTest.TestShotList);

                        if (Statistics.MaxDeviation == 0)
                        {
                            Item.SubItems.Add("-");
                        }
                        else
                        {
                            Item.SubItems.Add(String.Format("{0:N0}", cDataFiles.StandardToMetric(Statistics.MaxDeviation, cDataFiles.eDataType.Velocity)));
                        }

                        if (Statistics.StdDev == 0.0)
                        {
                            Item.SubItems.Add("-");
                        }
                        else
                        {
                            Item.SubItems.Add(String.Format("{0:F2}", cDataFiles.StandardToMetric(Statistics.StdDev, cDataFiles.eDataType.Velocity)));
                        }
                    }

                    //----------------------------------------------------------------------------*
                    // Add the item to the list
                    //----------------------------------------------------------------------------*

                    AddItem(Item);
                }
            }
        }
예제 #19
0
        //============================================================================*
        // cBatch() - Copy Constructor
        //============================================================================*

        public cBatch(cBatch Batch)
        {
            Copy(Batch);
        }