Advertisement
Guest User

Untitled

a guest
May 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.47 KB | None | 0 0
  1.         protected override void OnRender(DrawingContext drawingContext)
  2.         {
  3.             if (this.Margin == WindowsUtilities.ZeroThickness)
  4.             {
  5.                 return;
  6.             }
  7.  
  8.             // Draw background.
  9.             var backgroundRect = new Rect(this.Margin.Left, this.Margin.Top,
  10.                 this.ActualWidth - this.Margin.Left - this.Margin.Right,
  11.                 this.ActualHeight - this.Margin.Top - this.Margin.Bottom
  12.             );
  13.  
  14.             // Draw border shadows.
  15.             var leftRect = new Rect(0, this.Margin.Top,
  16.                 this.Margin.Left, this.ActualHeight - this.Margin.Top - this.Margin.Bottom
  17.             );
  18.             drawingContext.DrawRectangle(leftBrush, null, leftRect);
  19.  
  20.             var topRect = new Rect(this.Margin.Left, 0,
  21.                 this.ActualWidth - this.Margin.Left - this.Margin.Right, this.Margin.Top
  22.             );
  23.             drawingContext.DrawRectangle(topBrush, null, topRect);
  24.  
  25.             var rightRect = new Rect(this.ActualWidth - this.Margin.Right,
  26.                 this.Margin.Top, this.Margin.Right,
  27.                 this.ActualHeight - this.Margin.Top - this.Margin.Bottom
  28.             );
  29.             drawingContext.DrawRectangle(rightBrush, null, rightRect);
  30.  
  31.             var bottomRect = new Rect(this.Margin.Left,
  32.                 this.ActualHeight - this.Margin.Bottom,
  33.                 this.ActualWidth - this.Margin.Left - this.Margin.Top,
  34.                 this.Margin.Bottom
  35.             );
  36.             drawingContext.DrawRectangle(bottomBrush, null, bottomRect);
  37.  
  38.             var topLeftRect = new Rect(0, 0, this.Margin.Left, this.Margin.Top);
  39.             drawingContext.DrawRectangle(topLeftBrush, null, topLeftRect);
  40.  
  41.             var topRightRect = new Rect(this.ActualWidth - this.Margin.Left, 0,
  42.                 this.Margin.Right, this.Margin.Top
  43.             );
  44.             drawingContext.DrawRectangle(topRightBrush, null, topRightRect);
  45.  
  46.             var bottomLeftRect = new Rect(0, this.ActualHeight - this.Margin.Bottom,
  47.                 this.Margin.Left, this.Margin.Bottom
  48.             );
  49.             drawingContext.DrawRectangle(bottomLeftBrush, null, bottomLeftRect);
  50.  
  51.             var bottomRightRect = new Rect(this.ActualWidth - this.Margin.Right,
  52.                 this.ActualHeight - this.Margin.Bottom,
  53.                 this.Margin.Right, this.Margin.Bottom
  54.             );
  55.             drawingContext.DrawRectangle(bottomRightBrush, null, bottomRightRect);
  56.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement