Exemplo n.º 1
0
        //============================================================================*
        // OnViewAmmo()
        //============================================================================*

        protected void OnViewAmmo(object sender, EventArgs args)
        {
            //----------------------------------------------------------------------------*
            // Get the selected object
            //----------------------------------------------------------------------------*

            ListViewItem Item = m_AmmoListView.SelectedItems[0];

            if (Item == null)
            {
                return;
            }

            cAmmo Ammo = (cAmmo)Item.Tag;

            if (Ammo == null)
            {
                return;
            }

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

            Cursor = Cursors.WaitCursor;

            cAmmoForm AmmoForm = new cAmmoForm(Ammo, m_DataFiles, true);

            Cursor = Cursors.Default;

            AmmoForm.ShowDialog();

            m_AmmoListView.Focus();
        }
        //============================================================================*
        // Populate()
        //============================================================================*

        public void Populate(cAmmo Ammo)
        {
            Populating = true;

            //----------------------------------------------------------------------------*
            // Create the format strings
            //----------------------------------------------------------------------------*

            m_strGroupFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.GroupSize);

            //----------------------------------------------------------------------------*
            // Reset the list view
            //----------------------------------------------------------------------------*

            Items.Clear();

            foreach (cAmmoTest AmmoTest in Ammo.TestList)
            {
                ListViewItem Item = AddAmmoTest(AmmoTest);
            }

            Focus();

            if (Items.Count > 0)
            {
                Items[0].Selected = true;

                EnsureVisible(Items[0].Index);
            }

            Populating = false;
        }
Exemplo n.º 3
0
        //============================================================================*
        // Import()
        //============================================================================*

        public void Import(cRWXMLDocument XMLDocument, XmlNode XMLThisNode, cDataFiles DataFiles, bool fCountOnly = false)
        {
            m_nImportCount = 0;
            m_nNewCount    = 0;
            m_nUpdateCount = 0;

            XmlNode XMLNode = XMLThisNode.FirstChild;

            while (XMLNode != null)
            {
                switch (XMLNode.Name)
                {
                case "Ammo":
                    cAmmo Ammo = new cAmmo();

                    if (Ammo.Import(XMLDocument, XMLNode, DataFiles))
                    {
                        AddSupply(Ammo, fCountOnly);
                    }

                    break;
                }

                XMLNode = XMLNode.NextSibling;
            }
        }
Exemplo n.º 4
0
        //============================================================================*
        // UpdateAmmoTabButtons()
        //============================================================================*

        public void UpdateAmmoTabButtons()
        {
            //----------------------------------------------------------------------------*
            // Print Buttons
            //----------------------------------------------------------------------------*

            //----------------------------------------------------------------------------*
            // Checked Only Button
            //----------------------------------------------------------------------------*

            if (m_AmmoListView.CheckedItems.Count == 0)
            {
                AmmoPrintCheckedRadioButton.Checked = false;
                AmmoPrintAllRadioButton.Checked     = true;
                AmmoPrintCheckedRadioButton.Enabled = false;

                m_DataFiles.Preferences.AmmoPrintAll     = true;
                m_DataFiles.Preferences.AmmoPrintChecked = false;
            }
            else
            {
                AmmoPrintCheckedRadioButton.Enabled = true;
            }

            //----------------------------------------------------------------------------*
            // Print Button
            //----------------------------------------------------------------------------*

            if (m_AmmoListView.Items.Count == 0)
            {
                AmmoListPrintButton.Enabled = false;

                NoAmmoListLabel.Visible = true;
            }
            else
            {
                AmmoListPrintButton.Enabled = true;

                NoAmmoListLabel.Visible = false;
            }

            //----------------------------------------------------------------------------*
            // Edit, View, Remove Buttons
            //----------------------------------------------------------------------------*

            if (m_AmmoListView.SelectedItems.Count > 0)
            {
                cAmmo Ammo = (cAmmo)m_AmmoListView.SelectedItems[0].Tag;

                EditAmmoButton.Enabled   = Ammo.Manufacturer != null && Ammo.BatchID == 0;
                ViewAmmoButton.Enabled   = true;
                RemoveAmmoButton.Enabled = Ammo.Manufacturer != null && (Ammo.BatchID == 0 || (m_DataFiles.Preferences.TrackInventory && m_DataFiles.SupplyQuantity(Ammo) == 0.0));
            }
            else
            {
                EditAmmoButton.Enabled   = false;
                ViewAmmoButton.Enabled   = false;
                RemoveAmmoButton.Enabled = false;
            }
        }
Exemplo n.º 5
0
        //============================================================================*
        // AddAmmo()
        //============================================================================*

        public ListViewItem AddAmmo(cAmmo Ammo, bool fSelect = false)
        {
            //----------------------------------------------------------------------------*
            // Verify that the firearm should be added to the list
            //----------------------------------------------------------------------------*

            if (!VerifyAmmo(Ammo))
            {
                return(null);
            }

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

            ListViewItem Item = new ListViewItem();

            SetAmmoData(Item, Ammo);

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

            AddItem(Item, fSelect);

            return(Item);
        }
Exemplo n.º 6
0
        //============================================================================*
        // AddSupply()
        //============================================================================*

        public override bool AddSupply(cSupply Supply, bool fCountOnly = false)
        {
            if (Supply.SupplyType != cSupply.eSupplyTypes.Ammo)
            {
                return(false);
            }

            m_nImportCount++;

            cAmmo Ammo = (cAmmo)Supply;

            foreach (cAmmo CheckAmmo in this)
            {
                if (CheckAmmo.CompareTo(Ammo) == 0)
                {
                    m_nUpdateCount += CheckAmmo.Append(Ammo, fCountOnly);

                    return(false);
                }
            }

            base.AddSupply(Ammo, fCountOnly);

            m_nNewCount++;

            return(true);
        }
Exemplo n.º 7
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

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

            //----------------------------------------------------------------------------*
            // Base Class
            //----------------------------------------------------------------------------*

            cSupply Supply = (cSupply)obj;

            int rc = base.CompareTo(Supply);

            //----------------------------------------------------------------------------*
            // PartNumber
            //----------------------------------------------------------------------------*

            if (rc == 0)
            {
                cAmmo Ammo = (cAmmo)Supply;

                rc = cDataFiles.ComparePartNumbers(m_strPartNumber, Ammo.m_strPartNumber);
            }

            return(rc);
        }
Exemplo n.º 8
0
        //============================================================================*
        // Synch() - AmmoTest
        //============================================================================*

        public void Synch(cAmmo CheckFactoryAmmo)
        {
            if (CheckFactoryAmmo != null && CheckFactoryAmmo.CompareTo(m_Ammo) == 0)
            {
                m_Ammo = CheckFactoryAmmo;
            }
        }
Exemplo n.º 9
0
        //============================================================================*
        // OnRemoveAmmo()
        //============================================================================*

        protected void OnRemoveAmmo(object sender, EventArgs args)
        {
            cAmmo Ammo = null;

            ListViewItem Item = m_AmmoListView.SelectedItems[0];

            if (Item != null)
            {
                Ammo = (cAmmo)Item.Tag;
            }

            if (Ammo == null)
            {
                m_AmmoListView.Focus();

                return;
            }

            //----------------------------------------------------------------------------*
            // Make sure the user is sure
            //----------------------------------------------------------------------------*

            if (MessageBox.Show(this, "Are you sure you wish to remove this ammo?", "Data Deletion Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                m_DataFiles.DeleteAmmo(Ammo);

                m_AmmoListView.Items.Remove(Item);
            }

            UpdateButtons();

            m_AmmoListView.Focus();
        }
Exemplo n.º 10
0
        //============================================================================*
        // AddAmmo()
        //============================================================================*

        private void AddAmmo(cAmmo Ammo)
        {
            //----------------------------------------------------------------------------*
            // If the Ammo already exists, our job is done, just exit
            //----------------------------------------------------------------------------*

            foreach (cAmmo CheckAmmo in m_DataFiles.AmmoList)
            {
                if (CheckAmmo.CompareTo(Ammo) == 0)
                {
                    return;
                }
            }

            //----------------------------------------------------------------------------*
            // Otherwise, add the new ammo to the list
            //----------------------------------------------------------------------------*

            m_DataFiles.AmmoList.Add(Ammo);

            //----------------------------------------------------------------------------*
            // And add the new Firearm to the Firearm ListView
            //----------------------------------------------------------------------------*

            m_AmmoListView.AddAmmo(Ammo, true);

            AddAmmoButton.Focus();
        }
Exemplo n.º 11
0
        //============================================================================*
        // cFactoryAmmoPrintForm() - Constructor
        //============================================================================*

        public cAmmoPrintForm(cAmmo FactoryAmmo, cDataFiles DataFiles)
        {
            InitializeComponent();

            m_Ammo      = FactoryAmmo;
            m_DataFiles = DataFiles;

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

            NumLabelsTextBox.TextChanged += OnNumLabelsTextChanged;

            PrintButton.Click += PrintButtonClicked;
            PaperComboBox.SelectedIndexChanged += OnPaperChanged;
            PageImageBox.MouseClick            += OnPageImageClicked;
            m_PrintDocument.PrintPage          += OnPrintPage;

            TestShotBlanksRadioButton.Click += OnTestShotBlanksClicked;
            TestDataRadioButton.Click       += OnTestDataClicked;

            //----------------------------------------------------------------------------*
            // Set defaults
            //----------------------------------------------------------------------------*

            PaperComboBox.SelectedIndex = m_DataFiles.Preferences.BatchPrintPaper;
            m_nStartLabel = m_DataFiles.Preferences.BatchPrintStartLabel;

            NumLabelsTextBox.Value = 1;

            if (m_DataFiles.Preferences.BatchPrintPaper != 1)
            {
                TestShotBlanksRadioButton.Checked = true;
            }
            else
            {
                TestShotBlanksRadioButton.Checked = false;
            }

            TestDataRadioButton.Checked = false;

            SetClientSizeCore(LabelFormatGroup.Location.X + LabelFormatGroup.Width + 10, CancelPrintButton.Location.Y + CancelPrintButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Create Page Image
            //----------------------------------------------------------------------------*

            CreatePageImage();

            m_fInitialized = true;

            UpdateButtons();

            DrawLabelImage(LabelRectangle());

            NumLabelsTextBox.Focus();
        }
Exemplo n.º 12
0
        //============================================================================*
        // cAmmoListPreviewDialog() - Constructor
        //============================================================================*

        public cAmmoListPreviewDialog(cDataFiles DataFiles, ListView AmmoListView)
        {
            m_DataFiles = DataFiles;

            if (m_DataFiles.Preferences.AmmoListPreviewMaximized)
            {
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                Location   = m_DataFiles.Preferences.AmmoListPreviewLocation;
                ClientSize = m_DataFiles.Preferences.AmmoListPreviewSize;
            }

            Text = String.Format("{0} Ammuniton List - Print Preview", Application.ProductName);

            PrintDocument AmmoListDocument = new PrintDocument();

            AmmoListDocument.PrintPage += OnPrintPage;

            Document = AmmoListDocument;

            UseAntiAlias = true;

            //----------------------------------------------------------------------------*
            // Add the unit of measure to the Bullet Weight column
            //----------------------------------------------------------------------------*

            m_AmmoColumns[4].Name += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.BulletWeight));
            m_AmmoColumns[7].Name += String.Format(" ({0})", m_DataFiles.Preferences.Currency);

            if (!m_DataFiles.Preferences.TrackInventory)
            {
                m_AmmoColumns[6].Name = "Box of";
            }

            //----------------------------------------------------------------------------*
            // Gather the list of ammo, reset flags, and exit
            //----------------------------------------------------------------------------*

            foreach (ListViewItem Item in AmmoListView.Items)
            {
                cAmmo Ammo = (cAmmo)Item.Tag;

                if (Ammo != null)
                {
                    if (!m_DataFiles.Preferences.AmmoPrintChecked || Ammo.Checked)
                    {
                        m_AmmoList.Add(Ammo);
                    }
                }
            }

            ResetPrintedFlag();

            m_fInitialized = true;
        }
Exemplo n.º 13
0
        //============================================================================*
        // SetAmmoData()
        //============================================================================*

        public void SetAmmoData(ListViewItem Item, cAmmo Ammo)
        {
            Item.SubItems.Clear();

            Item.Text = Ammo.Manufacturer != null?Ammo.Manufacturer.ToString() : "Reloads";

            Item.Group   = Groups[(int)Ammo.FirearmType];
            Item.Tag     = Ammo;
            Item.Checked = Ammo.Checked;

            Item.SubItems.Add(Ammo.PartNumber);
            Item.SubItems.Add(Ammo.Type);
            Item.SubItems.Add(Ammo.Reload ? "Y" : "");

            if (Ammo.FirearmType != cFirearm.eFireArmType.Shotgun)
            {
                Item.SubItems.Add(Ammo.TestList.Count > 0 ? "Y" : "");
            }

            cCaliber.CurrentFirearmType = Ammo.Caliber.FirearmType;
            Item.SubItems.Add(Ammo.Caliber.ToString());

            Item.SubItems.Add(String.Format(m_strBulletWeightFormat, cDataFiles.StandardToMetric(Ammo.BulletWeight, m_eFirearmType != cFirearm.eFireArmType.Shotgun ? cDataFiles.eDataType.BulletWeight : cDataFiles.eDataType.ShotWeight)));
            Item.SubItems.Add(String.Format(m_strDimensionFormat, cDataFiles.StandardToMetric(Ammo.BulletDiameter, cDataFiles.eDataType.Dimension)));
            Item.SubItems.Add(Ammo.BallisticCoefficient > 0.0 ? String.Format("{0:F3}", Ammo.BallisticCoefficient) : "-");

            if (Ammo.FirearmType != cFirearm.eFireArmType.Shotgun)
            {
                Item.SubItems.Add(String.Format("{0:F3}", cBullet.CalculateSectionalDensity(Ammo.BulletDiameter, Ammo.BulletWeight)));
            }

            Item.SubItems.Add(Ammo.MinimumStockLevel != 0 ? String.Format("{0:N0}", Ammo.MinimumStockLevel) : "-");

            double dCost = 0.0;

            if (m_DataFiles.Preferences.TrackInventory)
            {
                Item.SubItems.Add(Ammo.QuantityOnHand != 0.0 ? String.Format("{0:N0}", Ammo.QuantityOnHand) : "-");

                dCost = Ammo.QuantityOnHand * m_DataFiles.SupplyCostEach(Ammo);
            }
            else
            {
                Item.SubItems.Add(Ammo.Quantity != 0.0 ? String.Format("{0:N0}", Ammo.Quantity) : "-");

                dCost = Ammo.Cost;
            }

            Item.SubItems.Add(dCost != 0.0 ? String.Format("{0:F2}", dCost) : "-");
        }
Exemplo n.º 14
0
        //============================================================================*
        // Synch() - Ammo
        //============================================================================*

        public bool Synch(cAmmo Ammo)
        {
            if (m_Supply.SupplyType != cSupply.eSupplyTypes.Ammo)
            {
                return(false);
            }

            if ((m_Supply as cAmmo).CompareTo(Ammo) == 0)
            {
                m_Supply = Ammo;

                return(true);
            }

            return(false);
        }
Exemplo n.º 15
0
        //============================================================================*
        // OnAmmoItemChecked()
        //============================================================================*

        protected void OnAmmoItemChecked(object sender, ItemCheckedEventArgs args)
        {
            if (!m_fInitialized || m_fPopulating)
            {
                return;
            }

            cAmmo Ammo = (cAmmo)args.Item.Tag;

            if (Ammo != null)
            {
                Ammo.Checked = args.Item.Checked;
            }

            UpdateAmmoTabButtons();
        }
Exemplo n.º 16
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public void Copy(cAmmoTest AmmoTest)
        {
            m_Ammo    = AmmoTest.m_Ammo;
            m_Firearm = AmmoTest.m_Firearm;

            m_TestDate        = AmmoTest.m_TestDate;
            m_dBarrelLength   = AmmoTest.m_dBarrelLength;
            m_dTwist          = AmmoTest.m_dTwist;
            m_nNumRounds      = AmmoTest.m_nNumRounds;
            m_nMuzzleVelocity = AmmoTest.m_nMuzzleVelocity;
            m_dBestGroup      = AmmoTest.m_dBestGroup;
            m_dBestGroupRange = AmmoTest.m_dBestGroupRange;
            m_strNotes        = AmmoTest.m_strNotes;

            m_TestShotList = new cTestShotList(AmmoTest.TestShotList);
        }
Exemplo n.º 17
0
        //============================================================================*
        // OnEditAmmo()
        //============================================================================*

        protected void OnEditAmmo(object sender, EventArgs args)
        {
            //----------------------------------------------------------------------------*
            // Get the selected Firearm
            //----------------------------------------------------------------------------*

            ListViewItem Item = m_AmmoListView.SelectedItems[0];

            if (Item == null)
            {
                return;
            }

            cAmmo Ammo = (cAmmo)Item.Tag;

            if (Ammo == null)
            {
                return;
            }

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

            Cursor = Cursors.WaitCursor;

            cAmmoForm AmmoForm = new cAmmoForm(Ammo, m_DataFiles);

            Cursor = Cursors.Default;

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

                cAmmo NewAmmo = AmmoForm.Ammo;
                m_DataFiles.Preferences.LastAmmo = AmmoForm.Ammo;

                UpdateAmmo(Ammo, NewAmmo);

                UpdateAmmoTabButtons();
            }

            m_AmmoListView.Focus();
        }
Exemplo n.º 18
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public void Copy(cAmmo Ammo, bool fCopyBase = true)
        {
            if (fCopyBase)
            {
                base.Copy(Ammo);
            }

            m_strPartNumber = Ammo.m_strPartNumber;
            m_strType       = Ammo.m_strType;
            m_nBatchID      = Ammo.m_nBatchID;
            m_fReload       = Ammo.m_fReload;

            m_Caliber = Ammo.m_Caliber;

            m_dBallisticCoefficient = Ammo.m_dBallisticCoefficient;
            m_dBulletDiameter       = Ammo.m_dBulletDiameter;
            m_dBulletWeight         = Ammo.m_dBulletWeight;

            m_TestList = new cAmmoTestList(Ammo.m_TestList);
        }
Exemplo n.º 19
0
        //============================================================================*
        // UpdateAmmo()
        //============================================================================*

        public ListViewItem UpdateAmmo(cAmmo Ammo, cAmmo NewAmmo, bool fSelect = false)
        {
            //----------------------------------------------------------------------------*
            // Find the Item
            //----------------------------------------------------------------------------*

            ListViewItem Item = null;

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

                    break;
                }
            }

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

            if (Item == null)
            {
                return(AddAmmo(Ammo, fSelect));
            }

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

            SetAmmoData(Item, NewAmmo);

            Item.Selected = fSelect;

            Focus();

            return(Item);
        }
Exemplo n.º 20
0
        //============================================================================*
        // UpdateAmmo()
        //============================================================================*

        private void UpdateAmmo(cAmmo OldAmmo, cAmmo NewAmmo)
        {
            //----------------------------------------------------------------------------*
            // Find the NewFirearm
            //----------------------------------------------------------------------------*

            foreach (cAmmo CheckAmmo in m_DataFiles.AmmoList)
            {
                //----------------------------------------------------------------------------*
                // See if this is the same Ammo
                //----------------------------------------------------------------------------*

                if (CheckAmmo.CompareTo(OldAmmo) == 0)
                {
                    //----------------------------------------------------------------------------*
                    // Update the current Firearm record
                    //----------------------------------------------------------------------------*

                    CheckAmmo.Copy(NewAmmo);

                    CheckAmmo.RecalculateInventory(m_DataFiles);

                    //----------------------------------------------------------------------------*
                    // Update the Firearm on the Firearm tab
                    //----------------------------------------------------------------------------*

                    m_AmmoListView.UpdateAmmo(OldAmmo, CheckAmmo, true);

                    return;
                }
            }

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

            AddAmmo(NewAmmo);
        }
Exemplo n.º 21
0
        //============================================================================*
        // OnAddAmmo()
        //============================================================================*

        protected void OnAddAmmo(object sender, EventArgs args)
        {
            //----------------------------------------------------------------------------*
            // Start the dialog
            //----------------------------------------------------------------------------*

            Cursor = Cursors.WaitCursor;

            cAmmoForm AmmoForm = new cAmmoForm(null, m_DataFiles);

            Cursor = Cursors.Default;

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

                cAmmo NewAmmo = AmmoForm.Ammo;
                m_DataFiles.Preferences.LastAmmo = AmmoForm.Ammo;

                m_AmmoListView.Focus();

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

                foreach (cAmmo CheckAmmo in m_DataFiles.AmmoList)
                {
                    if (CheckAmmo.CompareTo(NewAmmo) == 0)
                    {
                        return;
                    }
                }

                AddAmmo(NewAmmo);
            }
        }
Exemplo n.º 22
0
        //============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cAmmo Ammo1, cAmmo Ammo2)
        {
            if (Ammo1 == null)
            {
                if (Ammo2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Ammo2 == null)
                {
                    return(1);
                }
            }

            return(Ammo1.CompareTo(Ammo2));
        }
Exemplo n.º 23
0
        //============================================================================*
        // ResolveIdentities()
        //============================================================================*

        public bool ResolveIdentities(cDataFiles Datafiles)
        {
            bool fChanged = false;

            if (m_Ammo != null && m_Ammo.Identity)
            {
                foreach (cAmmo Ammo in Datafiles.AmmoList)
                {
                    if (m_Ammo.CompareTo(Ammo) == 0)
                    {
                        m_Ammo = Ammo;

                        fChanged = true;

                        break;
                    }
                }
            }

            if (m_Firearm != null && m_Firearm.Identity)
            {
                foreach (cFirearm Firearm in Datafiles.FirearmList)
                {
                    if (m_Firearm.CompareTo(Firearm) == 0)
                    {
                        m_Firearm = Firearm;

                        fChanged = true;

                        break;
                    }
                }
            }

            return(fChanged);
        }
Exemplo n.º 24
0
        //============================================================================*
        // Append()
        //============================================================================*

        public int Append(cAmmo Ammo, bool fCountOnly = false)
        {
            int nUpdateCount = 0;

            if (m_dBallisticCoefficient == 0.0 && Ammo.m_dBallisticCoefficient != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dBallisticCoefficient = Ammo.m_dBallisticCoefficient;
                }

                nUpdateCount++;
            }

            if (m_dBulletDiameter == 0.0 && Ammo.m_dBulletDiameter != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dBulletDiameter = Ammo.m_dBulletDiameter;
                }

                nUpdateCount++;
            }

            if (m_dBulletWeight == 0.0 && Ammo.m_dBulletWeight != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dBulletWeight = Ammo.m_dBulletWeight;
                }

                nUpdateCount++;
            }

            return(nUpdateCount);
        }
Exemplo n.º 25
0
        //============================================================================*
        // cAmmoTestListView() - Constructor
        //============================================================================*

        public cAmmoTestListView(cDataFiles DataFiles, cAmmo Ammo)
            : base(DataFiles, cPreferences.eApplicationListView.AmmoTestListView)
        {
            m_DataFiles = DataFiles;
            m_Ammo      = Ammo;

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

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

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

            SortingOrder = m_DataFiles.Preferences.AmmoTestSortOrder;

            SortingColumn = m_DataFiles.Preferences.AmmoTestSortColumn;

            m_arColumns[2].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Velocity));
            m_arColumns[3].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.GroupSize));
            m_arColumns[5].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Range));

            PopulateColumns(m_arColumns);

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

            Populate(m_Ammo);

            Initialized = true;
        }
Exemplo n.º 26
0
        //============================================================================*
        // cAmmo() - Copy Constructor
        //============================================================================*

        public cAmmo(cAmmo Ammo)
            : base(Ammo)
        {
            Copy(Ammo);
        }
        //============================================================================*
        // 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);
                }
            }

            cAmmo FactoryAmmo1 = (cAmmo)(Object1 as ListViewItem).Tag;
            cAmmo FactoryAmmo2 = (cAmmo)(Object2 as ListViewItem).Tag;

            if (FactoryAmmo1 == null)
            {
                if (FactoryAmmo2 == null)
                {
                    return(0);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (FactoryAmmo2 == null)
                {
                    return(1);
                }
            }

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

            bool   fSpecial = false;
            int    rc       = 0;
            string strPart1 = "";
            string strPart2 = "";

            switch (SortColumn)
            {
            //----------------------------------------------------------------------------*
            // Manufacturer
            //----------------------------------------------------------------------------*

            case 0:
                if (FactoryAmmo1.Manufacturer == null)
                {
                    if (FactoryAmmo2.Manufacturer == null)
                    {
                        rc = 0;
                    }
                    else
                    {
                        rc = "Reload".CompareTo(FactoryAmmo2.Manufacturer.Name);
                    }
                }
                else
                {
                    if (FactoryAmmo2.Manufacturer == null)
                    {
                        rc = FactoryAmmo1.Manufacturer.Name.CompareTo("Reload");
                    }
                    else
                    {
                        rc = FactoryAmmo1.Manufacturer.CompareTo(FactoryAmmo2.Manufacturer);
                    }
                }

                if (rc == 0)
                {
                    strPart1 = FactoryAmmo1.PartNumber;
                    strPart2 = FactoryAmmo2.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;

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

            case 1:
                strPart1 = FactoryAmmo1.PartNumber;
                strPart2 = FactoryAmmo2.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;

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

            case 6:
                rc = FactoryAmmo1.BulletWeight.CompareTo(FactoryAmmo2.BulletWeight);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Ballistic Coefficient
            //----------------------------------------------------------------------------*

            case 8:
                rc = FactoryAmmo1.BallisticCoefficient.CompareTo(FactoryAmmo2.BallisticCoefficient);

                fSpecial = true;

                break;
            }

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

                return(rc);
            }

            return(base.Compare(Object1, Object2));
        }
Exemplo n.º 28
0
        //============================================================================*
        // Import()
        //============================================================================*

        public void Import(cRWXMLDocument XMLDocument, XmlNode XMLThisNode, cDataFiles DataFiles, cAmmo Ammo, bool fCountOnly = false)
        {
            m_nNewCount    = 0;
            m_nUpdateCount = 0;

            XmlNode XMLNode = XMLThisNode.FirstChild;

            while (XMLNode != null)
            {
                switch (XMLNode.Name)
                {
                case "AmmoTest":
                    cAmmoTest AmmoTest = new cAmmoTest();
                    AmmoTest.Ammo = Ammo;

                    if (AmmoTest.Import(XMLDocument, XMLNode, DataFiles))
                    {
                        AddAmmoTest(AmmoTest);
                    }

                    break;
                }

                XMLNode = XMLNode.NextSibling;
            }
        }
Exemplo n.º 29
0
        //============================================================================*
        // cAmmoTestForm() - Constructor
        //============================================================================*

        public cAmmoTestForm(cAmmo Ammo, cAmmoTest AmmoTest, cDataFiles DataFiles, bool fViewOnly = false)
        {
            InitializeComponent();

            m_DataFiles = DataFiles;
            m_fViewOnly = fViewOnly;

            string strTitle = "";

            if (AmmoTest == null)
            {
                m_AmmoTest          = new cAmmoTest();
                m_AmmoTest.Ammo     = Ammo;
                m_AmmoTest.TestDate = DateTime.Today;

                if (Ammo.TestList.Count == 0)
                {
                    m_AmmoTest.Firearm = null;
                }
                else
                {
                    foreach (cFirearm Firearm in m_DataFiles.FirearmList)
                    {
                        if (Firearm.HasCaliber(Ammo.Caliber))
                        {
                            m_AmmoTest.Firearm = Firearm;

                            break;
                        }
                    }
                }

                strTitle = "Add";

                OKButton.Text = "Add";
            }
            else
            {
                m_AmmoTest = new cAmmoTest(AmmoTest);

                if (m_AmmoTest.Ammo == null)
                {
                    m_AmmoTest.Ammo = Ammo;
                }

                if (Ammo != null && Ammo.TestList.Count == 0)
                {
                    m_AmmoTest.Firearm = null;
                }

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

                    OKButton.Text = "Update";
                }
                else
                {
                    AmmoTestCancelButton.Text = "Close";
                    OKButton.Visible          = false;

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

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

                    strTitle = "View";
                }
            }

            SetClientSizeCore(AmmoDataGroupBox.Location.X + AmmoDataGroupBox.Width + 10, AmmoTestCancelButton.Location.Y + AmmoTestCancelButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Dialog Title
            //----------------------------------------------------------------------------*

            strTitle += " Ammo Test";

            Text = strTitle;

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

            if (!m_fViewOnly)
            {
                TestDatePicker.TextChanged += OnDateChanged;

                BarrelLengthTextBox.TextChanged   += OnTextChanged;
                TwistTextBox.TextChanged          += OnTextChanged;
                NumShotsTextBox.TextChanged       += OnTextChanged;
                MuzzleVelocityTextBox.TextChanged += OnTextChanged;
                BestGroupTextBox.TextChanged      += OnTextChanged;
                BestGroupRangeTextBox.TextChanged += OnTextChanged;

                NumShotsTextBox.TextChanged += OnNumShotsTextChanged;

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

                NotesTextBox.ReadOnly = true;
            }

            EditShotsButton.Click += OnEditShotsClicked;

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

            SetStaticToolTips();

            SetInputParameters();

            ManufacturerLabel.Text         = m_AmmoTest.Ammo.Manufacturer.ToString();
            CaliberLabel.Text              = m_AmmoTest.Ammo.Caliber.ToString();
            PartNumberLabel.Text           = m_AmmoTest.Ammo.PartNumber;
            TypeLabel.Text                 = m_AmmoTest.Ammo.Type;
            BulletWeightLabel.Text         = String.Format("{0:G0} {1}", cDataFiles.StandardToMetric(m_AmmoTest.Ammo.BulletWeight, cDataFiles.eDataType.BulletWeight), cDataFiles.MetricString(cDataFiles.eDataType.BulletWeight));
            BulletDiameterLabel.Text       = String.Format("{0:F3} {1}", cDataFiles.StandardToMetric(m_AmmoTest.Ammo.BulletDiameter, cDataFiles.eDataType.Dimension), cDataFiles.MetricString(cDataFiles.eDataType.Dimension));
            BallisticCoefficientLabel.Text = String.Format("{0:F3}", m_AmmoTest.Ammo.BallisticCoefficient);

            switch (m_AmmoTest.Ammo.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;
            }

            //----------------------------------------------------------------------------*
            // Populate Firearm Combo
            //----------------------------------------------------------------------------*

            if (!m_AmmoTest.Ammo.Reload && (m_AmmoTest.Firearm == null || m_AmmoTest.Ammo.TestList.Count == 0))
            {
                FirearmCombo.Items.Add("Factory");
                FirearmCombo.SelectedIndex = 0;
                FirearmCombo.Enabled       = false;
            }
            else
            {
                foreach (cFirearm Firearm in m_DataFiles.FirearmList)
                {
                    if (Firearm.FirearmType == m_AmmoTest.Ammo.FirearmType &&
                        Firearm.HasCaliber(m_AmmoTest.Ammo.Caliber))
                    {
                        FirearmCombo.Items.Add(Firearm);
                    }
                }

                FirearmCombo.SelectedItem = m_AmmoTest.Firearm;

                if (FirearmCombo.SelectedIndex < 0 && FirearmCombo.Items.Count > 0)
                {
                    FirearmCombo.SelectedIndex = 0;
                }

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

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

            TestDatePicker.Value = m_AmmoTest.TestDate;

            if (m_AmmoTest.Firearm != null)
            {
                BarrelLengthTextBox.Value = cDataFiles.StandardToMetric(m_AmmoTest.Firearm.BarrelLength, cDataFiles.eDataType.Firearm);
                TwistTextBox.Value        = cDataFiles.StandardToMetric(m_AmmoTest.Firearm.Twist, cDataFiles.eDataType.Firearm);

                BarrelLengthTextBox.Enabled = false;
                TwistTextBox.Enabled        = false;
            }
            else
            {
                BarrelLengthTextBox.Value = cDataFiles.StandardToMetric(m_AmmoTest.BarrelLength, cDataFiles.eDataType.Firearm);
                TwistTextBox.Value        = cDataFiles.StandardToMetric(m_AmmoTest.Twist, cDataFiles.eDataType.Firearm);

                BarrelLengthTextBox.Enabled = true;
                TwistTextBox.Enabled        = true;
            }

            PopulateShotList();

            NumShotsTextBox.Value       = m_AmmoTest.NumRounds;
            BestGroupTextBox.Value      = cDataFiles.StandardToMetric(m_AmmoTest.BestGroup, cDataFiles.eDataType.GroupSize);
            BestGroupRangeTextBox.Value = (int)cDataFiles.StandardToMetric(m_AmmoTest.BestGroupRange, cDataFiles.eDataType.Range);
            MuzzleVelocityTextBox.Value = (int)cDataFiles.StandardToMetric(m_AmmoTest.MuzzleVelocity, cDataFiles.eDataType.Velocity);

            if (m_AmmoTest.Firearm == null)
            {
                NumShotsTextBox.Enabled       = false;
                BestGroupTextBox.Enabled      = false;
                BestGroupRangeTextBox.Enabled = false;
                MuzzleVelocityTextBox.Enabled = true;
            }
            else
            {
                MuzzleVelocityTextBox.Enabled = true;
                NumShotsTextBox.Enabled       = true;
                BestGroupTextBox.Enabled      = true;
                BestGroupRangeTextBox.Enabled = true;
                MuzzleVelocityTextBox.Enabled = true;
            }

            NotesTextBox.Text = m_AmmoTest.Notes;

            PopulateShotList();

            m_fInitialized = true;

            UpdateButtons();
        }
Exemplo n.º 30
0
        //============================================================================*
        // VerifyAmmo()
        //============================================================================*

        public bool VerifyAmmo(cAmmo Ammo)
        {
            //----------------------------------------------------------------------------*
            // Make sure we're tracking reloads if this is a reload
            //----------------------------------------------------------------------------*


            //----------------------------------------------------------------------------*
            // Check the internal filters
            //----------------------------------------------------------------------------*

            if (m_eFirearmType != cFirearm.eFireArmType.None && Ammo.FirearmType != m_eFirearmType)
            {
                return(false);
            }

            if (m_Caliber != null && m_Caliber.CompareTo(Ammo.Caliber) != 0)
            {
                return(false);
            }

            if (m_Manufacturer != null && m_Manufacturer.CompareTo(Ammo.Manufacturer) != 0)
            {
                return(false);
            }

            //----------------------------------------------------------------------------*
            // Check the external filters
            //----------------------------------------------------------------------------*

            if (Ammo.Reload)
            {
                if (Ammo.BatchID != 0)
                {
                    if (!m_DataFiles.Preferences.AmmoMyReloadFilter)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!m_DataFiles.Preferences.AmmoFactoryReloadFilter)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (!m_DataFiles.Preferences.AmmoFactoryFilter)
                {
                    return(false);
                }
            }

            //----------------------------------------------------------------------------*
            // Check the inventory control filters
            //----------------------------------------------------------------------------*

            if (m_DataFiles.Preferences.TrackInventory)
            {
                if (!m_DataFiles.Preferences.TrackReloads && Ammo.Reload && Ammo.BatchID != 0)
                {
                    return(false);
                }

                if (Ammo.QuantityOnHand <= 0.0 && m_DataFiles.Preferences.AmmoNonZeroFilter)
                {
                    return(false);
                }

                if (Ammo.QuantityOnHand >= Ammo.MinimumStockLevel && m_DataFiles.Preferences.AmmoMinStockFilter)
                {
                    return(false);
                }
            }

            return(true);
        }