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 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;
		}
Exemplo n.º 5
0
		public override void DrawInteriorWithFrame(CGRect cellFrame, NSView inView)
		{
			var frame = cellFrame;
			var data = ObjectValue as MacImageData;
			if (data != null)
			{
				if (data.Image != null)
				{
					var imageSize = data.Image.Size;
					if (imageSize.Width > 0 && imageSize.Height > 0)
					{
						var newHeight = (nfloat)Math.Min(imageSize.Height, frame.Height);
						var newWidth = (nfloat)(imageSize.Width * newHeight / imageSize.Height);

						if (DrawsBackground && !Highlighted)
						{
							var g = NSGraphicsContext.CurrentContext.GraphicsPort;
							g.SetFillColor(BackgroundColor.CGColor);
							g.FillRect(new CGRect(frame.X, frame.Y, newWidth + ImagePadding, frame.Height));
						}

						var imageRect = new CGRect(frame.X, frame.Y, newWidth, newHeight);
						imageRect.Y += (frame.Height - newHeight) / 2;

						nfloat alpha = Enabled ? 1 : (nfloat)0.5;

						if (data.Image.RespondsToSelector(new Selector(selDrawInRectFromRectOperationFractionRespectFlippedHints)))
							// 10.6+
							data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, alpha, true, null);
						else
						{
							// 10.5-
							#pragma warning disable 618
							data.Image.Flipped = ControlView.IsFlipped; 
							#pragma warning restore 618
							data.Image.Draw(imageRect, new CGRect(CGPoint.Empty, data.Image.Size), NSCompositingOperation.SourceOver, alpha);
						}
						frame.Width -= newWidth + ImagePadding;
						frame.X += newWidth + ImagePadding;
					}
				}
			}

			var titleSize = AttributedStringValue.Size;
			
			// test to see if the text height is bigger then the cell, if it is,
			// don't try to center it or it will be pushed up out of the cell!
			if (titleSize.Height < frame.Size.Height)
			{
				//frame.Y = frame.Y + (frame.Size.Height - titleSize.Height) / 2;
			}
			
			if (UseTextShadow)
			{
				var str = new NSMutableAttributedString(StringValue);
				str.AddAttribute(NSStringAttributeKey.Shadow, Highlighted ? TextHighlightShadow : TextShadow, new NSRange(0, (int)str.Length));
				AttributedStringValue = str;
			}
			
			base.DrawInteriorWithFrame(frame, inView);
		}
Exemplo n.º 6
0
		public override void DrawInteriorWithFrame (SD.RectangleF cellFrame, NSView inView)
		{
			var data = ObjectValue as MacImageData;
			if (data != null) {
					
				if (data.Image != null) {
					var imageSize = data.Image.Size;
					if (imageSize.Width > 0 && imageSize.Height > 0) {
						var newHeight = Math.Min (imageSize.Height, cellFrame.Height);
						var newWidth = imageSize.Width * newHeight / imageSize.Height;
						
						var imageRect = new SD.RectangleF (cellFrame.X, cellFrame.Y, newWidth, newHeight);
						imageRect.Y += (cellFrame.Height - newHeight) / 2;

						if (data.Image.RespondsToSelector (new Selector (selDrawInRectFromRectOperationFractionRespectFlippedHints)))
							// 10.6+
							data.Image.Draw (imageRect, new SD.RectangleF (SD.PointF.Empty, data.Image.Size), NSCompositingOperation.SourceOver, 1, true, null);
						else {
							// 10.5-
							#pragma warning disable 618
							data.Image.Flipped = this.ControlView.IsFlipped; 
							#pragma warning restore 618
							data.Image.Draw (imageRect, new SD.RectangleF (SD.PointF.Empty, data.Image.Size), NSCompositingOperation.SourceOver, 1);
						}
						cellFrame.Width -= newWidth + ImagePadding;
						cellFrame.X += newWidth + ImagePadding;
					}
				}
			}

			SD.SizeF titleSize = this.AttributedStringValue.Size;
			
			// test to see if the text height is bigger then the cell, if it is,
			// don't try to center it or it will be pushed up out of the cell!
			if (titleSize.Height < cellFrame.Size.Height) {
				cellFrame.Y = cellFrame.Y + (cellFrame.Size.Height - titleSize.Height) / 2;
			}
			
			if (UseTextShadow) {
				var str = new NSMutableAttributedString(this.StringValue);
				str.AddAttribute (NSAttributedString.ShadowAttributeName, this.Highlighted ? TextHighlightShadow : TextShadow, new NSRange(0, str.Length));
				this.AttributedStringValue = str;
			}
			
			base.DrawInteriorWithFrame (cellFrame, inView);
		}
Exemplo n.º 7
0
		private void UpdateStatusBar()
		{
			if (mediaListController.Count < 1)
			{
                statusFilename.StringValue = statusTimestamp.StringValue = statusGps.StringValue = statusKeywords.StringValue = "";
				statusIndex.StringValue = "No files";
				return;
			}

			var mm = mediaListController.Current;

            statusFilename.StringValue = mm.Name;

			var timestamp = mm.Timestamp.ToString("yyyy/MM/dd HH:mm:ss");
			if (mm.FileAndExifTimestampMatch)
			{
				statusTimestamp.StringValue = timestamp;
			}
			else
			{
				var str = new NSMutableAttributedString(timestamp);
				str.AddAttribute(
					NSAttributedString.ForegroundColorAttributeName, 
					NSColor.Yellow,
					new NSRange(0, timestamp.Length));
				str.AddAttribute(
					NSAttributedString.UnderlineStyleAttributeName, 
					new NSNumber((int) NSUnderlineStyle.Single), 
					new NSRange(0, timestamp.Length));
				statusTimestamp.AttributedStringValue = str;
			}
			statusIndex.StringValue = String.Format(
				"{0} of {1}", 
				mediaListController.CurrentIndex + 1, 
				mediaListController.Count);

            statusKeywords.StringValue = mm.Keywords;
            statusGps.StringValue = "";

            if (mm.HasPlaceName)
            {
                SetStatusGps(mm);
            }
            else
            {
                ClearStatusGps();
                Task.Run( () =>
                {
                    mm.ToPlaceName();
                    BeginInvokeOnMainThread( () => 
                    {
                        SetStatusGps(mm);
                    });
                });
            }
		}
Exemplo n.º 8
0
		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;
		}
Exemplo n.º 9
0
		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;
		}
		public void DisplayInfo(string message)
		{
			var attr = new NSMutableAttributedString(message);
			attr.AddAttribute(
				NSAttributedString.BackgroundColorAttributeName, 
				NSColor.FromDeviceRgba(0, 0, 0, 0.75f),
				new NSRange(0, message.Length));
			infoText.AttributedStringValue = attr;
		}
Exemplo n.º 11
0
        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, Toolkit.CurrentEngine.Defaults.FallbackLinkColor.ToNSColor (), range);
            attrStr.AddAttribute (NSStringAttributeKey.UnderlineStyle, singleUnderlineStyle, range);

            return attrStr;
        }
Exemplo n.º 12
0
        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 ();
        }