Example #1
0
        public override void OnInitializeContent(CustomeDropDown dropDownControl, GridRenderStyleInfo style)
        {
            if (dropDownControl.ListBoxPart != null)
            {
                dropDownControl.ListBoxPart.SelectionChanged -= this.OnComboBoxSelectionChanged;
            }

            base.OnInitializeContent(dropDownControl, style);
        }
        protected override void OnRender(DrawingContext dc, RenderCellArgs rca, GridRenderStyleInfo cellInfo)
        {
            if (rca.CellUIElements != null)
            {
                return;
            }

            // Will only get hit if SupportsRenderOptimization is true, otherwise rca.CellVisuals is never null.
            string s = String.Format("Render{0}/{1}", rca.RowIndex, rca.ColumnIndex);

            GridTextBoxPaint.DrawText(dc, rca.CellRect, s, cellInfo);
        }
        private void InitDefaultProperties(TextBox textBox, GridRenderStyleInfo style)
        {
            Thickness margins = style.TextMargins.ToThickness();

            // TextBoxView always has a minimum margin of 2 for left and right.
            // Margin is hardcoded below so that TextBox behavior is properly emulated.
            margins.Left  = Math.Max(0, margins.Left - 2);
            margins.Right = Math.Max(0, margins.Right - 2);

            textBox.Padding         = margins;
            textBox.BorderThickness = new Thickness(0);
            VirtualizingCellsControl.SetWantsMouseInput(textBox, true);

            textBox.Text = GetControlText(style);
        }
        private SparkLine GetSparkLine(GridRenderStyleInfo cellInfo)
        {
            Syncfusion.XlsIO.ISparklineGroup spGroup = cellInfo.CellValue as Syncfusion.XlsIO.ISparklineGroup;
            SparkLine sparkLine = new SparkLine();

            if (spGroup != null)
            {
                sparkLine.DataMemberPath = "";

                switch (spGroup.SparklineType)
                {
                case Syncfusion.XlsIO.SparklineType.Column:
                    sparkLine.SparkLineType = SparkLineTypes.Column;
                    break;

                case Syncfusion.XlsIO.SparklineType.Line:
                    sparkLine.SparkLineType = SparkLineTypes.Line;
                    break;

                case Syncfusion.XlsIO.SparklineType.ColumnStacked100:
                    sparkLine.SparkLineType = SparkLineTypes.WinLoss;
                    break;

                default:
                    break;
                }

                sparkLine.ItemsSource = GetSparkLineItemSource(spGroup, cellInfo).AsEnumerable <double>();

                // Hightlinght color.
                sparkLine.FirstPointHighlightBrush     = GetSparkLineBrush(spGroup.FirstPointColor);
                sparkLine.HighPointHighlightBrush      = GetSparkLineBrush(spGroup.HighPointColor);
                sparkLine.LowPointHighlightBrush       = GetSparkLineBrush(spGroup.LowPointColor);
                sparkLine.LastPointHighlightBrush      = GetSparkLineBrush(spGroup.LastPointColor);
                sparkLine.NegativePointsHighlightBrush = GetSparkLineBrush(spGroup.NegativePointColor);

                sparkLine.IsLastPointHighlighted      = spGroup.ShowLastPoint;
                sparkLine.IsFirstPointHighlighted     = spGroup.ShowFirstPoint;
                sparkLine.IsLowPointHighlighted       = spGroup.ShowLowPoint;
                sparkLine.IsHighPointHighlighted      = spGroup.ShowHighPoint;
                sparkLine.IsNegativePointsHighlighted = spGroup.ShowNegativePoint;

                sparkLine.IsFirstPointHighlighted = true;
                sparkLine.IsLastPointHighlighted  = true;
            }
            return(sparkLine);
        }
Example #5
0
        public override void CreateRendererElement(UserControl1 uiElement, GridRenderStyleInfo style)
        {
            var range = this.GridControl.Model.SelectedRanges;
            var grid  = uiElement.child;

            if (range != null && range.AnyRangeContains(GridRangeInfo.Cell(style.CellIdentity.RowIndex, style.CellIdentity.ColumnIndex)))
            {
                if (grid.Model.SelectedRanges.Count == 0)
                {
                    grid.Model.SelectedRanges.Add(GridRangeInfo.Table());
                    grid.InvalidateCell(GridRangeInfo.Cell(0, 0));
                }
            }
            else
            {
                grid.Model.SelectedRanges.Clear();
                grid.InvalidateCells();
            }
            base.CreateRendererElement(uiElement, style);
        }
        public override void CreateRendererElement(ContentControl uiElement, GridRenderStyleInfo style)
        {
            bool found = false;

            if (style.CellItemTemplateKey != null)
            {
                DataTemplate dt = (DataTemplate)style.GridControl.TryFindResource(style.CellItemTemplateKey);
                found = dt != null;
                if (found)
                {
                    uiElement.ContentTemplate = dt;
                }
            }

            if (!found)
            {
                uiElement.ContentTemplate = style.CellItemTemplate;
            }

            uiElement.Content = style.CellValue;
            base.CreateRendererElement(uiElement, style);
        }
Example #7
0
        protected override void ArrangeUIElement(Syncfusion.Windows.Controls.Cells.ArrangeCellArgs aca, CustomeDropDown uiElement, GridRenderStyleInfo style)
        {
            base.ArrangeUIElement(aca, uiElement, style);
            var dropDownControl = uiElement;

            if (style.ItemsSource != null)
            {
                dropDownControl.ListBoxPart.ItemsSource       = this.CustomDropDownModel.GetDataSource(style);
                dropDownControl.ListBoxPart.DisplayMemberPath = style.HasDisplayMember ? style.DisplayMember : string.Empty;
                dropDownControl.ListBoxPart.SelectedValue     = this.GetControlValue(style);
                if (style.HasValueMember)
                {
                    dropDownControl.ListBoxPart.SelectedValuePath = style.ValueMember;
                }
            }

            uiElement.ListBoxPart.SelectionChanged += this.OnComboBoxSelectionChanged;
        }
        protected override void OnRender(System.Windows.Media.DrawingContext dc, RenderCellArgs rca, GridRenderStyleInfo style)
        {
            base.OnRender(dc, rca, style);
            GridRangeInfo range = GridControl.Model.SelectedCells;

            if (range.Bottom == rca.RowIndex && range.Right == rca.ColumnIndex)
            {
                Rect r = rca.CellRect;
                r.X      = r.Right - 2;
                r.Width  = 4;
                r.Y      = r.Bottom - 2;
                r.Height = 4;
                dc.DrawRectangle(Brushes.Black, null, r);
            }
        }
 public override void CreateRendererElement(TextBox textBox, GridRenderStyleInfo style)
 {
     base.CreateRendererElement(textBox, style);
     this.InitDefaultProperties(textBox, style);
 }
 /// <summary>
 /// Called to initialize the content of the cell
 /// using the information from the cell style (value, text,
 /// behavior etc.). You must override this method in your
 /// derived class.
 /// </summary>
 /// <param name="textBox">The text box.</param>
 /// <param name="style">The cell style info.</param>
 public override void OnInitializeContent(TextBox textBox, GridRenderStyleInfo style)
 {
     base.OnInitializeContent(textBox, style);
     this.InitDefaultProperties(textBox, style);
 }
        protected override void OnRender(System.Windows.Media.DrawingContext dc, RenderCellArgs rca, GridRenderStyleInfo cellInfo)
        {
            if (rca.CellUIElements != null)
            {
                return;
            }

            Rect      cellRect  = rca.CellRect;
            SparkLine sparkLine = GetSparkLine(cellInfo);

            if (sparkLine != null)
            {
                sparklinePaint.DrawSparkline(dc, cellRect, sparkLine, cellInfo);
                cellInfo.EnableFloatingCell = false;
                // cellInfo.ModelStyle.EnableFloatingCell = false;
            }

            base.OnRender(dc, rca, cellInfo);
        }
 public override void OnInitializeContent(SparkLine uiElement, GridRenderStyleInfo style)
 {
     base.OnInitializeContent(uiElement, style);
 }
 public override void CreateRendererElement(SparkLine uiElement, GridRenderStyleInfo style)
 {
     base.CreateRendererElement(uiElement, style);
 }
        private List <double> GetSparkLineItemSource(Syncfusion.XlsIO.ISparklineGroup spGroup, GridRenderStyleInfo cellInfo)
        {
            List <double> itemSource = new List <double>();

            // get the sparklines count.
            for (int line = 0; line < spGroup.Count; line++)
            {
                // ISparklineGroup spGroup = spGroups[i];
                ISparklines spLines = spGroup[line];
                for (int j = 0; j < spLines.Count; j++)
                {
                    ISparkline spLine    = spGroup[line][j];
                    IRange     dataRange = spLine.DataRange;
                    for (int rowInd = dataRange.Row; rowInd <= dataRange.LastRow; rowInd++)
                    {
                        if (spLine.ReferenceRange.Row == cellInfo.RowIndex)
                        {
                            for (int colInd = dataRange.Column; colInd <= dataRange.LastColumn; colInd++)
                            {
                                double cellValue;
                                if (double.TryParse(cellInfo.GridModel[rowInd, colInd].FormattedText, out cellValue))
                                {
                                    itemSource.Add(cellValue);
                                }
                            }
                        }
                    }
                }
            }

            return(itemSource);
        }