예제 #1
0
        //============================================================================*
        // AddLoad()
        //============================================================================*

        public bool AddLoad(cLoad Load)
        {
            foreach (cLoad CheckLoad in this)
            {
                if (CheckLoad.CompareTo(Load) == 0)
                {
                    return(false);
                }
            }

            Add(Load);

            return(true);
        }
예제 #2
0
        //============================================================================*
        // UpdateLoad()
        //============================================================================*

        private void UpdateLoad(cLoad OldLoad, cLoad NewLoad)
        {
            //----------------------------------------------------------------------------*
            // Find the NewLoad
            //----------------------------------------------------------------------------*

            foreach (cLoad CheckLoad in m_DataFiles.LoadList)
            {
                //----------------------------------------------------------------------------*
                // See if this is the same Load
                //----------------------------------------------------------------------------*

                if (CheckLoad.CompareTo(OldLoad) == 0)
                {
                    //----------------------------------------------------------------------------*
                    // Update the current NewLoad record
                    //----------------------------------------------------------------------------*

                    CheckLoad.FirearmType = NewLoad.FirearmType;
                    CheckLoad.Caliber     = NewLoad.Caliber;
                    CheckLoad.Bullet      = NewLoad.Bullet;
                    CheckLoad.Powder      = NewLoad.Powder;
                    CheckLoad.Case        = NewLoad.Case;
                    CheckLoad.Primer      = NewLoad.Primer;
                    CheckLoad.ChargeList  = new cChargeList(NewLoad.ChargeList);

                    //----------------------------------------------------------------------------*
                    // Update the New Load on the LoadData tab
                    //----------------------------------------------------------------------------*

                    m_LoadDataListView.UpdateLoad(CheckLoad, LoadDataFirearmTypeCombo.Value, LoadDataCaliberCombo.SelectedIndex > 0 ? (cCaliber)LoadDataCaliberCombo.SelectedItem : null, LoadDataBulletCombo.SelectedIndex > 0 ? (cBullet)LoadDataBulletCombo.SelectedItem : null, LoadDataPowderCombo.SelectedIndex > 0 ? (cPowder)LoadDataPowderCombo.SelectedItem : null, true);

                    //----------------------------------------------------------------------------*
                    // Update the tab data
                    //----------------------------------------------------------------------------*

                    PopulateBatchListView();

                    return;
                }
            }

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

            AddLoad(NewLoad);
        }
예제 #3
0
        //============================================================================*
        // Populate()
        //============================================================================*

        public void Populate(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder)
        {
            Populating = true;

            Items.Clear();

            ListViewItem SelectItem = null;

            foreach (cLoad CheckLoad in m_DataFiles.LoadList)
            {
                if (CheckLoad.CompareTo(Load) == 0)
                {
                    ListViewItem Item = AddLoad(CheckLoad, eFirearmType, Caliber, Bullet, Powder);

                    SelectItem = Item;
                }
            }

            if (SelectItem != null)
            {
                SelectItem.Selected = true;

                EnsureVisible(SelectItem.Index);
            }
            else
            {
                if (Items.Count > 0)
                {
                    Items[0].Selected = true;

                    m_DataFiles.Preferences.LastBatchLoadSelected = (cLoad)Items[0].Tag;

                    EnsureVisible(Items[0].Index);
                }
            }

            Populating = false;
        }
예제 #4
0
        //============================================================================*
        // AddLoad()
        //============================================================================*

        private void AddLoad(cLoad Load)
        {
            //----------------------------------------------------------------------------*
            // If the Load already exists, update the existing one and exit
            //----------------------------------------------------------------------------*

            foreach (cLoad CheckLoad in m_DataFiles.LoadList)
            {
                if (CheckLoad.CompareTo(Load) == 0)
                {
                    UpdateLoad(CheckLoad, Load);

                    return;
                }
            }

            //----------------------------------------------------------------------------*
            // Add the new Load to the list
            //----------------------------------------------------------------------------*

            m_DataFiles.LoadList.Add(Load);

            //----------------------------------------------------------------------------*
            // Add the new Load to the LoadData tab
            //----------------------------------------------------------------------------*

            cCaliber.CurrentFirearmType = Load.FirearmType;

            m_LoadDataListView.AddLoad(Load, LoadDataFirearmTypeCombo.Value, LoadDataCaliberCombo.SelectedIndex > 0 ? (cCaliber)LoadDataCaliberCombo.SelectedItem : null, LoadDataBulletCombo.SelectedIndex > 0 ? (cBullet)LoadDataBulletCombo.SelectedItem : null, LoadDataPowderCombo.SelectedIndex > 0 ? (cPowder)LoadDataPowderCombo.SelectedItem : null, true);

            //----------------------------------------------------------------------------*
            // Update the Load Data Tab BulletCombo
            //----------------------------------------------------------------------------*

            PopulateLoadDataCaliberCombo();

            m_LoadDataListView.Focus();
        }