public override void AwakeFromNib () { ivGravatar.WantsLayer = true; ivGravatar.Layer.CornerRadius = ivGravatar.Frame.Width / 2; ivGravatar.Layer.MasksToBounds = true; DisplayGravatar (XamarinAccountEmail); // Change button text color to white and centered (lame that you can't do this in IB) var coloredTitle = new NSMutableAttributedString (btnLogin.Title); var titleRange = new NSRange (0, coloredTitle.Length); coloredTitle.AddAttribute (NSAttributedString.ForegroundColorAttributeName, NSColor.White, titleRange); var centeredAttribute = new NSMutableParagraphStyle (); centeredAttribute.Alignment = NSTextAlignment.Center; coloredTitle.AddAttribute (NSAttributedString.ParagraphStyleAttributeName, centeredAttribute, titleRange); btnLogin.AttributedTitle = coloredTitle; btnLogin.Activated += (object sender, EventArgs e) => Login(); var txtDelegate = new CustomNSTextFieldDelegate (); txtDelegate.ReturnKeyPressed += () => Login(); txtPassword.Delegate = txtDelegate; txtEmail.StringValue = XamarinAccountEmail; txtEmail.FocusRingType = NSFocusRingType.None; txtPassword.FocusRingType = NSFocusRingType.None; txtPassword.SelectText (this); txtPassword.BecomeFirstResponder (); }
public static string GetTextRange(this NSTextView textView, NSRange range) { var data = textView.RtfFromRange(range); NSError error; NSDictionary dictionary; var attributedString = new NSAttributedString(data, new NSDictionary(), out dictionary, out error); return attributedString.Value; }
public CTFrame GetFrame (NSRange stringRange, CGPath path, CTFrameAttributes frameAttributes) { if (path == null) throw new ArgumentNullException ("path"); var frame = CTFramesetterCreateFrame (Handle, stringRange, path.Handle, frameAttributes == null ? IntPtr.Zero : frameAttributes.Dictionary.Handle); if (frame == IntPtr.Zero) return null; return new CTFrame (frame, true); }
public override void AwakeFromNib () { base.AwakeFromNib (); this.AddressLabel.StringValue = Properties_Resources.EnterWebAddress; this.UserLabel.StringValue = Properties_Resources.User + ": "; this.PasswordLabel.StringValue = Properties_Resources.Password + ": "; this.AddressDelegate = new TextFieldDelegate(); this.AddressText.Delegate = this.AddressDelegate; this.UserDelegate = new TextFieldDelegate(); this.UserText.Delegate = this.UserDelegate; this.PasswordDelegate = new TextFieldDelegate(); this.PasswordText.Delegate = this.PasswordDelegate; this.ContinueButton.Title = Properties_Resources.Continue; this.CancelButton.Title = Properties_Resources.Cancel; this.AddressText.StringValue = (Controller.PreviousAddress == null || String.IsNullOrEmpty (Controller.PreviousAddress.ToString ())) ? "https://" : Controller.PreviousAddress.ToString (); this.UserText.StringValue = String.IsNullOrEmpty (Controller.saved_user) ? Environment.UserName : Controller.saved_user; // this.PasswordText.StringValue = String.IsNullOrEmpty (Controller.saved_password) ? "" : Controller.saved_password; this.PasswordText.StringValue = ""; // Cmis server address help link string helpLabel = Properties_Resources.Help + ": "; string helpLink = Properties_Resources.WhereToFind; string addressUrl = @"https://github.com/aegif/CmisSync/wiki/What-address"; this.AddressHelp.AllowsEditingTextAttributes = true; this.AddressHelp.Selectable = true; var attrStr = new NSMutableAttributedString(helpLabel + helpLink); var labelRange = new NSRange(0, helpLabel.Length); var linkRange = new NSRange(helpLabel.Length, helpLink.Length); var url = new NSUrl(addressUrl); var font = this.AddressHelp.Font; var paragraph = new NSMutableParagraphStyle() { LineBreakMode = this.AddressHelp.Cell.LineBreakMode, Alignment = this.AddressHelp.Alignment }; attrStr.BeginEditing(); attrStr.AddAttribute(NSAttributedString.LinkAttributeName, url, linkRange); attrStr.AddAttribute(NSAttributedString.ForegroundColorAttributeName, NSColor.Blue, linkRange); attrStr.AddAttribute(NSAttributedString.ForegroundColorAttributeName, NSColor.Gray, labelRange); attrStr.AddAttribute(NSAttributedString.UnderlineStyleAttributeName, new NSNumber(1), linkRange); attrStr.AddAttribute(NSAttributedString.FontAttributeName, font, new NSRange(0, attrStr.Length)); attrStr.AddAttribute(NSAttributedString.ParagraphStyleAttributeName, paragraph, new NSRange(0, attrStr.Length)); attrStr.EndEditing(); this.AddressHelp.AttributedStringValue = attrStr; InsertEvent (); // Must be called after InsertEvent() CheckTextFields (); }
public override void AwakeFromNib () { ivStatusImage.WantsLayer = true; View.Gear = ivStatusImage; btnTryAgain.Hidden = true; btnTryAgain.Activated += (object sender, EventArgs e) => ProcessOrder(); // Change button text color to white and centered (lame that you can't do this in IB) var coloredTitle = new NSMutableAttributedString (btnTryAgain.Title); var titleRange = new NSRange (0, coloredTitle.Length); coloredTitle.AddAttribute (NSAttributedString.ForegroundColorAttributeName, NSColor.White, titleRange); var centeredAttribute = new NSMutableParagraphStyle (); centeredAttribute.Alignment = NSTextAlignment.Center; coloredTitle.AddAttribute (NSAttributedString.ParagraphStyleAttributeName, centeredAttribute, titleRange); btnTryAgain.AttributedTitle = coloredTitle; ProcessOrder (); }
public override void AwakeFromNib () { viewEmptyBasket.WantsLayer = true; viewEmptyBasket.Layer = new CALayer () {BackgroundColor = NSColor.White.CGColor}; viewBasket.WantsLayer = true; viewBasket.Layer = new CALayer () {BackgroundColor = NSColor.White.CGColor}; // Change button text color to white and centered (lame that you can't do this in IB) var coloredTitle = new NSMutableAttributedString (btnCheckout.Title); var titleRange = new NSRange (0, coloredTitle.Length); coloredTitle.AddAttribute (NSAttributedString.ForegroundColorAttributeName, NSColor.White, titleRange); var centeredAttribute = new NSMutableParagraphStyle (); centeredAttribute.Alignment = NSTextAlignment.Center; coloredTitle.AddAttribute (NSAttributedString.ParagraphStyleAttributeName, centeredAttribute, titleRange); btnCheckout.AttributedTitle = coloredTitle; tvBasketProducts.Source = new ShoppingBasketTableViewSource (); btnCheckout.Activated += (object sender, EventArgs e) => CheckoutInitiated(); View.ViewController = this; RefreshBasket (); }
public override void AwakeFromNib () { // Change button text color to white and centered (lame that you can't do this in IB) var coloredTitle = new NSMutableAttributedString (btnPlaceOrder.Title); var titleRange = new NSRange (0, coloredTitle.Length); coloredTitle.AddAttribute (NSAttributedString.ForegroundColorAttributeName, NSColor.White, titleRange); var centeredAttribute = new NSMutableParagraphStyle (); centeredAttribute.Alignment = NSTextAlignment.Center; coloredTitle.AddAttribute (NSAttributedString.ParagraphStyleAttributeName, centeredAttribute, titleRange); btnPlaceOrder.AttributedTitle = coloredTitle; txtFirstName.StringValue = _user.FirstName; txtLastName.StringValue = _user.LastName; LoadCountries (); cbCountry.Changed += (object sender, EventArgs e) => { LoadStates(); }; txtAddress1.SelectText (this); txtAddress1.BecomeFirstResponder (); btnPlaceOrder.Activated += OnBtnPlaceOrder; }
public extern static void void_objc_msgSend_nsrange (IntPtr receiver, IntPtr selector, NSRange arg1);
static extern IntPtr CTTypesetterCreateLine (IntPtr typesetter, NSRange stringRange);
static extern IntPtr CTTypesetterCreateLineWithOffset (IntPtr typesetter, NSRange stringRange, double offset);
static extern void CTFrameGetLineOrigins(IntPtr handle, NSRange range, [Out] PointF[] origins);
// ------------------------------------------------------------------------------- // control:textView:completions:forPartialWordRange:indexOfSelectedItem: // // Use this method to override NSFieldEditor's default matches (which is a much bigger // list of keywords). By not implementing this method, you will then get back // NSSearchField's default feature. // ------------------------------------------------------------------------------- //public string[] FilterCompletions (NSControl control, NSTextView textView, string [] words, NSRange charRange, int index) string[] handleFilterCompletions (NSControl control, NSTextView textView, string[] words, NSRange charRange, int index) { var partialString = textView.Value; List<string> matches = new List<string> (); if (partialString.Length > 0) { // find any match in our keyword array against what was typed - matches = (from c in builtInKeywords where c.StartsWith (partialString, StringComparison.OrdinalIgnoreCase) orderby c select c).ToList (); } return matches.ToArray(); }
public SizeF SuggestFrameSize (NSRange stringRange, CTFrameAttributes frameAttributes, SizeF constraints, out NSRange fitRange) { return CTFramesetterSuggestFrameSizeWithConstraints ( handle, stringRange, frameAttributes == null ? IntPtr.Zero : frameAttributes.Dictionary.Handle, constraints, out fitRange); }
static NSAttributedString GetAttributedString (string text) { var attrStr = new NSMutableAttributedString (text); var range = new NSRange (0, attrStr.Length); attrStr.AddAttribute (NSAttributedString.ForegroundColorAttributeName, NSColor.Blue, range); attrStr.AddAttribute (NSAttributedString.UnderlineStyleAttributeName, NSNumber.FromInt32 ((int)MonoMac.AppKit.NSUnderlineStyle.Single), range); return attrStr; }
public extern static void void_objc_msgSend_stret_rnsrange (ref NSRange stret, IntPtr receiver, IntPtr selector);
public override string [] GetCompletions(NSControl control, NSTextView text_view, string [] a, MonoMac.Foundation.NSRange range, int b) { return(new string [0]); }
void DoAppend (NSColor color, string text) { var pos = Storage.Length; Storage.Append (new NSAttributedString (text)); var range = new NSRange (pos, text.Length); Text.SetFont (font, range); Text.SetTextColor (color, range); }
public static Range Convert (NSRange range) { return new Range (range.Location, range.Length); }
public CTStringAttributes GetCoreTextAttributes (int location, out NSRange effectiveRange) { var attr = GetAttributes (location, out effectiveRange); return attr == null ? null : new CTStringAttributes (attr); }
static extern SizeF CTFramesetterSuggestFrameSizeWithConstraints ( IntPtr framesetter, NSRange stringRange, IntPtr frameAttributes, SizeF constraints, out NSRange fitRange);
public UIStringAttributes GetUIKitAttributes (int location, out NSRange effectiveRange) { var attr = GetAttributes (location, out effectiveRange); return attr == null ? null : new UIStringAttributes (attr); }
static extern IntPtr CTFramesetterCreateFrame (IntPtr framesetter, NSRange stringRange, IntPtr path, IntPtr frameAttributes);
public UIStringAttributes GetUIKitAttributes (int location, out NSRange longestEffectiveRange, NSRange rangeLimit) { var attr = GetAttributes (location, out longestEffectiveRange, rangeLimit); return attr == null ? null : new UIStringAttributes (attr); }
public void GetLineOrigins(NSRange range, PointF[] origins) { if (origins == null) throw new ArgumentNullException ("origins"); if (range.Length != 0 && origins.Length < range.Length) throw new ArgumentException ("origins must contain at least range.Length elements.", "origins"); else if (origins.Length < CFArray.GetCount (CTFrameGetLines (handle))) throw new ArgumentException ("origins must contain at least GetLines().Length elements.", "origins"); CTFrameGetLineOrigins (handle, range, origins); }
static NSAttributedString GetAttributedString (string text) { var attrStr = new NSMutableAttributedString (text); var range = new NSRange (0, attrStr.Length); var singleUnderlineStyle = NSNumber.FromInt32 ((int)NSUnderlineStyle.Single); attrStr.AddAttribute (NSStringAttributeKey.ForegroundColor, NSColor.Blue, range); attrStr.AddAttribute (NSStringAttributeKey.UnderlineStyle, singleUnderlineStyle, range); return attrStr; }
private static NSMutableAttributedString buildAttributedString(string text, CTFont font, Color? fontColor=null) { // Create a new attributed string from text NSMutableAttributedString atts = new NSMutableAttributedString(text); var attRange = new NSRange(0, atts.Length); var attsDic = new NSMutableDictionary(); // Font attribute NSObject fontObject = new NSObject(font.Handle); attsDic.Add(FontAttributedName, fontObject); // -- end font if (fontColor.HasValue) { // Font color var fc = fontColor.Value; NSColor color = NSColor.FromDeviceRgba(fc.R / 255f, fc.G / 255f, fc.B / 255f, fc.A / 255f); NSObject colorObject = new NSObject(color.Handle); attsDic.Add(ForegroundColorAttributedName, colorObject); // -- end font Color } if (underLine) { // Underline int single = (int)MonoMac.AppKit.NSUnderlineStyle.Single; int solid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid; var attss = single | solid; var underlineObject = NSNumber.FromInt32(attss); //var under = NSAttributedString.UnderlineStyleAttributeName.ToString(); attsDic.Add(UnderlineStyleAttributeName, underlineObject); // --- end underline } if (strikeThrough) { // StrikeThrough // NSColor bcolor = NSColor.Blue; // NSObject bcolorObject = new NSObject(bcolor.Handle); // attsDic.Add(NSAttributedString.StrikethroughColorAttributeName, bcolorObject); int stsingle = (int)MonoMac.AppKit.NSUnderlineStyle.Single; int stsolid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid; var stattss = stsingle | stsolid; var stunderlineObject = NSNumber.FromInt32(stattss); attsDic.Add(StrikethroughStyleAttributeName, stunderlineObject); // --- end underline } // Text alignment var alignment = CTTextAlignment.Left; var alignmentSettings = new CTParagraphStyleSettings(); alignmentSettings.Alignment = alignment; var paragraphStyle = new CTParagraphStyle(alignmentSettings); NSObject psObject = new NSObject(paragraphStyle.Handle); // end text alignment attsDic.Add(ParagraphStyleAttributeName, psObject); atts.SetAttributes(attsDic, attRange); return atts; }
// not bound public static void DrawGlyphs(this NSLayoutManager layout, NSRange range, CGPoint point) { Messaging.void_objc_msgSend_NSRange_CGPoint(layout.Handle, selDrawGlyphs, range, point); }
public CTLine GetLine (NSRange stringRange, double offset) { var h = CTTypesetterCreateLineWithOffset (Handle, stringRange, offset); if (h == IntPtr.Zero) return null; return new CTLine (h, true); }
// replacementString should allow nulls public static bool ShouldChangeTextNew(this NSTextView textView, NSRange affectedCharRange, string replacementString) { IntPtr intPtr = replacementString != null ? NSString.CreateNative(replacementString) : IntPtr.Zero; bool result; result = Messaging.bool_objc_msgSend_NSRange_IntPtr(textView.Handle, selShouldChangeTextInRangeReplacementString_Handle, affectedCharRange, intPtr); if (intPtr != IntPtr.Zero) NSString.ReleaseNative(intPtr); return result; }
public CTLine GetLine (NSRange stringRange) { var h = CTTypesetterCreateLine (Handle, stringRange); if (h == IntPtr.Zero) return null; return new CTLine (h, true); }
public void SetAttributes(CTStringAttributes attrs, NSRange range) { SetAttributes (attrs == null ? null : attrs.Dictionary, range); }