//============================================================================*
        // SetFirearmAccessoryData()
        //============================================================================*

        public void SetFirearmAccessoryData(ListViewItem Item, cGear Gear)
        {
            Item.SubItems.Clear();

            Item.Text = Gear.Manufacturer.ToString();

            Item.Group = Groups[(int)Gear.GearType];
            Item.Tag   = Gear;

            Item.SubItems.Add(String.Format("{0}", Gear.PartNumber));
            Item.SubItems.Add(String.Format("{0}", Gear.SerialNumber));
            Item.SubItems.Add(String.Format("{0}", Gear.Description));

            Item.SubItems.Add(Gear.Parent != null ? String.Format("{0}", Gear.Parent.ToString()) : "");

            Item.SubItems.Add(String.Format("{0}", Gear.Source));
            Item.SubItems.Add(!String.IsNullOrEmpty(Gear.Source) ? String.Format("{0}", Gear.PurchaseDate.ToShortDateString()) : "");
            Item.SubItems.Add(!String.IsNullOrEmpty(Gear.Source) && Gear.PurchasePrice > 0.0 ? String.Format("{0:F2}", Gear.PurchasePrice) : "-");
            Item.SubItems.Add(!String.IsNullOrEmpty(Gear.Source) && Gear.Tax > 0.0 ? String.Format("{0:F2}", Gear.Tax) : "-");
            Item.SubItems.Add(!String.IsNullOrEmpty(Gear.Source) && Gear.Shipping > 0.0 ? String.Format("{0:F2}", Gear.Shipping) : "-");

            double dTotal = Gear.PurchasePrice + Gear.Tax + Gear.Shipping;

            Item.SubItems.Add(!String.IsNullOrEmpty(Gear.Source) && dTotal != 0.0 ? String.Format("{0:F2}", dTotal) : "-");
        }
Exemplo n.º 2
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public override void Copy(cGear Gear)
        {
            if (Gear.GearType != eGearTypes.Scope)
            {
                return;
            }

            base.Copy(Gear);

            cScope Scope = (cScope)Gear;

            m_strPower     = Scope.m_strPower;
            m_strObjective = Scope.m_strObjective;

            m_nTubeSize        = Scope.m_nTubeSize;
            m_eTubeMeasurement = Scope.m_eTubeMeasurement;
            m_eTurretType      = Scope.m_eTurretType;

            m_dTurretClick = Scope.m_dTurretClick;

            m_strBattery = Scope.m_strBattery;
            m_dEyeRelief = Scope.m_dEyeRelief;

            FixTubeSize();
        }
        //============================================================================*
        // VerifyFirearmAccessory()
        //============================================================================*

        public bool VerifyFirearmAccessory(cGear Gear)
        {
            //----------------------------------------------------------------------------*
            // Check Filters
            //----------------------------------------------------------------------------*

            if (!m_afFilters[(int)Gear.GearType])
            {
                return(false);
            }

            //----------------------------------------------------------------------------*
            // If firearm  is null, it's good to go
            //----------------------------------------------------------------------------*

            if (m_Firearm == null)
            {
                return(true);
            }

            //----------------------------------------------------------------------------*
            // Otherwise, only  gear  for the specified firearm is ok
            //----------------------------------------------------------------------------*

            cFirearm Firearm = (cFirearm)Gear.Parent;

            if (Firearm == null || Firearm.CompareTo(m_Firearm) != 0)
            {
                return(false);
            }

            return(true);
        }
        //============================================================================*
        // AddFirearmAccessory()
        //============================================================================*

        public ListViewItem AddFirearmAccessory(cGear Gear, bool fSelect = true)
        {
            //----------------------------------------------------------------------------*
            // Verify that the accessory should be added to the list
            //----------------------------------------------------------------------------*

            if (!VerifyFirearmAccessory(Gear))
            {
                return(null);
            }

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

            ListViewItem Item = new ListViewItem();

            SetFirearmAccessoryData(Item, Gear);

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

            AddItem(Item, fSelect);

            return(Item);
        }
Exemplo n.º 5
0
        //============================================================================*
        // cGear() - Copy Constructor
        //============================================================================*

        public cGear(cGear Gear)
        {
            Copy(Gear);

            if (String.IsNullOrEmpty(m_strDescription))
            {
                SetDefaultDescription();
            }
        }
Exemplo n.º 6
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public override void Copy(cGear Gear)
        {
            if (Gear.GearType != eGearTypes.Light)
            {
                return;
            }

            base.Copy(Gear);

            cLight Light = (cLight)Gear;

            m_nLumens = Light.m_nLumens;

            m_strBattery = Light.m_strBattery;
        }
Exemplo n.º 7
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public override void Copy(cGear Gear)
        {
            if (Gear.GearType != eGearTypes.Magnifier)
            {
                return;
            }

            base.Copy(Gear);

            cMagnifier Magnifier = (cMagnifier)Gear;

            m_strMagnification = Magnifier.m_strMagnification;
            m_dFoV             = Magnifier.m_dFoV;
            m_dEyeRelief       = Magnifier.m_dEyeRelief;
        }
Exemplo n.º 8
0
        //============================================================================*
        // Synch() - Gear
        //============================================================================*

        public virtual bool Synch(cGear Gear)
        {
            if (Gear == null || Parent == null)
            {
                return(false);
            }

            if (CompareTo(Gear) == 0)
            {
                m_Parent = Gear;

                return(true);
            }

            return(false);
        }
Exemplo n.º 9
0
        //============================================================================*
        // Synch() - Firearm
        //============================================================================*

        public virtual bool Firearm(cFirearm Firearm)
        {
            if (Firearm == null || Parent == null)
            {
                return(false);
            }

            if (CompareTo(Firearm) == 0)
            {
                m_Parent = Firearm;

                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public override void Copy(cGear Gear)
        {
            if (Gear.GearType != eGearTypes.RedDot)
            {
                return;
            }

            base.Copy(Gear);

            cRedDot RedDot = (cRedDot)Gear;

            m_dDotMOA          = RedDot.m_dDotMOA;
            m_dCowitnessHeight = RedDot.m_dCowitnessHeight;
            m_dTubeDiameter    = RedDot.m_dTubeDiameter;

            m_strBattery = RedDot.m_strBattery;
        }
Exemplo n.º 11
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public virtual void Copy(cGear Gear)
        {
            base.Copy(Gear);

            m_eType        = Gear.m_eType;
            m_Manufacturer = Gear.m_Manufacturer;

            m_strPartNumber   = Gear.m_strPartNumber;
            m_strSerialNumber = Gear.m_strSerialNumber;
            m_strDescription  = Gear.m_strDescription;
            m_strNotes        = Gear.m_strNotes;

            m_strSource = Gear.m_strSource;
            m_Date      = Gear.PurchaseDate;
            m_dPrice    = Gear.m_dPrice;
            m_dTax      = Gear.m_dTax;
            m_dShipping = Gear.m_dShipping;
        }
        //============================================================================*
        // UpdateFirearmAccessory()
        //============================================================================*

        public ListViewItem UpdateFirearmAccessory(cGear Gear, bool fSelect = false)
        {
            //----------------------------------------------------------------------------*
            // Find the Item
            //----------------------------------------------------------------------------*

            ListViewItem Item = null;

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

                    break;
                }
            }

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

            if (Item == null)
            {
                return(AddFirearmAccessory(Gear, fSelect));
            }

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

            SetFirearmAccessoryData(Item, Gear);

            if (fSelect)
            {
                Item.Selected = fSelect;

                Item.EnsureVisible();
            }

            return(Item);
        }
        //============================================================================*
        // CompareGear()
        //============================================================================*

        public int CompareGear(cGear Gear1, cGear Gear2)
        {
            int rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

            if (rc == 0)
            {
                rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                if (rc == 0)
                {
                    rc = Gear1.Description.CompareTo(Gear2.Description);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);
                    }
                }
            }

            return(rc);
        }
Exemplo n.º 14
0
        //============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cGear Gear1, cGear Gear2)
        {
            if (Gear1 == null)
            {
                if (Gear2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Gear2 == null)
                {
                    return(1);
                }
            }

            return(Gear1.CompareTo(Gear2));
        }
Exemplo n.º 15
0
        //============================================================================*
        // Append()
        //============================================================================*

        public int Append(cGear Gear, bool fCountOnly = false)
        {
            int nUpdateCount = 0;

            if (String.IsNullOrEmpty(m_strDescription) && !String.IsNullOrEmpty(Gear.m_strDescription))
            {
                if (!fCountOnly)
                {
                    m_strDescription = Gear.m_strDescription;
                }

                nUpdateCount++;
            }

            if (String.IsNullOrEmpty(m_strNotes) && !String.IsNullOrEmpty(Gear.m_strNotes))
            {
                if (!fCountOnly)
                {
                    m_strNotes = Gear.m_strNotes;
                }

                nUpdateCount++;
            }

            if (String.IsNullOrEmpty(m_strSource) && !String.IsNullOrEmpty(Gear.m_strSource))
            {
                if (!fCountOnly)
                {
                    m_strSource = Gear.m_strSource;
                }

                nUpdateCount++;
            }

            if (m_dPrice == 0.0 && Gear.m_dPrice != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dPrice = Gear.m_dPrice;
                }

                nUpdateCount++;
            }

            if (m_dTax == 0.0 && Gear.m_dTax != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dTax = Gear.m_dTax;
                }

                nUpdateCount++;
            }

            if (m_dShipping == 0.0 && Gear.m_dShipping != 0.0)
            {
                if (!fCountOnly)
                {
                    m_dShipping = Gear.m_dShipping;
                }

                nUpdateCount++;
            }

            return(nUpdateCount);
        }
Exemplo n.º 16
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

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

            int rc = 0;

            //----------------------------------------------------------------------------*
            // Gear Type
            //----------------------------------------------------------------------------*

            cGear Gear = (cGear)obj;

            if (sm_fSortByType)
            {
                rc = m_eType.CompareTo(Gear.m_eType);
            }

            //----------------------------------------------------------------------------*
            // Manufacturer
            //----------------------------------------------------------------------------*

            if (rc == 0)
            {
                if (m_Manufacturer != null)
                {
                    rc = m_Manufacturer.CompareTo(Gear.m_Manufacturer);
                }
                else
                {
                    if (Gear.m_Manufacturer != null)
                    {
                        rc = -1;
                    }
                    else
                    {
                        rc = 0;
                    }
                }

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

                if (rc == 0)
                {
                    rc = cDataFiles.ComparePartNumbers(m_strPartNumber, Gear.PartNumber);

                    //----------------------------------------------------------------------------*
                    // Serial Number
                    //----------------------------------------------------------------------------*

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(m_strSerialNumber, Gear.SerialNumber);
                    }
                }
            }

            return(rc);
        }
Exemplo n.º 17
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);
                }
            }

            cGear Gear1 = (cGear)(Object1 as ListViewItem).Tag;
            cGear Gear2 = (cGear)(Object2 as ListViewItem).Tag;

            if (Gear1 == null)
            {
                if (Gear2 == null)
                {
                    return(0);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Gear2 == null)
                {
                    return(1);
                }
            }

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

            bool fSpecial = false;
            int  rc       = 0;

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

            case 0:
                rc = CompareGear(Gear1, Gear2);

                fSpecial = true;

                break;

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

            case 1:
                rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Serial  Number
            //----------------------------------------------------------------------------*

            case 2:
                rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Description
            //----------------------------------------------------------------------------*

            case 3:
                rc = Gear1.Description.CompareTo(Gear2.Description);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                        if (rc == 0)
                        {
                            rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);
                        }
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Firearm
            //----------------------------------------------------------------------------*

            case 4:
                rc = (Object1 as ListViewItem).SubItems[4].Text.CompareTo((Object2 as ListViewItem).SubItems[4].Text);

                if (rc == 0)
                {
                    CompareGear(Gear1, Gear2);
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Source
            //----------------------------------------------------------------------------*

            case 5:
                rc = Gear1.Source.CompareTo(Gear2.Source);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                        if (rc == 0)
                        {
                            rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);

                            if (rc == 0)
                            {
                                rc = Gear1.Description.CompareTo(Gear2.Description);
                            }
                        }
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Date
            //----------------------------------------------------------------------------*

            case 6:
                rc = Gear1.PurchaseDate.CompareTo(Gear2.PurchaseDate);

                if (rc == 0)
                {
                    rc = CompareGear(Gear1, Gear2);
                }

                fSpecial = true;

                break;

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

            case 7:
                rc = Gear1.PurchasePrice.CompareTo(Gear2.PurchasePrice);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                        if (rc == 0)
                        {
                            rc = Gear1.Description.CompareTo(Gear2.Description);

                            if (rc == 0)
                            {
                                rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);

                                if (rc == 0)
                                {
                                    rc = Gear1.Source.CompareTo(Gear2.Source);
                                }
                            }
                        }
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Tax
            //----------------------------------------------------------------------------*

            case 8:
                rc = Gear1.Tax.CompareTo(Gear2.Tax);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                        if (rc == 0)
                        {
                            rc = Gear1.Description.CompareTo(Gear2.Description);

                            if (rc == 0)
                            {
                                rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);

                                if (rc == 0)
                                {
                                    rc = Gear1.Source.CompareTo(Gear2.Source);
                                }
                            }
                        }
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Shipping
            //----------------------------------------------------------------------------*

            case 9:
                rc = Gear1.Shipping.CompareTo(Gear2.Shipping);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                        if (rc == 0)
                        {
                            rc = Gear1.Description.CompareTo(Gear2.Description);

                            if (rc == 0)
                            {
                                rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);

                                if (rc == 0)
                                {
                                    rc = Gear1.Source.CompareTo(Gear2.Source);
                                }
                            }
                        }
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Total
            //----------------------------------------------------------------------------*

            case 10:
                double dTotal1 = 0.0;

                if ((Object1 as ListViewItem).Text != "-")
                {
                    Double.TryParse((Object1 as ListViewItem).SubItems[10].Text, out dTotal1);
                }

                double dTotal2 = 0.0;

                if ((Object2 as ListViewItem).Text != "-")
                {
                    Double.TryParse((Object2 as ListViewItem).SubItems[10].Text, out dTotal2);
                }

                rc = dTotal1.CompareTo(dTotal2);

                if (rc == 0)
                {
                    rc = Gear1.Manufacturer.CompareTo(Gear2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Gear1.PartNumber, Gear2.PartNumber);

                        if (rc == 0)
                        {
                            rc = Gear1.Description.CompareTo(Gear2.Description);

                            if (rc == 0)
                            {
                                rc = cDataFiles.ComparePartNumbers(Gear1.SerialNumber, Gear2.SerialNumber);

                                if (rc == 0)
                                {
                                    rc = Gear1.Source.CompareTo(Gear2.Source);
                                }
                            }
                        }
                    }
                }

                fSpecial = true;

                break;
            }

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

                return(rc);
            }

            return(base.Compare(Object1, Object2));
        }
Exemplo n.º 18
0
        //============================================================================*
        // GearTypeString() - cGear
        //============================================================================*

        public static string GearTypeString(cGear Gear)
        {
            return(GearTypeString(Gear.GearType));
        }