/// <summary> /// Allocate a new MoleculeGridPageControl /// and link into any associated QueryResultsContol /// </summary> /// <param name="qm"></param> /// <param name="container"></param> /// <returns></returns> public static MoleculeGridPageControl AllocateNewMoleculeGridPageControl( QueryManager qm, Control container) { QueryResultsControl qrc = null; PopupGrid pug = null; MoleculeGridPageControl page; MoleculeGridPanel panel; MoleculeGridControl grid; Query q = qm.Query; ResultsFormat rf = qm.ResultsFormat; page = new MoleculeGridPageControl(); // Create a new, clean page, panel and grids panel = page.MoleculeGridPanel; grid = panel.SelectBaseGridViewGrid(qm); qm.LinkMember(grid); // link grid into qm grid.ShowCheckMarkCol = q.ShowGridCheckBoxes; if (container is QueryResultsControl && rf.NotPopupOutputFormContext) // normal query results { qrc = container as QueryResultsControl; qrc.RemoveExistingControlsFromResultsPageControlContainer(); // properly dispose of any existing DevExpress controls qrc.MoleculeGridPageControl = page; // link query results to this page qrc.ResultsPageControlContainer.Controls.Add(page); page.Dock = DockStyle.Fill; } return(page); }
/// <summary> /// /// </summary> /// <param name="gridPanel"></param> /// <param name="qm"></param> public static void DisplayData( MoleculeGridPanel gridPanel, QueryManager qm) { if (gridPanel == null) // if grid panel not defined assume display is in normal results panel { gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel; QbUtil.SetMode(QueryMode.Browse); // put into browse mode } else if (gridPanel.Parent is PopupGrid) // display in popup grid { PopupGrid pug = gridPanel.Parent as PopupGrid; pug.Initialize(qm); // be sure popup is initialized WindowsHelper.FitFormOnScreen(pug); pug.Show(); } MoleculeGridControl grid = qm.MoleculeGrid; gridPanel.Visible = true; grid.Visible = true; grid.DataSource = qm.DataTable; // set the datasource for the grid to the datatable RefreshDataDisplay(qm); }
/// <summary> /// DisplayStructureInPopupGrid /// </summary> /// <param name="title"></param> /// <param name="cidLabel"></param> /// <param name="structLabel"></param> /// <param name="structure"></param> public static void DisplayStructureInPopupGrid( string title, string cidLabel, string structLabel, MoleculeMx structure) { List <MoleculeMx> structures = new List <MoleculeMx>(); structures.Add(structure); PopupGrid pg = new PopupGrid(); bool embedDataInQuery = false; DisplayStructures(title, cidLabel, structLabel, structures, pg.MoleculeGridPanel, embedDataInQuery); return; }
public void Initialize(QueryManager qm) { Qm = qm; StatusBarManager sbm = new StatusBarManager(); qm.LinkMember(sbm); sbm.SetupViewZoomControls(null, ZoomPctBarItem, ZoomSlider); sbm.ZoomSliderPct = 100; // set to 100% initially if (LastGridCreated != null && LastGridCreated.WindowState == FormWindowState.Normal) { try { Size = LastGridCreated.Size; } catch (Exception ex) { ex = ex; } } LastGridCreated = this; }
/// <summary> /// Display the tool data /// </summary> /// <param name="qm"></param> /// <param name="serializeContentInQuery"></param> public static void DisplayDataOld( // Old version from 1/4/2017 QueryManager qm, MoleculeGridPanel gridPanel, bool serializeContentInQuery, bool fitDataToGridWidth = false) { MoleculeGridControl grid = null; bool displayAsNormalQueryResults = (gridPanel == null); // if grid panel not defined assume display is in normal results panel bool displayAsPopupGrid = (gridPanel != null && gridPanel.Parent is PopupGrid); // display in popup grid Query q = qm.Query; q.SetupQueryPagesAndViews(); // be sure we have a default view page if (serializeContentInQuery) { // no database behind this table so persist within the query MetaTable mt = q.Tables[0].MetaTable; // assume just one metatable foreach (MetaColumn mc in mt.MetaColumns) // no criteria allowed { mc.IsSearchable = false; } q.SerializeMetaTablesWithQuery = true; // if no broker then save the metatable definition q.SerializeResultsWithQuery = true; // also save results when saving the query q.BrowseSavedResultsUponOpen = true; // open the results when the query is opened q.ResultsDataTable = qm.DataTable; // point the query to this results table } ResultsFormatFactory rff = new ResultsFormatFactory(qm, OutputDest.WinForms); rff.Build(); // build format ResultsFormatter fmtr = new ResultsFormatter(qm); // and formatter if (displayAsNormalQueryResults) { gridPanel = SessionManager.Instance.QueryResultsControl.MoleculeGridPageControl.MoleculeGridPanel; QbUtil.AddQuery(qm.Query); // add to the list of visible queries QueriesControl.Instance.CurrentBrowseQuery = qm.Query; // make it current } grid = gridPanel.SelectBaseGridViewGrid(qm); //if (qm.ResultsFormat.UseBandedGridView) // grid = gridPanel.BandedViewGrid; //else grid = gridPanel.LayoutViewGrid; qm.MoleculeGrid = grid; grid.QueryManager = qm; DataTableMx dt = qm.DataTable; // save ref to data table grid.DataSource = null; // clear source for header build if (fitDataToGridWidth && grid.BGV != null) { grid.BGV.OptionsView.ColumnAutoWidth = true; // set view for auto width to fit within view } grid.FormatGridHeaders(qm.ResultsFormat); qm.DataTable = dt; // restore data table qm.DataTableManager.SetResultsKeysFromDatatable(); // set the results keys if (displayAsNormalQueryResults) { QbUtil.SetMode(QueryMode.Browse); // put into browse mode } else if (displayAsPopupGrid) { PopupGrid pug = gridPanel.Parent as PopupGrid; pug.Initialize(qm); // be sure popup is initialized pug.Show(); } gridPanel.Visible = true; grid.Visible = true; grid.DataSource = qm.DataTable; // set the datasource for the grid to the datatable RefreshDataDisplay(qm); return; }
/// <summary> /// Create and execute the drill down query /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BuildAndRunDrillDownQuery(object sender, PivotCellEventArgs e) { object o; PivotDrillDownDataSource ds = e.CreateDrillDownDataSource(); if (ds.RowCount <= 0) { return; // no data } Query q2 = Qm.Query.Clone(); q2.ShowGridCheckBoxes = false; // Build name for drilldown from row and column fields values string txt = ""; PivotGridField[] rf = e.GetRowFields(); PivotGridField[] ca = e.GetColumnFields(); Array.Resize(ref rf, rf.Length + ca.Length); Array.Copy(ca, 0, rf, rf.Length - ca.Length, ca.Length); foreach (PivotGridField f in rf) { o = e.GetFieldValue(f); if (o != null && o.ToString() != "") { if (txt != "") { txt += ", "; } txt += o.ToString(); } } if (e.ColumnValueType == PivotGridValueType.GrandTotal || e.RowValueType == PivotGridValueType.GrandTotal) { txt += " Grand Total"; } else if (e.ColumnValueType == PivotGridValueType.Total || e.RowValueType == PivotGridValueType.Total) { txt += " Total"; } q2.UserObject.Name = txt; // Create DataTable containing drill down data DataTableMx dt2 = DataTableManager.BuildDataTable(q2); for (int ri = 0; ri < ds.RowCount; ri++) { // copy rows over DataRowMx dr2 = dt2.NewRow(); object[] vo = dr2.ItemArrayRef; // get ref to the item array for (int ci = 0; ci < dt2.Columns.Count; ci++) { //if (ci == 14) ci = ci; // debug vo[ci] = ds.GetValue(ri, ci); // direct copy into ItemArray } dt2.Rows.Add(dr2); } QueryManager qm2 = ToolHelper.SetupQueryManager(q2, dt2); qm2.ResultsFormat.OutputFormContext = OutputFormContext.Popup; PopupGrid pug = new PopupGrid(qm2); MoleculeGridPanel.ConfigureAndShow(qm2, pug); return; }
/// <summary> /// Format grid and show the data /// </summary> /// <param name="qm"></param> /// <param name="container">Either a QueryResultsControl or a PopupGrid</param> public static void ConfigureAndShow( QueryManager qm, Control container) { QueryResultsControl qrc = null; PopupGrid pug = null; MoleculeGridPageControl page; MoleculeGridPanel panel; MoleculeGridControl grid; Query q = qm.Query; ResultsFormat rf = qm.ResultsFormat; //qm.QueryResultsControl = null; page = new MoleculeGridPageControl(); // Create a new, clean page, panel and grids panel = page.MoleculeGridPanel; grid = panel.SelectBaseGridViewGrid(qm); qm.LinkMember(grid); // link grid into qm grid.ShowCheckMarkCol = q.ShowGridCheckBoxes; DataTableMx dt = qm.DataTable; // save ref to data table grid.DataSource = null; // clear source for header build qm.DataTable = dt; // restore data table grid.FormatGridHeaders(qm.ResultsFormat); // qm.MoleculeGrid.V.Columns.Count should be set for proper cols if (container is QueryResultsControl && rf.NotPopupOutputFormContext) // normal query results { qrc = container as QueryResultsControl; qrc.RemoveExistingControlsFromResultsPageControlContainer(); // properly dispose of any existing DevExpress controls qrc.MoleculeGridPageControl = page; // link query results to this page qrc.ResultsPageControlContainer.Controls.Add(page); page.Dock = DockStyle.Fill; //qm.QueryResultsControl = qrc; // link view set into query manager (used for filtering) if (q.Parent == null) // switch display to browse mode if root query { QbUtil.SetMode(QueryMode.Browse, q); } if (rf.Query.LogicType == QueryLogicType.And) // log grid query by logic type { UsageDao.LogEvent("QueryGridAnd", ""); } else if (rf.Query.LogicType == QueryLogicType.Or) { UsageDao.LogEvent("QueryGridOr", ""); } else if (rf.Query.LogicType == QueryLogicType.Complex) { UsageDao.LogEvent("QueryGridComplex", ""); } } else if (container is PopupGrid || rf.PopupOutputFormContext) // popup results { if (container is PopupGrid) { pug = container as PopupGrid; } else // create a popup { pug = new PopupGrid(qm); pug.Text = q.UserObject.Name; } if (pug.Controls.ContainsKey(panel.Name)) // remove any existing panel control { pug.Controls.RemoveByKey(panel.Name); } pug.Controls.Add(panel); pug.MoleculeGridPanel = panel; // restore direct link as well grid.ScaleView(q.ViewScale); UIMisc.PositionPopupForm(pug); pug.Text = q.UserObject.Name; pug.Show(); } else { throw new Exception("Invalid container type: " + container.GetType()); } // Set the DataSource to the real DataTable panel.SetDataSource(qm, dt); return; }