Example #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;
                }
            }
        }
Example #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);
            }
        }