private void DrawWindowBackgroundGradient(RectangleF drawingRect, CGPath clippingPath) { var window = (AppStoreWindow)Window; clippingPath.ApplyClippingPathInCurrentContext(); if (window.IsTextured()) { // If this is a textured window, we can draw the real background gradient and noise pattern var contentBorderThickness = window.TitleBarHeight; if (window.IsFullScreen()) { contentBorderThickness -= window.MinimumTitleBarHeight(); } window.SetAutorecalculatesContentBorderThickness(false, NSRectEdge.MaxYEdge); window.SetContentBorderThickness(contentBorderThickness, NSRectEdge.MaxYEdge); NSGraphicsExtensions.DrawWindowBackground(drawingRect); } else { // Not textured, we have to fake the background gradient and noise pattern var drawsAsMainWindow = window.DrawsAsMainWindow(); var startColor = drawsAsMainWindow ? window.TitleBarStartColor : window.InactiveTitleBarStartColor; var endColor = drawsAsMainWindow ? window.TitleBarEndColor : window.InactiveTitleBarEndColor; if (startColor == default(NSColor)) { startColor = AppStoreWindow.DefaultTitleBarStartColor(drawsAsMainWindow); } if (endColor == default(NSColor)) { endColor = AppStoreWindow.DefaultTitleBarEndColor(drawsAsMainWindow); } var context = NSGraphicsContext.CurrentContext.GraphicsPort; var gradient = DrawingHelper.CreateGraidentWithColors(startColor, endColor); context.DrawLinearGradient(gradient, new PointF(drawingRect.GetMidX(), drawingRect.GetMinY()), new PointF(drawingRect.GetMidX(), drawingRect.GetMaxY()), 0); if (drawsAsMainWindow) { var noiseRect = new RectangleF(1.0f, 1.0f, drawingRect.Width, drawingRect.Height); if (window.ShowBaselineSeparator) { var separatorHeight = BaselineSeparatorFrame.Height; noiseRect.Y -= separatorHeight; noiseRect.Height += separatorHeight; } NSGraphicsContext.CurrentContext.SaveGraphicsState(); var noiseClippingPath = DrawingHelper.CreateClippingPath(noiseRect, CORNER_CLIP_RADIUS); context.AddPath(noiseClippingPath); context.Clip(); DrawNoise(0.1f); NSGraphicsContext.CurrentContext.RestoreGraphicsState(); } } if (window.ShowBaselineSeparator) { DrawBaselineSeparator(BaselineSeparatorFrame); } }