Example #1
0
        internal async void ApplyState()
        {
            FilterButtonInfo filterButtonInfo = _owner.FilterButtonInfo;

            if (filterButtonInfo == null)
            {
                Bitmap = await SR.GetImage("NoSortFilter.png");
            }
            else
            {
                SortState sortState = filterButtonInfo.GetSortState();
                if (filterButtonInfo.IsFiltered())
                {
                    switch (sortState)
                    {
                    case SortState.None:
                        Bitmap = await SR.GetImage("Filter.png");

                        break;

                    case SortState.Ascending:
                        Bitmap = await SR.GetImage("FilterAscend.png");

                        break;

                    case SortState.Descending:
                        Bitmap = await SR.GetImage("FilterDescend.png");

                        break;
                    }
                }
                else
                {
                    switch (sortState)
                    {
                    case SortState.None:
                        Bitmap = await SR.GetImage("NoSortFilter.png");

                        break;

                    case SortState.Ascending:
                        Bitmap = await SR.GetImage("Ascend.png");

                        break;

                    case SortState.Descending:
                        Bitmap = await SR.GetImage("Descend.png");

                        break;
                    }
                }
            }
        }
Example #2
0
 public SortCommand(Excel p_excel, FilterButtonInfo info, bool ascending)
 {
     _info      = info;
     _ascending = ascending;
     _excel     = p_excel;
 }
Example #3
0
 public FilterCommand(Excel p_excel, FilterButtonInfo info, int column)
 {
     _excel  = p_excel;
     _column = column;
     _info   = info;
 }
Example #4
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
        }