/// <summary> /// Setup the form with existing criteria /// </summary> /// <param name="qc"></param> void Setup( QueryColumn qc) { string op, tok, val; CheckEdit option = null; CheckEdit subOption = null; int i1; MetaColumn mc = qc.MetaColumn; string prompt = "Select the search criteria that you want to apply to " + qc.ActiveLabel + " from the list below and enter the limiting value(s)."; bool removeDuplicates = mc.IgnoreCase; // remove dups if ignoring case UIMisc.SetListControlItemsFromDictionary(Value.Properties.Items, mc.Dictionary, removeDuplicates); // setup dropdown switch (mc.DataType) { case MetaColumnType.Integer: case MetaColumnType.Number: case MetaColumnType.QualifiedNo: Setup(true, true, false, false); break; case MetaColumnType.String: Setup(true, true, true, false); break; case MetaColumnType.Date: prompt += " Dates can be entered in the common standard ways: e.g. 12/31/2004 or 31-Dec-04."; Setup(true, true, false, true); break; case MetaColumnType.DictionaryId: Setup(false, false, false, false); break; } // Fill in the form with the current criteria Instance.Text = "Search Criteria for " + qc.ActiveLabel; Instance.Prompt.Text = prompt; ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(qc.Criteria); if (psc == null) { // create default values psc = new ParsedSingleCriteria(); psc.Op = "="; } if (mc.DataType == MetaColumnType.Date && psc.OpEnum != CompareOp.Within) // format dates for user if not within clause { if (psc.Value != "") { psc.Value = DateTimeMx.Format(psc.Value); } if (psc.Value2 != "") { psc.Value2 = DateTimeMx.Format(psc.Value2); } if (psc.ValueList != null) { for (i1 = 0; i1 < psc.ValueList.Count; i1++) { tok = (string)psc.ValueList[i1]; if (tok != null && tok != "") { psc.ValueList[i1] = DateTimeMx.Format(tok); } } } } else if (mc.DataType == MetaColumnType.DictionaryId && psc.Value != "") { // transform database value to dictionary value val = DictionaryMx.LookupWordByDefinition(mc.Dictionary, psc.Value); if (val != null && val != "") { psc.Value = val; } } op = psc.Op; // Fill fields based on criteria types if (op == "" || op.IndexOf("=") >= 0 || op.IndexOf("<") >= 0 || op.IndexOf(">") >= 0) { option = BasicOp; if (op == "=" || op == "") { BasicOpBut.Text = "Equals"; } else if (op == "<") { BasicOpBut.Text = "<"; } else if (op == "<=") { BasicOpBut.Text = UnicodeString.LessOrEqual; } else if (op == "<>") { BasicOpBut.Text = UnicodeString.NotEqual; } else if (op == ">") { BasicOpBut.Text = ">"; } else if (op == ">=") { BasicOpBut.Text = UnicodeString.GreaterOrEqual; } Value.Text = psc.Value; // put in current value } else if (Lex.Eq(op, "Between")) { option = Between; Limit1.Text = psc.Value; Limit2.Text = psc.Value2; } else if (Lex.Eq(op, "In")) { option = InList; StringBuilder sb = new StringBuilder(); for (i1 = 0; i1 < psc.ValueList.Count; i1++) { if (i1 > 0) { sb.Append(", "); } sb.Append((string)psc.ValueList[i1]); } ValueList.Text = sb.ToString(); // set value } else if (Lex.Eq(op, "Like")) { option = Like; tok = psc.Value.Replace("%", ""); // remove sql wildcard characters Substring.Text = tok; } else if (Lex.Eq(op, "Within")) { option = Within; WithinValue.Text = psc.Value; string value2 = psc.Value2; if (Lex.Contains(value2, "Day")) // translate alternative values { value2 = "Day(s)"; } else if (Lex.Contains(value2, "Week")) { value2 = "Week(s)"; } else if (Lex.Contains(value2, "Month")) { value2 = "Month(s)"; } else if (Lex.Contains(value2, "Year")) { value2 = "Year(s)"; } WithinUnits.Text = value2; } else if (Lex.Eq(op, "is not null")) { option = IsNotNull; } else if (Lex.Eq(op, "is null")) { option = IsNull; } else if (Lex.Eq(op, "is not null or is null")) { option = All; } else // oops { MessageBoxMx.ShowError("Unrecognized criteria type"); qc.Criteria = qc.CriteriaDisplay = ""; return; } option.Checked = true; return; }
public void Setup(ColumnInfo colInfo) { bool check; string s; InSetup = true; ColInfo = colInfo; // save ref to colInfo QueryColumn qc = colInfo.Qc; ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(ColInfo.Qc.SecondaryCriteria); // parse criteria Dictionary <string, object> listDict = new Dictionary <string, object>(); if (psc != null && psc.OpEnum != CompareOp.In) { psc = null; // switching from other criteria type } if (psc != null && Lex.Contains(qc.SecondaryCriteria, "(All)")) { psc = null; // rebuild if "all" items } if (psc != null) // list of previously selected items { foreach (string vs in psc.ValueList) { if (qc.MetaColumn.DataType == MetaColumnType.CompoundId) { s = CompoundId.Format(vs); } else if (qc.MetaColumn.DataType == MetaColumnType.Date) { s = DateTimeMx.Format(vs); } else { s = vs; } listDict[s.ToUpper()] = null; } } else // setup default criteria { qc.SecondaryCriteria = qc.MetaColumn.Name + " in ('(All)')"; qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " in list (All)"; } ColumnStatistics stats = colInfo.Rfld.GetStats(); CheckedListBoxItemCollection items = ItemList.Items; items.Clear(); check = (psc == null || listDict.ContainsKey("(All)".ToUpper()) || listDict.ContainsKey("All".ToUpper())); AddItem("(All)", check); if (stats.NullsExist || Math.Abs(1) == 1) { // always include blank/nonblank since there may be null rows because other tables have more rows for key check = (psc == null || listDict.ContainsKey("(Blanks)".ToUpper()) || listDict.ContainsKey("Blanks".ToUpper())); BlanksPos = items.Count; AddItem("(Blanks)", check); check = (psc == null || listDict.ContainsKey("(Non blanks)".ToUpper()) || listDict.ContainsKey("Nonblanks".ToUpper())); NonBlanksPos = items.Count; AddItem("(Non blanks)", check); } else { BlanksPos = NonBlanksPos = -1; } foreach (MobiusDataType mdt in stats.DistinctValueList) { s = mdt.FormattedText; check = (psc == null || listDict.ContainsKey(s.ToUpper())); AddItem(s, check); if (items.Count >= 100) { AddItem("...", check); break; } } int itemHeight = 18; // height of single item (really 17 but add a bit extra) int fullHeight = ItemList.Top + 6 + ItemList.Items.Count * itemHeight; // full height of control if (fullHeight < this.Height) { this.Height = fullHeight; } InSetup = false; return; }
/// <summary> /// Build & show the Print Preview dialog /// </summary> /// <param name="printableDxControl"></param> /// <returns></returns> static DialogResult ShowDialog( IPrintable printableDxControl) { string leftColumn, middleColumn, rightColumn; int m; Query query = Instance.Qm.Query; int printScale = query.PrintScale; // scale the document if (printScale < 0 && !(Instance.Qm.MoleculeGrid.MainView is DevExpress.XtraGrid.Views.BandedGrid.BandedGridView)) { // if not banded view be sure not fit to width printScale = query.PrintScale = 100; } Instance.Qm.ResultsFormat.PageScale = printScale; // do view scaling based on printScale ResultsFormat rf = Instance.Qm.ResultsFormat; PrintingSystem ps = new PrintingSystem(); Instance.Ps = ps; Instance.PrintControl.PrintingSystem = ps; PrintableComponentLink pcl = new PrintableComponentLink(ps); Instance.Pcl = pcl; pcl.Component = printableDxControl; ps.Links.Add(pcl); pcl.CreateDetailArea += new CreateAreaEventHandler(Instance.PrintableComponentLink_CreateDetailArea); pcl.CreateDetailHeaderArea += new CreateAreaEventHandler(Instance.PrintableComponentLink_CreateDetailHeaderArea); pcl.CreateInnerPageHeaderArea += new CreateAreaEventHandler(Instance.PrintableComponentLink_InnerPageHeaderArea); pcl.CreateMarginalHeaderArea += new CreateAreaEventHandler(Instance.PrintableComponentLink_CreateMarginalHeaderArea); pcl.CreateReportHeaderArea += new CreateAreaEventHandler(Instance.PrintableComponentLink_CreateReportHeaderArea); if (query.PrintMargins > 0) { m = query.PrintMargins / 10; pcl.Margins = new Margins(m, m, m, m); } if (query.PrintOrientation == Orientation.Vertical) { pcl.Landscape = false; } else { pcl.Landscape = true; } PageHeaderFooter phf = pcl.PageHeaderFooter as PageHeaderFooter; phf.Header.Content.Clear(); middleColumn = rf.Query.UserObject.Name; // use query name for heading phf.Header.Content.AddRange(new string[] { "", middleColumn, "" }); phf.Header.LineAlignment = BrickAlignment.Center; phf.Header.Font = new Font("Arial", 10, FontStyle.Bold); leftColumn = "Mobius: " + DateTimeMx.Format(DateTimeMx.GetCurrentDate()); middleColumn = "Confidential"; rightColumn = "Page [Page #]"; phf.Footer.Content.Clear(); phf.Footer.Content.AddRange(new string[] { leftColumn, middleColumn, rightColumn }); phf.Footer.LineAlignment = BrickAlignment.Center; // Todo: If DataTable is big just use a subset for preview? Takes about 5 secs to format 100 structs. Instance.PreviewRowCount = Instance.Qm.DataTable.Rows.Count; Progress.Show("Formatting preview...", "Mobius", true); pcl.CreateDocument(); Progress.Hide(); if (printScale > 0) // scale to percentage { ps.Document.ScaleFactor = 1.0f; // keep document scale at 1.0 ps.Document.AutoFitToPagesWidth = 0; } else { Instance.Qm.MoleculeGrid.ScaleBandedGridView(100.0); // scale grid to full size before setting doc scale ps.Document.AutoFitToPagesWidth = (int)-printScale; // fit to 1 or more pages int pctScale = (int)(ps.Document.ScaleFactor * 100); Instance.Qm.ResultsFormat.PageScale = pctScale; Instance.Qm.MoleculeGrid.ScaleBandedGridView(pctScale / 100.0); // scale grid down to get structures correct size pcl.CreateDocument(); // recreate the doc } ps.StartPrint += new PrintDocumentEventHandler(Instance.PrintingSystem_StartPrint); ps.PrintProgress += new PrintProgressEventHandler(Instance.PrintingSystem_PrintProgress); ps.EndPrint += new EventHandler(Instance.PrintingSystem_EndPrint); ps.ShowPrintStatusDialog = true; Form shell = SessionManager.Instance.ShellForm; Instance.Location = shell.Location; Instance.Size = shell.Size; Instance.WindowState = shell.WindowState; RibbonControl src = SessionManager.Instance.RibbonCtl; // model this ribbon on shell ribbon if (src != null) { Instance.RibbonControl.RibbonStyle = src.RibbonStyle; Instance.RibbonControl.ApplicationIcon = src.ApplicationIcon; } DialogResult dr = Instance.ShowDialog(shell); // show the preview query.PrintMargins = pcl.Margins.Left * 10; // keep margins in milliinches if (pcl.Landscape) { query.PrintOrientation = Orientation.Horizontal; } else { query.PrintOrientation = Orientation.Vertical; } Progress.Hide(); // just in case return(dr); }