Exemplo n.º 1
0
        //============================================================================*
        // CompareTo()
        //============================================================================*

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

            //----------------------------------------------------------------------------*
            // Base Class
            //----------------------------------------------------------------------------*

            cSupply Supply = (cSupply)obj;

            int rc = base.CompareTo(Supply);

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

            if (rc == 0)
            {
                cCase Case = (cCase)Supply;

                rc = cDataFiles.ComparePartNumbers(m_strPartNumber, Case.m_strPartNumber);

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

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

            return(rc);
        }
Exemplo n.º 2
0
        //============================================================================*
        // Synch() - Case
        //============================================================================*

        public bool Synch(cCase Case)
        {
            if (m_Case != null && m_Case.CompareTo(Case) == 0)
            {
                m_Case = Case;

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        //============================================================================*
        // cLoad() - Copy Constructor
        //============================================================================*

        public cLoad(cLoad Load)
        {
            m_eFirearmType = Load.m_eFirearmType;
            m_Caliber      = Load.m_Caliber;
            m_Bullet       = Load.m_Bullet;
            m_Powder       = Load.m_Powder;
            m_Case         = Load.m_Case;
            m_Primer       = Load.m_Primer;
            m_fChecked     = Load.m_fChecked;
            m_fIdentity    = Load.m_fIdentity;

            m_ChargeList = new cChargeList(Load.m_ChargeList);
        }
Exemplo n.º 4
0
        //============================================================================*
        // Copy()
        //============================================================================*

        public void Copy(cCase Case, bool fCopyBase = true)
        {
            if (fCopyBase)
            {
                base.Copy(Case);
            }

            m_strPartNumber = Case.m_strPartNumber;
            m_Caliber       = Case.m_Caliber;
            m_fMatch        = Case.m_fMatch;
            m_fMilitary     = Case.m_fMilitary;
            m_fLargePrimer  = Case.m_fLargePrimer;
            m_fSmallPrimer  = Case.m_fSmallPrimer;
        }
Exemplo n.º 5
0
        //============================================================================*
        // Synch() - Case
        //============================================================================*

        public bool Synch(cCase Case)
        {
            if (m_Supply.SupplyType != cSupply.eSupplyTypes.Cases)
            {
                return(false);
            }

            if ((m_Supply as cCase).CompareTo(Case) == 0)
            {
                m_Supply = Case;

                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        //============================================================================*
        // Append()
        //============================================================================*

        public int Append(cCase Case, bool fCountOnly = false)
        {
            int nUpdateCount = base.Append(Case, fCountOnly);

            if (!m_fMatch && Case.m_fMatch)
            {
                if (fCountOnly)
                {
                    m_fMatch = Case.m_fMatch;
                }

                nUpdateCount++;
            }

            if (!m_fMilitary && Case.m_fMilitary)
            {
                if (fCountOnly)
                {
                    m_fMilitary = Case.m_fMilitary;
                }

                nUpdateCount++;
            }

            if (!m_fLargePrimer && Case.m_fLargePrimer)
            {
                if (fCountOnly)
                {
                    m_fLargePrimer = Case.m_fLargePrimer;
                }

                nUpdateCount++;
            }

            if (!m_fSmallPrimer && Case.m_fSmallPrimer)
            {
                if (fCountOnly)
                {
                    m_fSmallPrimer = Case.m_fSmallPrimer;
                }

                nUpdateCount++;
            }

            return(nUpdateCount);
        }
        //============================================================================*
        // PopulateChargeListView()
        //============================================================================*

        private void PopulateChargeListView()
        {
            //----------------------------------------------------------------------------*
            // ChargeListView Data
            //----------------------------------------------------------------------------*

            cFirearm.eFireArmType FirearmType = m_Load.FirearmType;
            cCaliber Caliber = m_Load.Caliber;
            cPowder  Powder  = m_Load.Powder;

            cBullet Bullet = MatchBulletRadioButton.Checked ? m_Load.Bullet : null;
            cPrimer Primer = MatchPrimerRadioButton.Checked ? m_Load.Primer : null;
            cCase   Case   = MatchCaseRadioButton.Checked ? m_Load.Case : null;

            m_ChargeListView.Populate(FirearmType, Caliber, Bullet, m_Load.Bullet.Weight, Powder, Primer, Case);

            UpdateButtons();
        }
Exemplo n.º 8
0
        //============================================================================*
        // Comparer()
        //============================================================================*

        public static int Comparer(cCase Case1, cCase Case2)
        {
            if (Case1 == null)
            {
                if (Case2 != null)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                if (Case2 == null)
                {
                    return(1);
                }
            }

            return(Case1.CompareTo(Case2));
        }
Exemplo n.º 9
0
        //============================================================================*
        // cCaseForm() - Constructor
        //============================================================================*

        public cCaseForm(cCase Case, cDataFiles DataFiles, bool fViewOnly = false)
        {
            InitializeComponent();

            m_DataFiles = DataFiles;
            m_fViewOnly = fViewOnly;

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

                m_fAdd = true;

                if (m_DataFiles.Preferences.LastCase == null)
                {
                    m_Case = new cCase();
                }
                else
                {
                    m_Case = new cCase(m_DataFiles.Preferences.LastCase);
                }

                m_Case.Military = false;

                m_Case.PartNumber     = "";
                m_Case.Quantity       = 0.0;
                m_Case.QuantityOnHand = 0.0;
                m_Case.Cost           = 0.0;

                m_Case.TotalAdjustQty    = 0.0;
                m_Case.TotalPurchaseCost = 0.0;
                m_Case.TotalPurchaseQty  = 0.0;
                m_Case.TotalUsedQty      = 0.0;

                m_Case.TransactionList.Clear();
                m_Case.RecalculateInventory(m_DataFiles);

                CaseOKButton.Text = "Add";
            }
            else
            {
                m_Case = new cCase(Case);

                m_OriginalCase = new cCase(m_Case);

                if (m_fViewOnly)
                {
                    CaseOKButton.Visible = false;

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

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

                    CaseCancelButton.Text = "Close";
                }
                else
                {
                    CaseOKButton.Text = "Update";
                }
            }

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

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

            if (!m_fViewOnly)
            {
                FirearmTypeCombo.SelectedIndexChanged += OnFirearmTypeSelectedChanged;
                CrossUseCheckBox.Click += OnCrossUseClicked;
                ManufacturerCombo.SelectedIndexChanged += OnManufacturerSelectedChanged;
                PartNumberTextBox.TextChanged          += OnPartNumberChanged;
                CaliberCombo.SelectedIndexChanged      += OnCaliberChanged;
                SmallPrimerRadioButton.Click           += OnSmallPrimerClicked;
                LargePrimerRadioButton.Click           += OnLargePrimerClicked;
                MatchCheckBox.Click    += OnMatchClicked;
                MilitaryCheckBox.Click += OnMilitaryClicked;

                QuantityTextBox.TextChanged += OnQuantityChanged;
                CostTextBox.TextChanged     += OnPriceChanged;
            }
            else
            {
                QuantityTextBox.ReadOnly = true;

                CostTextBox.ReadOnly = true;
            }

            InventoryButton.Click += OnInventoryClicked;

            //----------------------------------------------------------------------------*
            // 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);
            }

            //----------------------------------------------------------------------------*
            // Populate Combo Boxes
            //----------------------------------------------------------------------------*

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

            PopulateCaliberCombo();

            if (!m_fViewOnly)
            {
                cControls.PopulateManufacturerCombo(ManufacturerCombo, m_DataFiles, m_Case.Manufacturer, cFirearm.eFireArmType.None, (int)cSupply.eSupplyTypes.Cases);
            }
            else
            {
                ManufacturerCombo.Items.Add(m_Case.Manufacturer);

                ManufacturerCombo.SelectedIndex = 0;
            }

            if (m_Case.Manufacturer == null)
            {
                m_Case.Manufacturer = (cManufacturer)ManufacturerCombo.SelectedItem;
            }

            //----------------------------------------------------------------------------*
            // Fill in Case data
            //----------------------------------------------------------------------------*

            PartNumberTextBox.Text   = m_Case.PartNumber;
            MatchCheckBox.Checked    = m_Case.Match;
            MilitaryCheckBox.Checked = m_Case.Military;

            HeadStampLabel.Text = m_Case.HeadStamp;

            if (!m_Case.LargePrimer && !m_Case.SmallPrimer)
            {
                if (m_Case.Caliber != null)
                {
                    if (m_Case.Caliber.LargePrimer && m_Case.Caliber.SmallPrimer)
                    {
                        m_Case.LargePrimer = true;
                    }
                    else
                    {
                        m_Case.LargePrimer = m_Case.Caliber.LargePrimer;
                        m_Case.SmallPrimer = m_Case.Caliber.SmallPrimer;
                    }
                }
            }

            SmallPrimerRadioButton.Checked = m_Case.SmallPrimer;
            LargePrimerRadioButton.Checked = m_Case.LargePrimer;

            SetCaseImage();

            PopulateInventoryData();

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

            string strTitle;

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

            strTitle += " Case";

            Text = strTitle;

            SetStaticToolTips();

            UpdateButtons();

            if (!m_fViewOnly)
            {
                FirearmTypeCombo.Focus();
            }
            else
            {
                CaseCancelButton.Focus();
            }

            m_fInitialized = true;
        }
        //============================================================================*
        // 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);
                }
            }

            cCase Case1 = (cCase)(Object1 as ListViewItem).Tag;
            cCase Case2 = (cCase)(Object2 as ListViewItem).Tag;

            if (Case1 == null)
            {
                if (Case2 == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (Case2 == null)
                {
                    return(1);
                }
            }

            bool fSpecial = false;
            int  rc       = 0;

            string strPart1 = "";
            string strPart2 = "";

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

            case 0:
                rc = Case1.Manufacturer.CompareTo(Case2.Manufacturer);

                if (rc == 0)
                {
                    strPart1 = Case1.PartNumber;
                    strPart2 = Case2.PartNumber;

                    if (strPart1.Length != strPart2.Length)
                    {
                        string strPad = "";

                        if (strPart1.Length < strPart2.Length)
                        {
                            while (strPart1.Length + strPad.Length < strPart2.Length)
                            {
                                strPad += " ";
                            }

                            strPart1 = strPad + strPart1;
                        }
                        else
                        {
                            while (strPart2.Length + strPad.Length < strPart1.Length)
                            {
                                strPad += " ";
                            }

                            strPart2 = strPad + strPart2;
                        }
                    }

                    rc = strPart1.CompareTo(strPart2);
                }

                fSpecial = true;

                break;

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

            case 1:
                rc = Case1.PartNumber.CompareTo(Case2.PartNumber);

                if (rc == 0)
                {
                    rc = Case1.Manufacturer.CompareTo(Case2.Manufacturer);
                }

                if (rc == 0)
                {
                    rc = cDataFiles.ComparePartNumbers(Case1.PartNumber, Case2.PartNumber);
                }

                fSpecial = true;

                break;

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

            case 2:
                rc = Case1.Caliber.CompareTo(Case2.Caliber);

                if (rc == 0)
                {
                    rc = Case1.Manufacturer.CompareTo(Case2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Case1.PartNumber, Case2.PartNumber);
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Match
            //----------------------------------------------------------------------------*

            case 6:
                rc = Case1.Match.CompareTo(Case2.Match);

                if (rc == 0)
                {
                    rc = Case1.Manufacturer.CompareTo(Case2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Case1.PartNumber, Case2.PartNumber);
                    }
                }

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Military
            //----------------------------------------------------------------------------*

            case 7:
                rc = Case1.Military.CompareTo(Case2.Military);

                if (rc == 0)
                {
                    rc = Case1.Manufacturer.CompareTo(Case2.Manufacturer);

                    if (rc == 0)
                    {
                        rc = cDataFiles.ComparePartNumbers(Case1.PartNumber, Case2.PartNumber);
                    }
                }

                fSpecial = true;

                break;

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

            case 8:
                double dQuantity1 = Case1.Quantity;
                double dQuantity2 = Case2.Quantity;

                if (m_DataFiles.Preferences.TrackInventory)
                {
                    dQuantity1 = Case1.QuantityOnHand;
                    dQuantity2 = Case2.QuantityOnHand;
                }

                rc = dQuantity1.CompareTo(dQuantity2);

                fSpecial = true;

                break;

            //----------------------------------------------------------------------------*
            // Cost
            //----------------------------------------------------------------------------*

            case 9:
                double dCost1 = 0.0;

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

                double dCost2 = 0.0;

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

                rc = dCost1.CompareTo(dCost2);

                fSpecial = true;

                break;
            }

            //----------------------------------------------------------------------------*
            // Return results
            //----------------------------------------------------------------------------*

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

                return(rc);
            }

            return(base.Compare(Object1, Object2));
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        //============================================================================*
        // OnPrintPage()
        //============================================================================*

        private void OnPrintPage(object sender, PrintPageEventArgs e)
        {
            //----------------------------------------------------------------------------*
            // Create the fonts
            //----------------------------------------------------------------------------*

//			Font TitleFont = new Font("Trebuchet MS", 16, FontStyle.Bold);
            Font SupplyTypeFont = new Font("Trebuchet MS", 14, FontStyle.Bold);
            Font HeaderFont     = new Font("Trebuchet MS", 10, FontStyle.Bold);
            Font DataFont       = new Font("Trebuchet MS", 8, FontStyle.Regular);

            //----------------------------------------------------------------------------*
            // Calculate Column Header Name Widths
            //----------------------------------------------------------------------------*

            string strText;
            SizeF  TextSize;

            foreach (cPrintColumn PrintColumn in m_BulletColumns)
            {
                TextSize = e.Graphics.MeasureString(PrintColumn.Name, HeaderFont);

                if (TextSize.Width > PrintColumn.Width)
                {
                    PrintColumn.Width = TextSize.Width;
                }
            }

            foreach (cPrintColumn PrintColumn in m_PowderColumns)
            {
                TextSize = e.Graphics.MeasureString(PrintColumn.Name, HeaderFont);

                if (TextSize.Width > PrintColumn.Width)
                {
                    PrintColumn.Width = TextSize.Width;
                }
            }

            foreach (cPrintColumn PrintColumn in m_CaseColumns)
            {
                TextSize = e.Graphics.MeasureString(PrintColumn.Name, HeaderFont);

                if (TextSize.Width > PrintColumn.Width)
                {
                    PrintColumn.Width = TextSize.Width;
                }
            }

            foreach (cPrintColumn PrintColumn in m_PrimerColumns)
            {
                TextSize = e.Graphics.MeasureString(PrintColumn.Name, HeaderFont);

                if (TextSize.Width > PrintColumn.Width)
                {
                    PrintColumn.Width = TextSize.Width;
                }
            }

            //----------------------------------------------------------------------------*
            // Calculate Header Widths for Supplies
            //----------------------------------------------------------------------------*

            foreach (cSupply Supply in m_SupplyList)
            {
                switch (Supply.SupplyType)
                {
                case cSupply.eSupplyTypes.Bullets:
                    TextSize = e.Graphics.MeasureString((Supply as cBullet).ToString(), DataFont);

                    if (TextSize.Width > m_BulletColumns[0].Width)
                    {
                        m_BulletColumns[0].Width = TextSize.Width;
                    }

                    break;

                case cSupply.eSupplyTypes.Powder:
                    TextSize = e.Graphics.MeasureString((Supply as cPowder).ToString(), DataFont);

                    if (TextSize.Width > m_PowderColumns[0].Width)
                    {
                        m_PowderColumns[0].Width = TextSize.Width;
                    }

                    break;

                case cSupply.eSupplyTypes.Primers:
                    TextSize = e.Graphics.MeasureString((Supply as cPrimer).ToShortString(), DataFont);

                    if (TextSize.Width > m_PrimerColumns[0].Width)
                    {
                        m_PrimerColumns[0].Width = TextSize.Width;
                    }

                    TextSize = e.Graphics.MeasureString((Supply as cPrimer).SizeString, DataFont);

                    if (TextSize.Width > m_PrimerColumns[1].Width)
                    {
                        m_PrimerColumns[1].Width = TextSize.Width;
                    }

                    TextSize = e.Graphics.MeasureString("0.00/1000", DataFont);

                    if (TextSize.Width > m_PrimerColumns[3].Width)
                    {
                        m_PrimerColumns[3].Width = TextSize.Width;
                    }
                    break;

                case cSupply.eSupplyTypes.Cases:
                    TextSize = e.Graphics.MeasureString((Supply as cCase).Manufacturer.Name, DataFont);

                    if (TextSize.Width > m_CaseColumns[0].Width)
                    {
                        m_CaseColumns[0].Width = TextSize.Width;
                    }

                    TextSize = e.Graphics.MeasureString((Supply as cCase).Caliber.ToString(), DataFont);

                    if (TextSize.Width > m_CaseColumns[2].Width)
                    {
                        m_CaseColumns[2].Width = TextSize.Width;
                    }

                    break;
                }
            }

            //----------------------------------------------------------------------------*
            // Loop through the supply types
            //----------------------------------------------------------------------------*

            Rectangle PageRect = e.PageBounds;

            int nXDPI = (int)((double)PageRect.Width / 8.5);
            int nYDPI = (int)((double)PageRect.Height / 11);

            PageRect.X     += (int)((double)nXDPI * 0.5);
            PageRect.Width -= ((int)((double)nXDPI * 0.5) * 2);

            PageRect.Y      += (int)((double)nYDPI * 0.5);
            PageRect.Height -= ((int)((double)nYDPI * 0.5) * 2);

            float nY = PageRect.Top;
            float nX = PageRect.Left;

            bool fPageHeader = false;

            for (int nSupplyType = 0; nSupplyType < (int)cSupply.eSupplyTypes.NumSupplyTypes; nSupplyType++)
            {
                cSupply.eSupplyTypes eSupplyType = (cSupply.eSupplyTypes)nSupplyType;

                //----------------------------------------------------------------------------*
                // Loop through the supplies in the list
                //----------------------------------------------------------------------------*

                bool fHeader = false;

                foreach (cSupply Supply in m_SupplyList)
                {
                    if (nY > PageRect.Bottom)
                    {
                        e.HasMorePages = true;

                        return;
                    }

                    //----------------------------------------------------------------------------*
                    // If this supply is not the right type, or has already been printed, skip
                    // to the next supply in the list
                    //----------------------------------------------------------------------------*

                    if (Supply.Printed || Supply.SupplyType != eSupplyType)
                    {
                        continue;
                    }

                    Supply.Printed = true;

                    //----------------------------------------------------------------------------*
                    // Draw the page header if needed
                    //----------------------------------------------------------------------------*

                    if (!fPageHeader)
                    {
                        //----------------------------------------------------------------------------*
                        // Draw the Title
                        //----------------------------------------------------------------------------*

                        nY = cPrintObject.PrintReportTitle("Load Shopping List", e, PageRect);

                        if (m_DataFiles.Preferences.TrackInventory)
                        {
                            strText = m_DataFiles.CostText;

                            TextSize = e.Graphics.MeasureString(strText, HeaderFont);

                            e.Graphics.DrawString(strText, HeaderFont, Brushes.Black, (PageRect.Width / 2) - (TextSize.Width / 2), nY);

                            nY += TextSize.Height;
                        }

                        nY += HeaderFont.Height;

                        fPageHeader = true;
                        fHeader     = false;
                    }

                    //----------------------------------------------------------------------------*
                    // Draw the supply type header if needed
                    //----------------------------------------------------------------------------*

                    if (!fHeader)
                    {
                        //----------------------------------------------------------------------------*
                        // Draw the supply type
                        //----------------------------------------------------------------------------*

                        switch (eSupplyType)
                        {
                        //----------------------------------------------------------------------------*
                        // Bullets
                        //----------------------------------------------------------------------------*

                        case cSupply.eSupplyTypes.Bullets:
                            strText = "Bullets";

                            TextSize = e.Graphics.MeasureString(strText, SupplyTypeFont);

                            nY += (TextSize.Height * (float)0.5);

                            e.Graphics.DrawString(strText, SupplyTypeFont, Brushes.Black, nX, nY);

                            nY += (TextSize.Height * (float)1.5);
                            nX  = PageRect.Left;

                            foreach (cPrintColumn PrintColumn in m_BulletColumns)
                            {
                                e.Graphics.DrawString(PrintColumn.Name, HeaderFont, Brushes.Black, nX, nY);

                                nX += (PrintColumn.Width + 20);
                            }

                            TextSize = e.Graphics.MeasureString(m_BulletColumns[0].Name, HeaderFont);

                            nY += TextSize.Height;

                            e.Graphics.DrawLine(Pens.Black, PageRect.Left, nY, nX, nY);

                            nX = PageRect.Left;

                            break;

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

                        case cSupply.eSupplyTypes.Powder:
                            strText = "Powder";

                            TextSize = e.Graphics.MeasureString(strText, SupplyTypeFont);

                            nY += (TextSize.Height * (float)0.5);

                            e.Graphics.DrawString(strText, SupplyTypeFont, Brushes.Black, nX, nY);

                            nY += (TextSize.Height * (float)1.5);
                            nX  = PageRect.Left;

                            foreach (cPrintColumn PrintColumn in m_PowderColumns)
                            {
                                e.Graphics.DrawString(PrintColumn.Name, HeaderFont, Brushes.Black, nX, nY);

                                nX += (PrintColumn.Width + 20);
                            }

                            TextSize = e.Graphics.MeasureString(m_PowderColumns[0].Name, HeaderFont);

                            nY += TextSize.Height;

                            e.Graphics.DrawLine(Pens.Black, PageRect.Left, nY, nX, nY);

                            nX = PageRect.Left;

                            break;

                        //----------------------------------------------------------------------------*
                        // Primers
                        //----------------------------------------------------------------------------*

                        case cSupply.eSupplyTypes.Primers:
                            strText = "Primers";

                            TextSize = e.Graphics.MeasureString(strText, SupplyTypeFont);

                            nY += (TextSize.Height * (float)0.5);

                            e.Graphics.DrawString(strText, SupplyTypeFont, Brushes.Black, nX, nY);

                            nY += (TextSize.Height * (float)1.5);
                            nX  = PageRect.Left;

                            foreach (cPrintColumn PrintColumn in m_PrimerColumns)
                            {
                                e.Graphics.DrawString(PrintColumn.Name, HeaderFont, Brushes.Black, nX, nY);

                                nX += (PrintColumn.Width + 20);
                            }

                            TextSize = e.Graphics.MeasureString(m_PrimerColumns[0].Name, HeaderFont);

                            nY += TextSize.Height;

                            e.Graphics.DrawLine(Pens.Black, PageRect.Left, nY, nX, nY);

                            nX = PageRect.Left;


                            break;

                        //----------------------------------------------------------------------------*
                        // Cases
                        //----------------------------------------------------------------------------*

                        case cSupply.eSupplyTypes.Cases:
                            strText = "Cases";

                            TextSize = e.Graphics.MeasureString(strText, SupplyTypeFont);

                            nY += (TextSize.Height * (float)0.5);

                            e.Graphics.DrawString(strText, SupplyTypeFont, Brushes.Black, nX, nY);

                            nY += (TextSize.Height * (float)1.5);
                            nX  = PageRect.Left;

                            foreach (cPrintColumn PrintColumn in m_CaseColumns)
                            {
                                e.Graphics.DrawString(PrintColumn.Name, HeaderFont, Brushes.Black, nX, nY);

                                nX += (PrintColumn.Width + 20);
                            }

                            TextSize = e.Graphics.MeasureString(m_CaseColumns[0].Name, HeaderFont);

                            nY += TextSize.Height;

                            e.Graphics.DrawLine(Pens.Black, PageRect.Left, nY, nX, nY);

                            nX = PageRect.Left;

                            break;
                        }

                        fHeader = true;
                    }

                    //----------------------------------------------------------------------------*
                    // Draw the supply info
                    //----------------------------------------------------------------------------*

                    switch (eSupplyType)
                    {
                    //----------------------------------------------------------------------------*
                    // Bullets
                    //----------------------------------------------------------------------------*

                    case cSupply.eSupplyTypes.Bullets:
                        cBullet Bullet = (cBullet)Supply;

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

                        strText = Bullet.ToString();

                        nX = PageRect.Left;

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_BulletColumns[0].Width + 20);

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

                        strText = String.Format("{0:F3}", Bullet.Diameter);

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_BulletColumns[1].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_BulletColumns[1].Width + 20);

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

                        strText = String.Format("{0:G0}", Bullet.Weight);

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_BulletColumns[2].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_BulletColumns[2].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Qty on Hand
                        //----------------------------------------------------------------------------*

                        double dQuantity = m_DataFiles.SupplyQuantity(Supply);

                        if (m_DataFiles.Preferences.TrackInventory)
                        {
                            if (dQuantity != 0.0)
                            {
                                strText = String.Format("{0:G0}", dQuantity);
                            }
                            else
                            {
                                strText = "-";
                            }
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_BulletColumns[3].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_BulletColumns[3].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Estimated Cost
                        //----------------------------------------------------------------------------*

                        if (dQuantity != 0.0)
                        {
                            strText = String.Format("{0}{1:F2}/100", m_DataFiles.Preferences.Currency, m_DataFiles.SupplyCostEach(Supply) * 100.0);
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + m_BulletColumns[4].Width - TextSize.Width, nY);

                        nX = PageRect.Left;

                        nY += TextSize.Height;

                        break;

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

                    case cSupply.eSupplyTypes.Powder:
                        cPowder Powder = (cPowder)Supply;

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

                        strText = Powder.ToString();

                        nX = PageRect.Left;

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_PowderColumns[0].Width + 20);

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

                        strText = Powder.FirearmType.ToString();

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_PowderColumns[1].Width + 20);

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

                        strText = Powder.Shape.ToString();

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_PowderColumns[2].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Qty on Hand
                        //----------------------------------------------------------------------------*

                        dQuantity = cDataFiles.StandardToMetric(m_DataFiles.SupplyQuantity(Powder) / 7000.0, cDataFiles.eDataType.CanWeight);

                        if (m_DataFiles.Preferences.TrackInventory)
                        {
                            if (dQuantity != 0.0)
                            {
                                strText = String.Format("{0:F3}", dQuantity);
                            }
                            else
                            {
                                strText = "-";
                            }
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_PowderColumns[3].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_PowderColumns[3].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Estimated Cost
                        //----------------------------------------------------------------------------*

                        if (dQuantity != 0.0)
                        {
                            strText = String.Format("{0}{1:F2}/{2}", m_DataFiles.Preferences.Currency, cDataFiles.StandardToMetric(m_DataFiles.SupplyCostEach(Powder) * 7000.0, cDataFiles.eDataType.CanWeight), cDataFiles.MetricString(cDataFiles.eDataType.CanWeight));
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + m_PowderColumns[4].Width - TextSize.Width, nY);

                        nX = PageRect.Left;

                        nY += TextSize.Height;

                        break;

                    //----------------------------------------------------------------------------*
                    // Primers
                    //----------------------------------------------------------------------------*

                    case cSupply.eSupplyTypes.Primers:
                        cPrimer Primer = (cPrimer)Supply;

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

                        strText = Primer.ToShortString();

                        nX = PageRect.Left;

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_PrimerColumns[0].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Size
                        //----------------------------------------------------------------------------*

                        strText = Primer.Size.ToString();

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_PrimerColumns[1].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Magnum
                        //----------------------------------------------------------------------------*

                        strText = Primer.Magnum ? "Yes" : "No";

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_PrimerColumns[2].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_PrimerColumns[2].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Qty on Hand
                        //----------------------------------------------------------------------------*

                        dQuantity = m_DataFiles.SupplyQuantity(Supply);

                        if (m_DataFiles.Preferences.TrackInventory)
                        {
                            if (dQuantity != 0.0)
                            {
                                strText = String.Format("{0:G0}", dQuantity);
                            }
                            else
                            {
                                strText = "-";
                            }
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_PrimerColumns[3].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_PrimerColumns[3].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Estimated Cost
                        //----------------------------------------------------------------------------*

                        if (dQuantity != 0.0)
                        {
                            strText = String.Format("{0}{1:F2}/1000", m_DataFiles.Preferences.Currency, m_DataFiles.SupplyCostEach(Supply) * 1000);
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + m_PrimerColumns[4].Width - TextSize.Width, nY);

                        nX = PageRect.Left;

                        nY += TextSize.Height;

                        break;

                    //----------------------------------------------------------------------------*
                    // Cases
                    //----------------------------------------------------------------------------*

                    case cSupply.eSupplyTypes.Cases:
                        cCase Case = (cCase)Supply;

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

                        strText = Case.Manufacturer.ToString();

                        nX = PageRect.Left;

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_CaseColumns[0].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Match
                        //----------------------------------------------------------------------------*

                        strText = "Y";

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        if (Case.Match)
                        {
                            e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_CaseColumns[1].Width / 2) - (TextSize.Width / 2), nY);
                        }

                        nX += (m_CaseColumns[1].Width + 20);

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

                        strText = Case.Caliber.ToString();

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX, nY);

                        nX += (m_CaseColumns[2].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Qty on Hand
                        //----------------------------------------------------------------------------*

                        dQuantity = m_DataFiles.SupplyQuantity(Supply);

                        if (m_DataFiles.Preferences.TrackInventory)
                        {
                            if (dQuantity != 0.0)
                            {
                                strText = String.Format("{0:G0}", dQuantity);
                            }
                            else
                            {
                                strText = "-";
                            }
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + (m_CaseColumns[3].Width / 2) - (TextSize.Width / 2), nY);

                        nX += (m_CaseColumns[3].Width + 20);

                        //----------------------------------------------------------------------------*
                        // Estimated Cost
                        //----------------------------------------------------------------------------*

                        if (dQuantity != 0.0)
                        {
                            strText = String.Format("{0}{1:F2}/100", m_DataFiles.Preferences.Currency, m_DataFiles.SupplyCostEach(Supply) * 100);
                        }
                        else
                        {
                            strText = "-";
                        }

                        TextSize = e.Graphics.MeasureString(strText, DataFont);

                        e.Graphics.DrawString(strText, DataFont, Brushes.Black, nX + m_CaseColumns[4].Width - TextSize.Width, nY);

                        nX = PageRect.Left;

                        nY += TextSize.Height;

                        break;
                    }
                }
            }

            e.HasMorePages = false;

            ResetPrintedFlag();
        }
Exemplo n.º 13
0
        //============================================================================*
        // ResolveIdentities()
        //============================================================================*

        public bool ResolveIdentities(cDataFiles DataFiles)
        {
            bool fChanged = false;

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

            if (m_Caliber.Identity)
            {
                foreach (cCaliber Caliber in DataFiles.CaliberList)
                {
                    if (!Caliber.Identity && Caliber.CompareTo(m_Caliber) == 0)
                    {
                        m_Caliber = Caliber;

                        fChanged = true;

                        break;
                    }
                }
            }

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

            if (m_Bullet.Identity)
            {
                foreach (cBullet Bullet in DataFiles.BulletList)
                {
                    if (!Bullet.Identity && m_Bullet.CompareTo(Bullet) == 0)
                    {
                        m_Bullet = Bullet;

                        fChanged = true;

                        break;
                    }
                }
            }

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

            if (m_Case.Identity)
            {
                foreach (cCase Case in DataFiles.CaseList)
                {
                    if (!Case.Identity && m_Case.CompareTo(Case) == 0)
                    {
                        m_Case = Case;

                        fChanged = true;

                        break;
                    }
                }
            }

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

            if (m_Powder.Identity)
            {
                foreach (cPowder Powder in DataFiles.PowderList)
                {
                    if (!Powder.Identity && m_Powder.CompareTo(Powder) == 0)
                    {
                        m_Powder = Powder;

                        fChanged = true;

                        break;
                    }
                }
            }

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

            if (m_Primer.Identity)
            {
                foreach (cPrimer Primer in DataFiles.PrimerList)
                {
                    if (!Primer.Identity && m_Primer.CompareTo(Primer) == 0)
                    {
                        m_Primer = Primer;

                        fChanged = true;

                        break;
                    }
                }
            }

            //----------------------------------------------------------------------------*
            // Charge List
            //----------------------------------------------------------------------------*

            fChanged = m_ChargeList.ResolveIdentities(DataFiles) ? true : fChanged;

            return(fChanged);
        }
Exemplo n.º 14
0
        //============================================================================*
        // cCase() - Copy Constructor
        //============================================================================*

        public cCase(cCase Case)
            : base(Case)
        {
            Copy(Case, false);
        }
Exemplo n.º 15
0
        //============================================================================*
        // PopulateCaliberCombo() - Case
        //============================================================================*

        public static void PopulateCaliberCombo(ComboBox CaliberCombo, cDataFiles DataFiles, cCase Case, cFirearm.eFireArmType eFirearmType = cFirearm.eFireArmType.None)
        {
            CaliberCombo.Items.Clear();

            cCaliber.CurrentFirearmType = eFirearmType;

            cCaliber SelectCaliber = null;

            foreach (cCaliber CheckCaliber in DataFiles.CaliberList)
            {
                if ((!DataFiles.Preferences.HideUncheckedCalibers || CheckCaliber.Checked) && !CheckCaliber.Rimfire)
                {
                    if (eFirearmType == cFirearm.eFireArmType.None || CheckCaliber.FirearmType == eFirearmType)
                    {
                        CaliberCombo.Items.Add(CheckCaliber);

                        if (Case != null && SelectCaliber == null && Case.Caliber != null && Case.Caliber.CompareTo(CheckCaliber) == 0)
                        {
                            SelectCaliber = CheckCaliber;
                        }
                    }
                }
            }

            if (SelectCaliber != null)
            {
                CaliberCombo.SelectedItem = SelectCaliber;

                if (CaliberCombo.SelectedIndex < 0 && CaliberCombo.Items.Count > 0)
                {
                    CaliberCombo.SelectedIndex = 0;
                }
            }
            else
            {
                if (Case != null && Case.Caliber != null)
                {
                    if (!CaliberCombo.Items.Contains(Case.Caliber))
                    {
                        CaliberCombo.Items.Add(Case.Caliber);
                    }

                    CaliberCombo.SelectedItem = Case.Caliber;
                }

                if (CaliberCombo.SelectedIndex == -1 && CaliberCombo.Items.Count > 0)
                {
                    CaliberCombo.SelectedIndex = 0;
                }
            }
        }