Beispiel #1
0
 internal static void ReleaseCellElement(
     CellElementProvider cellProvider,
     GridRowElement rowElement,
     GridCellElement cell)
 {
     GridExportUtils.ReleaseCellElement(cellProvider, rowElement, cell, true);
 }
Beispiel #2
0
            public override bool OnMouseMove(MouseEventArgs e)
            {
                if (e.Button != MouseButtons.Left)
                {
                    this.mouseDownPoint = Point.Empty;
                    return(base.OnMouseMove(e));
                }

                if (!this.GridViewElement.IsInEditMode && this.ShouldBeginDrag(this.mouseDownPoint, e.Location))
                {
                    RadElement element = this.GridControl.ElementTree.GetElementAtPoint(e.Location);

                    GridCellElement cell = element as GridCellElement;

                    if (cell != null && cell == this.GridViewElement.CurrentCell)
                    {
                        DragObject dragObject = new DragObject();

                        dragObject.Values.Add(AppointmentFields.Summary, cell.RowInfo.Cells["Summary"].Value);
                        dragObject.Values.Add(AppointmentFields.Start, cell.RowInfo.Cells["Start"].Value);
                        dragObject.Values.Add(AppointmentFields.End, cell.RowInfo.Cells["End"].Value);
                        dragObject.Values.Add(AppointmentFields.Description, cell.RowInfo.Cells["Description"].Value);
                        dragObject.Values.Add(AppointmentFields.Background, cell.RowInfo.Cells["BackgroundID"].Value);
                        dragObject.Values.Add(AppointmentFields.Status, cell.RowInfo.Cells["StatusID"].Value);
                        dragObject.Values.Add(AppointmentFields.Location, cell.RowInfo.Cells["Location"].Value);

                        dragObject.Status = AppointmentFields.Row;

                        this.GridViewElement.ElementTree.Control.DoDragDrop(dragObject, DragDropEffects.Copy);
                        return(true);
                    }
                }

                return(base.OnMouseMove(e));
            }
Beispiel #3
0
        private void gridView_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            GridCellElement    cellElement = e.CellElement;
            GridViewDataColumn columnInfo  = e.CellElement.ColumnInfo as GridViewDataColumn;

            if (cellElement is GridCheckBoxCellElement)
            {
            }

            if (columnInfo != null && !cellElement.RowInfo.IsCurrent && !cellElement.RowInfo.IsSelected &&
                cellElement.RowElement.RowVisualState != GridRowElement.RowVisualStates.Hovered &&
                (columnInfo.Name == "Category" && Object.Equals(cellElement.Text, columnInfo.NullValue) ||
                 columnInfo == changedColumn))
            {
                e.CellElement.BackColor     = columnInfo.Name == "Category" ? Color.Pink : Color.PaleGoldenrod;
                e.CellElement.GradientStyle = GradientStyles.Solid;
                e.CellElement.DrawFill      = true;
            }
            else
            {
                e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
            }
        }
Beispiel #4
0
        internal static double GetRowHeight(
            RadGridView radGridView,
            RowElementProvider rowProvider,
            CellElementProvider cellProvider,
            GridViewRowInfo gridViewRowInfo,
            bool exportVisualSettings)
        {
            double val1 = 0.0;

            if (radGridView.AutoSizeRows && exportVisualSettings)
            {
                GridRowElement element1 = rowProvider.GetElement(gridViewRowInfo, (object)null) as GridRowElement;
                element1.InitializeRowView(radGridView.TableElement);
                element1.Initialize(gridViewRowInfo);
                radGridView.TableElement.Children.Add((RadElement)element1);
                foreach (GridViewColumn column in (Collection <GridViewDataColumn>)element1.ViewTemplate.Columns)
                {
                    if (!(column is GridViewRowHeaderColumn) && !(column is GridViewIndentColumn))
                    {
                        GridCellElement element2 = cellProvider.GetElement(column, (object)element1) as GridCellElement;
                        element1.Children.Add((RadElement)element2);
                        element2.Initialize(column, element1);
                        val1 = Math.Max(val1, (double)GridExportUtils.GetCellDesiredSize(element2).Height);
                        GridExportUtils.ReleaseCellElement(cellProvider, element1, element2);
                    }
                }
                GridExportUtils.ReleaseRowElement(radGridView, rowProvider, element1);
            }
            return(Math.Max(val1, (double)radGridView.TableElement.RowScroller.ElementProvider.GetElementSize(gridViewRowInfo).Height));
        }
        public override RectangleF ArrangeCell(RectangleF clientRect, GridCellElement cell)
        {
            RowDetailsGrid grid = (RowDetailsGrid)Owner.GridViewElement.GridControl;

            if (cell.ColumnInfo == grid.DetailsColumn)
            {
                cell.StretchHorizontally  = true;
                cell.BypassLayoutPolicies = true;
                if (cell.RowElement.IsCurrent)
                {
                    return(new RectangleF(0, Owner.RowHeight, availableSize.Width - systemWidth, grid.DetailsRowHeight - Owner.RowHeight));
                }
                else
                {
                    return(RectangleF.Empty);
                }
            }

            if (cell is GridDataCellElement)
            {
                clientRect.Height = Owner.RowHeight;
            }

            return(base.ArrangeCell(clientRect, cell));
        }
        private static void ConfigureGridLines(GridCellElement cellElement, Color lineColor)
        {
            cellElement.BorderBottomWidth = 1;
            cellElement.BorderBottomColor = lineColor;

            cellElement.BorderRightWidth = 1;
            cellElement.BorderRightColor = lineColor;
        }
Beispiel #7
0
 internal static SizeF GetCellDesiredSize(GridCellElement cell)
 {
     cell.SetContent();
     cell.UpdateInfo();
     (cell as GridHeaderCellElement)?.UpdateArrowState();
     cell.ResetLayout(true);
     cell.Measure(new SizeF((float)cell.ColumnInfo.Width, float.PositiveInfinity));
     return(cell.DesiredSize);
 }
Beispiel #8
0
        //اسم ستونی که انتخاب شده را ذخیره می کند
        void radGridViewExtended1_CellMouseMove(object sender, MouseEventArgs e)
        {
            GridCellElement cell = (GridCellElement)sender;

            if (cell.Value != null)
            {
                _ColumnName = null;
                _ColumnName = cell.ColumnInfo.FieldName;
            }
        }
Beispiel #9
0
 private void radGridView1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right && radGridView1.RowCount != 0)
     {
         RadGridView     grid = (RadGridView)sender;
         GridCellElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
         if (cell != null && cell.ToString() != "Telerik.WinControls.UI.GridHeaderCellElement")
         {
             Point p = (sender as Control).PointToScreen(e.Location);
             radContextMenu1.Show(p.X, p.Y);
         }
     }
 }
        protected override void CreateChildElements()
        {
            base.CreateChildElements();

            this.cellElement = new GridCellElement(null, this);
            this.cellElement.StretchHorizontally = true;
            this.cellElement.StretchVertically   = true;
            this.Children.Add(cellElement);

            this.hostedControl = new AdvanceFilterControl();
            RadHostItem hostItem = new RadHostItem(this.hostedControl);

            this.cellElement.Children.Add(hostItem);
        }
Beispiel #11
0
        private void OrderGV_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            GridCellElement    cellElement = e.CellElement;
            GridViewDataColumn ColumnItem  = e.CellElement.ColumnInfo as GridViewDataColumn;

            if (ColumnItem.OwnerTemplate is MasterGridViewTemplate)
            {
                //布尔型居中 指定字段居中
                if (ColumnItem != null &&
                    ColumnItem.DataType == typeof(bool) || CenterColumnName.Contains(ColumnItem.Name))
                {
                    e.CellElement.TextAlignment = ContentAlignment.MiddleCenter;
                }
            }
        }
Beispiel #12
0
        // Fires when the editor changes its value. The value is stored only inside the editor.
        void radGridView1_ValueChanged(object sender, EventArgs e)
        {
            TrackBarEditor editor = sender as TrackBarEditor;

            if (editor != null)
            {
                GridCellElement cell = this.radGridView1.TableElement.GetCellElement(this.radGridView1.CurrentRow, this.radGridView1.Columns["Opacity"]);

                if (cell != null)
                {
                    cell.Text = editor.Value + " %";
                }

                GridCellElement imageCell = this.radGridView1.TableElement.GetCellElement(this.radGridView1.CurrentRow, this.radGridView1.Columns["Image"]);

                if (imageCell != null)
                {
                    imageCell.ImageOpacity = (double)((int)editor.Value / 100.0);
                }
            }
        }
Beispiel #13
0
        internal static void ReleaseCellElement(
            CellElementProvider cellProvider,
            GridRowElement rowElement,
            GridCellElement cell,
            bool cache)
        {
            GridVirtualizedCellElement virtualizedCellElement = cell as GridVirtualizedCellElement;

            if (virtualizedCellElement != null)
            {
                if (cache)
                {
                    cellProvider.CacheElement((IVirtualizedElement <GridViewColumn>)virtualizedCellElement);
                }
                virtualizedCellElement.Detach();
                rowElement.Children.Remove((RadElement)cell);
            }
            else
            {
                cell.Dispose();
            }
        }
Beispiel #14
0
        private void gridView_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            int             columnIndex = e.CellElement.ColumnIndex;
            int             rowIndex    = e.CellElement.RowIndex;
            GridCellElement cell        = e.CellElement;

            if (rowIndex == rowBeginIndex - 1)
            {
                if (columnIndex == totalColumnIndex || columnIndex == comissionColumnIndex ||
                    columnIndex == feeColumnIndex || columnIndex == clientColumnIndex)
                {
                    if (cell.IsSelected)
                    {
                        cell.BackColor = Color.FromArgb(162, 207, 223);
                    }
                }
            }
            else if (rowIndex > rowBeginIndex - 1 && rowIndex < rowBeginIndex + 8)
            {
                if (columnIndex == totalColumnIndex || columnIndex == comissionColumnIndex ||
                    columnIndex == feeColumnIndex || columnIndex == clientColumnIndex)
                {
                    if (cell.IsSelected)
                    {
                        cell.BackColor = Color.FromArgb(228, 227, 216);
                    }
                }
            }

            if (IsNumber(e.CellElement.Value))
            {
                e.CellElement.Alignment = ContentAlignment.TopRight;
            }
            else
            {
                e.CellElement.Alignment = ContentAlignment.TopLeft;
            }
        }
Beispiel #15
0
        public override RectangleF ArrangeCell(RectangleF clientRect, GridCellElement cell)
        {
            GridViewRowDetailsExtended grid = (GridViewRowDetailsExtended)Owner.GridViewElement.GridControl;

            if (ReferenceEquals(cell.ColumnInfo, grid.DetailsColumn))
            {
                cell.StretchHorizontally  = true;
                cell.BypassLayoutPolicies = true;

                if (cell.RowElement is RowDetailsRowElement)
                {
                    if (((GridViewRowDetailsExtended)cell.RowElement.GridControl).EnableAllExpand && ((GridViewRowDetailsExtended)cell.RowElement.GridControl).ShowRowDetails)
                    {
                        return(new RectangleF(0, Owner.RowHeight, _availableSize.Width - _systemWidth, grid.DetailsRowHeight - Owner.RowHeight));
                    }
                    else if (((GridViewRowDetailsExtended)cell.RowElement.GridControl).ShowRowDetails)
                    {
                        return(cell.RowElement.IsCurrent ? new RectangleF(0, Owner.RowHeight, _availableSize.Width - _systemWidth, grid.DetailsRowHeight - Owner.RowHeight) : RectangleF.Empty);
                    }
                    else
                    {
                        return(RectangleF.Empty);
                    }
                }
                else
                {
                    return(RectangleF.Empty);
                }
            }

            if (cell is GridDataCellElement)
            {
                clientRect.Height = Owner.RowHeight;
            }

            return(base.ArrangeCell(clientRect, cell));
        }
        //, GridRowElement rowElement)
        /// <summary>
        /// The move rows.
        /// </summary>
        /// <param name="targetGrid">
        /// The target grid.
        /// </param>
        /// <param name="dragGrid">
        /// The drag grid.
        /// </param>
        /// <param name="dragRows">
        /// The drag rows.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        private void MoveRows(RadGridView targetGrid, RadGridView dragGrid, GridCellElement cellElement)
        {
            dragGrid.BeginUpdate();
            targetGrid.BeginUpdate();

            Console.WriteLine("HERE!");
            targetGrid.Rows[cellElement.RowIndex].Cells[cellElement.ColumnIndex].Value = "blq";

            dragGrid.EndUpdate(true);
            targetGrid.EndUpdate(true);
        }
Beispiel #17
0
 public CellFormattingEventArgs(GridCellElement cell)
     : base(cell.RowInfo, cell.ColumnInfo)
 {
     this.cellElement = cell;
 }
        /// <summary>
        /// The move rows.
        /// </summary>
        /// <param name="targetGrid">
        /// The target grid.
        /// </param>
        /// <param name="dragGrid">
        /// The drag grid.
        /// </param>
        /// <param name="dragRows">
        /// The drag rows.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        private void MoveCell(RadGridView targetGrid, RadGridView dragGrid, GridCellElement cellElement, int index, int indexRow, int indexColumn)
        {
            dragGrid.BeginUpdate();
            targetGrid.BeginUpdate();

            if (targetGrid != null)
            {
                targetGrid.Rows[indexRow].Cells[indexColumn].Value = cellElement.Value;
                targetGrid.Rows[indexRow].Cells[indexColumn].Tag = cellElement.Tag;

                dragGrid.Rows[cellElement.RowIndex].Cells[cellElement.ColumnIndex].Value = "";
                dragGrid.Rows[cellElement.RowIndex].Cells[cellElement.ColumnIndex].Tag = null;
            }

            dragGrid.EndUpdate(true);
            targetGrid.EndUpdate(true);
        }
    protected override bool ProcessMouseSelection(System.Drawing.Point mousePosition, GridCellElement currentCell)
    {
        bool result = base.ProcessMouseSelection(mousePosition, currentCell);

        if (result)
        {
            List <GridViewRowInfo> orderedRows = new List <GridViewRowInfo>();
            PrintGridTraverser     traverser   = new PrintGridTraverser(this.GridControl.MasterView);
            traverser.ProcessHiddenRows = true;
            traverser.ProcessHierarchy  = true;

            while (traverser.MoveNext())
            {
                orderedRows.Add(traverser.Current);
            }
            int minIndex = int.MaxValue;
            int maxIndex = int.MinValue;
            foreach (GridViewDataRowInfo selectedRow in this.GridControl.SelectedRows)
            {
                int rowIndex = orderedRows.IndexOf(selectedRow);
                if (rowIndex > maxIndex)
                {
                    maxIndex = rowIndex;
                }
                if (rowIndex < minIndex)
                {
                    minIndex = rowIndex;
                }
            }
            this.GridControl.ClearSelection();
            for (int i = minIndex; i <= maxIndex; i++)
            {
                if (!orderedRows[i].IsSelected)
                {
                    orderedRows[i].IsSelected = true;
                }
            }
        }
        return(result);
    }