コード例 #1
0
        private void CtComplexCriteria_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)             // right button ContextMenu
            {
                Point p = new Point(e.X, e.Y);
                CriteriaComplexRtClickContextMenu.Show(CtComplexCriteria, p);
            }

            else
            {
                if (CriteriaComplex.Edit(Query))
                {
                    LabeledCriteria labeledCriteria = CriteriaEditor.ConvertComplexCriteriaToEditable(Query, false);
                    RichTextBox     coloredCriteria = CriteriaEditor.ColorCodeCriteria(labeledCriteria.Text, Query);
                    CtComplexCriteria.Rtf = coloredCriteria.Rtf;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Complex criteria editor
        ///
        /// Editing complex criteria involves several steps including the following:
        ///  1. ConvertSimpleCriteriaToComplex (MqlUtil) - Initial conversion to set up complex criteria
        ///  2. ConvertComplexCriteriaToEditable - Convert raw complex criteria into a more editable form
        ///  3. ConvertEditableCriteriaToComplex - Convert editable format back to raw format checking for basic errors
        ///  4. ConvertComplexCriteriaToSimple (MqlUtil) - Convert back to simple format, may be loss of criteria
        /// </summary>
        /// <param name="q"></param>
        /// <returns></returns>

        public static bool Edit(
            Query q)
        {
            if (Instance == null)
            {
                Instance = new CriteriaComplex();
            }
            Instance.Query = q;

            QueryTable qt;
            MoleculeMx cs;

            DataTable dt = BuildTableGridList(q);

            Instance.TableGrid.DataSource = dt;

            Instance.LabeledCriteria = CriteriaEditor.ConvertComplexCriteriaToEditable(q, true);
            RichTextBox coloredCriteria   = CriteriaEditor.ColorCodeCriteria(Instance.LabeledCriteria.Text, q);
            string      formattedCriteria = coloredCriteria.Rtf;

            Instance.Criteria.Rtf = formattedCriteria;

            if (coloredCriteria.Text.Length == 1)
            {             // if single starter char then position cursor at start
                Instance.Criteria.SelectionStart  = 0;
                Instance.Criteria.SelectionLength = 0;
            }

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        internal void Render()
        {
            Query q             = Query;
            int   criteriaCount = 0;

            if (q == null || q.Tables.Count <= 0)
            {
                return;
            }
            //if (q.Tables.Count <= 0 || !SS.I.ShowCriteriaTab) return;

            Rendering = true;
            Clear();
            CriteriaTabYPos = 0;

            bool shownKeyCriteria = false;
            int  summarizable = 0, summarized = 0;

            for (int ti = 0; ti < q.Tables.Count; ti++)
            {
                QueryTable qt = q.Tables[ti];
                string     txt;
                bool       shownTableLabel = false;

                if (qt.MetaTable.SummarizedExists)
                {
                    summarizable++;
                }
                if (qt.MetaTable.UseSummarizedData)
                {
                    summarized++;
                }

                if (q.LogicType == QueryLogicType.Complex)
                {
                    continue;                     // if complex logic don't show simple criteria
                }
                if (qt.MetaTable.IgnoreCriteria)
                {
                    continue;                     // skip if criteria should be ignored
                }
                foreach (QueryColumn qc in qt.QueryColumns)
                {
                    if (qc.IsKey)
                    {
                        if (shownKeyCriteria)
                        {
                            continue;                                           // skip if already shown
                        }
                        shownKeyCriteria = true;
                    }

                    else if (qc.Criteria == "" && !qc.ShowOnCriteriaForm)
                    {
                        continue;
                    }

                    if (qc.MetaColumn.IsDatabaseSetColumn)
                    {
                        continue;                                                        // don't show db list
                    }
                    if (!shownTableLabel)
                    {
                        shownTableLabel = true;
                        if (!qt.MetaTable.IsRootTable || ti > 0)
                        {
                            AddCriteriaTabTableLabel(qt);
                        }
                    }

                    if (qc.MetaColumn.DataType == MetaColumnType.Structure)
                    {
                        AddCriteriaTabStructureItem(qc);
                        criteriaCount++;
                    }

                    else                     // other column types
                    {
                        if (qc.IsKey)
                        {
                            txt = q.KeyCriteriaDisplay;
                        }

                        else
                        {
                            txt = qc.CriteriaDisplay;
                            if (txt != "")
                            {
                                if (qc.FilterSearch && !qc.FilterRetrieval)
                                {
                                    txt += " (Search only)";
                                }
                                else if (!qc.FilterSearch && qc.FilterRetrieval)
                                {
                                    txt += " (Retrieve only)";
                                }
                                else if (!qc.FilterSearch && !qc.FilterRetrieval)
                                {
                                    txt += " (Disabled)";
                                }
                            }
                        }

                        AddCriteriaTabItem(qc, txt);
                        if (qc.IsKey)
                        {
                            criteriaCount++;
                        }
                    }
                }
            }

            if (q.LogicType == QueryLogicType.Complex)
            {             // convert & show complex logic
                AddComplexCriteriaPanel();
                LabeledCriteria labeledCriteria = CriteriaEditor.ConvertComplexCriteriaToEditable(q, false);
                RichTextBox     coloredCriteria = CriteriaEditor.ColorCodeCriteria(labeledCriteria.Text, q);
                CtComplexCriteria.Rtf = coloredCriteria.Rtf;

                MenuComplexApplyCriteriaToRetrieval.Checked = q.FilterResults;
            }

            AddCriteriaLogicPanel(q.LogicType);                      // add criteria type panel
            AddQueryDescription(q.UserObject.Description.TrimEnd()); // add description panel
            Rendering = false;
            return;
        }