Exemplo n.º 1
0
        // special mouse handling for filter row
        private void _flex_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)
        {
            // detect clicks on filter row
            if ((e.Button & MouseButtons.Left) != 0 && _row > 0 && _flex.MouseRow == _row)
            {
                // get the column that was clicked
                HitTestInfo ht  = _flex.HitTest(e.X, e.Y);
                int         col = ht.Column;

                // fixed column? select the whole filter row
                if (col < _flex.Cols.Fixed)
                {
                    _flex.Select(_row, _flex.Cols.Fixed, _row, _flex.Cols.Count - 1);
                    _flex.FinishEditing(true);
                }

                // clicked a cell on the filter row, select it
                else
                {
                    _flex.Select(_row, col);
                }

                // eat the event (no sorting, sizing etc)
                // unless this is a checkbox <<1.4>>
                if (ht.Type != HitTestTypeEnum.Checkbox)
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 2
0
        // open appointment form on double click
        protected override void OnBeforeDoubleClick(BeforeMouseDownEventArgs e)
        {
            Appointment app = GetRowAppointment(HitTest(new Point(e.X, e.Y)).Row);

            if (app != null)
            {
                Schedule.EditAppointment(app);
                e.Cancel = true;
            }
            base.OnBeforeDoubleClick(e);
        }
Exemplo n.º 3
0
        // special mouse handling for template row
        private void _flex_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)
        {
            // we're interested in the left button
            if ((e.Button & MouseButtons.Left) == 0 || _row < 0 || !Visible)
            {
                return;
            }

            // get the cell that was clicked
            HitTestInfo ht  = _flex.HitTest(e.X, e.Y);
            int         row = ht.Row;
            int         col = ht.Column;

            // handle clicks on template row
            if (row == _row)
            {
                // fixed column? select the whole template row
                if (col < _flex.Cols.Fixed)
                {
                    _flex.FinishEditing();
                    if (_dirty)
                    {
                        AddNewRow();
                    }
                }
                else
                {
                    _flex.Select(row, col);
                }

                // eat the event (no sorting, sizing etc) unless this is a checkbox <<1.4>>
                if (ht.Type != HitTestTypeEnum.Checkbox)
                {
                    e.Cancel = true;
                }
            }
            else if (_flex.Row == _row)             // handle regular clicks on rows away from template
            {
                // finish pending edits
                _flex.FinishEditing();
                if (_dirty)
                {
                    // add new row
                    AddNewRow();

                    // select cell that was clicked
                    _flex.Select(row, col);

                    // done with selection for now
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 4
0
        // start dragging columns
        private void _flex_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)
        {
            // we're interested in the left button
            if ((e.Button & MouseButtons.Left) == 0)
            {
                return;
            }

            // check that the click was on a column header
            HitTestInfo hti = _flex.HitTest(e.X, e.Y);

            if (hti.Type != HitTestTypeEnum.ColumnHeader)
            {
                return;
            }

            // check that the click was on the first row
            // (in case there's additional fixed rows)
            if (hti.Row > 0)
            {
                return;
            }

            // check that the click was on a scrollable column
            ColumnCollection cols = _flex.Cols;

            if (hti.Column < cols.Fixed)
            {
                return;
            }

            // eat the event
            e.Cancel = true;

            // check that we have at least one non-grouped column
            var visCount = 0;

            for (var i = cols.Fixed; i < cols.Count; i++)
            {
                if (cols[i].Visible)
                {
                    visCount++;
                }
            }
            if (visCount < 2)
            {
                return;
            }

            // start dragging column
            _dragger.StartDragging(cols[hti.Column]);
        }
Exemplo n.º 5
0
        // expand/collapse child grid
        //
        // if the user clicks the icons (drawn in the method above), either
        // create a child grid (and bind it to the detail records), or remove
        // the existing one.
        //
        override protected void OnBeforeMouseDown(BeforeMouseDownEventArgs e)
        {
            // always call base implementation
            base.OnBeforeMouseDown(e);

            // check that it's the Left button and that we have a hierarchy
            if (e.Button != MouseButtons.Left || _colChild == null)
            {
                return;
            }

            // check that it's a row header cell
            HitTestInfo hit = HitTest(e.X, e.Y);

            if (hit.Type != HitTestTypeEnum.RowHeader || hit.Row < Rows.Fixed)
            {
                return;
            }

            // check that the click was over the collapse/expand icon
            if (e.X < Cols[0].Right - (Glyphs[GlyphEnum.Collapsed].Width + 4))
            {
                return;
            }

            // if the row has no children and the user can't add new, cancel <<B2>>
            IList list = _colChild[hit.Row] as IList;

            if (list == null || list.Count == 0)
            {
                if (!AllowAddNew)
                {
                    return;
                }
            }

            // all checks OK, cancel click before proceeding
            e.Cancel = true;
            Select(hit.Row, Cols.Fixed, hit.Row, Cols.Count - 1, false);

            // toggle row state
            ToggleRowState(hit.Row);
        }
        private void gridRoteiros_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)
        {
            if (e.Clicks > 1)
            {
                return;
            }
            //start dragging when the user clicks the cell
            C1FlexGrid  flex = (C1FlexGrid)sender;
            HitTestInfo hti  = flex.HitTest(e.X, e.Y);

            if (hti.Type == HitTestTypeEnum.Cell)
            {
                //select the row
                int index = hti.Row;
                if (index != 0)
                {
                    flex.Select(index, 0, index, flex.Cols.Count - 1, false);

                    ////save info for target
                    //_src = flex;

                    //do drag drop
                    DragDropEffects dd = flex.DoDragDrop(flex.Clip, DragDropEffects.Move);
                    //if it worked, delete row from source (it's a move)
                    if (dd == DragDropEffects.Move)
                    {
                        //flex.Rows.Remove(index);
                        //colunaOrdenacao = SEM_ORDENACAO;
                        //LimparGridRoteiros();
                        //PopulaRoteirosGrid(fachada.CarregarRoteiros(controladorSelecionado, painelSelecionado));
                        //gridRoteiros.Select()
                    }

                    ////done, reset info
                    //_src = null;
                }
            }
        }
Exemplo n.º 7
0
        private void c1FlexGrid1_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)
        {
            if (c1FlexGrid1.HitTest().Type == HitTestTypeEnum.Checkbox)
            {
                if (cRange.r1 != cRange.r2)
                {
                    int col, row;
                    col = c1FlexGrid1.HitTest(e.X, e.Y).Column;
                    row = c1FlexGrid1.HitTest(e.X, e.Y).Row;
                    //Cancel the default mouse down action
                    e.Cancel = true;
                    C1.Win.C1FlexGrid.CheckEnum chValue = c1FlexGrid1.GetCellCheck(row, col);
                    List <DataRowView>          drList  = new List <DataRowView>();
                    for (int i = cRange.r1; i <= cRange.r2; i++)
                    {
                        drList.Add(c1FlexGrid1.Rows[i].DataSource as DataRowView);
                    }

                    foreach (DataRowView dr in drList)
                    {
                        switch (chValue)
                        {
                        case C1.Win.C1FlexGrid.CheckEnum.Checked:
                        case C1.Win.C1FlexGrid.CheckEnum.TSChecked:
                            dr["chon"] = false;
                            break;

                        case C1.Win.C1FlexGrid.CheckEnum.Unchecked:
                        case C1.Win.C1FlexGrid.CheckEnum.TSUnchecked:
                            dr["chon"] = true;
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        // special mouse handling for filter row
        private void _flex_BeforeMouseDown(object sender, BeforeMouseDownEventArgs e)
        {
            // detect clicks on filter row
            if ((e.Button & MouseButtons.Left) != 0 && _row > 0 && _flex.MouseRow == _row)
            {
                // get the column that was clicked
                HitTestInfo ht = _flex.HitTest(e.X, e.Y);
                int col = ht.Column;

                // fixed column? select the whole filter row
                if (col < _flex.Cols.Fixed)
                {
                    _flex.Select(_row, _flex.Cols.Fixed, _row, _flex.Cols.Count - 1);
                    _flex.FinishEditing(true);
                }

                // clicked a cell on the filter row, select it
                else
                {
                    _flex.Select(_row, col);
                }

                // eat the event (no sorting, sizing etc)
                // unless this is a checkbox <<1.4>>
                if (ht.Type != HitTestTypeEnum.Checkbox)
                    e.Cancel = true;
            }
        }
Exemplo n.º 9
0
        // expand/collapse child grid
        //
        // if the user clicks the icons (drawn in the method above), either
        // create a child grid (and bind it to the detail records), or remove
        // the existing one.
        //
        override protected void OnBeforeMouseDown(BeforeMouseDownEventArgs e)
        {
            // always call base implementation
            base.OnBeforeMouseDown(e);

            // check that it's the Left button and that we have a hierarchy
            if (e.Button != MouseButtons.Left || _colChild == null)
            {
                return;
            }

            // check that it's a row header cell
            HitTestInfo hit = HitTest(e.X, e.Y);

            if (hit.Type != HitTestTypeEnum.RowHeader || hit.Row < Rows.Fixed)
            {
                return;
            }

            // check that the click was over the collapse/expand icon
            if (e.X < Cols[0].Right - (Glyphs[GlyphEnum.Collapsed].Width + 4) || _colChild[hit.Row] == null)
            {
                return;
            }

            // all checks OK, cancel click before proceeding
            e.Cancel = true;
            Select(hit.Row, Cols.Fixed, hit.Row, Cols.Count - 1, false);

            // create and show child grid
            if (Rows[hit.Row].UserData == null)
            {
                // create child grid
                C1FlexDataTree childGrid = new C1FlexDataTree();
                childGrid.Visible    = false;
                childGrid.ScrollBars = ScrollBars.Horizontal;

                // attach child grid to parent, set data source
                Controls.Add(childGrid);

                childGrid.ApplyParentStyles(this);
                childGrid.DataSource = _colChild[hit.Row];

                // save references:
                // child grid Tag property contains a reference to the parent row
                // parent row UserData contains a reference to the child grid
                childGrid.Tag          = Rows[hit.Row];
                Rows[hit.Row].UserData = childGrid;

                // add node row (unbound) to display child
                Rows.InsertNode(hit.Row + 1, -1);

                // move child grid into position, make it visible
                childGrid.UpdatePosition();
                childGrid.Visible = true;
                childGrid.Focus();
            }
            else             // hide and delete child grid
            {
                // get child grid
                C1FlexDataTree childGrid = (C1FlexDataTree)Rows[hit.Row].UserData;

                // break references
                Rows[hit.Row].UserData = null;
                childGrid.Tag          = null;

                // clear child and remove it from parent
                childGrid.Controls.Clear();
                Controls.Remove(childGrid);

                // delete container row
                var removeRowIndex = hit.Row + 1;
                if (Rows.Count > removeRowIndex)
                {
                    Rows.Remove(removeRowIndex);
                }
            }
        }