Exemplo n.º 1
0
        //*** CellsPanel.Measure -> RowsLayer.Measure -> RowItem.UpdateChildren -> 行列改变时 CellItem.UpdateChildren -> RowItem.Measure -> CellItem.Measure ***//

        public void UpdateChildren()
        {
            // 刷新绑定的Cell
            int row    = OwnRow.Row;
            int column = Column;

            if (CellLayout != null)
            {
                row    = CellLayout.Row;
                column = CellLayout.Column;
            }
            BindingCell = OwnRow.OwnPanel.CellCache.GetCachedCell(row, column);
            if (BindingCell == null)
            {
                return;
            }

            Background = BindingCell.ActualBackground;
            var       excel = Excel;
            Worksheet sheet = BindingCell.Worksheet;

            // 迷你图
            Sparkline sparkline = sheet.GetSparkline(row, column);

            if (_sparkInfo != sparkline)
            {
                SparkLine = sparkline;
                SynSparklineView();
            }

            // 收集所有DrawingObject
            List <DrawingObject> list = new List <DrawingObject>();

            DrawingObject[] objArray = sheet.GetDrawingObject(row, column, 1, 1);
            if ((objArray != null) && (objArray.Length > 0))
            {
                list.AddRange(objArray);
            }

            IDrawingObjectProvider drawingObjectProvider = DrawingObjectManager.GetDrawingObjectProvider(excel);

            if (drawingObjectProvider != null)
            {
                DrawingObject[] objArray2 = drawingObjectProvider.GetDrawingObjects(sheet, row, column, 1, 1);
                if ((objArray2 != null) && (objArray2.Length > 0))
                {
                    list.AddRange(objArray2);
                }
            }

            _dataBarObject       = null;
            _iconObject          = null;
            _customDrawingObject = null;
            if (list.Count > 0)
            {
                foreach (DrawingObject obj in list)
                {
                    if (obj is DataBarDrawingObject bar)
                    {
                        _dataBarObject = bar;
                    }
                    else if (obj is IconDrawingObject icon)
                    {
                        _iconObject = icon;
                    }
                    else if (obj is CustomDrawingObject cust)
                    {
                        _customDrawingObject = cust;
                    }
                }
            }

            bool noBarIcon = SynContitionalView();
            bool noCust    = SynCustomDrawingObjectView();

            if (sparkline == null && noBarIcon && noCust && !string.IsNullOrEmpty(BindingCell.Text))
            {
                _tb.Text = BindingCell.Text;
                ApplyStyle();
            }
            else
            {
                _tb.ClearValue(TextBlock.TextProperty);
            }
            SynStrikethroughView();

#if UWP || WASM
            // 手机上体验不好
            if (!excel.IsTouching)
            {
                FilterButtonInfo info = excel.GetFilterButtonInfo(row, column, BindingCell.SheetArea);
                if (info != FilterButtonInfo)
                {
                    FilterButtonInfo = info;
                    SynFilterButton();
                }
            }
#endif
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sets the value of the <see cref="T:GrapeCity.Windows.SpreadSheet.UI.DrawingObjectManager.IDrawingObjectProvider" /> attached property
 /// for a given <see cref="T:GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet" /> control.
 /// </summary>
 /// <param name="element">A <see cref="T:GrapeCity.Windows.SpreadSheet.UI.GcSpreadSheet" /></param>
 /// <param name="value">An instance of custom <see cref="T:GrapeCity.Windows.SpreadSheet.UI.IDrawingObjectProvider" /></param>
 public static void SetDrawingObjectProvider(Excel element, IDrawingObjectProvider value)
 {
     element.SetValue(DrawingObjectProviderProperty, value);
 }