Esempio n. 1
0
        void GroupHeaderButton_Click(object sender, RoutedEventArgs e)
        {
            GroupHeaderButton presenter = sender as GroupHeaderButton;
            Worksheet         sheet     = _excel.ActiveSheet;

            if (((presenter != null) && (sheet != null)) && !_excel.IsEditing)
            {
                int level = int.Parse(presenter.Level) - 1;
                if (level >= 0)
                {
                    _excel.InvalidateRangeGroup();
                    if (Orientation == Windows.UI.Xaml.Controls.Orientation.Horizontal)
                    {
                        RowGroupHeaderExpandExtent rowGroupHeaderExpandExtent = new RowGroupHeaderExpandExtent(level);
                        if (!_excel.RaiseRangeGroupStateChanging(true, -1, level))
                        {
                            RowGroupHeaderExpandUndoAction command = new RowGroupHeaderExpandUndoAction(sheet, rowGroupHeaderExpandExtent);
                            _excel.DoCommand(command);
                            _excel.RaiseRangeGroupStateChanged(true, -1, level);
                        }
                    }
                    else if (Orientation == Windows.UI.Xaml.Controls.Orientation.Vertical)
                    {
                        ColumnGroupHeaderExpandExtent     columnGroupHeaderExpandExtent = new ColumnGroupHeaderExpandExtent(level);
                        ColumnGroupHeaderExpandUndoAction action2 = new ColumnGroupHeaderExpandUndoAction(sheet, columnGroupHeaderExpandExtent);
                        if (!_excel.RaiseRangeGroupStateChanging(false, -1, level))
                        {
                            _excel.DoCommand(action2);
                            _excel.RaiseRangeGroupStateChanged(false, -1, level);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        protected override Size MeasureOverride(Size availableSize)
        {
            int    maxLevel = GetMaxLevel(Orientation);
            double size     = CalcMinWidthOrHeight(availableSize, Orientation);

            if (maxLevel == -1 || size == 0.0)
            {
                _maxLevel = -1;
                _lastSize = 0;
                return(availableSize);
            }

            if (_maxLevel == maxLevel && _lastSize == size)
            {
                foreach (UIElement elem in Children)
                {
                    elem.Measure(availableSize);
                }
                return(availableSize);
            }

            _maxLevel = maxLevel;
            _lastSize = size;
            Children.Clear();
            if ((_headButtons != null) && (_headButtons.Count > 0))
            {
                foreach (GroupHeaderButton rbp in _headButtons)
                {
                    rbp.Click -= GroupHeaderButton_Click;
                }
            }

            _headButtons = new List <GroupHeaderButton>();
            for (int i = 0; i < maxLevel + 2; i++)
            {
                GroupHeaderButton presenter = new GroupHeaderButton();
                presenter.Click += GroupHeaderButton_Click;
                presenter.Level  = (i + 1).ToString();
                presenter.Height = size;
                presenter.Width  = size;
                Children.Add(presenter);
                _headButtons.Add(presenter);
            }

            MeasureBorderLines(availableSize);
            return(availableSize);
        }