//============================================================================*
        // CaliberList() - Copy Constructor
        //============================================================================*

        public cCaliberList(cCaliberList CaliberList)
        {
            Clear();

            foreach (cCaliber Caliber in CaliberList)
            {
                Add(Caliber);
            }
        }
Exemple #2
0
        //============================================================================*
        // CreateShareFile()
        //============================================================================*

        private void CreateShareFile()
        {
            //----------------------------------------------------------------------------*
            // Gather all the needed info to store the loads to be shared
            //----------------------------------------------------------------------------*

            cManufacturerList ShareManufacturerList = new cManufacturerList();
            cCaliberList      ShareCaliberList      = new cCaliberList();
            cBulletList       ShareBulletList       = new cBulletList();
            cCaseList         ShareCaseList         = new cCaseList();
            cPowderList       SharePowderList       = new cPowderList();
            cPrimerList       SharePrimerList       = new cPrimerList();

            cLoadList ShareLoadList = new cLoadList();

            foreach (ListViewItem Item in m_LoadDataListView.CheckedItems)
            {
                cLoad Load = (cLoad)Item.Tag;

                if (Load != null && Load.Bullet != null && Load.Case != null && Load.Powder != null && Load.Primer != null)
                {
                    foreach (cBulletCaliber BulletCaliber in Load.Bullet.BulletCaliberList)
                    {
                        ShareCaliberList.AddCaliber(BulletCaliber.Caliber);
                    }

                    ShareManufacturerList.AddManufacturer(Load.Bullet.Manufacturer);
                    ShareBulletList.AddBullet(Load.Bullet);

                    ShareManufacturerList.AddManufacturer(Load.Case.Manufacturer);
                    ShareCaseList.AddCase(Load.Case);

                    ShareManufacturerList.AddManufacturer(Load.Powder.Manufacturer);
                    SharePowderList.AddPowder(Load.Powder);

                    ShareManufacturerList.AddManufacturer(Load.Primer.Manufacturer);
                    SharePrimerList.AddPrimer(Load.Primer);

                    ShareLoadList.Add(Load);
                }
            }

            //----------------------------------------------------------------------------*
            // Now create a cRWXMLDocument and export the load data to it
            //----------------------------------------------------------------------------*

            cRWXMLDocument XMLDocument = new cRWXMLDocument(m_DataFiles);

            XmlElement MainElement = XMLDocument.CreateElement("Body");

            XMLDocument.AppendChild(MainElement);

            XmlText XMLTextElement = XMLDocument.CreateTextNode(String.Format("{0} Load Data Share File Export", Application.ProductName));

            MainElement.AppendChild(XMLTextElement);

            ShareManufacturerList.Export(XMLDocument, MainElement);
            ShareBulletList.Export(XMLDocument, MainElement, false);
            ShareCaliberList.Export(XMLDocument, MainElement);
            ShareCaseList.Export(XMLDocument, MainElement, false);
            SharePowderList.Export(XMLDocument, MainElement, false);
            SharePrimerList.Export(XMLDocument, MainElement, false);

            ShareLoadList.Export(XMLDocument, MainElement);

            //----------------------------------------------------------------------------*
            // Save the Exported XML Share File
            //----------------------------------------------------------------------------*

            SaveFileDialog SaveDialog = new SaveFileDialog();

            SaveDialog.AddExtension     = true;
            SaveDialog.CheckPathExists  = true;
            SaveDialog.DefaultExt       = "xml";
            SaveDialog.FileName         = String.Format("{0} Load Data Share File - {1}{2}{3}", Application.ProductName, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            SaveDialog.Filter           = "XML Files {*.xml)|*.xml";
            SaveDialog.InitialDirectory = Path.Combine(m_DataFiles.GetDataPath(), "Share");
            SaveDialog.OverwritePrompt  = true;
            SaveDialog.Title            = String.Format("Export Load Data");
            SaveDialog.ValidateNames    = true;

            if (SaveDialog.ShowDialog() == DialogResult.OK)
            {
                XMLDocument.Save(SaveDialog.OpenFile());
            }
        }
Exemple #3
0
        //============================================================================*
        // SetMinMax()
        //============================================================================*

        private void SetMinMax()
        {
            //----------------------------------------------------------------------------*
            // Get Load
            //----------------------------------------------------------------------------*

            cLoad Load = null;

            if (LoadCombo.SelectedIndex > 0)
            {
                Load = (cLoad)LoadCombo.SelectedItem;
            }

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

            cBullet Bullet = null;

            if (BulletCombo.SelectedIndex > 0 || BulletCombo.SelectedItem is cBullet)
            {
                Bullet = (cBullet)BulletCombo.SelectedItem;
            }

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

            cFirearm Firearm = null;

            if (FirearmCombo.SelectedIndex > 0)
            {
                Firearm = (cFirearm)FirearmCombo.SelectedItem;
            }

            //----------------------------------------------------------------------------*
            // Get caliber list depending on the firearm or bullet selected
            //----------------------------------------------------------------------------*

            cCaliberList CaliberList = m_DataFiles.CaliberList;

            if (Bullet != null)
            {
                CaliberList = new cCaliberList();

                foreach (cBulletCaliber BulletCaliber in Bullet.BulletCaliberList)
                {
                    CaliberList.Add(BulletCaliber.Caliber);
                }
            }
            else
            {
                if (Firearm != null)
                {
                    CaliberList = new cCaliberList();

                    foreach (cFirearmCaliber FirearmCaliber in Firearm.CaliberList)
                    {
                        CaliberList.Add(FirearmCaliber.Caliber);
                    }
                }
            }

            //----------------------------------------------------------------------------*
            // Set Caliber Min/Max
            //----------------------------------------------------------------------------*

            double dMinDiameter = 1000.0;
            double dMaxDiameter = 0.0;

            double dMinWeight = cBullet.MaxBulletWeight;
            double dMaxWeight = 0.0;

            foreach (cCaliber Caliber in CaliberList)
            {
                if ((Load == null || Load.Caliber.CompareTo(Caliber) == 0) &&
                    (Firearm == null || Firearm.HasCaliber(Caliber)) &&
                    (Bullet == null || Bullet.HasCaliber(Caliber)))
                {
                    if (Caliber.MinBulletDiameter < dMinDiameter)
                    {
                        dMinDiameter = Caliber.MinBulletDiameter;
                    }

                    if (Caliber.MaxBulletDiameter > dMaxDiameter)
                    {
                        dMaxDiameter = Caliber.MaxBulletDiameter;
                    }

                    if (Caliber.MinBulletWeight < dMinWeight)
                    {
                        dMinWeight = Caliber.MinBulletWeight;
                    }

                    if (Caliber.MaxBulletWeight > dMaxWeight)
                    {
                        dMaxWeight = Caliber.MaxBulletWeight;
                    }
                }
            }

            CaliberTextBox.MinValue = cDataFiles.StandardToMetric(dMinDiameter, cDataFiles.eDataType.Dimension);
            CaliberTextBox.MaxValue = cDataFiles.StandardToMetric(dMaxDiameter, cDataFiles.eDataType.Dimension);

            if (!CaliberTextBox.ValueOK)
            {
                CaliberTextBox.Value = CaliberTextBox.MinValue;

                m_StabilityData.BulletDiameter = cDataFiles.MetricToStandard(CaliberTextBox.MinValue, cDataFiles.eDataType.Dimension);
            }

            if (CaliberTextBox.MinValue == CaliberTextBox.MaxValue)
            {
                CaliberTextBox.Enabled = false;

                m_StabilityData.BulletDiameter = cDataFiles.MetricToStandard(CaliberTextBox.MinValue, cDataFiles.eDataType.Dimension);
            }
            else
            {
                CaliberTextBox.Enabled = true;
            }

            //----------------------------------------------------------------------------*
            // Set Weight Min/Max
            //----------------------------------------------------------------------------*

            if (Bullet != null)
            {
                WeightTextBox.MinValue = cDataFiles.StandardToMetric(Bullet.Weight, cDataFiles.eDataType.BulletWeight);
                WeightTextBox.MaxValue = cDataFiles.StandardToMetric(Bullet.Weight, cDataFiles.eDataType.BulletWeight);

                WeightTextBox.Enabled = false;
            }
            else
            {
                WeightTextBox.MinValue = cDataFiles.StandardToMetric(dMinWeight, cDataFiles.eDataType.BulletWeight);
                WeightTextBox.MaxValue = cDataFiles.StandardToMetric(dMaxWeight, cDataFiles.eDataType.BulletWeight);

                WeightTextBox.Enabled = true;
            }

            if (!WeightTextBox.ValueOK)
            {
                WeightTextBox.Value = WeightTextBox.MinValue;

                m_StabilityData.BulletWeight = cDataFiles.MetricToStandard(WeightTextBox.Value, cDataFiles.eDataType.BulletWeight);
            }

            //----------------------------------------------------------------------------*
            // Set Length Min/Max
            //----------------------------------------------------------------------------*

            LengthTextBox.MinValue = cDataFiles.StandardToMetric(0.050, cDataFiles.eDataType.Dimension);
            LengthTextBox.MaxValue = cDataFiles.StandardToMetric(3.0, cDataFiles.eDataType.Dimension);

            LengthTextBox.Enabled = Bullet == null || Bullet.Length == 0.0;

            //----------------------------------------------------------------------------*
            // Set Ballistic Coefficient Min/Max
            //----------------------------------------------------------------------------*

            BallisticCoefficientTextBox.Enabled = (Bullet != null) ? false : true;

            //----------------------------------------------------------------------------*
            // Set Muzzle Velocity Min/Max
            //----------------------------------------------------------------------------*

            if (Load != null)
            {
                int nMinValue = 5000;
                int nMaxValue = 500;

                bool fTestFound = false;

                foreach (cCharge Charge in Load.ChargeList)
                {
                    foreach (cChargeTest ChargeTest in Charge.TestList)
                    {
                        fTestFound = true;

                        if (ChargeTest.MuzzleVelocity < nMinValue)
                        {
                            nMinValue = ChargeTest.MuzzleVelocity;
                        }

                        if (ChargeTest.MuzzleVelocity > nMaxValue)
                        {
                            nMaxValue = ChargeTest.MuzzleVelocity;
                        }
                    }
                }

                if (fTestFound)
                {
                    VelocityTextBox.MinValue = (int)cDataFiles.StandardToMetric(nMinValue, cDataFiles.eDataType.Velocity);
                    VelocityTextBox.MaxValue = (int)cDataFiles.StandardToMetric(nMaxValue, cDataFiles.eDataType.Velocity);
                }
                else
                {
                    VelocityTextBox.MinValue = cm_nMinVelocity;
                    VelocityTextBox.MaxValue = (int)cDataFiles.StandardToMetric(5000, cDataFiles.eDataType.Velocity);
                }
            }
            else
            {
                VelocityTextBox.MinValue = (int)cDataFiles.StandardToMetric(cm_nMinVelocity, cDataFiles.eDataType.Velocity);
                VelocityTextBox.MaxValue = (int)cDataFiles.StandardToMetric(5000, cDataFiles.eDataType.Velocity);
            }

            if (!VelocityTextBox.ValueOK)
            {
                VelocityTextBox.Value = VelocityTextBox.MinValue;

                m_StabilityData.MuzzleVelocity = (int)cDataFiles.MetricToStandard(VelocityTextBox.Value, cDataFiles.eDataType.Velocity);
            }

            //----------------------------------------------------------------------------*
            // Set Twist Min/Max
            //----------------------------------------------------------------------------*

            if (Firearm != null)
            {
                TwistTextBox.Enabled = false;
            }
            else
            {
                TwistTextBox.MinValue = cDataFiles.StandardToMetric(5, cDataFiles.eDataType.Firearm);
                TwistTextBox.MaxValue = cDataFiles.StandardToMetric(78, cDataFiles.eDataType.Firearm);

                TwistTextBox.Enabled = true;
            }
        }