Ejemplo n.º 1
0
        //============================================================================*
        // cSupplyListPreviewDialog() - Constructor
        //============================================================================*

        public cSupplyListPreviewDialog(cDataFiles DataFiles, ListView SuppliesListView)
        {
            m_DataFiles = DataFiles;

            if (m_DataFiles.Preferences.ShoppingListPreviewMaximized)
            {
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                Location   = m_DataFiles.Preferences.ShoppingListPreviewLocation;
                ClientSize = m_DataFiles.Preferences.ShoppingListPreviewSize;
            }

            if (m_DataFiles.Preferences.SupplyPrintBelowStock)
            {
                Text = String.Format("{0} Supplies Shopping List - Print Preview", Application.ProductName);
            }
            else
            {
                Text = String.Format("{0} Supplies List - Print Preview", Application.ProductName);
            }

            PrintDocument ShoppingListDocument = new PrintDocument();

            ShoppingListDocument.PrintPage += OnPrintPage;

            Document = ShoppingListDocument;

            UseAntiAlias = true;

            //----------------------------------------------------------------------------*
            // Set diameter and weight for bullet list header
            //----------------------------------------------------------------------------*

            m_BulletColumns[1].Name += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Dimension));
            m_BulletColumns[2].Name += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.BulletWeight));

            //----------------------------------------------------------------------------*
            // Set can weight for powder list header
            //----------------------------------------------------------------------------*

            m_PowderColumns[3].Name += String.Format(" ({0}s)", cDataFiles.MetricString(cDataFiles.eDataType.CanWeight));
            m_PowderColumns[4].Name += String.Format(" ({0}s)", cDataFiles.MetricString(cDataFiles.eDataType.CanWeight));

            //----------------------------------------------------------------------------*
            // Gather the list of supplies, reset flags, and exit
            //----------------------------------------------------------------------------*

            m_SupplyList = new cSupplyList();

            foreach (ListViewItem Item in SuppliesListView.Items)
            {
                cSupply Supply = (cSupply)Item.Tag;

                if (Supply != null && (!m_DataFiles.Preferences.SupplyPrintChecked || Supply.Checked))
                {
                    m_SupplyList.Add(Supply);
                }
            }

            //----------------------------------------------------------------------------*
            // Reset flags and exit
            //----------------------------------------------------------------------------*

            ResetPrintedFlag();

            m_fInitialized = true;
        }