// Token: 0x060068FD RID: 26877 RVA: 0x001D9CD0 File Offset: 0x001D7ED0 internal void DrawBackgroundAndBorderIntoContext(DrawingContext dc, Brush backgroundBrush, Brush borderBrush, Thickness borderThickness, Rect renderBounds, bool isFirstChunk, bool isLastChunk) { this._backgroundBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(backgroundBrush); this._renderBounds = renderBounds; this._borderBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(borderBrush); this._borderThickness = borderThickness; if (!isFirstChunk) { this._borderThickness.Top = 0.0; } if (!isLastChunk) { this._borderThickness.Bottom = 0.0; } if (this._borderBrush != null) { Pen pen = new Pen(); pen.Brush = this._borderBrush; pen.Thickness = this._borderThickness.Left; if (pen.CanFreeze) { pen.Freeze(); } if (this._borderThickness.IsUniform) { dc.DrawRectangle(null, pen, new Rect(new Point(this._renderBounds.Left + pen.Thickness * 0.5, this._renderBounds.Bottom - pen.Thickness * 0.5), new Point(this._renderBounds.Right - pen.Thickness * 0.5, this._renderBounds.Top + pen.Thickness * 0.5))); } else { if (DoubleUtil.GreaterThan(this._borderThickness.Left, 0.0)) { dc.DrawLine(pen, new Point(this._renderBounds.Left + pen.Thickness / 2.0, this._renderBounds.Top), new Point(this._renderBounds.Left + pen.Thickness / 2.0, this._renderBounds.Bottom)); } if (DoubleUtil.GreaterThan(this._borderThickness.Right, 0.0)) { pen = new Pen(); pen.Brush = this._borderBrush; pen.Thickness = this._borderThickness.Right; if (pen.CanFreeze) { pen.Freeze(); } dc.DrawLine(pen, new Point(this._renderBounds.Right - pen.Thickness / 2.0, this._renderBounds.Top), new Point(this._renderBounds.Right - pen.Thickness / 2.0, this._renderBounds.Bottom)); } if (DoubleUtil.GreaterThan(this._borderThickness.Top, 0.0)) { pen = new Pen(); pen.Brush = this._borderBrush; pen.Thickness = this._borderThickness.Top; if (pen.CanFreeze) { pen.Freeze(); } dc.DrawLine(pen, new Point(this._renderBounds.Left, this._renderBounds.Top + pen.Thickness / 2.0), new Point(this._renderBounds.Right, this._renderBounds.Top + pen.Thickness / 2.0)); } if (DoubleUtil.GreaterThan(this._borderThickness.Bottom, 0.0)) { pen = new Pen(); pen.Brush = this._borderBrush; pen.Thickness = this._borderThickness.Bottom; if (pen.CanFreeze) { pen.Freeze(); } dc.DrawLine(pen, new Point(this._renderBounds.Left, this._renderBounds.Bottom - pen.Thickness / 2.0), new Point(this._renderBounds.Right, this._renderBounds.Bottom - pen.Thickness / 2.0)); } } } if (this._backgroundBrush != null) { dc.DrawRectangle(this._backgroundBrush, null, new Rect(new Point(this._renderBounds.Left + this._borderThickness.Left, this._renderBounds.Top + this._borderThickness.Top), new Point(this._renderBounds.Right - this._borderThickness.Right, this._renderBounds.Bottom - this._borderThickness.Bottom))); } }
/// <summary> /// Draw background and border. /// </summary> /// <param name="dc">Drawing context.</param> /// <param name="backgroundBrush">The brush used for background.</param> /// <param name="borderBrush">The brush used for border.</param> /// <param name="borderThickness">Border thickness.</param> /// <param name="renderBounds">Render bounds of the visual.</param> /// <param name="isFirstChunk">Whether this is paragraph's first chunk.</param> /// <param name="isLastChunk">Whether this is paragraph's last chunk.</param> internal void DrawBackgroundAndBorderIntoContext(DrawingContext dc, Brush backgroundBrush, Brush borderBrush, Thickness borderThickness, Rect renderBounds, bool isFirstChunk, bool isLastChunk) { // We do not want to cause the user's Brushes to become frozen when we // freeze the Pen in OnRender, therefore we make our own copy of the // Brushes if they are not already frozen. _backgroundBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(backgroundBrush); _renderBounds = renderBounds; _borderBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(borderBrush); _borderThickness = borderThickness; // Exclude top/bottom border if this is not the first/last chunk of the paragraph. if (!isFirstChunk) { _borderThickness.Top = 0.0; } if (!isLastChunk) { _borderThickness.Bottom = 0.0; } // If we have a brush with which to draw the border, do so. // NB: We double draw corners right now. Corner handling is tricky (bevelling, &c...) and // we need a firm spec before doing "the right thing." (greglett, ffortes) if (_borderBrush != null) { // Initialize the first pen. Note that each pen is created via new() // and frozen if possible. Doing this avoids the overhead of // maintaining changed handlers. Pen pen = new Pen(); pen.Brush = _borderBrush; pen.Thickness = _borderThickness.Left; if (pen.CanFreeze) { pen.Freeze(); } if (_borderThickness.IsUniform) { // Uniform border; stroke a rectangle. dc.DrawRectangle(null, pen, new Rect( new Point(_renderBounds.Left + pen.Thickness * 0.5, _renderBounds.Bottom - pen.Thickness * 0.5), new Point(_renderBounds.Right - pen.Thickness * 0.5, _renderBounds.Top + pen.Thickness * 0.5))); } else { if (DoubleUtil.GreaterThan(_borderThickness.Left, 0)) { dc.DrawLine(pen, new Point(_renderBounds.Left + pen.Thickness / 2, _renderBounds.Top), new Point(_renderBounds.Left + pen.Thickness / 2, _renderBounds.Bottom)); } if (DoubleUtil.GreaterThan(_borderThickness.Right, 0)) { pen = new Pen(); pen.Brush = _borderBrush; pen.Thickness = _borderThickness.Right; if (pen.CanFreeze) { pen.Freeze(); } dc.DrawLine(pen, new Point(_renderBounds.Right - pen.Thickness / 2, _renderBounds.Top), new Point(_renderBounds.Right - pen.Thickness / 2, _renderBounds.Bottom)); } if (DoubleUtil.GreaterThan(_borderThickness.Top, 0)) { pen = new Pen(); pen.Brush = _borderBrush; pen.Thickness = _borderThickness.Top; if (pen.CanFreeze) { pen.Freeze(); } dc.DrawLine(pen, new Point(_renderBounds.Left, _renderBounds.Top + pen.Thickness / 2), new Point(_renderBounds.Right, _renderBounds.Top + pen.Thickness / 2)); } if (DoubleUtil.GreaterThan(_borderThickness.Bottom, 0)) { pen = new Pen(); pen.Brush = _borderBrush; pen.Thickness = _borderThickness.Bottom; if (pen.CanFreeze) { pen.Freeze(); } dc.DrawLine(pen, new Point(_renderBounds.Left, _renderBounds.Bottom - pen.Thickness / 2), new Point(_renderBounds.Right, _renderBounds.Bottom - pen.Thickness / 2)); } } } // Draw background in rectangle inside border. if (_backgroundBrush != null) { dc.DrawRectangle(_backgroundBrush, null, new Rect( new Point(_renderBounds.Left + _borderThickness.Left, _renderBounds.Top + _borderThickness.Top), new Point(_renderBounds.Right - _borderThickness.Right, _renderBounds.Bottom - _borderThickness.Bottom))); } }
// ------------------------------------------------------------------ // Set information about column rules that are necessary for rendering // process. Draw column rules if necessary. // // arrayColumnDesc - column description including rectangle coordinates, etc // columnVStart - vertical start coordinate of column rule // columnHeight - height of column rule // columnProperties - column properties. // ------------------------------------------------------------------ internal void DrawColumnRules(ref PTS.FSTRACKDESCRIPTION[] arrayColumnDesc, double columnVStart, double columnHeight, ColumnPropertiesGroup columnProperties) { // Compute column rules data first. Point[] rulePositions = null; double ruleWidth = columnProperties.ColumnRuleWidth; if (arrayColumnDesc.Length > 1) { if (ruleWidth > 0) { int gapWidth = (arrayColumnDesc[1].fsrc.u - (arrayColumnDesc[0].fsrc.u + arrayColumnDesc[0].fsrc.du)) / 2; rulePositions = new Point[(arrayColumnDesc.Length - 1) * 2]; for (int index = 1; index < arrayColumnDesc.Length; index++) { double u = TextDpi.FromTextDpi(arrayColumnDesc[index].fsrc.u - gapWidth); double v = columnVStart; double dv = columnHeight; rulePositions[(index - 1) * 2].X = u; rulePositions[(index - 1) * 2].Y = v; rulePositions[(index - 1) * 2 + 1].X = u; rulePositions[(index - 1) * 2 + 1].Y = v + dv; } } } // Check if update of the visual render data is needed. bool needsUpdate = _ruleWidth != ruleWidth; if (!needsUpdate && _rulePositions != rulePositions) { int prevSize = _rulePositions == null ? 0 : _rulePositions.Length; int newSize = rulePositions == null ? 0 : rulePositions.Length; if (prevSize == newSize) { for (int index = 0; index < rulePositions.Length; index++) { if (!DoubleUtil.AreClose(rulePositions[index].X, _rulePositions[index].X) || !DoubleUtil.AreClose(rulePositions[index].Y, _rulePositions[index].Y)) { needsUpdate = true; break; } } } else { needsUpdate = true; } } // Draw column rules if necessary if (needsUpdate) { _ruleWidth = ruleWidth; _rulePositions = rulePositions; // Open DrawingContext and draw background. // If background is not set, Open will clear the render data, but it // will preserve visual children. using (DrawingContext dc = RenderOpen()) { if (rulePositions != null) { // We do not want to cause the user's Brush to become frozen when we // freeze pen below, therefore we make our own copy of the Brush if // it is not already frozen. Brush columnRuleBrush = (Brush)FreezableOperations.GetAsFrozenIfPossible(columnProperties.ColumnRuleBrush); Pen pen = new Pen(columnRuleBrush, ruleWidth); // Freeze the pen if possible. Doing this avoids the overhead of // maintaining changed handlers. if (pen.CanFreeze) { pen.Freeze(); } for (int index = 0; index < rulePositions.Length; index += 2) { dc.DrawLine(pen, rulePositions[index], rulePositions[index + 1]); } } } } }
// Token: 0x06006A51 RID: 27217 RVA: 0x001E4130 File Offset: 0x001E2330 internal void DrawColumnRules(ref PTS.FSTRACKDESCRIPTION[] arrayColumnDesc, double columnVStart, double columnHeight, ColumnPropertiesGroup columnProperties) { Point[] array = null; double columnRuleWidth = columnProperties.ColumnRuleWidth; if (arrayColumnDesc.Length > 1 && columnRuleWidth > 0.0) { int num = (arrayColumnDesc[1].fsrc.u - (arrayColumnDesc[0].fsrc.u + arrayColumnDesc[0].fsrc.du)) / 2; array = new Point[(arrayColumnDesc.Length - 1) * 2]; for (int i = 1; i < arrayColumnDesc.Length; i++) { double x = TextDpi.FromTextDpi(arrayColumnDesc[i].fsrc.u - num); array[(i - 1) * 2].X = x; array[(i - 1) * 2].Y = columnVStart; array[(i - 1) * 2 + 1].X = x; array[(i - 1) * 2 + 1].Y = columnVStart + columnHeight; } } bool flag = this._ruleWidth != columnRuleWidth; if (!flag && this._rulePositions != array) { int num2 = (this._rulePositions == null) ? 0 : this._rulePositions.Length; int num3 = (array == null) ? 0 : array.Length; if (num2 == num3) { for (int j = 0; j < array.Length; j++) { if (!DoubleUtil.AreClose(array[j].X, this._rulePositions[j].X) || !DoubleUtil.AreClose(array[j].Y, this._rulePositions[j].Y)) { flag = true; break; } } } else { flag = true; } } if (flag) { this._ruleWidth = columnRuleWidth; this._rulePositions = array; using (DrawingContext drawingContext = base.RenderOpen()) { if (array != null) { Brush brush = (Brush)FreezableOperations.GetAsFrozenIfPossible(columnProperties.ColumnRuleBrush); Pen pen = new Pen(brush, columnRuleWidth); if (pen.CanFreeze) { pen.Freeze(); } for (int k = 0; k < array.Length; k += 2) { drawingContext.DrawLine(pen, array[k], array[k + 1]); } } } } }