コード例 #1
0
        private void SetupColumnsSelectorDropDown(object sender, EventArgs e)
        {
            DropDownButton            b    = sender as DropDownButton;
            ParsedColumnExpressionMsx expr = b.Tag as ParsedColumnExpressionMsx;

            ColumnExpressionSelectorDropDown.Setup(expr, Axis, Visual, b, this, EditValueChanged);
        }
コード例 #2
0
        private void RemoveExpression_Click(object sender, EventArgs e)
        {
            ParsedColumnExpressionMsx cx = LastDropDownButtonClicked.Tag as ParsedColumnExpressionMsx;

            if (AxisExpressionList.ColExprList.Contains(cx))
            {
                AxisExpressionList.ColExprList.Remove(cx);
            }

            AxisExpressionList.Expression = AxisExpressionList.Format();
            SetupLayoutPanel();
            EditValueChanged();
            return;
        }
コード例 #3
0
        public List <ParsedColumnExpressionMsx> ColExprList = new List <ParsedColumnExpressionMsx>(); // list of parsed column expressions in axis expression

        /// <summary>
        /// Parse an axis expression
        /// </summary>
        /// <param name="axisExpr"></param>
        /// <returns></returns>

        public static ParsedExpressionListMsx Parse(string axisExpr)
        {
            ParsedExpressionListMsx ax = new ParsedExpressionListMsx();

            ax.Expression = axisExpr;

            List <string> colExprs = Split(axisExpr);

            foreach (string colExpr in colExprs)
            {
                ParsedColumnExpressionMsx cx = ParsedColumnExpressionMsx.Parse(colExpr);
                ax.ColExprList.Add(cx);
                cx.ParentAxisExpressionList = ax;
            }

            return(ax);
        }
コード例 #4
0
        private void MoveExpressionRightMenuItem_Click(object sender, EventArgs e)
        {
            ParsedColumnExpressionMsx cx = LastDropDownButtonClicked.Tag as ParsedColumnExpressionMsx;
            int i1 = AxisExpressionList.ColExprList.IndexOf(cx);

            if (i1 >= (AxisExpressionList.ColExprList.Count - 1))
            {
                return;
            }

            AxisExpressionList.ColExprList.Remove(cx);
            AxisExpressionList.ColExprList.Insert(i1 + 1, cx);
            AxisExpressionList.Expression = AxisExpressionList.Format();

            SetupLayoutPanel();
            EditValueChanged();
            return;
        }
コード例 #5
0
        /// <summary>
        /// Format an axis expression by catenating the associated individual
        /// collumn expressions with comma separators
        /// </summary>
        /// <returns></returns>

        public string Format()
        {
            string expr = "";

            for (int ei = 0; ei < ColExprList.Count; ei++)
            {
                if (Lex.IsDefined(expr))
                {
                    expr += ", ";
                }

                ParsedColumnExpressionMsx ce = ColExprList[ei];

                string colExpr = ce.FormatEscapedExpression();
                expr += colExpr;
            }

            return(expr);
        }
コード例 #6
0
        }                                                                                                // return true if the extra menu item was selected

        private void ColButton_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)             // right button ContextMenu
            {
                DropDownButton b = sender as DropDownButton;
                LastDropDownButtonClicked = b;
                ParsedColumnExpressionMsx cx = b.Tag as ParsedColumnExpressionMsx;
                if (cx == null || cx.ColumnNames.Count == 0)
                {
                    return;                                                          // probable the add (+) button
                }
                List <ParsedColumnExpressionMsx> cxl = cx.AxisExpression.ColExprList;
                int i = cxl.IndexOf(cx);

                MoveExpressionLeftMenuItem.Enabled  = (i > 0);
                MoveExpressionRightMenuItem.Enabled = (i >= 0 && i < cxl.Count - 1);
                Point p = new Point(0, b.Height);
                ExpressionRtClickContextMenu.Show(b, p);
            }
        }
コード例 #7
0
        public static string GetColumnButtonLabel(ParsedColumnExpressionMsx cx)
        {
            string exprLabel;

            if (cx != null && cx.ColumnNames.Count > 0)
            {
                exprLabel = cx.ColumnNames[0];
                if (Lex.Ne(cx.Expression, exprLabel) && Lex.Ne(cx.Expression, "[" + exprLabel + "]"))
                {
                    exprLabel = cx.Expression;
                }
            }

            else             // add button
            {
                exprLabel = "+";
            }

            return(exprLabel);
        }
コード例 #8
0
/// <summary>
/// Setup the LayoutPanel with the list of defined column expressions and button to add an expression as appropriate
/// </summary>

        public void SetupLayoutPanel()
        {
            int cols = AxisExpressionList.ColExprList.Count;

            if (cols == 0)
            {
                cols++;
            }
            if (MultiExpressionSelectionAllowed)
            {
                cols++;
            }

            LayoutPanel.Controls.Clear();
            LayoutPanel.ColumnCount = cols;

            for (int ci = cols - 1; ci >= 0; ci--)             // insert in reverse order
            {
                ParsedColumnExpressionMsx cx = null;

                if (ci < AxisExpressionList.ColExprList.Count)
                {
                    cx = AxisExpressionList.ColExprList[ci];
                }

                else
                {
                    cx = new ParsedColumnExpressionMsx();
                    cx.AxisExpression = AxisExpressionList;
                }


                DropDownButton b         = BuildColumnDropDownButton();
                string         exprLabel = GetColumnButtonLabel(cx);
                b.Text = exprLabel;                 // should be formatted expression instead?
                b.Tag  = cx;
                LayoutPanel.Controls.Add(b, ci, 0);
            }

            return;
        }
コード例 #9
0
        /// <summary>
        /// Setup the dropdown for a Column(s) expression
        /// </summary>
        /// <param name="parsedColExpr"></param>
        /// <param name="axis"></param>
        /// <param name="visual"></param>
        /// <param name="b"></param>
        /// <param name="parentColumnExressionSelectorControl"></param>
        /// <param name="callerEditValueChanged"></param>

        public void Setup(
            ParsedColumnExpressionMsx parsedColExpr,
            AxisMsx axis,
            VisualMsx visual,
            DropDownButton b,
            ColumnsSelector parentColumnExressionSelectorControl,
            EventHandler callerEditValueChanged = null)
        {
            InSetup = true;

            ParsedColExpr = parsedColExpr;
            Axis          = axis;
            Visual        = visual;

            InvokingButton         = b;
            PC                     = parentColumnExressionSelectorControl;
            SVM                    = PC.SVM;
            CallerEditValueChanged = callerEditValueChanged;

            DataTableMsx dt = GetSelectorDataTable();

            if (dt != null)
            {
                TableSelector.Name = dt.Name;
            }
            else
            {
                TableSelector.Name = "";
            }

            List <DataTableMsx> tables = Axis.GetAllowedDataTables();

            ColumnList.Items.Clear();

            string selectedColName = null;

            if (parsedColExpr.ColumnNames.Count > 0)
            {
                selectedColName = parsedColExpr.ColumnNames[0];
            }

            foreach (DataColumnMsx col in dt.Columns)
            {
                CheckedListBoxItem item = new CheckedListBoxItem();
                item.Description = col.Name;
                if (Lex.Eq(col.Name, selectedColName))
                {
                    item.CheckState = CheckState.Checked;
                }

                ColumnList.Items.Add(item);
            }

            //DataMapControl.ShowSelectedColumnCheckBoxes = true;
            //DataMapControl.SelectSingleColumn = true;
            //DataMapControl.ShowTableControls = false;
            //DataMapControl.Setup(SVM, DataMapSelectedColumnChanged);

            ////DataMapControl.MobiusTableNameCol.Visible = false;
            ////DataMapControl.MobiusColNameCol.Visible = false;

            //DataMapControl.FieldGridView.OptionsView.ColumnAutoWidth = false;
            ////DataMapControl.FieldGridView.OptionsView.ShowColumnHeaders = false;

            InSetup = false;

            return;
        }
コード例 #10
0
        public static ParsedColumnExpressionMsx Parse(string expr)
        {
            Lex lex = new Lex();

            lex.SetDelimiters(" , ; ( ) [ ]");
            lex.OpenString(expr);
            StringBuilder   sb = new StringBuilder();
            PositionedToken lastTok = null, leftBracket = null;

            ParsedColumnExpressionMsx colExpr = new ParsedColumnExpressionMsx();

            colExpr.Expression = expr;
            List <PositionedToken> tokens = new List <PositionedToken>();           // list of tokens seen
            int parenDepth = 0;


            while (true)
            {
                PositionedToken pTok = lex.GetPositionedToken();
                if (pTok == null)
                {
                    break;
                }

                tokens.Add(pTok);

                if (lastTok != null)
                {                 // include same white space between tokens
                    int wsBeg = lastTok.Position + lastTok.Text.Length;
                    sb.Append(expr.Substring(wsBeg, pTok.Position - wsBeg));
                }

                string tok = pTok.Text;

                if (pTok.Text == "(")
                {
                    parenDepth++;
                }
                else if (pTok.Text == ")")
                {
                    parenDepth--;
                }

                else if (tok == "[")
                {
                    leftBracket = pTok;
                }

                else if (tok == "]")
                {
                    if (leftBracket != null)
                    {
                        int    p       = leftBracket.Position + 1;
                        int    l       = pTok.Position - p;
                        string colName = expr.Substring(p, l);
                        colExpr.ColumnNames.Add(colName);

                        leftBracket = null;
                    }
                }

                else if (Lex.Eq(tok, "as"))
                {
                    pTok = lex.GetPositionedToken();
                    if (pTok == null)
                    {
                        break;
                    }
                    tokens.Add(pTok);

                    colExpr.Alias = expr.Substring(pTok.Position + 2).Trim();
                }

                lastTok = pTok;
            }

            return(colExpr);
        }