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

        public void Populate(cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, double dBulletWeight, cPowder Powder, cPrimer Primer, cCase Case)
        {
            Populating = true;

            //----------------------------------------------------------------------------*
            // LoadsListView Items
            //----------------------------------------------------------------------------*

            Items.Clear();

            while (Columns.Count > 3)
            {
                Columns.RemoveAt(3);
            }

            ListViewItem SelectItem = null;

            foreach (cLoad Load in m_DataFiles.LoadList)
            {
                if (Load.FirearmType == eFirearmType &&
                    (Caliber == null || Load.Caliber.CompareTo(Caliber) == 0) &&
                    (Bullet == null || Load.Bullet.CompareTo(Bullet) == 0) &&
                    (Load.Bullet.Weight == dBulletWeight) &&
                    (Powder == null || Load.Powder.CompareTo(Powder) == 0) &&
                    (Case == null || Load.Case.CompareTo(Case) == 0) &&
                    (Primer == null || Load.Primer.CompareTo(Primer) == 0))
                {
                    ListViewItem Item = AddLoad(Load);

                    if (Item != null && Load.CompareTo(m_DataFiles.Preferences.LastCopyLoadSelected) == 0)
                    {
                        SelectItem = Item;
                    }
                }
            }

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

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

                    Items[0].EnsureVisible();
                }
            }

            Populating = false;
        }
        //============================================================================*
        // Populate()
        //============================================================================*

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

            //----------------------------------------------------------------------------*
            // LoadsListView Items
            //----------------------------------------------------------------------------*

            Items.Clear();

            while (Columns.Count > 5)
            {
                Columns.RemoveAt(5);
            }

            ListViewItem SelectItem = null;

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

                if (Item != null && Load.CompareTo(m_DataFiles.Preferences.LastLoadSelected) == 0)
                {
                    SelectItem = Item;
                }
            }

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

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

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

            Populating = false;
        }