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

        public ListViewItem UpdateManufacturer(cManufacturer OldManufacturer, cManufacturer Manufacturer, bool fSelect = false)
        {
            //----------------------------------------------------------------------------*
            // Find the Item
            //----------------------------------------------------------------------------*

            ListViewItem Item = null;

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

                    break;
                }
            }

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

            if (Item == null)
            {
                return(AddManufacturer(Manufacturer, fSelect));
            }

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

            SetManufacturerData(Item, Manufacturer);

            Item.Selected = fSelect;

            Focus();

            return(Item);
        }
        //============================================================================*
        // cManufacturerForm() - Constructor
        //============================================================================*

        public cManufacturerForm(cManufacturer Manufacturer, ref cDataFiles DataFiles, bool fViewOnly = false)
        {
            InitializeComponent();

            m_DataFiles = DataFiles;
            m_fViewOnly = fViewOnly;

            if (Manufacturer == null)
            {
                if (m_fViewOnly)
                {
                    return;
                }

                m_Manufacturer = new cManufacturer();

                m_fAdd = true;

                OKButton.ButtonType = cOKButton.eButtonTypes.Add;
            }
            else
            {
                m_Manufacturer         = new cManufacturer(Manufacturer);
                m_OriginalManufacturer = Manufacturer;

                if (m_fViewOnly)
                {
                    OKButton.Visible            = false;
                    FormCancelButton.ButtonType = cCancelButton.eButtonTypes.Close;

                    int nButtonX = (this.Size.Width / 2) - (FormCancelButton.Width / 2);

                    FormCancelButton.Location = new Point(nButtonX, FormCancelButton.Location.Y);
                }
                else
                {
                    OKButton.ButtonType = cOKButton.eButtonTypes.Update;
                }
            }

            SetClientSizeCore(FirearmsGroup.Location.X + FirearmsGroup.Width + 10, FormCancelButton.Location.Y + FormCancelButton.Height + 20);

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

            if (!m_fViewOnly)
            {
                NameTextBox.TextChanged      += OnNameChanged;
                WebsiteTextBox.TextChanged   += OnWebsiteChanged;
                HeadStampTextBox.TextChanged += OnHeadStampChanged;

                AmmoCheckBox.Click        += OnCheckBoxClicked;
                BulletsCheckBox.Click     += OnCheckBoxClicked;
                CasesCheckBox.Click       += OnCheckBoxClicked;
                PowderCheckBox.Click      += OnCheckBoxClicked;
                PrimersCheckBox.Click     += OnCheckBoxClicked;
                BulletMoldsCheckBox.Click += OnCheckBoxClicked;

                HandgunsCheckBox.Click += OnCheckBoxClicked;
                RiflesCheckBox.Click   += OnCheckBoxClicked;
                ShotgunsCheckBox.Click += OnCheckBoxClicked;

                ToolsCheckBox.Click += OnCheckBoxClicked;

                ScopesCheckBox.Click     += OnCheckBoxClicked;
                LasersCheckBox.Click     += OnCheckBoxClicked;
                RedDotsCheckBox.Click    += OnCheckBoxClicked;
                MagnifiersCheckBox.Click += OnCheckBoxClicked;
                LightsCheckBox.Click     += OnCheckBoxClicked;
                TriggersCheckBox.Click   += OnCheckBoxClicked;
                FurnitureCheckBox.Click  += OnCheckBoxClicked;
                BipodsCheckBox.Click     += OnCheckBoxClicked;
                PartsCheckBox.Click      += OnCheckBoxClicked;
                OtherCheckBox.Click      += OnCheckBoxClicked;
            }
            else
            {
                AmmoCheckBox.AutoCheck        = false;
                BulletsCheckBox.AutoCheck     = false;
                CasesCheckBox.AutoCheck       = false;
                PowderCheckBox.AutoCheck      = false;
                PrimersCheckBox.AutoCheck     = false;
                BulletMoldsCheckBox.AutoCheck = false;

                HandgunsCheckBox.AutoCheck = false;
                RiflesCheckBox.AutoCheck   = false;
                ShotgunsCheckBox.AutoCheck = false;

                ToolsCheckBox.AutoCheck = false;

                ScopesCheckBox.AutoCheck     = false;
                LasersCheckBox.AutoCheck     = false;
                RedDotsCheckBox.AutoCheck    = false;
                MagnifiersCheckBox.AutoCheck = false;
                LightsCheckBox.AutoCheck     = false;
                TriggersCheckBox.AutoCheck   = false;
                FurnitureCheckBox.AutoCheck  = false;
                BipodsCheckBox.AutoCheck     = false;
                PartsCheckBox.AutoCheck      = false;
                OtherCheckBox.AutoCheck      = false;
            }

            OKButton.Click += OnOKClicked;

            //----------------------------------------------------------------------------*
            // Populate the data fields
            //----------------------------------------------------------------------------*

            NameTextBox.Value = m_Manufacturer.Name;

            WebsiteTextBox.Value = m_Manufacturer.Website;

            AmmoCheckBox.Checked        = m_Manufacturer.Ammo;
            BulletsCheckBox.Checked     = m_Manufacturer.Bullets;
            BulletMoldsCheckBox.Checked = m_Manufacturer.BulletMolds;
            CasesCheckBox.Checked       = m_Manufacturer.Cases;
            PowderCheckBox.Checked      = m_Manufacturer.Powder;
            PrimersCheckBox.Checked     = m_Manufacturer.Primers;

            if (fViewOnly || CasesCheckBox.Checked)
            {
                HeadStampTextBox.Enabled = true;

                HeadStampTextBox.Value = m_Manufacturer.HeadStamp;
            }
            else
            {
                HeadStampTextBox.Enabled = false;

                HeadStampTextBox.Value = "";
            }

            HandgunsCheckBox.Checked = m_Manufacturer.Handguns;
            RiflesCheckBox.Checked   = m_Manufacturer.Rifles;
            ShotgunsCheckBox.Checked = m_Manufacturer.Shotguns;

            ToolsCheckBox.Checked = m_Manufacturer.Tools;

            ScopesCheckBox.Checked     = m_Manufacturer.Scopes;
            LasersCheckBox.Checked     = m_Manufacturer.Lasers;
            RedDotsCheckBox.Checked    = m_Manufacturer.RedDots;
            MagnifiersCheckBox.Checked = m_Manufacturer.Magnifiers;
            LightsCheckBox.Checked     = m_Manufacturer.Lights;
            TriggersCheckBox.Checked   = m_Manufacturer.Triggers;
            FurnitureCheckBox.Checked  = m_Manufacturer.Furniture;
            BipodsCheckBox.Checked     = m_Manufacturer.Bipods;
            PartsCheckBox.Checked      = m_Manufacturer.Parts;
            OtherCheckBox.Checked      = m_Manufacturer.Misc;

            //----------------------------------------------------------------------------*
            // Build Title String
            //----------------------------------------------------------------------------*

            string strTitle;

            if (Manufacturer == null)
            {
                strTitle = "Add";
            }
            else
            {
                if (!m_fViewOnly)
                {
                    strTitle = "Edit";
                }
                else
                {
                    strTitle = "View";

                    NameTextBox.ReadOnly = true;
                    NameTextBox.Select(0, 0);
                    WebsiteTextBox.ReadOnly   = true;
                    HeadStampTextBox.ReadOnly = true;
                }
            }

            strTitle += " Manufacturer";

            Text = strTitle;

            SetStaticToolTips();

            CheckProductUse();

            UpdateButtons();

            m_fInitialized = true;
        }
예제 #3
0
        //============================================================================*
        // VerifyManufacturer()
        //============================================================================*

        public bool VerifyManufacturer(cManufacturer Manufacturer)
        {
            return(true);
        }
예제 #4
0
        //============================================================================*
        // cPrimerForm() - Constructor
        //============================================================================*

        public cPrimerForm(cPrimer Primer, cDataFiles DataFiles, bool fViewOnly = false)
        {
            InitializeComponent();
            m_fViewOnly = fViewOnly;

            m_DataFiles = DataFiles;

            if (Primer == null)
            {
                if (m_fViewOnly)
                {
                    return;
                }

                if (m_DataFiles.Preferences.LastPrimer != null)
                {
                    m_Primer = new cPrimer(m_DataFiles.Preferences.LastPrimer);

                    m_Primer.Model = "";
                    m_Primer.TransactionList.Clear();
                    m_Primer.RecalculateInventory(m_DataFiles);
                }
                else
                {
                    m_Primer = new cPrimer();
                }

                PrimerOKButton.Text = "Add";
            }
            else
            {
                m_Primer = new cPrimer(Primer);

                if (m_fViewOnly)
                {
                    PrimerOKButton.Visible = false;

                    int nButtonX = (this.Size.Width / 2) - (PrimerCancelButton.Width / 2);

                    PrimerCancelButton.Location = new Point(nButtonX, PrimerCancelButton.Location.Y);

                    PrimerCancelButton.Text = "Close";
                }
                else
                {
                    PrimerOKButton.Text = "Update";
                }
            }

            m_OriginalManufacturer = m_Primer.Manufacturer;
            m_strOriginalModel     = m_Primer.Model;

            SetClientSizeCore(GeneralGroupBox.Location.X + GeneralGroupBox.Width + 10, PrimerCancelButton.Location.Y + PrimerCancelButton.Height + 20);

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

            if (!m_fViewOnly)
            {
                FirearmTypeCombo.SelectedIndexChanged += OnFirearmTypeSelected;
                CrossUseCheckBox.Click += OnCrossUseClicked;
                ManufacturerCombo.SelectedIndexChanged += OnManufacturerChanged;
                SizeCombo.SelectedIndexChanged         += OnSizeChanged;

                StandardCheckBox.Click  += OnPrimerTypeClicked;
                MagnumCheckBox.Click    += OnPrimerTypeClicked;
                BenchRestCheckBox.Click += OnPrimerTypeClicked;
                MilitaryCheckBox.Click  += OnPrimerTypeClicked;

                ModelTextBox.TextChanged += OnModelChanged;

                QuantityTextBox.TextChanged += OnQuantityChanged;
                CostTextBox.TextChanged     += OnPriceChanged;

                PrimerOKButton.Click += OnOKClicked;
            }
            else
            {
                ModelTextBox.ReadOnly    = true;
                QuantityTextBox.ReadOnly = true;
                CostTextBox.ReadOnly     = true;
            }

            InventoryButton.Click += OnInventoryClicked;

            //----------------------------------------------------------------------------*
            // Populate Firearm Type Combo
            //----------------------------------------------------------------------------*

            FirearmTypeCombo.Value   = m_Primer.FirearmType;
            CrossUseCheckBox.Checked = m_Primer.CrossUse;

            //----------------------------------------------------------------------------*
            // Populate Primer Size Combo
            //----------------------------------------------------------------------------*

            if (!m_fViewOnly)
            {
                SizeCombo.Items.Clear();

                SizeCombo.Items.Add("Small");
                SizeCombo.Items.Add("Large");

                SizeCombo.SelectedIndex = (int)m_Primer.Size;
            }
            else
            {
                SizeCombo.Items.Clear();

                SizeCombo.Items.Add(m_Primer.ShortSizeString);

                SizeCombo.SelectedIndex = 0;
            }

            //----------------------------------------------------------------------------*
            // Set Labels for inventory tracking if needed
            //----------------------------------------------------------------------------*

            if (m_DataFiles.Preferences.TrackInventory)
            {
                QuantityLabel.Text = "Qty on Hand:";

                QuantityTextBox.BorderStyle = BorderStyle.None;
                QuantityTextBox.Font        = new Font(QuantityTextBox.Font, FontStyle.Bold);
                QuantityTextBox.Location    = new Point(QuantityTextBox.Location.X, QuantityTextBox.Location.Y + 3);
                QuantityTextBox.Enabled     = false;

                CostTextBox.BorderStyle = BorderStyle.None;
                CostTextBox.Font        = new Font(CostTextBox.Font, FontStyle.Bold);
                CostTextBox.TextAlign   = HorizontalAlignment.Left;
                CostTextBox.Location    = new Point(CostTextBox.Location.X, CostTextBox.Location.Y + 3);
                CostTextBox.Enabled     = false;

                InventoryGroupBox.Text = "Inventory Info";

                CostLabel.Text = "Value:";
            }
            else
            {
                InventoryButton.Visible = false;

                CostLabel.Text = String.Format("Cost ({0}):", m_DataFiles.Preferences.Currency);
            }

            //----------------------------------------------------------------------------*
            // Fill in Primer data
            //----------------------------------------------------------------------------*

            ModelTextBox.Text = m_Primer.Model;

            StandardCheckBox.Checked  = m_Primer.Standard;
            MagnumCheckBox.Checked    = m_Primer.Magnum;
            MilitaryCheckBox.Checked  = m_Primer.Military;
            BenchRestCheckBox.Checked = m_Primer.BenchRest;

            PopulateInventoryData();

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

            string strTitle;

            if (Primer == null)
            {
                strTitle = "Add";
            }
            else
            if (m_fViewOnly)
            {
                strTitle = "View";
            }
            else
            {
                strTitle = "Edit";
            }

            strTitle += " Primer";

            Text = strTitle;

            PopulateManufacturerCombo();

            UpdateButtons();

            m_fInitialized = true;
        }
예제 #5
0
        //============================================================================*
        // UpdateButtons()
        //============================================================================*

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

            bool   fEnableOK  = m_fChanged;
            string strToolTip = "";

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

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

            //----------------------------------------------------------------------------*
            // Check for duplicate
            //----------------------------------------------------------------------------*

            ModelTextBox.ToolTip = cm_strModelToolTip;

            bool fDuplicate = false;

            cManufacturer Manufacturer = (cManufacturer)ManufacturerCombo.SelectedItem;

            if (Manufacturer != null && m_OriginalManufacturer != null && m_strOriginalModel != null)
            {
                if (Manufacturer.CompareTo(m_OriginalManufacturer) != 0 ||
                    ModelTextBox.Text.ToUpper() != m_strOriginalModel.ToUpper())
                {
                    foreach (cPrimer CheckPrimer in m_DataFiles.PrimerList)
                    {
                        if (Manufacturer.CompareTo(CheckPrimer.Manufacturer) == 0)
                        {
                            if (ModelTextBox.Text.ToUpper() == CheckPrimer.Model.ToUpper())
                            {
                                fDuplicate = true;

                                fEnableOK = false;

                                ModelTextBox.BackColor = Color.LightPink;

                                strToolTip += String.Format("\n\nThis primer, \"{0} {1}\", already exists.  Duplicate primers are not allowed.", (ManufacturerCombo.SelectedItem as cManufacturer).Name, ModelTextBox.Text);

                                break;
                            }
                        }
                    }

                    if (!fDuplicate)
                    {
                        ModelTextBox.BackColor = SystemColors.Window;
                    }
                }
            }

            if (m_DataFiles.Preferences.ToolTips)
            {
                ModelTextBox.ToolTip += strToolTip;
            }

            //----------------------------------------------------------------------------*
            // Check Uses
            //----------------------------------------------------------------------------*

            strToolTip = "";

            if (!StandardCheckBox.Checked && !MagnumCheckBox.Checked)
            {
                fEnableOK = false;

                StandardCheckBox.BackColor = Color.LightPink;
                MagnumCheckBox.BackColor   = Color.LightPink;

                strToolTip += "\n\nYou must select either Standard, Magnum, or both.";
            }
            else
            {
                StandardCheckBox.BackColor = SystemColors.Control;
                MagnumCheckBox.BackColor   = SystemColors.Control;
            }

            if (m_DataFiles.Preferences.ToolTips)
            {
                m_StandardToolTip.SetToolTip(StandardCheckBox, cm_strStandardToolTip + strToolTip);
                m_MagnumToolTip.SetToolTip(MagnumCheckBox, cm_strMagnumToolTip + strToolTip);
            }

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

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

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

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

            //----------------------------------------------------------------------------*
            // Enable or disable OK button
            //----------------------------------------------------------------------------*

            PrimerOKButton.Enabled = fEnableOK;
        }
예제 #6
0
        //============================================================================*
        // OnDrawSubItem()
        //============================================================================*

        protected override void OnDrawSubItem(DrawListViewSubItemEventArgs args)
        {
            //----------------------------------------------------------------------------*
            // Website Column
            //----------------------------------------------------------------------------*

            if (args.Header.Text == "Website")
            {
                Brush WebsiteBrush = Brushes.Blue;

                cManufacturer Manufacturer = (cManufacturer)args.Item.Tag;

                if (Manufacturer.WebSiteVisited)
                {
                    WebsiteBrush = Brushes.Maroon;
                }

                if (args.Item.Selected)
                {
                    if (Focused)
                    {
                        args.SubItem.BackColor = SystemColors.Highlight;

                        WebsiteBrush = Brushes.White;
                    }
                    else
                    {
                        args.SubItem.BackColor = SystemColors.ControlLight;
                    }

                    args.SubItem.ForeColor = SystemColors.HighlightText;
                }
                else
                {
                    args.SubItem.BackColor = SystemColors.Window;
                    args.SubItem.ForeColor = SystemColors.WindowText;
                }

                args.DrawBackground();

                Font WebSiteFont = new Font(SystemFonts.DefaultFont, FontStyle.Underline | FontStyle.Bold);

                args.Graphics.DrawString(args.SubItem.Text, WebSiteFont, WebsiteBrush, args.Bounds);

                return;
            }

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

            if (args.Header.Text == "Caliber" || args.Header.Text == "Primary Caliber")
            {
                cCaliber Caliber = GetCaliberFromTag(args.Item);

                if (Caliber != null && !String.IsNullOrEmpty(Caliber.SAAMIPDF))
                {
                    Brush ViewBrush = Brushes.Blue;

                    if (args.Item.Selected)
                    {
                        if (Focused)
                        {
                            args.SubItem.BackColor = SystemColors.Highlight;

                            ViewBrush = Brushes.White;
                        }
                        else
                        {
                            args.SubItem.BackColor = SystemColors.ControlLight;
                        }

                        args.SubItem.ForeColor = SystemColors.HighlightText;
                    }
                    else
                    {
                        args.SubItem.BackColor = SystemColors.Window;
                        args.SubItem.ForeColor = Color.Blue;
                    }

                    args.DrawBackground();

                    Font ViewFont = new Font(SystemFonts.DefaultFont, FontStyle.Underline | FontStyle.Bold);

                    SizeF TextSize = args.Graphics.MeasureString(args.SubItem.Text, ViewFont);

                    Rectangle Rect = args.Bounds;

                    Rect.Y += (Rect.Height / 2) - (int)(TextSize.Height / 2);

                    if (args.ColumnIndex == 0 && CheckBoxes)
                    {
                        CheckBoxRenderer.DrawCheckBox(args.Graphics, new Point(Rect.Left + 4, Rect.Top), args.Bounds, "", ViewFont, false, (args.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));

                        Size BoxSize = CheckBoxRenderer.GetGlyphSize(args.Graphics, (args.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));

                        args.Graphics.DrawString(args.SubItem.Text, ViewFont, ViewBrush, args.Bounds.X + BoxSize.Width + 6, args.Bounds.Y);
                    }
                    else
                    {
                        args.Graphics.DrawString(args.SubItem.Text, ViewFont, ViewBrush, args.Bounds.X + 4, args.Bounds.Y);
                    }

                    return;
                }
            }

            //----------------------------------------------------------------------------*
            // Batch-Made Ammo
            //----------------------------------------------------------------------------*

            if (args.Header.Text == "Part Number" && args.Item.Text == "Batch Editor")
            {
                string strBatchNumber = args.SubItem.Text;

                if (strBatchNumber.Length >= 7 && strBatchNumber.Substring(0, 6) == "Batch ")
                {
                    strBatchNumber = strBatchNumber.Substring(6);
                }
                else
                {
                    strBatchNumber = "";
                }

                int nBatchID = 0;

                Int32.TryParse(strBatchNumber, out nBatchID);

                if (nBatchID > 0)
                {
                    Brush ViewBrush = Brushes.Blue;

                    if (args.Item.Selected)
                    {
                        if (Focused)
                        {
                            args.SubItem.BackColor = SystemColors.Highlight;

                            ViewBrush = Brushes.White;
                        }
                        else
                        {
                            args.SubItem.BackColor = SystemColors.ControlLight;
                        }

                        args.SubItem.ForeColor = SystemColors.HighlightText;
                    }
                    else
                    {
                        args.SubItem.BackColor = SystemColors.Window;
                        args.SubItem.ForeColor = Color.Blue;
                    }

                    args.DrawBackground();

                    Font ViewFont = new Font(SystemFonts.DefaultFont, FontStyle.Underline | FontStyle.Bold);

                    SizeF TextSize = args.Graphics.MeasureString(args.SubItem.Text, ViewFont);

                    Rectangle Rect = args.Bounds;

                    Rect.Y += (Rect.Height / 2) - (int)(TextSize.Height / 2);

                    if (args.ColumnIndex == 0 && CheckBoxes)
                    {
                        CheckBoxRenderer.DrawCheckBox(args.Graphics, new Point(Rect.Left + 4, Rect.Top), args.Bounds, "", ViewFont, false, (args.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));

                        Size BoxSize = CheckBoxRenderer.GetGlyphSize(args.Graphics, (args.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));

                        args.Graphics.DrawString(args.SubItem.Text, ViewFont, ViewBrush, args.Bounds.X + BoxSize.Width + 6, args.Bounds.Y);
                    }
                    else
                    {
                        args.Graphics.DrawString(args.SubItem.Text, ViewFont, ViewBrush, args.Bounds.X + 4, args.Bounds.Y);
                    }

                    return;
                }
            }

            //----------------------------------------------------------------------------*
            // Checkmark Column
            //----------------------------------------------------------------------------*

            if (args.SubItem.Text == "Y")
            {
                Bitmap CheckImage = null;

                if (args.Item.Selected)
                {
                    if (Focused)
                    {
                        args.SubItem.BackColor = SystemColors.Highlight;

                        CheckImage = sm_CheckMarkSelectedImage;
                    }
                    else
                    {
                        args.SubItem.BackColor = SystemColors.ControlLight;

                        CheckImage = sm_CheckMarkImage;
                    }

                    args.SubItem.ForeColor = SystemColors.HighlightText;
                }
                else
                {
                    CheckImage = sm_CheckMarkImage;

                    args.SubItem.ForeColor = SystemColors.WindowText;
                    args.SubItem.BackColor = SystemColors.Window;
                }

                args.DrawBackground();

                args.Graphics.DrawImage(CheckImage, args.Bounds.Left + (args.Bounds.Width / 2) - (CheckImage.Width / 2), args.Bounds.Top + (args.Bounds.Height / 2) - (CheckImage.Height / 2));

                return;
            }

            args.DrawDefault = true;
        }
예제 #7
0
        //============================================================================*
        // PopulateManufacturerCombo()
        //============================================================================*

        public static void PopulateManufacturerCombo(ComboBox ManufacturerCombo, cDataFiles DataFiles, cManufacturer Manufacturer = null, cFirearm.eFireArmType eFirearmType = cFirearm.eFireArmType.None, int nSupplyType = -1)
        {
            ManufacturerCombo.Items.Clear();

            //----------------------------------------------------------------------------*
            // Loop through the manufacturers
            //----------------------------------------------------------------------------*

            cManufacturer SelectManufacturer = null;

            foreach (cManufacturer CheckManufacturer in DataFiles.ManufacturerList)
            {
                //----------------------------------------------------------------------------*
                // Check that this manufacturer provides the specfied firearm type, if any
                //----------------------------------------------------------------------------*

                switch (eFirearmType)
                {
                case cFirearm.eFireArmType.None:
                    break;

                case cFirearm.eFireArmType.Handgun:
                    if (!CheckManufacturer.Handguns)
                    {
                        continue;
                    }

                    break;

                case cFirearm.eFireArmType.Rifle:
                    if (!CheckManufacturer.Rifles)
                    {
                        continue;
                    }

                    break;

                case cFirearm.eFireArmType.Shotgun:
                    if (!CheckManufacturer.Shotguns)
                    {
                        continue;
                    }

                    break;
                }

                //----------------------------------------------------------------------------*
                // Check that this manufacturer provides the specfied supply type, if any
                //----------------------------------------------------------------------------*

                switch (nSupplyType)
                {
                case -1:
                    break;

                case (int)cSupply.eSupplyTypes.Bullets:
                    if (!CheckManufacturer.Bullets && !CheckManufacturer.BulletMolds)
                    {
                        continue;
                    }

                    break;

                case (int)cSupply.eSupplyTypes.Cases:
                    if (!CheckManufacturer.Cases)
                    {
                        continue;
                    }

                    break;

                case (int)cSupply.eSupplyTypes.Powder:
                    if (!CheckManufacturer.Powder)
                    {
                        continue;
                    }

                    break;

                case (int)cSupply.eSupplyTypes.Primers:
                    if (!CheckManufacturer.Primers)
                    {
                        continue;
                    }

                    break;
                }

                //----------------------------------------------------------------------------*
                // If we get to here, the manufacturer is ok to be added to the combo
                //----------------------------------------------------------------------------*

                if (Manufacturer != null && CheckManufacturer.CompareTo(Manufacturer) == 0)
                {
                    SelectManufacturer = CheckManufacturer;
                }

                ManufacturerCombo.Items.Add(CheckManufacturer);
            }

            if (SelectManufacturer != null)
            {
                ManufacturerCombo.SelectedIndex = ManufacturerCombo.Items.IndexOf(SelectManufacturer);

                if (ManufacturerCombo.SelectedIndex < 0 && ManufacturerCombo.Items.Count > 0)
                {
                    ManufacturerCombo.SelectedIndex = 0;
                }
            }
            else
            {
                if (ManufacturerCombo.Items.Count > 0)
                {
                    ManufacturerCombo.SelectedIndex = 0;
                }
            }
        }
예제 #8
0
        //============================================================================*
        // cManufacturer() - Copy Constructor
        //============================================================================*

        public cManufacturer(cManufacturer Manufacturer)
        {
            Copy(Manufacturer);
        }
예제 #9
0
        //============================================================================*
        // Append()
        //============================================================================*

        public int Append(cManufacturer Manufacturer, bool fCountOnly = false)
        {
            int nUpdateCount = 0;

            if (String.IsNullOrEmpty(m_strWebsite) && !String.IsNullOrEmpty(Manufacturer.m_strWebsite))
            {
                if (!fCountOnly)
                {
                    m_strWebsite = Manufacturer.m_strWebsite;

                    m_fWebsiteVisited = false;
                }

                nUpdateCount++;
            }

            if (!m_fAmmo && Manufacturer.m_fAmmo)
            {
                if (!fCountOnly)
                {
                    m_fAmmo = Manufacturer.m_fAmmo;
                }

                nUpdateCount++;
            }

            if (!m_fBullets && Manufacturer.m_fBullets)
            {
                if (!fCountOnly)
                {
                    m_fBullets = Manufacturer.m_fBullets;
                }

                nUpdateCount++;
            }

            if (!m_fCases && Manufacturer.m_fCases)
            {
                if (!fCountOnly)
                {
                    m_fCases = Manufacturer.m_fCases;
                }

                nUpdateCount++;
            }

            if (!m_fPowder && Manufacturer.m_fPowder)
            {
                if (!fCountOnly)
                {
                    m_fPowder = Manufacturer.m_fPowder;
                }

                nUpdateCount++;
            }

            if (!m_fPrimers && Manufacturer.m_fPrimers)
            {
                if (!fCountOnly)
                {
                    m_fPrimers = Manufacturer.m_fPrimers;
                }

                nUpdateCount++;
            }

            if (!m_fBulletMolds && Manufacturer.m_fBulletMolds)
            {
                if (!fCountOnly)
                {
                    m_fBulletMolds = Manufacturer.m_fBulletMolds;
                }

                nUpdateCount++;
            }

            if (String.IsNullOrEmpty(m_strHeadStamp) && !String.IsNullOrEmpty(Manufacturer.m_strHeadStamp))
            {
                if (!fCountOnly)
                {
                    m_strHeadStamp = Manufacturer.m_strHeadStamp;
                }

                nUpdateCount++;
            }

            if (!m_fHandguns && Manufacturer.m_fHandguns)
            {
                if (!fCountOnly)
                {
                    m_fHandguns = Manufacturer.m_fHandguns;
                }

                nUpdateCount++;
            }

            if (!m_fRifles && Manufacturer.m_fRifles)
            {
                if (!fCountOnly)
                {
                    m_fRifles = Manufacturer.m_fRifles;
                }

                nUpdateCount++;
            }

            if (!m_fShotguns && Manufacturer.m_fShotguns)
            {
                if (!fCountOnly)
                {
                    m_fShotguns = Manufacturer.m_fShotguns;
                }

                nUpdateCount++;
            }

            if (!m_fScopes && Manufacturer.m_fScopes)
            {
                if (!fCountOnly)
                {
                    m_fScopes = Manufacturer.m_fScopes;
                }

                nUpdateCount++;
            }

            if (!m_fLasers && Manufacturer.m_fLasers)
            {
                if (!fCountOnly)
                {
                    m_fLasers = Manufacturer.m_fLasers;
                }

                nUpdateCount++;
            }

            if (!m_fRedDots && Manufacturer.m_fRedDots)
            {
                if (!fCountOnly)
                {
                    m_fRedDots = Manufacturer.m_fRedDots;
                }

                nUpdateCount++;
            }

            if (!m_fMagnifiers && Manufacturer.m_fMagnifiers)
            {
                if (!fCountOnly)
                {
                    m_fMagnifiers = Manufacturer.m_fMagnifiers;
                }

                nUpdateCount++;
            }

            if (!m_fLights && Manufacturer.m_fLights)
            {
                if (!fCountOnly)
                {
                    m_fLights = Manufacturer.m_fLights;
                }

                nUpdateCount++;
            }

            if (!m_fTriggers && Manufacturer.m_fTriggers)
            {
                if (!fCountOnly)
                {
                    m_fTriggers = Manufacturer.m_fTriggers;
                }

                nUpdateCount++;
            }

            if (!m_fFurniture && Manufacturer.m_fFurniture)
            {
                if (!fCountOnly)
                {
                    m_fFurniture = Manufacturer.m_fFurniture;
                }

                nUpdateCount++;
            }

            if (!m_fBipods && Manufacturer.m_fBipods)
            {
                if (!fCountOnly)
                {
                    m_fBipods = Manufacturer.m_fBipods;
                }

                nUpdateCount++;
            }

            if (!m_fParts && Manufacturer.m_fParts)
            {
                if (!fCountOnly)
                {
                    m_fParts = Manufacturer.m_fParts;
                }

                nUpdateCount++;
            }

            if (!m_fMisc && Manufacturer.m_fMisc)
            {
                if (!fCountOnly)
                {
                    m_fMisc = Manufacturer.m_fMisc;
                }

                nUpdateCount++;
            }

            return(nUpdateCount);
        }