/// プレビュー画像の描画 /// @param dc 描画先 /// @param layoutElement 描画対象 private void DrawPreview(DrawingContext dc, LayoutElement layoutElement) { var bitmap = App.ScreenCaptureTimer.GetBitmapSource(layoutElement); if (bitmap == null) { // エラーが起きた場合は赤色の四角形を描画 var boundRect = layoutElement.GetBoundRect( App.RuntimeOptions.CurrentSampleWidth, App.RuntimeOptions.CurrentSampleHeight).ToRect(); dc.DrawRectangle(Brushes.Red, null, boundRect); } else { // プレビューの描画 var actualBoundRect = layoutElement.GetActualBoundRect( App.RuntimeOptions.CurrentSampleWidth, App.RuntimeOptions.CurrentSampleHeight).ToRect(); dc.DrawImage(bitmap, actualBoundRect); } }
/// 枠線とキャプションの描画 /// @param dc 描画先 /// @param layoutElement 描画対象 /// @param index 描画対象のインデックス private void DrawBorder(DrawingContext dc, LayoutElement layoutElement, int index) { // フレームサイズ var boundRect = layoutElement.GetBoundRect( App.RuntimeOptions.CurrentSampleWidth, App.RuntimeOptions.CurrentSampleHeight).ToRect(); // スタイルの取得 Brush textBrush; Pen framePen; this.CreateBorderStyle(layoutElement, out framePen, out textBrush); // フレームの描画 var inflateValue = framePen.Thickness / 2; var infraleRect = Rect.Inflate(boundRect, -inflateValue, -inflateValue); dc.DrawRectangle(null, framePen, infraleRect); // ヘッダーのドロップシャドウの描画 var shadowOffset = 1.0; var shadowPoint = new Point(boundRect.X + shadowOffset, boundRect.Y + shadowOffset); var shadowBoundRect = new Rect(boundRect.X + shadowOffset, boundRect.Y + shadowOffset, boundRect.Width - shadowOffset, boundRect.Height - shadowOffset); var shadow = this.CreateHeader(layoutElement, index, shadowBoundRect, BrushesAndPens.DropShadowBrush); dc.DrawText(shadow, shadowPoint); // ヘッダーの描画 var headerPoint = new Point(boundRect.X, boundRect.Y); var header = this.CreateHeader(layoutElement, index, boundRect, textBrush); dc.DrawText(header, headerPoint); }