public override void DrawRect(CGRect dirtyRect) { if (Selected) { NSColor.White.SetFill(); NSBezierPath.FillRect(dirtyRect); } else if (!darkTheme) { NSColor.FromRgb(245, 245, 245).Set(); NSBezierPath.FillRect(dirtyRect); } if (!darkTheme) { NSColor.FromRgb(233, 233, 233).Set(); NSBezierPath.FillRect(new CGRect(dirtyRect.X, 0, dirtyRect.Width, 1)); NSBezierPath.FillRect(new CGRect(dirtyRect.Right - 1, 0, 1, dirtyRect.Height)); } else if (!Selected) { NSColor.FromWhite(1.0f, 0.21f).Set(); NSBezierPath.FillRect(new CGRect(dirtyRect.Right - 1, 0, 1, dirtyRect.Height)); } }
// Draw the view public override void DrawRect(CoreGraphics.CGRect dirtyRect) { CGRect bounds = this.Bounds; // Using the system focus ring instead. Achieved by overriding DrawFocusRingMask and FocusRingMaskBounds // // Am I the window's first responder? // if (this.Window.FirstResponder == this) { // NSColor.KeyboardFocusIndicator.Set(); // NSBezierPath.DefaultLineWidth = 4.0f; // NSBezierPath.StrokeRect(bounds); // } if (Highlighted) { NSGradient gr = new NSGradient(NSColor.White, mBgColor); gr.DrawInRect(bounds, new CGPoint(0.0f, 0.0f)); } else { mBgColor.Set(); NSBezierPath.FillRect(bounds); } DrawStringCenteredInRectangle(mLetter, bounds); }
public override void DrawBackground(CoreGraphics.CGRect dirtyRect) { NSColor.White.Set(); NSBezierPath.FillRect(dirtyRect); this.DrawSeparator(dirtyRect); }
public override void DrawRect(CGRect dirtyRect) { bool isSelected = owner.TreeView.IsRowSelected(owner.TreeView.RowForItem(node)); var paintInfo = owner.EventsHandler.OnPaintNode(node.ToNodeInfo(), false); if (isSelected) { NSColor.SelectedMenuItem.SetFill(); } else { switch (paintInfo.Coloring) { case NodeColoring.Alive: NSColor.FromDeviceRgba(0.74f, 0.93f, 0.74f, 1f).SetFill(); break; case NodeColoring.Deleted: NSColor.FromDeviceRgba(0.90f, 0.90f, 0.98f, 1f).SetFill(); break; default: NSColor.White.SetFill(); break; } } NSBezierPath.FillRect(dirtyRect); // paintInfo.DrawFocusedMsgMark todo }
public override void AwakeFromNib() { base.AwakeFromNib(); logViewerControlAdapter = new LogViewerControlAdapter(); logViewerControlAdapter.View.MoveToPlaceholder(this.logViewerPlaceholder); selectCurrentTimeButton.ToolTip = "Find current time in search results"; selectCurrentTimeButton.Image.Template = true; tableView.DataSource = dataSource; tableView.Delegate = new Delegate() { owner = this }; ((SearchResultsDropdownTable)tableView).owner = this; ((SearchResultsScrollView)dropdownScrollView).owner = this; dropdownContainerView.CanBeFirstResponder = true; dropdownContainerView.OnPaint += dirtyRect => { if (!dropdownExpanded.GetValueOrDefault()) { return; } NSColor.WindowBackground.SetFill(); NSBezierPath.FillRect(dirtyRect.ToCGRect()); NSColor.WindowFrame.SetStroke(); NSBezierPath.StrokeRect(dropdownContainerView.Bounds); }; dropdownContainerView.OnResignFirstResponder = () => viewModel.OnDropdownContainerLostFocus();; }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); (highlighted ? NSColor.Green : Color).SetFill(); NSBezierPath.FillRect(dirtyRect); }
void TestStringWithOrigin(Graphics g) { for (int multiline = 0; multiline <= 1; ++multiline) { for (int h = (int)StringAlignment.Near; h <= (int)StringAlignment.Far; ++h) { for (int v = (int)StringAlignment.Near; v <= (int)StringAlignment.Far; ++v) { var fmt = new StringFormat((StringAlignment)h, (StringAlignment)v); PointF origin = new PointF(10 + multiline * 250 + h * 100, 10 + v * 100); var txt = "test"; if (multiline == 1) { txt += "\nfoo bar"; } var sz = g.MeasureString(txt, font); var measuredBox = new RectangleF(origin, sz); measuredBox.X -= h * sz.Width / 2; measuredBox.Y -= v * sz.Height / 2; g.FillRectangle(measuredBoxBrush, measuredBox); g.DrawString(txt, font, textBrush, origin, fmt); NSColor.Red.SetFill(); var originRect = new RectangleF(origin, new SD.SizeF()); originRect.Inflate(2, 2); NSBezierPath.FillRect(originRect); } } } }
public override void DrawRect(CGRect dirtyRect) { if (dirtyRect.Y <= 0) { BorderColor.Set(); NSBezierPath.FillRect(new CGRect(dirtyRect.X, 0, dirtyRect.Width, 1)); } }
// Experimental public override void DrawFocusRingMask() { var control = Control.FromHandle(Handle); if (control != null && control.Enabled && control.Focused && control.ShowFocusCues) { NSBezierPath.FillRect(Bounds); } }
static void DrawSeparator(nfloat x, CGRect dirtyRect) { var sepRect = new CGRect(x - 6.5, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 4 : 3, 1, 16); if (sepRect.IntersectsWith(dirtyRect)) { NSColor.LightGray.SetFill(); NSBezierPath.FillRect(sepRect); } }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { mPath.RemoveAllPoints(); CGRect bounds = this.Bounds; // Fill view with green NSColor.Green.Set(); NSBezierPath.FillRect(bounds); NSColor.White.Set(); foreach (Oval oval in Ovals) { mPath.AppendPathWithOvalInRect(oval.Rect); } mPath.Stroke(); }
public override void DrawRect(CGRect dirtyRect) { if (BackgroundColor != null) { BackgroundColor.SetFill(); NSBezierPath.FillRect(dirtyRect); } else { base.DrawRect(dirtyRect); } if (OnPaint != null) { OnPaint(dirtyRect.ToRectangleF()); } }
public override void DrawRect(CGRect dirtyRect) { if (progressValue != null) { var r = Bounds; r.Inflate(-0.5f, -0.5f); var cl = NSColor.FromDeviceRgba(0f, 0.3f, 1f, 0.20f); cl.SetStroke(); NSBezierPath.StrokeRect(r); cl.SetFill(); r.Width = (int)(r.Width * progressValue.Value); NSBezierPath.FillRect(r); } base.DrawRect(dirtyRect); }
public override void DrawRect(CGRect dirtyRect) { bool isSelected = node.IsSelected; bool isDarkMode = owner.ViewModel.ColorTheme == Presenters.ColorThemeMode.Dark; var paintInfo = owner.ViewModel.PaintNode(node, false); if (isSelected) { NSColor.SelectedMenuItem.SetFill(); } else { switch (paintInfo.Coloring) { case NodeColoring.Alive: if (isDarkMode) { NSColor.FromDeviceRgba(0.0f, 0.20f, 0.0f, 1f).SetFill(); } else { NSColor.FromDeviceRgba(0.74f, 0.93f, 0.74f, 1f).SetFill(); } break; case NodeColoring.Deleted: if (isDarkMode) { NSColor.FromDeviceRgba(0.30f, 0.30f, 0.30f, 1f).SetFill(); } else { NSColor.FromDeviceRgba(0.90f, 0.90f, 0.98f, 1f).SetFill(); } break; default: NSColor.TextBackground.SetFill(); break; } } NSBezierPath.FillRect(dirtyRect); // paintInfo.DrawFocusedMsgMark todo }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); if (statusIcons.Count == 0 || buildResults.Hidden) { return; } var x = LeftMostStatusItemX(); var sepRect = new CGRect(x - 9, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 5 : 4, 1, 16); if (!sepRect.IntersectsWith(dirtyRect)) { return; } NSColor.LightGray.SetFill(); NSBezierPath.FillRect(sepRect); }
public override void DrawRect(CGRect dirtyRect) { // Viewの領域を描画 NSColor.Red.SetStroke(); NSBezierPath.StrokeRect(this.Bounds); // ドラッグの状態によって図形の色を変える if (isDragging) { NSColor.Blue.SetFill(); } else { NSColor.Red.SetFill(); } // 図形を描画 NSBezierPath.FillRect(GetRect()); }
public override void DrawBackground(CGRect dirtyRect) { base.DrawBackground(dirtyRect); if (row < 0 || row >= owner.dataSource.items.Count) { return; } var bmk = owner.dataSource.items[row].Data.Bookmark; ModelColor?cl = null; switch (owner.presentationDataAccess.Coloring) { case Settings.Appearance.ColoringMode.None: break; case Settings.Appearance.ColoringMode.Sources: var ls = bmk.GetSafeLogSource(); if (ls != null) { cl = ls.Color; } break; case Settings.Appearance.ColoringMode.Threads: var t = bmk.GetSafeThread(); if (t != null) { cl = t.ThreadColor; } break; } if (cl != null) { cl.Value.ToColor().ToNSColor().SetFill(); NSBezierPath.FillRect(dirtyRect); } DrawFocusedMessage(); }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { CGRect bounds = this.Bounds; // Fill view with green NSColor.Green.Set(); NSBezierPath.FillRect(bounds); // Draw the path in white NSColor.Red.Set(); mPath.Stroke(); if (mImages.Count > 0) { foreach (StretchImage image in mImages) { StretchImage drawImage = image.GetFlippedImage(); CGRect imageRect = new CGRect(0, 0, drawImage.Size.Width, drawImage.Size.Height); drawImage.DrawInRect(image.DrawingRect(), imageRect, NSCompositingOperation.SourceOver, image.Opacity); } } }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { if (DarkTheme) { NSColor.Clear.Set(); NSGraphics.RectFill(dirtyRect, NSCompositingOperation.SourceOver); return; } else { NSColor.FromRgb(245, 245, 245).Set(); NSBezierPath.FillRect(dirtyRect); } if (dirtyRect.Y == 0 && !DarkTheme) { NSColor.FromRgb(233, 233, 233).Set(); NSBezierPath.FillRect(new CGRect(dirtyRect.X, 0, dirtyRect.Width, 1)); } }
public void CIFilterOutputImageTest() { NSImage nsImg = new NSImage(new CGSize(400, 400)); nsImg.LockFocus(); NSColor.Red.SetFill(); NSBezierPath.FillRect(new CGRect(0, 0, 400, 400)); nsImg.UnlockFocus(); CIImage img = CIImage.FromCGImage(nsImg.CGImage); var gloom = new CIGloom() { Image = img, Intensity = 5, Radius = 1 }; var output = gloom.OutputImage; Assert.IsNotNull(output, "CIFilterOutputImageTest - output was null"); }
public override void DrawBackground(CGRect dirtyRect) { base.DrawBackground(dirtyRect); if (row < 0 || row >= owner.dataSource.items.Count) { return; } if (owner.viewModel.Theme == Presenters.ColorThemeMode.Light) { Color?cl = owner.dataSource.items[row].Data.ContextColor; if (cl != null) { cl.Value.ToNSColor().SetFill(); NSBezierPath.FillRect(dirtyRect); } } DrawFocusedMessage(); }
public override void DrawRect(CGRect dirtyRect) { if (BackgroundColor != null) { BackgroundColor.SetFill(); NSBezierPath.FillRect(dirtyRect); } else { base.DrawRect(dirtyRect); } if (RespectInteriorBackgroundStyle && (Superview as NSTableRowView)?.InteriorBackgroundStyle == NSBackgroundStyle.Dark) { DarkBgAttributedStringWithLinks.DrawString(Bounds); } else { AttributedStringWithLinks.DrawString(Bounds); } #if NSLINKLABEL_DEBUG int i = 0; foreach (var r in GetLinksRectsInternal()) { if (((++i) % 2) == 0) { NSColor.Yellow.SetFill(); } else { NSColor.Green.SetFill(); } NSBezierPath.FillRect(r.Value); } }
public override void DrawRect(System.Drawing.RectangleF dirtyRect) { // TODO: Why doesn't the background fill compiled under 64-bit Mono? BackgroundColor.SetFill(); NSBezierPath.FillRect(dirtyRect); }
public override void DrawSelection(CGRect dirtyRect) { owner.selectedBkColor().SetFill(); NSBezierPath.FillRect(dirtyRect); DrawFocusedMessage(); }
public override void DrawSelection(CoreGraphics.CGRect dirtyRect) { NSColor.FromRgb(225, 225, 225).Set(); NSBezierPath.FillRect(dirtyRect); }
public override void DrawRect(CGRect dirtyRect) { NSColor.FromRgb(245, 245, 245).Set(); NSBezierPath.FillRect(new CGRect(0, 0, dirtyRect.Width, 50)); }
// Create the set of display lists for the bitmaps bool MakeGLDisplayListFirst(char first, int count, int baseDL) { int curListIndex; NSColor blackColor; NSMutableDictionary attribDict; int dListNum; NSString currentChar; char currentUnichar; SizeF charSize; RectangleF charRect = RectangleF.Empty; NSImage theImage; bool retval; // Make sure the list isn't already under construction GL.GetInteger(GetPName.ListIndex, out curListIndex); if (curListIndex != 0) { Console.WriteLine("Display list already under construction"); return(false); } // Save pixel unpacking state GL.PushClientAttrib(ClientAttribMask.ClientPixelStoreBit); GL.PixelStore(PixelStoreParameter.UnpackSwapBytes, 0); GL.PixelStore(PixelStoreParameter.UnpackLsbFirst, 0); GL.PixelStore(PixelStoreParameter.UnpackSkipPixels, 0); GL.PixelStore(PixelStoreParameter.UnpackSkipRows, 0); GL.PixelStore(PixelStoreParameter.UnpackRowLength, 0); GL.PixelStore(PixelStoreParameter.UnpackAlignment, 0); blackColor = NSColor.Black; attribDict = new NSMutableDictionary(); attribDict.SetValueForKey(font, NSAttributedString.FontAttributeName); attribDict.SetValueForKey(NSColor.White, NSAttributedString.ForegroundColorAttributeName); attribDict.SetValueForKey(blackColor, NSAttributedString.BackgroundColorAttributeName); theImage = new NSImage(new SizeF(0, 0)); retval = true; for (dListNum = baseDL, currentUnichar = first; currentUnichar < first + count; dListNum++, currentUnichar++) { currentChar = new NSString(Char.ToString(currentUnichar)); charSize = currentChar.StringSize(attribDict); charRect.Size = charSize; charRect = charRect.Integral(); if (charRect.Size.Width > 0 && charRect.Size.Height > 0) { theImage.Size = charRect.Size; theImage.LockFocus(); NSGraphicsContext.CurrentContext.ShouldAntialias = false; blackColor.Set(); NSBezierPath.FillRect(charRect); currentChar.DrawString(charRect, attribDict); theImage.UnlockFocus(); if (!MakeDisplayList(dListNum, theImage)) { retval = false; break; } } } return(retval); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); var attributes = new NSStringAttributes { ForegroundColor = NSColor.Blue, Font = NSFont.FromFontName("Andale Mono", 14) }; ProcessTextFormat(attributes); NSColor.Black.SetFill(); NSBezierPath.FillRect(dirtyRect); lock (Terminal) { int row = ViewTop; float verticalOffset = -row * (float)CharacterHeight; var lines = Terminal.ViewPort.GetLines(ViewTop, Rows); foreach (var line in lines) { if (line == null) { row++; continue; } int column = 0; var xform = new NSAffineTransform(); xform.Scale((nfloat)(line.DoubleWidth ? 2.0 : 1.0), (nfloat)((line.DoubleHeightTop || line.DoubleHeightBottom) ? 2.0 : 1.0)); xform.Concat(); var spanStart = 0; while (column < line.Count) { bool selected = TextSelection == null ? false : TextSelection.Within(column, row); var backgroundColor = GetBackgroundColor(line[column].Attributes, selected); if (column < (line.Count - 1) && GetBackgroundColor(line[column + 1].Attributes, TextSelection == null ? false : TextSelection.Within(column + 1, row)) == backgroundColor) { column++; continue; } var rect = new CGRect( spanStart * CharacterWidth, ((row - (line.DoubleHeightBottom ? 1 : 0)) * CharacterHeight + verticalOffset) * (line.DoubleHeightBottom | line.DoubleHeightTop ? 0.5 : 1.0), ((column - spanStart + 1) * CharacterWidth) + 0.9, CharacterHeight + 0.9 ); backgroundColor.SetFill(); NSBezierPath.FillRect(rect); column++; spanStart = column; } xform.Invert(); xform.Concat(); row++; } row = ViewTop; foreach (var line in lines) { if (line == null) { row++; continue; } int column = 0; var xform = new NSAffineTransform(); xform.Scale((nfloat)(line.DoubleWidth ? 2.0 : 1.0), (nfloat)((line.DoubleHeightTop || line.DoubleHeightBottom) ? 2.0 : 1.0)); xform.Concat(); var spanStart = 0; string toDisplay = string.Empty; while (column < line.Count) { bool selected = TextSelection == null ? false : TextSelection.Within(column, row); var foregroundColor = GetForegroundColor(line[column].Attributes, selected); toDisplay += line[column].Char.ToString() + line[column].CombiningCharacters; if ( column < (line.Count - 1) && GetForegroundColor(line[column + 1].Attributes, TextSelection == null ? false : TextSelection.Within(column + 1, row)) == foregroundColor && line[column + 1].Attributes.Underscore == line[column].Attributes.Underscore && line[column + 1].Attributes.Reverse == line[column].Attributes.Reverse && line[column + 1].Attributes.Bright == line[column].Attributes.Bright ) { column++; continue; } var textPosition = new CGPoint( spanStart * CharacterWidth, ((row - (line.DoubleHeightBottom ? 1 : 0)) * CharacterHeight + verticalOffset + attributes.Font.Descender) * (line.DoubleHeightBottom | line.DoubleHeightTop ? 0.5 : 1.0) ); attributes.ForegroundColor = foregroundColor; attributes.UnderlineStyle = line[column].Attributes.Underscore ? 1 : 0; var nsStr = new NSString(toDisplay); nsStr.DrawAtPoint(textPosition, attributes.Dictionary); column++; spanStart = column; toDisplay = ""; } xform.Invert(); xform.Concat(); row++; } if (Terminal.CursorState.ShowCursor) { var cursorY = Terminal.ViewPort.TopRow - ViewTop + Terminal.CursorState.CurrentRow; var cursorRect = new CGRect( Terminal.CursorState.CurrentColumn * CharacterWidth, cursorY * CharacterHeight, CharacterWidth + 0.9, CharacterHeight + 0.9 ); var path = NSBezierPath.FromRect(cursorRect); GetForegroundColor(Terminal.CursorState.Attributes, false).Set(); path.Stroke(); } } }
public override void DrawFocusRingMask() => NSBezierPath.FillRect(FocusRingMaskBounds);
// To get standard focus ring public override void DrawFocusRingMask() { NSBezierPath.FillRect(this.Bounds); }