예제 #1
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;
        }
예제 #2
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();
        }