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

        public static int Comparer(cPowder Powder1, cPowder Powder2)
        {
            if (Powder1 == null)
            {
                if (Powder2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Powder2 == null)
                {
                    return(1);
                }
            }

            return(Powder1.CompareTo(Powder2));
        }
Пример #2
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

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

            cLoad Load = (cLoad)obj;

            //----------------------------------------------------------------------------*
            // FirearmType
            //----------------------------------------------------------------------------*

            int rc = m_eFirearmType.CompareTo(Load.m_eFirearmType);

            //----------------------------------------------------------------------------*
            // Caliber
            //----------------------------------------------------------------------------*

            if (rc == 0)
            {
                if (m_Caliber == null)
                {
                    rc = -1;
                }
                else
                {
                    rc = m_Caliber.CompareTo(Load.m_Caliber);
                }

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

                if (rc == 0)
                {
                    if (m_Bullet == null)
                    {
                        rc = -1;
                    }
                    else
                    {
                        rc = m_Bullet.CompareTo(Load.m_Bullet);
                    }

                    //----------------------------------------------------------------------------*
                    // Powder
                    //----------------------------------------------------------------------------*

                    if (rc == 0)
                    {
                        if (m_Powder == null)
                        {
                            rc = -1;
                        }
                        else
                        {
                            rc = m_Powder.CompareTo(Load.m_Powder);
                        }

                        //----------------------------------------------------------------------------*
                        // Case
                        //----------------------------------------------------------------------------*

                        if (rc == 0)
                        {
                            if (m_Case == null)
                            {
                                rc = -1;
                            }
                            else
                            {
                                rc = m_Case.CompareTo(Load.m_Case);
                            }

                            //----------------------------------------------------------------------------*
                            // Primer
                            //----------------------------------------------------------------------------*

                            if (rc == 0)
                            {
                                if (m_Primer == null)
                                {
                                    rc = -1;
                                }
                                else
                                {
                                    rc = m_Primer.CompareTo(Load.m_Primer);
                                }
                            }
                        }
                    }
                }
            }

            return(rc);
        }
Пример #3
0
        //============================================================================*
        // UpdateButtons()
        //============================================================================*

        private void UpdateButtons()
        {
            if (m_fViewOnly)
            {
                return;
            }

            SetMinMax();

            bool fEnableOK = m_fChanged;

            //----------------------------------------------------------------------------*
            // Check Model
            //----------------------------------------------------------------------------*

            string strText = cm_strModelToolTip;

            if (!ModelTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            if (m_fAdd)
            {
                bool fTypeFound = false;

                foreach (cPowder Powder in m_DataFiles.PowderList)
                {
                    if (m_Powder.CompareTo(Powder) == 0)
                    {
                        fEnableOK = false;

                        strText += "\n\nThis Manufacturer/Type combination already exists.  Duplicates are not allowed.";

                        fTypeFound = true;

                        break;
                    }
                }

                if (fTypeFound)
                {
                    ModelTextBox.BackColor = Color.LightPink;
                }
                else
                {
                    ModelTextBox.BackColor = SystemColors.Window;
                }
            }

            if (m_DataFiles.Preferences.ToolTips)
            {
                m_ModelToolTip.SetToolTip(ModelTextBox, strText);
            }

            //----------------------------------------------------------------------------*
            // Check Quantity
            //----------------------------------------------------------------------------*

            if (!QuantityTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            //----------------------------------------------------------------------------*
            // Check Price
            //----------------------------------------------------------------------------*

            if (!CostTextBox.ValueOK)
            {
                fEnableOK = false;
            }

            //----------------------------------------------------------------------------*
            // Set Buttons
            //----------------------------------------------------------------------------*

            PowderOKButton.Enabled = fEnableOK;
        }