public SearchBarView() { TranslatesAutoresizingMaskIntoConstraints = false; WantsLayer = true; Layer.BackgroundColor = NSColor.White.CGColor; searchIcon = new NSImageView(); searchIcon.Image = NSImage.ImageNamed("Search"); searchIcon.TranslatesAutoresizingMaskIntoConstraints = false; SearchField = new NSTextField(); SearchField.DrawsBackground = false; SearchField.FocusRingType = NSFocusRingType.None; SearchField.Bordered = false; SearchField.TranslatesAutoresizingMaskIntoConstraints = false; SearchField.Font = NSFont.FromFontName("SF UI Display Regular", 14); SearchField.TextColor = NSColor.FromRgb(100, 100, 100); SearchField.PlaceholderString = "Search music here..."; ProgressIndicator = new NSProgressIndicator(); ProgressIndicator.TranslatesAutoresizingMaskIntoConstraints = false; ProgressIndicator.Style = NSProgressIndicatorStyle.Spinning; //ProgressIndicator.Hidden = true; AddSubview(searchIcon); AddSubview(SearchField); AddSubview(ProgressIndicator); ProgressIndicator.StartAnimation(this); BuildConstraints(); }
public void AddItem(string identifier, string title) { var layer = new CATextLayer(); layer.String = title; layer.SetFont("SF UI Text Bold"); layer.FontSize = 12; layer.ForegroundColor = NSColor.FromRgb(80, 80, 80).CGColor; layer.ContentsScale = NSScreen.MainScreen.BackingScaleFactor; var attrs = new NSStringAttributes(); attrs.Font = NSFont.FromFontName("SF UI Text Bold", 12); var stringSize = NSStringDrawing.StringSize(layer.String, attrs); var frame = new CGRect(new CGPoint(0, 0), stringSize); layer.Frame = frame; layer.AnchorPoint = new CGPoint(0, 0.5f); items.Add(new BreadcrumbViewItem { Identifier = identifier, Title = title, Layer = layer }); Layer.AddSublayer(layer); NeedsDisplay = true; }
public TerminalView (CGRect rect) : base (rect) { fontNormal = NSFont.FromFontName ("Lucida Sans Typewriter", 14); fontBold = NSFont.FromFontName ("Lucida Sans Typewriter Bold", 14); fontItalic = NSFont.FromFontName ("Lucida Sans Typewriter Oblique", 14); fontBoldItalic = NSFont.FromFontName ("Lucida Sans Typewriter Bold Oblique", 14); ComputeCellDimensions (); var cols = (int)(rect.Width / cellWidth); var rows = (int)(rect.Height / cellHeight); terminal = new Terminal (this, new TerminalOptions () { Cols = cols, Rows = rows }); FullBufferUpdate (); caret = new NSView (new CGRect (0, cellDelta, cellHeight, cellWidth)) { WantsLayer = true }; AddSubview (caret); debug = new NSView (new CGRect (0, 0, 10, 10)) { WantsLayer = true }; //AddSubview (debug); var caretColor = NSColor.FromColor (NSColor.Blue.ColorSpace, 0.4f, 0.2f, 0.9f, 0.5f); caret.Layer.BackgroundColor = caretColor.CGColor; debug.Layer.BackgroundColor = caretColor.CGColor; }
public override void AwakeFromNib() { try { string[] lines = File.ReadAllLines("settings.txt"); if (lines.Length == 4) { textBox3.StringValue = lines[0]; textBox1.StringValue = lines[1]; textBox2.StringValue = lines[2]; minerCli = lines[3]; } } catch (Exception e) { Debug.WriteLine(e.Message); PrintToConsoleOutput($"Could not find 'settings.txt'"); } consoleControl1.Font = NSFont.FromFontName("Courier", 11); Window.WillClose += (sender, e) => { StopMining(); }; }
public override void AwakeFromNib() { base.AwakeFromNib(); codeTextView.Font = NSFont.FromFontName("Courier", 11); codeTextView.AutomaticQuoteSubstitutionEnabled = false; helpLink.LinkClicked = (sender, e) => events.OnHelpLinkClicked(); }
public BooleanEditorControl() { BooleanEditor = new NSButton { AllowsMixedState = true, ControlSize = NSControlSize.Small, Font = NSFont.FromFontName(DefaultFontName, DefaultFontSize), Title = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; BooleanEditor.SetButtonType(NSButtonType.Switch); // update the value on 'enter' BooleanEditor.Activated += (sender, e) => { switch (BooleanEditor.State) { case NSCellStateValue.Off: ViewModel.Value = false; break; case NSCellStateValue.On: ViewModel.Value = true; break; } }; AddSubview(BooleanEditor); this.DoConstraints(new[] { BooleanEditor.ConstraintTo(this, (cb, c) => cb.Width == c.Width), BooleanEditor.ConstraintTo(this, (cb, c) => cb.Top == c.Top + 5), BooleanEditor.ConstraintTo(this, (cb, c) => cb.Left == c.Left + 4), }); UpdateTheme(); }
public void SetItem(GenericOutlineItemWrapper item) { this.item = item; if (!item.IsCategory) { ImageView.Image = NSImage.ImageNamed(item.Icon).Tint(NSColor.FromRgb(45, 45, 45)); TextField.Font = NSFont.FromFontName("SF UI Display Regular", 14); TextField.TextColor = NSColor.FromRgb(45, 45, 45); AddSubview(ImageView); } else { ImageView.RemoveFromSuperview(); TextField.Font = NSFont.FromFontName("SF UI Display Medium", 13); TextField.TextColor = NSColor.FromRgb(135, 135, 135); } TextField.StringValue = item.Text; if (cachedIsCategory != item.IsCategory) { cachedIsCategory = item.IsCategory; RebuildConstraints(); } }
public CodeEditorControlHandler() { try { te = new Controls.Mac.TextEditor(); te.Font = NSFont.FromFontName("Menlo", 11.0f); te.Editable = true; te.Selectable = true; te.AutoresizingMask = NSViewResizingMask.WidthSizable; te.MaxSize = new CGSize(1000, 10000000); te.Formatter = new LanguageFormatter(te, new PythonDescriptor()); sv = new NSScrollView { AutoresizesSubviews = true, BorderType = NSBorderType.NoBorder, HasVerticalScroller = true, HasHorizontalScroller = true, AutoresizingMask = NSViewResizingMask.WidthSizable }; var cv = new NSClipView { AutoresizesSubviews = true }; cv.DocumentView = te; sv.ContentView = cv; this.Control = sv; te.BecomeFirstResponder(); } catch (Exception ex) { string configfiledir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Documents", "DWSIM Application Data"); if (!Directory.Exists(configfiledir)) { Directory.CreateDirectory(configfiledir); } File.WriteAllText(System.IO.Path.Combine(configfiledir, "lasterror2.txt"), ex.ToString()); } }
public (bool success, string filePath) LoadFont(EmbeddedFont font) { try { var data = NSData.FromStream(font.ResourceStream); var provider = new CGDataProvider(data); var cGFont = CGFont.CreateFromProvider(provider); var name = cGFont.PostScriptName; if (CTFontManager.RegisterGraphicsFont(cGFont, out var error)) { return(true, name); } else //Lets check if the font is already registered { var uiFont = NSFont.FromFontName(name, 10); if (uiFont != null) { return(true, name); } } Debug.WriteLine(error.Description); } catch (Exception ex) { Debug.WriteLine(ex); } return(false, null); }
public override NSFont ConvertFont(NSFont fontObj, NSFontTraitMask trait) { // be a little less conservative when converting fonts to use the name when translating to italics. // e.g. 'Klavika Medium' translates to 'Klavika Italic' if adding italic trait, instead of // 'Klavika Medium Italic'. if (trait == NSFontTraitMask.Italic || trait == NSFontTraitMask.Unitalic) { var oldName = (string)FontTypefaceHandler.GetName(fontObj.Handle); const string italicSuffix = " Italic"; string newName = null; if (trait == NSFontTraitMask.Italic) { newName = oldName + italicSuffix; } else if (oldName.EndsWith(italicSuffix, StringComparison.OrdinalIgnoreCase)) { newName = oldName.Substring(0, oldName.Length - italicSuffix.Length); } if (newName != null) { foreach (var descriptor in AvailableMembersOfFontFamily(fontObj.FamilyName)) { var fontName = (string)Messaging.GetNSObject <NSString>(descriptor.ValueAt(1)); if (string.Equals(fontName, newName, StringComparison.OrdinalIgnoreCase)) { var postScriptName = (string)Messaging.GetNSObject <NSString>(descriptor.ValueAt(0)); return(NSFont.FromFontName(postScriptName, fontObj.PointSize)); } } } } return(base.ConvertFont(fontObj, trait)); }
public PredefinedValuesEditor() { base.TranslatesAutoresizingMaskIntoConstraints = false; this.comboBox = new NSComboBox { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = NSColor.Clear, StringValue = String.Empty, ControlSize = NSControlSize.Small, Editable = false, Font = NSFont.FromFontName(DefaultFontName, DefaultFontSize), }; this.comboBox.SelectionChanged += (sender, e) => { ViewModel.ValueName = comboBox.SelectedValue.ToString(); }; this.popUpButton = new NSPopUpButton { TranslatesAutoresizingMaskIntoConstraints = false, StringValue = String.Empty, ControlSize = NSControlSize.Small, Font = NSFont.FromFontName(DefaultFontName, DefaultFontSize), }; popupButtonList = new NSMenu(); popUpButton.Menu = popupButtonList; popUpButton.Activated += (o, e) => { ViewModel.ValueName = (o as NSPopUpButton).Title; }; UpdateTheme(); }
public Task <NSImage> LoadImageAsync( ImageSource imagesource, CancellationToken cancelationToken = default(CancellationToken), float scale = 1f) { NSImage image = null; var fontsource = imagesource as FontImageSource; if (fontsource != null) { var font = NSFont.FromFontName(fontsource.FontFamily ?? string.Empty, (float)fontsource.Size) ?? NSFont.SystemFontOfSize((float)fontsource.Size); var iconcolor = fontsource.Color.IsDefault ? _defaultColor : fontsource.Color; var attString = new NSAttributedString(fontsource.Glyph, font: font, foregroundColor: iconcolor.ToNSColor()); var imagesize = ((NSString)fontsource.Glyph).StringSize(attString.GetAttributes(0, out _)); using (var context = new CGBitmapContext(IntPtr.Zero, (nint)imagesize.Width, (nint)imagesize.Height, 8, (nint)imagesize.Width * 4, NSColorSpace.GenericRGBColorSpace.ColorSpace, CGImageAlphaInfo.PremultipliedFirst)) { using (var ctline = new CTLine(attString)) { ctline.Draw(context); } using (var cgImage = context.ToImage()) { image = new NSImage(cgImage, imagesize); } } } return(Task.FromResult(image)); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Do any additional setup after loading the view. _titleLabel.Font = NSFont.FromFontName("Kunstler Script", 72.0f); AppendMessage("Use the File menu to open a GEDCOM file copy of your tree. See website documentation on how to generate a GEDCOM if you are unsure.\n\n"); }
public NativeMacOsCell(NSString cellId) { Identifier = cellId; WantsLayer = true; Layer.BackgroundColor = NSColor.FromRgb(218, 255, 127).CGColor; _imageView = new NSImageView(); _headingLabel = new NSTextField() { Font = NSFont.FromFontName("Cochin-BoldItalic", 22f), TextColor = NSColor.FromRgb(127, 51, 0), BackgroundColor = NSColor.Clear }; _subheadingLabel = new NSTextField() { Font = NSFont.FromFontName("AmericanTypewriter", 12f), TextColor = NSColor.FromRgb(38, 127, 0), Alignment = NSTextAlignment.Center, BackgroundColor = NSColor.Clear }; AddSubview(_headingLabel); AddSubview(_subheadingLabel); AddSubview(_imageView); }
private static NSFont GetSystemFont(nfloat size, FontWeight fontWeight, FontStyle fontStyle, string fontFamilyName) { //based on Fonts available @ http://iosfonts.com/ //for Windows parity feature, we will not support FontFamily="HelveticaNeue-Bold" (will ignore Bold and must be set by FontWeight property instead) var rootFontFamilyName = fontFamilyName.Split(new[] { '-' }).FirstOrDefault(); if (rootFontFamilyName.HasValue()) { var font = new StringBuilder(rootFontFamilyName); if (fontWeight != FontWeights.Normal || fontStyle == FontStyle.Italic) { font.Append("-"); font.Append(GetFontWeight(fontWeight)); font.Append(GetFontStyle(fontStyle)); } var updatedFont = NSFont.FromFontName(font.ToString(), size); if (updatedFont != null) { return(updatedFont); } font.Log().Warn("Failed to apply Font " + font); return(NSFont.FromFontName(rootFontFamilyName, size)); } return(null); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Create the font and the materials that will be shared among the features in the word cloud Font = NSFont.FromFontName("Myriad Set BoldItalic", 50) != null?NSFont.FromFontName("Myriad Set BoldItalic", 50) : NSFont.FromFontName("Avenir Heavy Oblique", 50); var frontAndBackMaterial = SCNMaterial.Create(); var sideMaterial = SCNMaterial.Create(); sideMaterial.Diffuse.Contents = NSColor.DarkGray; Materials = new SCNMaterial[] { frontAndBackMaterial, sideMaterial, frontAndBackMaterial }; // Add different features to the word cloud PlaceFeature("Techniques", new CGPoint(10, -8), 0); PlaceFeature("SpriteKit materials", new CGPoint(-16, -7), 0.05f); PlaceFeature("Inverse Kinematics", new CGPoint(-12, -6), 0.1f); PlaceFeature("Actions", new CGPoint(-10, 6), 0.15f); PlaceFeature("SKTexture", new CGPoint(4, 9), 0.2f); PlaceFeature("JavaScript", new CGPoint(-4, 8), 0.25f); PlaceFeature("Alembic", new CGPoint(-3, -8), 0.3f); PlaceFeature("OpenSubdiv", new CGPoint(-1, 6), 0.35f); PlaceFeature("Assets catalog", new CGPoint(1, 5), 0.85f); PlaceFeature("SIMD bridge", new CGPoint(3, -6), 0.45f); PlaceFeature("Physics", new CGPoint(-0.5f, 0), 0.47f); PlaceFeature("Vehicle", new CGPoint(5, 3), 0.50f); PlaceFeature("Fog", new CGPoint(7, 2), 0.95f); PlaceFeature("SpriteKit Overlays", new CGPoint(-10, 1), 0.60f); PlaceFeature("Particles", new CGPoint(-13, -1), 0.65f); PlaceFeature("Forward shadows", new CGPoint(8, -1), 0.7f); PlaceFeature("Snapshot", new CGPoint(6, -2), 0.75f); PlaceFeature("Physics Fields", new CGPoint(-6, -3), 0.8f); PlaceFeature("Archiving", new CGPoint(-11, 3), 0.9f); PlaceFeature("Performance tools", new CGPoint(-2, -5), 1); }
private NSFont FontForTextType(TextType type, int level) { var fontSize = FontCGSizeorTextType(type, level); var font = NSFont.FromFontName("Myriad Set Semibold", fontSize) != null?NSFont.FromFontName("Myriad Set", fontSize) : NSFont.FromFontName("Avenir Medium", fontSize); ; switch (type) { case TextType.Code: font = NSFont.FromFontName("Menlo", fontSize); break; case TextType.Bullet: font = NSFont.FromFontName("Myriad Set", fontSize) != null?NSFont.FromFontName("Myriad Set", fontSize) : NSFont.FromFontName("Avenir Medium", fontSize); break; case TextType.Body: if (level != 0) { font = NSFont.FromFontName("Myriad Set", fontSize) != null?NSFont.FromFontName("Myriad Set", fontSize) : NSFont.FromFontName("Avenir Medium", fontSize); } break; } return(font); }
private static NSFont GetFontFromFile(nfloat size, string file) { var fileName = Path.GetFileNameWithoutExtension(file); var fileExtension = Path.GetExtension(file)?.Replace(".", ""); var url = NSBundle .MainBundle .GetUrlForResource( name: fileName, fileExtension: fileExtension, subdirectory: "Fonts" ); if (url == null) { return(null); } var fontData = NSData.FromUrl(url); if (fontData == null) { return(null); } //iOS loads NSFonts based on the PostScriptName of the font file using (var fontProvider = new CGDataProvider(fontData)) { using (var font = CGFont.CreateFromProvider(fontProvider)) { return(font != null?NSFont.FromFontName(font.PostScriptName, size) : null); } } }
public override void SetupSlide(PresentationViewController presentationViewController) { // Create the font and the materials that will be shared among the features in the word cloud Font = NSFont.FromFontName("Myriad Set BoldItalic", 50) != null?NSFont.FromFontName("Myriad Set BoldItalic", 50) : NSFont.FromFontName("Avenir Heavy Oblique", 50); var frontAndBackMaterial = SCNMaterial.Create(); var sideMaterial = SCNMaterial.Create(); sideMaterial.Diffuse.Contents = NSColor.DarkGray; Materials = new SCNMaterial[] { frontAndBackMaterial, sideMaterial, frontAndBackMaterial }; // Add different features to the word cloud PlaceFeature("Export to DAE", new CGPoint(10, -8), 0); PlaceFeature("OpenGL Core Profile", new CGPoint(-16, -7), 0.05f); PlaceFeature("Warmup", new CGPoint(-12, -10), 0.1f); PlaceFeature("Constraints", new CGPoint(-10, 6), 0.15f); PlaceFeature("Custom projection", new CGPoint(4, 9), 0.2f); PlaceFeature("Skinning", new CGPoint(-4, 8), 0.25f); PlaceFeature("Morphing", new CGPoint(-3, -8), 0.3f); PlaceFeature("Performance Statistics", new CGPoint(-1, 6), 0.35f); PlaceFeature("CIFilters", new CGPoint(1, 5), 0.85f); PlaceFeature("GLKit Math", new CGPoint(3, -10), 0.45f); PlaceFeature("Depth of Field", new CGPoint(-0.5f, 0), 0.47f); PlaceFeature("Animation Events", new CGPoint(5, 3), 0.50f); PlaceFeature("Shader Modifiers", new CGPoint(7, 2), 0.95f); PlaceFeature("GOBO", new CGPoint(-10, 1), 0.60f); PlaceFeature("Ray testing", new CGPoint(-8, 0), 0.65f); PlaceFeature("Skybox", new CGPoint(8, -1), 0.7f); PlaceFeature("Fresnel", new CGPoint(6, -2), 0.75f); PlaceFeature("SCNShape", new CGPoint(-6, -3), 0.8f); PlaceFeature("Levels of detail", new CGPoint(-11, 3), 0.9f); PlaceFeature("Animation blending", new CGPoint(-2, -5), 1); }
public static NSAttributedString AttributedTitle(string title, NSColor color, String fontName, float fontSize, NSTextAlignment textAlignment) { NSMutableParagraphStyle ps = new NSMutableParagraphStyle(); ps.Alignment = textAlignment; ps.LineSpacing = 0.0f; NSColor fontColor = color; NSFont font = NSFont.FromFontName(fontName, fontSize); if (font == null) { font = NSFont.SystemFontOfSize(fontSize); } NSString titleObj = new NSString(title); NSStringAttributes attributes = new NSStringAttributes(); attributes.Font = font; attributes.ForegroundColor = fontColor; attributes.ParagraphStyle = ps; attributes.ToolTip = titleObj; NSAttributedString buttonString = new NSAttributedString(title, attributes); return(buttonString); }
public StringEditorControl() { StringEditor = new NSTextField { BackgroundColor = NSColor.Clear, ControlSize = NSControlSize.Small, Font = NSFont.FromFontName(DefaultFontName, DefaultFontSize), StringValue = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; // update the value on keypress StringEditor.Changed += (sender, e) => { ViewModel.Value = StringEditor.StringValue; }; AddSubview(StringEditor); this.DoConstraints(new[] { StringEditor.ConstraintTo(this, (s, c) => s.Width == c.Width - 34), StringEditor.ConstraintTo(this, (s, c) => s.Height == DefaultControlHeight - 3), StringEditor.ConstraintTo(this, (s, c) => s.Left == s.Left + 4), StringEditor.ConstraintTo(this, (s, c) => s.Top == s.Top + 1), }); UpdateTheme(); }
public RectangleEditorControl() { // TODO localize XLabel.Frame = new CGRect(38, 27, 25, 22); XLabel.Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs XLabel.StringValue = "X"; XEditor.Frame = new CGRect(4, 46, 90, 20); YLabel.Frame = new CGRect(166, 27, 25, 22); YLabel.Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs YLabel.StringValue = "Y"; YEditor.Frame = new CGRect(132, 46, 90, 20); WidthLabel.Frame = new CGRect(24, -6, 50, 22); WidthLabel.Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs WidthLabel.StringValue = "WIDTH"; WidthEditor.Frame = new CGRect(4, 13, 90, 20); HeightLabel.Frame = new CGRect(150, -6, 50, 22); HeightLabel.Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs HeightLabel.StringValue = "HEIGHT"; HeightEditor.Frame = new CGRect(132, 13, 90, 20); RowHeight = 66; }
static void Main(string[] args) { Style.Add <ListBox, NSScrollView>("ListNative", (widget, control) => { control.BorderType = NSBorderType.NoBorder; var list = control.DocumentView as NSTableView; list.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.SourceList; }); Style.Add <TextArea, NSScrollView>("TextConsole", (widget, control) => { control.BorderType = NSBorderType.NoBorder; var textbox = control.DocumentView as NSTextView; textbox.RichText = false; textbox.Font = NSFont.FromFontName("Monaco", 12); }); Style.Add <ToolBar, NSToolbar>("ToolBar", (widget, control) => { control.DisplayMode = NSToolbarDisplayMode.Icon; }); Style.Add <Window, NSWindow> ("MainWindow", (widget, control) => { control.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary; }); var generator = Generator.GetGenerator("Eto.Platform.Mac.Generator, Eto.Platform.Mac"); var app = new Program(generator); app.Run(); }
private static NSFont _ToUIFont(string family, float size, FontAttributes attributes) { bool isBold = (uint)(attributes & FontAttributes.Bold) > 0U; bool isItalic = (uint)(attributes & FontAttributes.Italic) > 0U; if (family != null) { try { var uiFont1 = NSFont.FromFontName(family, (nfloat)size); if (uiFont1 != null) { return(uiFont1); } } catch { } } if (isBold & isItalic) { var uiFont = NSFont.SystemFontOfSize((nfloat)size); return(NSFont.BoldSystemFontOfSize((nfloat)size)); } if (isBold) { return(NSFont.BoldSystemFontOfSize((nfloat)size)); } //if (isItalic) // return NSFont.ItalicSystemFontOfSize ((nfloat)size); return(NSFont.SystemFontOfSize((nfloat)size)); }
static void Main(string[] args) { Style.Add <ListBoxHandler>("ListNative", handler => { handler.Scroll.BorderType = NSBorderType.NoBorder; handler.Control.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.SourceList; }); Style.Add <TextAreaHandler>("TextConsole", handler => { handler.Scroll.BorderType = NSBorderType.NoBorder; handler.Control.RichText = false; handler.Control.Font = NSFont.FromFontName("Monaco", 12); }); Style.Add <ToolBarHandler>("ToolBar", handler => { handler.Control.DisplayMode = NSToolbarDisplayMode.Icon; }); Style.Add <FormHandler> ("MainWindow", handler => { handler.Control.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary; }); var app = new Program(Eto.Platforms.Mac); app.Run(); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { int index = Convert.ToInt32(row); string title = null; NSTableCellView tableCellView = null; if (row == 0) { title = "Page Results"; tableCellView = (NSTableCellView)tableView.MakeView("GROUPITEM", this); var textField = (NSTextField)tableCellView.Subviews [0]; textField.StringValue = title; var gridView = tableCellView.Subviews [1]; gridView.WantsLayer = true; gridView.Layer.BackgroundColor = NSColor.Grid.CGColor; tableCellView.WantsLayer = true; tableCellView.Layer.BackgroundColor = NSColor.Control.CGColor; return(tableCellView); } tableCellView = (NSTableCellView)tableView.MakeView("PAGEITEM", this); int rowIndex = index - 1; title = SearchResults [rowIndex].FileTitle; string section = SearchResults [rowIndex].GuideCardTitle; var viewList = tableCellView.Subviews; NSTextField titleTF = (NSTextField)viewList [0]; titleTF.Cell.DrawsBackground = true; titleTF.Cell.BackgroundColor = NSColor.Clear; titleTF.Cell.Font = NSFont.FromFontName("Helvetica Neue Medium", 12); titleTF.StringValue = title; titleTF.ToolTip = title; NSTextField sectionTF = (NSTextField)viewList [1]; sectionTF.Cell.DrawsBackground = true; sectionTF.Cell.BackgroundColor = NSColor.Clear; sectionTF.Cell.Font = NSFont.FromFontName("Helvetica Neue", 12); sectionTF.StringValue = section; sectionTF.ToolTip = section; var boxView = (NSView)viewList [2]; boxView.WantsLayer = true; boxView.Layer.BackgroundColor = NSColor.Grid.CGColor; return(tableCellView); }
protected BasePointEditorControl(IHostResourceProvider hostResources) : base(hostResources) { XLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; XEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; XEditor.ProxyResponder = new ProxyResponder(this, ProxyRowType.FirstView); XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; YEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; YEditor.ProxyResponder = new ProxyResponder(this, ProxyRowType.LastView); YEditor.ValueChanged += OnInputUpdated; AddSubview(XLabel); AddSubview(XEditor); AddSubview(YLabel); AddSubview(YEditor); const float editorHeight = 18; this.AddConstraints(new[] { NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 3f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, YEditor, NSLayoutAttribute.Left, 1f, -10f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, XEditor, NSLayoutAttribute.Bottom, 1f, -4f), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 3f), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, XEditor, NSLayoutAttribute.Width, 1f, 0f), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, XLabel, NSLayoutAttribute.Top, 1f, 0f), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, XEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, YEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), }); AppearanceChanged(); }
static NSFont _ToNativeFont(string family, float size, FontAttributes attributes) { NSFont defaultFont = NSFont.SystemFontOfSize(size); NSFont font = null; NSFontDescriptor descriptor = null; var bold = (attributes & FontAttributes.Bold) != 0; var italic = (attributes & FontAttributes.Italic) != 0; if (family != null && family != DefaultFontName) { try { descriptor = new NSFontDescriptor().FontDescriptorWithFamily(family); font = NSFont.FromDescription(descriptor, size); if (font == null) { var cleansedFont = CleanseFontName(family); font = NSFont.FromFontName(cleansedFont, size); } } catch { Debug.WriteLine("Could not load font named: {0}", family); } } //if we didn't found a Font or Descriptor for the FontFamily use the default one if (font == null) { font = defaultFont; descriptor = defaultFont.FontDescriptor; } if (descriptor == null) { descriptor = defaultFont.FontDescriptor; } if (bold || italic) { var traits = (NSFontSymbolicTraits)0; if (bold) { traits |= NSFontSymbolicTraits.BoldTrait; } if (italic) { traits |= NSFontSymbolicTraits.ItalicTrait; } var fontDescriptorWithTraits = descriptor.FontDescriptorWithSymbolicTraits(traits); font = NSFont.FromDescription(fontDescriptorWithTraits, size); } return(font.ScreenFontWithRenderingMode(NSFontRenderingMode.AntialiasedIntegerAdvancements)); }
public static NSAttributedString AttributedPartialTitle(string title, List <string> keyWordsList, NSColor fontColor, string fontName, float fontSize, NSTextAlignment textAlignment, NSLineBreakMode breakMode) { string patten = "\\b("; int i = 0; foreach (var item in keyWordsList) { if (i != 0) { patten = patten + "|" + item; } else { patten = patten + item; } i++; } patten = patten + ")\\b"; string [] results = Regex.Split(title, patten); NSMutableParagraphStyle ps = new NSMutableParagraphStyle(); ps.Alignment = textAlignment; ps.LineBreakMode = breakMode; NSMutableAttributedString attrTitle = new NSMutableAttributedString(); foreach (var item in results) { //Console.WriteLine ("result:{0}", item); if (item.Length == 0) { continue; } if (keyWordsList.Contains(item)) { NSStringAttributes attributes = new NSStringAttributes(); attributes.Font = NSFont.FromFontName(fontName + " Bold Italic", fontSize); attributes.ForegroundColor = Utility.ColorWithRGB(0, 0, 0, 0.45f); attributes.ParagraphStyle = ps; NSAttributedString attrString = new NSAttributedString(item, attributes); attrTitle.Append(attrString); } else { NSStringAttributes attributes = new NSStringAttributes(); attributes.Font = NSFont.FromFontName(fontName, fontSize); attributes.ForegroundColor = fontColor; attributes.ParagraphStyle = ps; NSAttributedString attrString = new NSAttributedString(item, attributes); attrTitle.Append(attrString); } } return(attrTitle); }
public static double GetLineHeight(string fontName) { var editorFont = Xwt.Drawing.Font.FromName(fontName); using (var nsFont = NSFont.FromFontName(editorFont.Family, (nfloat)editorFont.Size)) using (var lm = new NSLayoutManager()) return(lm.DefaultLineHeightForFont(nsFont)); }