Пример #1
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public void Copy(cBulletCaliber BulletCaliber)
        {
            m_Caliber = BulletCaliber.m_Caliber;

            m_dCOL  = BulletCaliber.m_dCOL;
            m_dCBTO = BulletCaliber.m_dCBTO;
        }
Пример #2
0
        //============================================================================*
        // Append()
        //============================================================================*

        public int Append(cBulletCaliber BulletCaliber, bool fCountOnly = false)
        {
            int nUpdateCount = 0;

            if (m_dCOL == 0.0 && BulletCaliber.m_dCOL != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dCOL = BulletCaliber.m_dCOL;
                }

                nUpdateCount++;
            }

            if (m_dCBTO == 0.0 && BulletCaliber.m_dCBTO != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dCBTO = BulletCaliber.m_dCBTO;
                }

                nUpdateCount++;
            }

            return(nUpdateCount);
        }
Пример #3
0
        //============================================================================*
        // CompareTo() - BulletCaliber
        //============================================================================*

        public int CompareTo(cBulletCaliber BulletCaliber)
        {
            if (BulletCaliber == null)
            {
                return(1);
            }

            int rc = m_Caliber.CompareTo(BulletCaliber.m_Caliber);

            return(rc);
        }
        //============================================================================*
        // SetBulletCaliberData()
        //============================================================================*

        public void SetBulletCaliberData(ListViewItem Item, cBulletCaliber BulletCaliber)
        {
            Item.SubItems.Clear();

            Item.Text = BulletCaliber.Caliber.ToString();

            Item.Tag = BulletCaliber;

            Item.SubItems.Add(String.Format(m_strDimensionFormat, cDataFiles.StandardToMetric(BulletCaliber.COL, cDataFiles.eDataType.Dimension)));
            Item.SubItems.Add(String.Format(m_strDimensionFormat, cDataFiles.StandardToMetric(BulletCaliber.CBTO, cDataFiles.eDataType.Dimension)));
        }
Пример #5
0
        //============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cBulletCaliber Caliber1, cBulletCaliber Caliber2)
        {
            if (Caliber1 == null)
            {
                if (Caliber2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }

            return(Caliber1.CompareTo(Caliber2));
        }
Пример #6
0
        //============================================================================*
        // BulletCaliber()
        //============================================================================*

        public cBulletCaliber BulletCaliber(cCaliber Caliber)
        {
            if (m_BulletCaliberList == null)
            {
                m_BulletCaliberList = new cBulletCaliberList();
            }

            cBulletCaliber BulletCaliber = null;

            foreach (cBulletCaliber CheckBulletCaliber in m_BulletCaliberList)
            {
                if (CheckBulletCaliber.Caliber.CompareTo(Caliber) == 0)
                {
                    BulletCaliber = CheckBulletCaliber;

                    break;
                }
            }

            return(BulletCaliber);
        }
        //============================================================================*
        // UpdateBulletCaliber()
        //============================================================================*

        public void UpdateBulletCaliber(cBulletCaliber BulletCaliber, bool fSelect = false)
        {
            foreach (ListViewItem Item in Items)
            {
                if ((Item.Tag as cBulletCaliber).Equals(BulletCaliber))
                {
                    SetBulletCaliberData(Item, BulletCaliber);

                    Item.Selected = fSelect;

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

                    return;
                }
            }

            AddBulletCaliber(BulletCaliber, fSelect);
        }
        //============================================================================*
        // AddBulletCaliber()
        //============================================================================*

        public ListViewItem AddBulletCaliber(cBulletCaliber BulletCaliber, bool fSelect = false)
        {
            //----------------------------------------------------------------------------*
            // Verify that the caliber shoudl be added
            //----------------------------------------------------------------------------*

            if (!VerifyBulletCaliber(BulletCaliber))
            {
                return(null);
            }

            //----------------------------------------------------------------------------*
            // Create the new Item
            //----------------------------------------------------------------------------*

            ListViewItem Item = new ListViewItem();

            SetBulletCaliberData(Item, BulletCaliber);

            base.AddItem(Item, fSelect);

            return(Item);
        }
Пример #9
0
        //============================================================================*
        // cBulletCaliber() - Copy Constructor
        //============================================================================*

        public cBulletCaliber(cBulletCaliber BulletCaliber)
        {
            Copy(BulletCaliber);
        }
Пример #10
0
        //============================================================================*
        // cBulletCaliberForm() - Constructor
        //============================================================================*

        public cBulletCaliberForm(cBulletCaliber BulletCaliber, cBullet Bullet, cDataFiles DataFiles)
        {
            InitializeComponent();

            m_Bullet    = Bullet;
            m_DataFiles = DataFiles;

            cCaliber.CurrentFirearmType = m_Bullet.FirearmType;

            //----------------------------------------------------------------------------*
            // Create the m_BulletCaliber object
            //----------------------------------------------------------------------------*

            if (BulletCaliber == null)
            {
                BulletCaliberOKButton.Text = "Add";

                m_fAdd = true;

                m_BulletCaliber = new cBulletCaliber();
            }
            else
            {
                m_BulletCaliber = new cBulletCaliber(BulletCaliber);

                BulletCaliberOKButton.Text = "Update";
            }

            SetClientSizeCore(SelectedCaliberLabel.Location.X + SelectedCaliberLabel.Width + 10, BulletCaliberCancelButton.Location.Y + BulletCaliberCancelButton.Height + 20);

            //----------------------------------------------------------------------------*
            // Set Control Event Handlers
            //----------------------------------------------------------------------------*

            CaliberCombo.SelectedIndexChanged += OnCaliberChanged;

            COALTextBox.TextChanged += OnCOLTextChanged;

            CBTOTextBox.TextChanged += OnCBTOTextChanged;

            BulletCaliberOKButton.Click += OnOKClicked;

            //----------------------------------------------------------------------------*
            // Fill in bullet caliber data
            //----------------------------------------------------------------------------*

            SetInputParameters();

            PopulateCaliberCombo();

            //----------------------------------------------------------------------------*
            // Set Static Tooltips
            //----------------------------------------------------------------------------*

            SetStaticToolTips();

            //----------------------------------------------------------------------------*
            // Set title and text fields
            //----------------------------------------------------------------------------*

            string strTitle;

            if (BulletCaliber == null)
            {
                strTitle = "Add";

                m_fChanged = true;
            }
            else
            {
                strTitle = "Edit";

                m_fChanged = false;
            }

            strTitle += " Cartridge Specific Data";

            Text = strTitle;

            m_fInitialized = true;

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

        public bool VerifyBulletCaliber(cBulletCaliber BulletCaliber)
        {
            return(true);
        }
Пример #12
0
        //============================================================================*
        // 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);
                }
            }

            cBulletCaliber BulletCaliber1 = (cBulletCaliber)(Object1 as ListViewItem).Tag;
            cBulletCaliber BulletCaliber2 = (cBulletCaliber)(Object2 as ListViewItem).Tag;

            if (BulletCaliber1 == null)
            {
                if (BulletCaliber2 == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (BulletCaliber2 == null)
                {
                    return(1);
                }
            }

            bool fSpecial = false;
            int  rc       = 0;

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

            case 1:
                rc = BulletCaliber1.COL.CompareTo(BulletCaliber2.COL);

                fSpecial = true;

                break;
            }

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

                return(rc);
            }

            return(base.Compare(Object1, Object2));
        }