/// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void Show(DataGridViewCell cell)
        {
            Items.Clear();
            Font = FontHelper.UIFont;

            string cellValue = cell.Value as string;

            foreach (PaFilter filter in FilterHelper.FilterList)
            {
                Items.Add(filter.Name);
                if (cellValue == filter.Name)
                {
                    SelectedIndex = Items.Count - 1;
                }
            }

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

            m_cell = cell;
            int col = cell.ColumnIndex;
            int row = cell.RowIndex;

            Width  = cell.DataGridView.Columns[col].Width;
            Height = (Math.Min(Items.Count, 15) * Font.Height) + 4;
            Rectangle rc = cell.DataGridView.GetCellDisplayRectangle(col, row, false);

            rc.Y += rc.Height;
            m_dropDown.Show(cell.DataGridView.PointToScreen(rc.Location));
            Focus();
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        public void Show(DataGridViewCell cell, IEnumerable <string> items)
        {
            // This is sort of a kludge, but right before the first time the list is
            // displayed, it's handle hasn't been created therefore the preferred
            // size cannot be accurately determined and the preferred width is needed
            // below. So to ensure the handle gets created, show then hide the drop-down.
            if (!IsHandleCreated)
            {
                Size = new Size(0, 0);
                _dropDown.Show(0, 0);
                _dropDown.Close();
            }

            Items.Clear();
            Items.AddRange(items.ToArray());
            SelectedItem = cell.Value as string;

            if (SelectedIndex < 0 && Items.Count > 0)
            {
                SelectedIndex = 0;
            }

            _associatedCell = cell;
            int col = cell.ColumnIndex;
            int row = cell.RowIndex;

            Width  = Math.Max(cell.DataGridView.Columns[col].Width, _listBox.PreferredSize.Width);
            Height = (Math.Min(Items.Count, 15) * _listBox.ItemHeight) + Padding.Vertical + 2;
            var rc = cell.DataGridView.GetCellDisplayRectangle(col, row, false);

            rc.Y += rc.Height;
            _dropDown.Show(cell.DataGridView.PointToScreen(rc.Location));
            _listBox.Focus();
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the event when the user has clicked on the drop-down button in a value
        /// cell. The object dropped-down depends on the expression type. If the expression
        /// type is normal, then the drop-down contains a list of field values found in the
        /// cache for the field specified in the field column. If the expression type is a
        /// phonetic search, then the drop-down is a search query options drop-down for the
        /// query that better be stored in the tag property of the current row's expression
        /// type cell. If the expression type is a regular expression, then their is no
        /// drop-down.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandleValueColumnButtonClicked(object sender, DataGridViewCellMouseEventArgs e)
        {
            string expType = m_grid[kTypeCol, e.RowIndex].Value as string;

            if (string.IsNullOrEmpty(expType))
            {
                return;
            }

            if ((m_grid[kFieldCol, e.RowIndex].Value as string) == FilterExpression.OtherFilterField)
            {
                if (FilterHelper.FilterList.Count != 0)
                {
                    m_filterDropDown.Show(m_grid[kValueCol, e.RowIndex]);
                }
            }
            else if (expType == m_expTypeToText[ExpressionType.PhoneticSrchPtrn])
            {
                SearchQuery           query = m_grid[kTypeCol, e.RowIndex].Tag as SearchQuery;
                SearchOptionsDropDown sodd  = new SearchOptionsDropDown(query);
                m_queryDropDown         = new CustomDropDown();
                m_queryDropDown.Closed += m_queryDropDown_Closed;
                m_queryDropDown.AddControl(sodd);
                Rectangle rc = m_grid.GetCellDisplayRectangle(2, e.RowIndex, false);
                rc.Y += rc.Height;
                m_queryDropDown.Show(m_grid.PointToScreen(rc.Location));
            }
            else
            {
                m_filterDropDown.Show(m_grid[kValueCol, e.RowIndex],
                                      m_grid[kFieldCol, e.RowIndex].Value as string);
            }
        }
Пример #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void grid_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                PaWordListGrid grid = sender as PaWordListGrid;

                if (e.ColumnIndex != 0 || !DoesGridQualifyForFeature(grid))
                {
                    return;
                }

                if (!grid.Focused)
                {
                    grid.Focus();
                    Application.DoEvents();
                }

                Rectangle rc = grid.GetCellDisplayRectangle(0, -1, false);
                Point     pt = new Point(rc.X, rc.Bottom);
                pt = grid.PointToScreen(pt);

                m_numPhonesCtrl.NumberOfPhones = (grid.SortOptions.AdvSortOrder[0] == 0 ?
                                                  m_numPhonesBefore[grid] : m_numPhonesAfter[grid]);

                m_numPhonesCtrl.Environment = (grid.SortOptions.AdvSortOrder[0] == 0 ?
                                               "before" : "after");

                m_dropDown.Tag = grid;
                m_dropDown.Show(pt);
            }
            catch { }
        }
Пример #5
0
 private void OnMouseClick(MouseUpEvent mouseEvent)
 {
     if (mouseEvent.button == 0) // Left click to select the tile
     {
         for (int i = 0; i < tileAreas.Count; i++)
         {
             if (tileAreas[i].Contains(mouseEvent.mousePosition))
             {
                 selectedTileNum = i;
                 selectedTile    = gridTilesList[i];
             }
         }
     }
     else if (mouseEvent.button == 1) // Right click to create dropdown menu of tile options for that tile
     {
         for (int i = 0; i < tileAreas.Count; i++)
         {
             if (tileAreas[i].Contains(mouseEvent.mousePosition))
             {
                 selectedTileNum = i;
                 selectedTile    = gridTilesList[i];
             }
         }
         CustomDropDown.Show(this, mouseEvent.mousePosition, selectedTile);
     }
 }
Пример #6
0
 /// ------------------------------------------------------------------------------------
 public void Show(Font fnt, Point location)
 {
     Size         = pnlOuter.Size;
     DialogResult = DialogResult.Cancel;
     SetFont(fnt, true);
     m_dropDown.Show(location);
     cboFontFamily.Focus();
 }
Пример #7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandleFeaturesListClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            PhoneInfo phoneInfo = m_grid.Rows[e.RowIndex].Cells["phone"].Value as PhoneInfo;

            if (phoneInfo != null)
            {
                m_lvFeatures.CurrentMasks = phoneInfo.Masks;
                Rectangle rc = m_grid.GetCellDisplayRectangle(0, e.RowIndex, true);
                Point     pt = new Point(rc.Left, rc.Bottom);
                pt = m_grid.PointToScreen(pt);
                m_dropdown.Show(pt);
                m_lvFeatures.Focus();
            }
        }
Пример #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the EditingControlShowing event of the m_dataGridView control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewEditingControlShowingEventArgs"/> instance containing the event data.</param>
        /// ------------------------------------------------------------------------------------
        private void m_dataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            Debug.Assert(TextControl == null && !m_regexMatchDropDown.Visible && !m_regexReplaceDropDown.Visible);
            if (IsRegEx(m_dataGridView.CurrentRow))
            {
                TextControl = e.Control as DataGridViewTextBoxEditingControl;
            }
            if (TextControl == null)
            {
                return;
            }

            Rectangle cellDisplayRect = m_dataGridView.GetCellDisplayRectangle(
                m_dataGridView.CurrentCell.ColumnIndex, m_dataGridView.CurrentCell.RowIndex, true);

            if (m_dataGridView.CurrentCell.ColumnIndex == colMatch.Index)
            {
                m_regexMatchDropDown.Show(m_dataGridView, cellDisplayRect.Left, cellDisplayRect.Bottom + 1);
            }
            else
            {
                string[] matchGroups = GetMatchGroups((string)m_dataGridView.CurrentRow.Cells[colMatch.Index].Value);
                if (matchGroups.Length > 0)
                {
                    m_cboMatchGroup.Items.AddRange(matchGroups);
                    string sGroup = ExistingMatchGroup;
                    m_cboMatchGroup.Items.Insert(0, sGroup.Length > 0 ? m_sRemoveItem : Empty);
                    m_regexReplaceDropDown.Show(m_dataGridView, cellDisplayRect.Left, cellDisplayRect.Bottom + 1);
                }
                else
                {
                    return;
                }
            }

            TextControl.HideSelection = false;
            TextControl.KeyDown      += txtControl_KeyDown;
            TextControl.TextChanged  += txtControl_TextChanged;
            TextControl.TextChanged  += UpdatePreview;
            TextControl.MouseClick   += txtControl_MouseClick;
        }