// Shared initialization code void Initialize() { repeatCount = 1; textAttrs = new NSStringAttributes() { Font = NSFont.UserFixedPitchFontOfSize(16) }; }
// Shared initialization code void Initialize() { repeatCount = 1; var font = NSFont.UserFixedPitchFontOfSize(16); textAttrs = new NSMutableDictionary(); textAttrs.SetValueForKey(font, NSAttributedString.FontAttributeName); }
void UpdateFont() { var fontSize = (int)Math.Round(Prefs.UI.Font.GetSize()); Preferences.DefaultFixedFontSize = fontSize; Preferences.DefaultFontSize = fontSize; Preferences.FixedFontFamily = NSFont.UserFixedPitchFontOfSize(0).FontName; Preferences.SansSerifFontFamily = NSFont.UserFontOfSize(0).FontName; }
public override void WindowDidLoad() { base.WindowDidLoad(); m_Engine = new Engine(this); m_Engine.Start(); // green screen TxtView.Font = NSFont.UserFixedPitchFontOfSize(12.0f); TxtView.BackgroundColor = NSColor.Black; TxtView.TextColor = NSColor.Green; Window.BackgroundColor = NSColor.Black; }
public NativeDragView() { WantsLayer = true; Layer.BackgroundColor = NSColor.SystemBlueColor.CGColor; field = new NSTextField { StringValue = "Click Me to Focus or Drag in Blue Rect", Alignment = NSTextAlignment.Center, Font = NSFont.UserFixedPitchFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Regular)), Bordered = true, BezelStyle = NSTextFieldBezelStyle.Square, DrawsBackground = true, BackgroundColor = NSColor.TextBackground, TextColor = NSColor.ControlText, Editable = false }; AddSubview(field); field.TranslatesAutoresizingMaskIntoConstraints = false; field.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, Padding).Active = true; field.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -Padding).Active = true; field.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active = true; NSEvent.AddLocalMonitorForEventsMatchingMask( NSEventMask.LeftMouseDragged | NSEventMask.LeftMouseUp, e => { switch (e.Type) { case NSEventType.LeftMouseDragged when isDragging: MouseDragged(e); return(null); case NSEventType.LeftMouseUp: isDragging = false; break; } return(e); }); }
private void Initialize() { // Setup our contents -- a scrolling text view // Create a simple NSTextView. NSTextView tv = new NSTextView(); tv.Font = NSFont.UserFixedPitchFontOfSize(13); tv.AutoresizingMask = NSViewResizingMask.MaxYMargin | NSViewResizingMask.MinXMargin | NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin | NSViewResizingMask.HeightSizable | NSViewResizingMask.MinYMargin; // Create a NSScrollView to which we add the NSTextView. NSScrollView sv = new NSScrollView(); sv.DocumentView = tv; sv.HasVerticalScroller = true; // Set the NSScrollView as our view. this.View = sv; }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { var view = tableView.MakeView(tableColumn.Identifier, this) as LogTableCellView; if (view == null) { return(null); } view.TextColor = NSColor.Text; var entry = ((LogTableViewDataSource)tableView.DataSource).GetEntry((int)row); var textField = view.TextField; textField.Font = NSFont.UserFixedPitchFontOfSize(12); switch (tableColumn.Identifier) { case "log-owner": textField.StringValue = entry.OwnerId ?? String.Empty; view.TextColor = gray; break; case "log-level": textField.StringValue = entry.Level.ToString(); switch (entry.Level) { case LogLevel.Critical: view.TextColor = red; break; case LogLevel.Error: view.TextColor = red; break; case LogLevel.Warning: view.TextColor = orange; break; case LogLevel.Info: view.TextColor = green; break; case LogLevel.Debug: view.TextColor = blue; break; case LogLevel.Verbose: view.TextColor = darkGray; break; } break; case "log-time": textField.StringValue = entry.RelativeTime.TotalSeconds.ToString(); view.TextColor = gray; break; case "log-tag": textField.StringValue = entry.Tag ?? String.Empty; view.TextColor = purple; break; case "log-message": textField.StringValue = entry.Message ?? String.Empty; view.TextColor = darkGray; break; } return(view); }