示例#1
0
/// <summary>
/// Configure dialog for current filter type and value
/// </summary>

        void ConfigureDialog()
        {
            QueryColumn     Qc, qc;
            MetaColumn      mc;
            XtraUserControl pc;
            int             dx, dy;

            qc = ColInfo.Qc;
            mc = qc.MetaColumn;

            FilterType ft = qc.SecondaryFilterType;

            if (qc.MetaColumn.DataType == MetaColumnType.Structure)
            {
                ft = FilterType.StructureSearch;
            }

            else if (ft == FilterType.Unknown)
            {
                ColumnStatistics stats = null;
                if (Qm != null && Qm.DataTableManager != null)
                {
                    stats = Qm.DataTableManager.GetStats(qc);
                }
                if (stats != null && stats.DistinctValueList.Count <= 5)                 // if small number of items default to checkbox list
                {
                    ft = FilterType.CheckBoxList;
                }
                else if (qc.MetaColumn.IsNumeric)
                {
                    ft = FilterType.RangeSlider;
                }
                else
                {
                    ft = FilterType.BasicCriteria;
                }
            }

            FilterBasicControl.Visible     = false;
            FilterListControl.Visible      = false;
            FilterItemControl.Visible      = false;
            FilterRangeControl.Visible     = false;
            FilterStructureControl.Visible = false;

            ChangeFilterType.Visible = true;
            EditStructure.Visible    = false;

            SetupFilter(ft);

            if (ft == FilterType.BasicCriteria)
            {
                pc = FilterBasicControl;
            }
            else if (ft == FilterType.CheckBoxList)
            {
                pc = FilterListControl;
                if (pc.Height < 30)
                {
                    pc.Height = Prototype.FilterListControl.Height;                                 // maintain minimum size
                }
                pc.Width = Width - 8;
            }
            else if (ft == FilterType.ItemSlider)
            {
                pc = FilterItemControl;
            }
            else if (ft == FilterType.RangeSlider)
            {
                pc = FilterRangeControl;
            }

            else if (ft == FilterType.StructureSearch)
            {
                pc = FilterStructureControl;
                if (pc.Height < 30)
                {
                    pc.Height = Prototype.FilterStructureControl.Height;                                 // maintain minimum size
                }
                pc.Width = Width - 8;
                EditStructure.Location   = Prototype.ChangeFilterType.Location;               // show edit structure in place of change filter type
                EditStructure.Visible    = true;
                ChangeFilterType.Visible = false;
            }

            else
            {
                throw new Exception("Unexpected SecondaryCriteriaType: " + ft);
            }

            pc.Visible = true;

            Size s0 = pc.Size;

            pc.Location = new Point(0, 0);
            int formHeight = pc.Bottom + HeightBelowDivider;

            if (Text != "")
            {
                formHeight += TitleBarHeight;                         // add title bar height if visible
            }
            Height  = formHeight;
            pc.Size = s0;             // restore filter control size

            Rectangle r = GetColumnHeaderBounds(ColInfo.GridColumn);
            Point     p = new Point(r.Left, r.Top - Height);         // place above cell header

            p = Grid.PointToScreen(p);
            if (p.Y < 0)
            {
                p = new Point(p.X, 0);                      // keep on screen
            }
            int screenWidth = Screen.PrimaryScreen.Bounds.Width;

            if (p.X + Width > screenWidth)
            {
                p = new Point(screenWidth - Width, p.Y);
            }
            Location = p;

            string crit = qc.SecondaryCriteria;

            return;
        }
示例#2
0
        private void FindNext_Click(object sender, EventArgs e)
        {
            string findText, cellText;
            bool   matches;

            string s = FindText.Text.Trim();

            if (s == "")
            {
                return;
            }

            if (InFindNext_Click)
            {
                return;                               // avoid recursion
            }
            InFindNext_Click = true;

            if (MatchCase.Checked)
            {
                findText = s;
            }
            else
            {
                findText = s.ToLower();
            }

            int startRow = Grid.Row;             // where we are now

            if (startRow < 0)
            {
                startRow = 0;
            }
            int startCol = Grid.Col;

            if (startCol < 0)
            {
                startCol = 0;
            }

            int row = startRow;             // where we will start to search
            int col = startCol;

            Progress.Text    = "Searching row " + row.ToString() + "...";
            Progress.Visible = true;
            FindNext.Enabled = false;
            CloseButton.Text = "Cancel";

            int t0 = TimeOfDay.Milliseconds();

            bool [] checkColumn = new bool[Grid.V.Columns.Count];             // get list of columns to check
            for (int ci = 0; ci < Grid.V.Columns.Count; ci++)
            {
                GridColumn gc   = Grid.V.Columns[ci];
                ColumnInfo cInf = Grid.GetColumnInfo(gc);
                if (cInf == null || cInf.Mc == null || cInf.Mc.IsGraphical)
                {
                    checkColumn[ci] = false;
                }
                else
                {
                    checkColumn[ci] = true;
                }
            }

            int iteration = -1;

// Loop through grid checking cells

            while (true)
            {
                iteration++;
                if (iteration > 0 && row == startRow && col == startCol)
                {                 // if back at start then not found
                    MessageBoxMx.Show(UmlautMobius.String + " cannot find the data you're searching for.", UmlautMobius.String,
                                      MessageBoxButtons.OK, MessageBoxIcon.Information);

                    break;
                }

                if (!Visible)
                {
                    break;             // cancelled by user
                }
                col++;                 // go to next column
                if (col >= Grid.V.Columns.Count)
                {
                    col = 1;                                 // start at 1st col past check mark col
                    row++;
                    if (TimeOfDay.Milliseconds() - t0 > 500) // update display periodically
                    {
                        Progress.Text = "Searching row " + row.ToString() + "...";
                        this.Refresh();
                        Application.DoEvents();
                        t0 = TimeOfDay.Milliseconds();
                    }
                }


                if (row >= Grid.V.RowCount)       // past end of grid?
                {
                    if (Dtm.RowRetrievalComplete) // end of grid & have all data
                    {
                        row = col = 0;            // cycle back to top
                    }
                    else                          // need to read more data
                    {
                        int chunkSize = 100;
                        Dtm.StartRowRetrieval(chunkSize);
                        Progress.Text = "Retrieving data...";

                        while (true)                         // loop until requested rows have been read, no more rows or cancel requested
                        {
                            Thread.Sleep(250);
                            Application.DoEvents();

                            if (row < Grid.V.RowCount)                             // have data for next row?
                            {
                                break;
                            }

                            else if (Dtm.RowRetrievalState != RowRetrievalState.Running)                             // must be at end of query
                            {
                                row = 0;
                                break;
                            }

                            else if (!Visible)                             // cancelled by user
                            {
                                Progress.Text    = "";
                                FindNext.Enabled = true;
                                CloseButton.Text = "Close";

                                InFindNext_Click = false;
                                return;
                            }
                        }

                        Progress.Text = "Searching row " + row.ToString() + "...";                         // restore search message
                    }
                }

                if (!checkColumn[col])
                {
                    continue;
                }

                object vo = Grid[row, col];

                if (NullValue.IsNull(vo))
                {
                    continue;
                }

                else if (vo is MobiusDataType && (vo as MobiusDataType).FormattedText != null)
                {
                    cellText = (vo as MobiusDataType).FormattedText; // use existing formatted value
                }
                else                                                 // need to format value
                {
                    CellInfo cInf = Grid.GetCellInfo(row, col);
                    cellText = Grid.Helpers.FormatFieldText(cInf);
                }

                if (String.IsNullOrEmpty(cellText))
                {
                    continue;
                }

                if (!MatchCase.Checked)
                {
                    cellText = cellText.ToLower();
                }

                if (MatchEntireCell.Checked)
                {
                    matches = (cellText == findText);
                }
                else
                {
                    matches = (cellText.IndexOf(findText) >= 0);
                }

                if (matches)
                {
                    //Grid.Focus();
                    Grid.SelectCell(row, col);
                    Grid.FocusCell(row, col);                     // put focus on cell found, may cause scroll event
                    Grid.NotFocusedRowToHighlight = row;
                    Grid.NotFocusedColToHighlight = col;

                    // Reposition search box out of the way if necessary (above current cell)

                    Rectangle findRect =                     // rectangle for find dialog
                                         new Rectangle(Instance.Left, Instance.Top, Instance.Width, Instance.Height);

                    Rectangle cellRect = Grid.GetCellRect(row, col);                                 // get rectangle relative to control
                    Point     p        = Grid.PointToScreen(new Point(cellRect.Left, cellRect.Top)); // get coords relative to screen
                    cellRect = new Rectangle(p.X, p.Y, cellRect.Width, cellRect.Height);

                    if (findRect.IntersectsWith(cellRect))
                    {
                        Instance.Top = cellRect.Top - Instance.Height - 4;
                    }

                    break;
                }
            }

            Progress.Text    = "";
            FindNext.Enabled = true;
            CloseButton.Text = "Close";

            InFindNext_Click = false;
            return;
        }