/// <summary> /// Build tooltip for data row /// </summary> /// <param name="dri">Data row index</param> /// <returns></returns> internal SuperToolTip BuildDataRowTooltip( TooltipDimensionDef ttDim, int dri) { ColumnMapMsx cm; QueryTable qt; QueryColumn qc; MetaTable mt; MetaColumn mc; int i1, i2; if (BaseQuery == null || BaseQuery.Tables.Count == 0 || Dtm == null) { return(null); } qt = BaseQuery.Tables[0]; SuperToolTip s = new SuperToolTip(); s.MaxWidth = 200; s.AllowHtmlText = DefaultBoolean.True; ToolTipItem i = new ToolTipItem(); i.AllowHtmlText = DefaultBoolean.True; i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; ColumnMapCollection cml2 = new ColumnMapCollection(); // list of fields we'll actually display int strPos = -1; ColumnMapCollection cml = ttDim.Fields; if (cml.Count == 0) { return(s); } for (i1 = 0; i1 < cml.Count; i1++) { cm = cml[i1]; qc = cm.QueryColumn; if (qc == null || !cm.Selected) { continue; } //if (qc.IsKey) continue; if (qc.MetaColumn.DataType == MetaColumnType.Structure) { strPos = i1; } for (i2 = 0; i2 < cml2.Count; i2++) // see if already have the column { if (qc == cml2[i2].QueryColumn) { break; } } if (i2 < cml2.Count) { continue; } cml2.Add(cm); } if (cml2.Count == 0) { return(null); // no fields } if (strPos < 0 && ttDim.IncludeStructure) { // include str if requested & not already included qc = qt.FirstStructureQueryColumn; strPos = cml2.Count; // put str at end //strPos = keyPos + 1; // place str after key if (qc != null && qc.Selected) // regular selected Qc? { cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc)); } else // look in root table for a structure { mt = qt.MetaTable.Root; if (mt.FirstStructureMetaColumn != null) { qt = new QueryTable(mt); qc = new QueryColumn(); // add qc with no vo pos as indicator that must be selected qc.MetaColumn = mt.FirstStructureMetaColumn; qc.Selected = true; qt.AddQueryColumn(qc); cml2.ColumnMapList.Insert(strPos, ColumnMapMsx.BuildFromQueryColumn(qc)); } } } string keyVal = ""; foreach (ColumnMapMsx fli0 in cml2.ColumnMapList) // format each field { qc = fli0.QueryColumn; mc = qc.MetaColumn; i.Text += "<b>"; // build label if (!Lex.IsNullOrEmpty(fli0.ParameterName)) { i.Text += fli0.ParameterName; } else { i.Text += fli0.QueryColumn.ActiveLabel; } i.Text += ": </b>"; if (qc.VoPosition >= 0) { int ti = qc.QueryTable.TableIndex; int dri2 = Dtm.AdjustDataRowToCurrentDataForTable(dri, ti, true); DataRowMx dr = Qm.DataTable.Rows[dri2]; if (dr == null) { continue; } ResultsTable rt = Rf.Tables[ti]; object fieldValue = dr[qc.VoPosition]; if (!NullValue.IsNull(fieldValue)) { if (qc.IsKey) { keyVal = fieldValue.ToString(); } MobiusDataType mdt = MobiusDataType.ConvertToMobiusDataType(qc.MetaColumn.DataType, fieldValue); FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatField(qc, mdt); if (mc.DataType != MetaColumnType.Structure) { i.Text += ffi.FormattedText; i.Text += "<br>"; } else { i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap); } } else { i.Text += "<br>"; // no data } } else if (!Lex.IsNullOrEmpty(keyVal)) // select structure from db (may already have) { MoleculeMx cs = MoleculeUtil.SelectMoleculeForCid(keyVal, qc.MetaColumn.MetaTable); if (cs != null) { int width = ResultsFormatFactory.QcWidthInCharsToDisplayColWidthInMilliinches(mc.Width, ResultsFormat); FormattedFieldInfo ffi = Qm.ResultsFormatter.FormatStructure(cs, new CellStyleMx(), 's', 0, width, -1); i = ToolTipUtil.AppendBitmapToToolTip(s, i, ffi.FormattedBitmap); } } } if (i.Text.Length > 0) { s.Items.Add(i); } if (s.Items.Count == 0) { // show something by default i = new ToolTipItem(); i.Text = "No fields selected"; i.LeftIndent = 6; i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; s.Items.Add(i); } //ToolTipTitleItem ti = new ToolTipTitleItem(); //ti.Text = "Dude"; //s.Items.Add(ti); //ToolTipItem i = new ToolTipItem(); //i.Text = "Subtext that is fairly long longer longest"; //i.LeftIndent = 6; //i.Appearance.TextOptions.WordWrap = WordWrap.Wrap; //s.Items.Add(i); //i = new ToolTipItem(); //Image img = Bitmap.FromFile(@"C:\Mobius_OpenSource\Mobius-3.0\ClientComponents\Resources\Mobius76x76DkBlueBack.bmp"); //i.Image = img; //s.Items.Add(i); //ToolTipSeparatorItem si = new ToolTipSeparatorItem(); return(s); //ChartPanel.ToolTipController.ToolTipLocation = ToolTipLocation.TopCenter; //ChartPanel.ToolTipController.AllowHtmlText = true; //string s = point.SeriesPointID.ToString(); //s = "This <b>SuperToolTip</b> supports <i>HTML formatting</i>"; }