/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> object ICloneable.Clone() { AxisInfo info = new AxisInfo(); if (this.resizableSet) { info.Resizable = this.Resizable; info.resizableSet = this.resizableSet; } if (this.sizeSet) { info.Size = this.Size; info.sizeSet = this.sizeSet; } if (this.visibleSet) { info.Visible = this.Visible; info.visibleSet = this.visibleSet; } if (this.tagSet) { info.Tag = Worksheet.CloneObject(this.Tag); info.tagSet = this.tagSet; } return(info); }
/// <summary> /// Composes the specified source. /// </summary> /// <param name="source">The source.</param> public void Compose(AxisInfo source) { if (source != null) { if (source.sizeSet) { this.size = source.size; this.sizeSet = true; } if (source.visibleSet) { this.visible = source.visible; this.visibleSet = true; } if (source.resizableSet) { this.resizable = source.resizable; this.resizableSet = true; } if (source.tagSet) { this.tag = Worksheet.CloneObject(source.tag); this.tagSet = true; } } }
/// <summary> /// Copies properties from another instance. /// </summary> /// <param name="info">The axis information source to copy.</param> public void CopyFrom(AxisInfo info) { if (info != null) { this.size = info.size; this.visible = info.visible; this.resizable = info.resizable; this.tag = Worksheet.CloneObject(info.tag); this.sizeSet = info.sizeSet; this.visibleSet = info.visibleSet; this.resizableSet = info.resizableSet; this.tagSet = info.tagSet; } }
/// <summary> /// 获取视口当前左上角位置(相对于第一行第一列) /// </summary> /// <param name="p_rowViewportIndex"></param> /// <param name="p_colViewportIndex"></param> /// <returns></returns> public Point GetTopLeftLocation(int p_rowViewportIndex, int p_colViewportIndex) { ViewportInfo view = GetViewportInfo(); if (view.RowViewportCount <= 0 || view.ColumnViewportCount <= 0 || p_rowViewportIndex < 0 || p_rowViewportIndex >= view.RowViewportCount || p_colViewportIndex < 0 || p_colViewportIndex >= view.ColumnViewportCount) { return(new Point()); } int topRow = view.TopRows[p_rowViewportIndex]; int leftCol = view.LeftColumns[p_colViewportIndex]; double x = 0.0; double y = 0.0; for (int i = 0; i < leftCol; i++) { if (_columnRangeGroup != null && !_columnRangeGroup.IsEmpty() && _columnRangeGroup.IsCollapsed(i)) { continue; } AxisInfo info = _viewportColumns[i]; if (info == null) { x += DefaultColumnWidth; } else if (info.Visible) { if (info.IsSizeSet() && info.Size >= 0.0) { x += info.Size; } else { x += DefaultColumnWidth; } } } for (int j = 0; j < topRow; j++) { if (_rowRangeGroup != null && !_rowRangeGroup.IsEmpty() && _rowRangeGroup.IsCollapsed(j)) { continue; } AxisInfo info = _viewportRows[j]; if (info == null) { y += DefaultRowHeight; } else if (info.Visible) { if (info.IsSizeSet() && info.Size >= 0.0) { y += info.Size; } else { y += DefaultRowHeight; } } } return(new Point(x, y)); }