Exemplo n.º 1
0
        private void FieldsButton_Click(object sender, EventArgs e)
        {
            Query      q;
            QueryTable qt, qt2;

            string advExprExt;
            Point  p = FieldsButton.PointToScreen(new Point(0, FieldsButton.Height));

            FieldSelectorControl.Query      = AdvancedEditorPseudoQuery;
            FieldSelectorControl.MetaColumn = null;           // no current selection

            int p1 = AdvancedExpr.SelectionStart;             // save position/selection since may change
            int p2 = AdvancedExpr.SelectionLength;

            Mobius.Data.QueryColumn qc = FieldSelectorControl.ShowMenu(p);
            if (qc == null)
            {
                return;
            }
            MetaColumn mc = qc.MetaColumn;

            string tok = '"' + mc.MetaTable.Name + "." + mc.Label + '"';

            InsertText(tok, p1, p2);

            qt2 = AdvancedEditorPseudoQuery.GetQueryTableByName(mc.MetaTable.Name);
            if (qt2 == null)
            {
                AdvancedEditorPseudoQuery.AddQueryTable(qc.QueryTable);
            }
        }
Exemplo n.º 2
0
/// <summary>
/// Add a new pivot grid field
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void AddPivotField_Click(object sender, EventArgs e)
        {
            QueryManager qm = PivotView.Qm;
            Query        q  = qm.Query;

            FieldSelectorControl.Query      = q;
            FieldSelectorControl.MetaColumn = null;
            Point p = AddPivotField.PointToScreen(new Point(0, AddPivotField.Height));

            Mobius.Data.QueryColumn qc = FieldSelectorControl.ShowMenu(p);
            if (qc == null)
            {
                return;
            }

            PivotGridPropertiesMx pp = PivotView.PivotGridPropertiesMx;

            ResultsField rfld = qm.ResultsFormat.GetResultsField(qc);

            if (rfld == null)
            {
                return;
            }

            PivotGridFieldMx field =             // add new field (must add to base view)
                                     PivotGridView.AddField(rfld, pp.PivotFields, null, GroupingTypeEnum.EqualValues);

            PivotGridFieldMx field2 = new PivotGridFieldMx();

            field.CopyField(field2);
            pp.PivotFields.Remove(field);             // remove from base view

            PivotGrid.BeginUpdate();
            object ds = PivotGrid.DataSource;

            PivotGrid.DataSource = null;
            PivotGrid.Fields.Add(field2);             // add to pivot grid
            PivotView.ConfigurePivotGridControlField(field2);
            PivotGrid.DataSource = ds;
            PivotGrid.EndUpdate();

            FillFieldDetailsGrid();
            return;
        }
Exemplo n.º 3
0
        void AddColumn(FieldSelectorControl fs, CheckEdit ascending)
        {
            if (fs.QueryColumn == null)
            {
                return;
            }
            SortColumn sc = new SortColumn();

            sc.QueryColumn = fs.QueryColumn;
            if (ascending.Checked)
            {
                sc.Direction = SortOrder.Ascending;
            }
            else
            {
                sc.Direction = SortOrder.Descending;
            }
            Columns.Add(sc);
        }
Exemplo n.º 4
0
        void SetupColumn(int ci, FieldSelectorControl fs, CheckEdit ascending, CheckEdit descending)
        {
            fs.Query = Query;
            if (ci >= Columns.Count)
            {
                fs.MetaColumn     = null;
                ascending.Checked = true;
                return;
            }

            QueryColumn qc = Columns[ci].QueryColumn;

            if (qc != null)
            {             // be sure any existing cols are still in query
                QueryTable qt2 = Query.GetTableByName(qc.QueryTable.MetaTable.Name);
                if (qt2 != null)
                {
                    QueryColumn qc2 = qt2.GetQueryColumnByName(qc.MetaColumn.Name);
                    if (qc2 == qc)
                    {
                        fs.MetaColumn = qc.MetaColumn;
                        if (Columns[ci].Direction == SortOrder.Ascending)
                        {
                            ascending.Checked = true;
                        }
                        else
                        {
                            descending.Checked = true;
                        }
                        return;
                    }
                }
            }

            fs.MetaColumn     = null;
            ascending.Checked = true;
        }
Exemplo n.º 5
0
        private void Timer_Tick(object sender, EventArgs e0)
        {
            QueryColumn qc;

            if (!Timer.Enabled)
            {
                return;
            }

            Timer.Enabled = false;

            MouseEventArgs e   = LastMouseDownEventArgs;
            Point          p   = new Point(e.X, e.Y);
            GridHitInfo    ghi = FieldGridView.CalcHitInfo(p);

            int ri = ghi.RowHandle;

            if (ri < 0)
            {
                return;
            }
            GridColumn gc = ghi.Column;

            if (gc == null)
            {
                return;
            }
            int c = gc.AbsoluteIndex;

            DataRow      dRow = FieldDataTable.Rows[ri];
            ColumnMapMsx i    = dRow["ColumnMapMsxRefCol"] as ColumnMapMsx;          // currently item

            if (i == null)
            {
                qc = null;
            }
            else
            {
                qc = i.QueryColumn;
            }

            if (Lex.Eq(gc.FieldName, "FieldDatabaseTableCol") || Lex.Eq(gc.FieldName, "FieldDatabaseColumnCol"))
            {
                FieldSelectorControl fieldSelector = new FieldSelectorControl();
                fieldSelector.QueryColumn = qc;

                p = this.PointToScreen(p);

                SelectColumnOptions sco = new SelectColumnOptions();

                sco.ExcludeImages = true;

                sco.FirstTableKeyOnly   = true;
                sco.SelectFromQueryOnly = true;
                sco.IncludeNoneItem     = true;

                DialogResult dr = fieldSelector.SelectColumnFromQuery(Query, fieldSelector.QueryColumn, sco, p.X, p.Y, out qc);
                if (dr != DialogResult.OK)
                {
                    return;
                }

                if (qc != null)
                {
                    if (i == null)
                    {
                        i = new ColumnMapMsx();
                    }
                    i.QueryColumn                  = qc;
                    dRow["FieldSelectedCol"]       = true;
                    dRow["ColumnMapMsxRefCol"]     = i;
                    dRow["FieldDatabaseTableCol"]  = qc.QueryTable.ActiveLabel;
                    dRow["FieldDatabaseColumnCol"] = qc.ActiveLabel;
                    FieldGrid.RefreshDataSource();
                }

                else                 // set to none
                {
                    dRow["ColumnMapMsxRefCol"]    = null;
                    dRow["FieldDatabaseTableCol"] = dRow["FieldDatabaseColumnCol"] = "";
                }

                if (ri == FieldDataTable.Rows.Count - 1)
                {                 // add blank row at end if needed
                    dRow = FieldDataTable.NewRow();
                    FieldDataTable.Rows.Add(dRow);
                }
            }

            //else if (Lex.Eq(gc.FieldName, "EditAxisPropertiesCol"))
            //{
            //  DialogResult dr = AxisOptionsDialog.ShowDialog(ax);
            //  if (dr == DialogResult.OK) Changed = true;
            //}

            return;
        }
Exemplo n.º 6
0
/// <summary>
/// Add a new filter
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void AddFilterButton_Click(object sender, EventArgs e)
        {
            QueryColumn qc = null;

            FieldSelectorControl fieldSelector = new FieldSelectorControl();
            Point p = new Point(AddFilterButton.Left, AddFilterButton.Bottom);

            p = this.PointToScreen(p);

            SelectColumnOptions flags = new SelectColumnOptions();

            flags.SearchableOnly      = true;
            flags.FirstTableKeyOnly   = true;
            flags.SelectFromQueryOnly = true;
            DialogResult dr = fieldSelector.SelectColumnFromQuery(Qm.Query, null, flags, p.X, p.Y, out qc);

            if (dr != DialogResult.OK)
            {
                return;
            }

            if (qc.SecondaryFilterType != FilterType.Unknown)
            {
            }                                                                 // already have a filter
            if (qc.MetaColumn.DataType == MetaColumnType.Structure)
            {
                qc.SecondaryFilterType = FilterType.StructureSearch;
            }

            else
            {
                ColumnStatistics stats = null;
                if (Qm != null && Qm.DataTableManager != null)
                {
                    stats = Qm.DataTableManager.GetStats(qc);
                }
                if (stats != null && stats.DistinctValueList.Count <= 10)
                {
                    qc.SecondaryFilterType = FilterType.CheckBoxList;
                }
                else if (qc.MetaColumn.IsNumeric)
                {
                    qc.SecondaryFilterType = FilterType.RangeSlider;
                }
                else
                {
                    qc.SecondaryFilterType = FilterType.BasicCriteria;
                }
            }

            ActiveQueryColumn = qc;

            if (!Qm.DataTableManager.FiltersEnabled)             // be sure filters are enabled & view also
            {
                Qm.DataTableManager.FiltersEnabled = true;
                Qm.DataTableManager.ApplyFilters();
                Qm.DataTableManager.UpdateFilterState();
                QueryResultsControl.GetQrcThatContainsControl(this).UpdateFilteredViews();
            }

            Render();
        }