Ejemplo n.º 1
0
        /// <summary>
        /// Set the DataSource for the grid
        /// </summary>
        /// <param name="qm"></param>
        /// <param name="dt"></param>

        public void SetDataSource(
            QueryManager qm,
            DataTableMx dt)
        {
            DataTableManager dtm = qm.DataTableManager;

            if (dtm != null)
            {             // be sure DataTable is ready for display
                //dtm.FiltersEnabled = false; // filters not enabled on entry
                //dtm.InitializeRowAttributes(true);
                //dtm.ApplyFilters();
                //dtm.UpdateFilterState();

                //if (QueryManager.StatusBarManager != null)
                //  QueryManager.StatusBarManager.DisplayFilterCountsAndString();
            }

            Grid.DataSource = dt;     // set the datasource for the grid to the datatable
            Grid.ForceRefilter();     // (why?)
            Grid.Refresh();
            Grid.Focus();             // place focus on grid so page up/down & scroll keys work
        }
Ejemplo n.º 2
0
/// <summary>
/// Setup & show the dialog
/// </summary>
/// <param name="queryManager"></param>
/// <param name="control"></param>
/// <returns></returns>

        public new static DialogResult Show(
            QueryManager queryManager,
            IPrintable control)
        {
// When the GridView is active we can mostly the standard DevExpress printing stuff.
// We just remove the Checkmark boxes and make sure all data is read in before starting the print.
// However, when LayoutView is active (Cids & structures only) we must work around a couple of issues.
// 1. Use CardView instead of LayoutView because LayoutView cards get split between pages.
// 2. Scaling does not put the proper number of cards per row. Fix by scaling the cards rather
//    than the print Document.
//
// Print scaling is persisted in Query.PrintScale

            if (Instance == null)
            {
                Instance = new PrintPreviewDialog();
            }
            Instance.Qm = queryManager;
            Query query = queryManager.Query;

            Instance.Control = control;

            if (control is MoleculeGridControl)
            {
                int    printScalePct = query.PrintScale;              // scale the document
                double scale         = printScalePct / 100.0;
                queryManager.ResultsFormat.PageScale = printScalePct; // do view scaling based on printScale

                MoleculeGridControl grid = control as MoleculeGridControl;
                ResultsFormat       rf   = queryManager.ResultsFormat;
                queryManager.DataTableManager.ResetFormattedBitmaps(); // for structures to be redrawn in correct size

                if (rf.UseBandedGridView)                              // hide check mark band for printing
                {
                    BandedGridView bgv = grid.MainView as BandedGridView;
                    if (Lex.Eq(bgv.Bands[0].Name, "CheckMark"))                     // hide checkmark band
                    {
                        bgv.Bands[0].Visible = false;
                    }

                    if (printScalePct > 0)
                    {
                        grid.ScaleBandedGridView(scale);                                        // scale the BandedGridView
                    }
                }

                else                 // switch to special card view for printing
                {
                    CardView cv = grid.GetCardView();
                    grid.MainView = cv;
                    string keyLabel = queryManager.Query.Tables[0].MetaTable.KeyMetaColumn.Label;
                    cv.CardCaptionFormat = keyLabel + ": {2}";                     // set proper caption

                    if (printScalePct > 0)
                    {
                        grid.ScaleCardView(scale);                                        // scale the CardView
                    }
                }

                DialogResult dr = ShowDialog(grid);

                // Reset the grid view

                queryManager.DataTableManager.ResetFormattedBitmaps();  // clear struct bitmaps so they get redrawn in correct size
                queryManager.ResultsFormat.PageScale = query.ViewScale; // switch back to doing view scaling based on viewScale

                if (rf.UseBandedGridView)                               // unhide check mark band
                {
                    BandedGridView bgv = grid.MainView as BandedGridView;
                    bgv.Bands[0].Visible = true;
                    grid.ScaleBandedGridView(query.ViewScale / 100.0);                     // scale back for viewing
                }

                else                 // switch back to layout view
                {
                    grid.MainView = grid.GetLayoutView();
                }

                grid.Refresh();

                return(dr);
            }

            else if (control is PivotGridControlMx)
            {
                PivotGridControlMx grid = control as PivotGridControlMx;
                DialogResult       dr   = ShowDialog(grid);
                return(dr);
            }

            //else if (control is ChartControlMx)
            //{
            //	ChartControlMx chart = control as ChartControlMx;
            //	DialogResult dr = ShowDialog(chart);
            //	return dr;
            //}

            else
            {
                throw new Exception("Invalid control type: " + control.GetType());
            }
        }