Ejemplo n.º 1
0
        void UpdateActiveSelectionLayouts()
        {
            Rect      rcSelection = _owner._cachedActiveSelectionLayout;
            Rect      rcFocus     = _owner._cachedFocusCellLayout;
            CellRange range       = null;

            _activeSelectionLayouts.Clear();
            CellRange viewportRange = GetViewportRange();

            if (_owner.IsActived && (_owner.Excel.ActiveSheet.ActiveCell != null))
            {
                Worksheet ws = _owner.Excel.ActiveSheet;
                range = new CellRange(ws.ActiveRowIndex, ws.ActiveColumnIndex, 1, 1);
                CellRange range3 = ws.SpanModel.Find(range.Row, range.Column);
                if ((range3 != null) && viewportRange.Intersects(range3.Row, range3.Column, range3.RowCount, range3.ColumnCount))
                {
                    range = CellRange.GetIntersect(viewportRange, range3, viewportRange.RowCount, viewportRange.ColumnCount);
                }
            }

            if (_owner.IsActived)
            {
                if ((viewportRange.RowCount == 0) || (viewportRange.ColumnCount == 0))
                {
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                }
                else if ((range != null) && !viewportRange.Contains(range))
                {
                    _activeSelectionLayouts.Add(rcSelection);
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                }
                else if (_owner._cachedActiveSelection != null &&
                         range != null &&
                         IsActiveCellBoundsValid &&
                         _owner._cachedActiveSelection != range &&
                         _owner._cachedActiveSelection.Contains(range))
                {
                    Rect   rect3 = new Rect(rcSelection.X, rcSelection.Y, rcSelection.Width, rcFocus.Y - rcSelection.Y);
                    Rect   rect4 = new Rect(rcSelection.X, rcFocus.Y, rcFocus.X - rcSelection.X, rcFocus.Height);
                    double width = rcSelection.Right - rcFocus.Right;
                    if (width < 0.0)
                    {
                        width = 0.0;
                    }
                    Rect   rect5  = new Rect(rcFocus.Right, rcFocus.Y, width, rcFocus.Height);
                    double height = rcSelection.Bottom - rcFocus.Bottom;
                    if (height < 0.0)
                    {
                        height = 0.0;
                    }
                    Rect rect6 = new Rect(rcSelection.X, rcFocus.Bottom, rcSelection.Width, height);
                    _activeSelectionLayouts.Add(rect3);
                    _activeSelectionLayouts.Add(rect4);
                    _activeSelectionLayouts.Add(rect5);
                    _activeSelectionLayouts.Add(rect6);
                }
                else
                {
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                    _activeSelectionLayouts.Add(Rect.Empty);
                }
            }
            else if ((viewportRange.RowCount == 0) || (viewportRange.ColumnCount == 0))
            {
                _activeSelectionLayouts.Add(Rect.Empty);
                _activeSelectionLayouts.Add(Rect.Empty);
                _activeSelectionLayouts.Add(Rect.Empty);
                _activeSelectionLayouts.Add(Rect.Empty);
            }
            else
            {
                _activeSelectionLayouts.Add(rcSelection);
                _activeSelectionLayouts.Add(Rect.Empty);
                _activeSelectionLayouts.Add(Rect.Empty);
                _activeSelectionLayouts.Add(Rect.Empty);
            }
        }