public void showSheetForWindow(NSWindow aWindow) withMessage(NSString aMessage) allowCancel(bool aAllowCancel)
		{
			window = aWindow;
			messageText = aMessage;
			allowCancel = aAllowCancel;
			NSApp.beginSheet(window) modalForWindow(window) modalDelegate(this) didEndSelector(__selector(didEndSheet:returnCode:contextInfo:)) contextInfo(null);
		}
Example #2
0
		public void AddSiteUrl(RectangleF frame)
		{
			url = UIButton.FromType(UIButtonType.Custom);
			url.LineBreakMode = UILineBreakMode.TailTruncation;
			url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
			url.TitleShadowOffset = new SizeF(0, 1);
			url.SetTitleColor(UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal);
			url.SetTitleColor(UIColor.Red, UIControlState.Highlighted);
			url.SetTitleShadowColor(UIColor.White, UIControlState.Normal);
			url.AddTarget(delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside);
			
			// Autosize the bio URL to fit available space
			var size = _urlSize;
			var urlFont = UIFont.BoldSystemFontOfSize(size);
			var urlSize = new NSString(_bio.Url).StringSize(urlFont);
			var available = Util.IsPad() ? 400 : 185; // Util.IsRetina() ? 185 : 250;		
			while(urlSize.Width > available)
			{
				urlFont = UIFont.BoldSystemFontOfSize(size--);
				urlSize = new NSString(_bio.Url).StringSize(urlFont);
			}
			
			url.Font = urlFont;			
			url.Frame = new RectangleF ((float)_left, (float)70, (float)(frame.Width - _left), (float)size);
			url.SetTitle(_bio.Url, UIControlState.Normal);
			url.SetTitle(_bio.Url, UIControlState.Highlighted);			
			AddSubview(url);
		}
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            var inset = this.TextContainerInset;
            var leftInset = inset.Left + this.TextContainer.LineFragmentPadding;
            var rightInset = inset.Left + this.TextContainer.LineFragmentPadding;
            var maxSize = new CGSize()
                {
                    Width = this.Frame.Width - (leftInset + rightInset),
                    Height = this.Frame.Height - (inset.Top + inset.Bottom)
                };
            var size = new NSString(this.Placeholder).StringSize(this.PlaceholderFont, maxSize, UILineBreakMode.WordWrap);
            var frame = new CGRect(new CGPoint(leftInset, inset.Top), size);

            this.placeholderLabel = new UILabel(frame)
                {
                    BackgroundColor = UIColor.Clear,
                    Font = this.PlaceholderFont,
                    LineBreakMode = UILineBreakMode.WordWrap,
                    Lines = 0,
                    Text = this.Placeholder,
                    TextColor = this.PlaceholderColor
                };
            
            this.Add(this.placeholderLabel);
        }
        public NativeiOSListViewCell(NSString cellId)
            : base(UITableViewCellStyle.Default, cellId)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Gray;

            ContentView.BackgroundColor = UIColor.FromRGB(218, 255, 127);

            imageView = new UIImageView();

            headingLabel = new UILabel()
            {
                Font = UIFont.FromName("Cochin-BoldItalic", 22f),
                TextColor = UIColor.FromRGB(127, 51, 0),
                BackgroundColor = UIColor.Clear
            };

            subHeadingLabel = new UILabel()
            {
                Font = UIFont.FromName("AmericanTypewriter", 12f),
                TextColor = UIColor.FromRGB(38, 127, 0),
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            ContentView.Add(headingLabel);
            ContentView.Add(subHeadingLabel);
            ContentView.Add(imageView);
        }
Example #5
0
		public static void RegisterDefaultSettings ()
		{
			var path = Path.Combine(NSBundle.MainBundle.PathForResource("Settings", "bundle"), "Root.plist");

			using (NSString keyString = new NSString ("Key"), defaultString = new NSString ("DefaultValue"), preferenceSpecifiers = new NSString ("PreferenceSpecifiers"))
			using (var settings = NSDictionary.FromFile(path))
			using (var preferences = (NSArray)settings.ValueForKey(preferenceSpecifiers))
			using (var registrationDictionary = new NSMutableDictionary ()) {
				for (nuint i = 0; i < preferences.Count; i++)
					using (var prefSpecification = preferences.GetItem<NSDictionary>(i))
					using (var key = (NSString)prefSpecification.ValueForKey(keyString))
						if (key != null)
							using (var def = prefSpecification.ValueForKey(defaultString))
								if (def != null)
									registrationDictionary.SetValueForKey(def, key);

				NSUserDefaults.StandardUserDefaults.RegisterDefaults(registrationDictionary);

				#if DEBUG
				SetSetting(SettingsKeys.UserReferenceKey, debugReferenceKey);
				#else
				SetSetting(SettingsKeys.UserReferenceKey, UIDevice.CurrentDevice.IdentifierForVendor.AsString());
				#endif

				Synchronize();
			}
		}
        public static NSCharacterSet CharacterSetWithCharactersInString(NSString aString)
        {
            NSMutableCharacterSet ms = (NSMutableCharacterSet)NSMutableCharacterSet.Alloc().Init();
            ms.AddCharactersInString(aString);

            return ms;
        }
        public QuoteTableCustomCell(NSString cellId)
            : base(UITableViewCellStyle.Default, cellId)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Gray;
            ContentView.BackgroundColor = UIColor.White;

            price = new UILabel () {
                Font = UIFont.FromName("AmericanTypewriter", 22f),
                TextColor = UIColor.FromRGB (127, 51, 0),
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            position = new UILabel () {
                Font = UIFont.FromName("AmericanTypewriter", 16f),
                TextColor = UIColor.FromRGB (38, 127, 0),
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            time = new UILabel () {
                Font = UIFont.FromName("AmericanTypewriter", 10f),
                TextColor = UIColor.FromRGB (38, 88, 0),
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            ContentView.AddSubviews(new UIView[] {price, position, time});
        }
Example #8
0
		[Export("skipScanner:")] // notice the colon at the end of the method name
		public NSString SkipScanner(NSString reportName)
		{

			//Task.Run(async () => { await App.XTCBackDoor.BackDoor()}).Wait();

			return new NSString();
		}
 public void LogInAndPay(NSString userName, NSString userPassword, string amount)
 {
     if (Payleven.LoginState == PLVPaylevenLoginState.PLVPaylevenLoginStateLoggedIn)
     {
         // Payleven: prepare device and make payment
         PrepareDeviceAndPay (amount);
     }
     else
     {
         // Payleven: login user
         Payleven.LoginWithUsername(userName, userPassword, new NSString (ApiKey), (errorHandler) =>
             {
                 if (errorHandler == null)
                 {
                     // Payleven: login successful
                     PrepareDeviceAndPay(amount);
                 }
                 else
                 {
                     // Payleven: login failed
                     StatusAction.Invoke(PLVPaylevenStatus.PLVPaylevenStatusLoginError);
                 }
             });
     }
 }
 public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
 {
     if (keyPath == "contentSize")
         OnSizeChanged (new NSObservedChange (change));
     else
         base.ObserveValue (keyPath, ofObject, change, context);
 }
Example #11
0
		public static UIFont GetPreferredFont (NSString textStyle, float scale)
		{
			UIFontDescriptor tmp = UIFontDescriptor.GetPreferredDescriptorForTextStyle (textStyle);
			UIFontDescriptor newBaseDescriptor = tmp.CreateWithSize (tmp.PointSize * scale);

			return UIFont.FromDescriptor (newBaseDescriptor, newBaseDescriptor.PointSize);
		}
 void AddNotesCell()
 {
     var cellIdentifier = new NSString("addBeerNotesCell");
     var cell = TableView.DequeueReusableCell(cellIdentifier) as AddBeerNotesCell ??
         new AddBeerNotesCell(cellIdentifier);
     cells.Add(cell);
 }
        public void OnMessageReceived(NSDictionary userInfo)
        {
            var parameters = new Dictionary<string, object>();
            var json = DictionaryToJson(userInfo);
            JObject values = JObject.Parse(json);

            var keyAps = new NSString("aps");

            if (userInfo.ContainsKey(keyAps))
            {
                NSDictionary aps = userInfo.ValueForKey(keyAps) as NSDictionary;

                if (aps != null)
                {
                    foreach (var apsKey in aps)
                    {
                        parameters.Add(apsKey.Key.ToString(), apsKey.Value);
                        JToken temp;
                        if (!values.TryGetValue(apsKey.Key.ToString(), out temp))
                            values.Add(apsKey.Key.ToString(), apsKey.Value.ToString());
                    }
                }
            }

            CrossPushNotification.PushNotificationListener.OnMessage(values, DeviceType.iOS);
        }
Example #14
0
        public static bool IsEqualToString(this NSString text, NSString text2)
        {
            if (text == null || text2 == null)
                return false;

            return text.Value.Equals(text2.Value);
        }
Example #15
0
        private UIImage CreateImage (NSString title, nfloat scale)
        {
            var titleAttrs = new UIStringAttributes () {
                Font = UIFont.FromName ("HelveticaNeue", 13f),
                ForegroundColor = Color.Gray,
            };

            var titleBounds = new CGRect (
                new CGPoint (0, 0),
                title.GetSizeUsingAttributes (titleAttrs)
            );

            var image = Image.TagBackground;
            var imageBounds = new CGRect (
                0, 0,
                (float)Math.Ceiling (titleBounds.Width) + image.CapInsets.Left + image.CapInsets.Right + 4f,
                (float)Math.Ceiling (titleBounds.Height) + image.CapInsets.Top + image.CapInsets.Bottom
            );

            titleBounds.X = image.CapInsets.Left + 2f;
            titleBounds.Y = image.CapInsets.Top;

            UIGraphics.BeginImageContextWithOptions (imageBounds.Size, false, scale);

            try {
                image.Draw (imageBounds);
                title.DrawString (titleBounds, titleAttrs);
                return UIGraphics.GetImageFromCurrentImageContext ();
            } finally {
                UIGraphics.EndImageContext ();
            }
        }
        void SetLayoutIdentifierForArray (NSString identifier, NSArray constraintsArray)
		{
			for (nuint i = 0; i < constraintsArray.Count; i++) {
				var constraint = constraintsArray.GetItem<NSLayoutConstraint> (i);
				constraint.SetIdentifier (identifier);
			}
        }
Example #17
0
		public ExpenseViewCell (NSString cellId) 
			: base(UITableViewCellStyle.Default, cellId)
		{
			date = new UILabel () {

				Font = UIFont.FromName("AvenirNext-Medium", 10f),
				TextAlignment = UITextAlignment.Left,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White
				, 
			};

			name = new UILabel () {

				Font = UIFont.FromName("AvenirNext-Italic", 8f),
				TextAlignment = UITextAlignment.Left,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White

			};

			amount = new UILabel () {

				Font = UIFont.FromName("AvenirNext-Regular", 8f),
				TextAlignment = UITextAlignment.Right,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White
			};

			ContentView.Add (date);
			ContentView.Add (name);
			ContentView.Add (amount);
		}
Example #18
0
		public void Display (string body, string title, GoalsAvailable goalAvailable, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
		{
			UIAlertView alert = new UIAlertView();
			alert.Title = title;
			alert.AddButton(acceptButtonTitle);
			alert.AddButton(cancelButtonTitle);
			alert.Message = body;
			alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
			alert.GetTextField(0).KeyboardType=UIKeyboardType.NumberPad;
			const int maxCharacters =7;
			alert.GetTextField(0).ShouldChangeCharacters = (textField, range, replacement) =>
			{
				var newContent = new NSString(textField.Text).Replace(range, new NSString(replacement)).ToString();
				int number;
				return newContent.Length <= maxCharacters && (replacement.Length == 0 || int.TryParse(replacement, out number));
			};
			alert.Clicked += (object s, UIButtonEventArgs ev) =>
			{
				if(action != null)
				{
					if(ev.ButtonIndex ==0)
					{
						string input = alert.GetTextField(0).Text;
						int goalValue;
						int.TryParse(input, out goalValue);
						action.Invoke(goalAvailable, goalValue);
					}
				}
			};
			alert.Show();
		}
 /// <summary>
 ///   Constructor
 /// </summary>
 /// <param name="caption">
 /// The caption, only used for RootElements that might want to summarize results
 /// </param>
 /// <param name="view">
 /// The view to display
 /// </param>
 /// <param name="transparent">
 /// If this is set, then the view is responsible for painting the entire area,
 /// otherwise the default cell paint code will be used.
 /// </param>
 public UIViewElement(string caption, UIView view, bool transparent)
     : base(caption)
 {
     this.View = view;
     this.Flags = transparent ? CellFlags.Transparent : 0;
     key = new NSString("UIViewElement" + _count++);
 }
Example #20
0
        public PatientCell(UITableViewCellStyle style, NSString ident, Patient showSpeaker)
            : base(style, ident)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Blue;

            nameLabel = new UILabel()
            {
                TextAlignment = UITextAlignment.Left,
                Font = bigFont,
                BackgroundColor = UIColor.FromWhiteAlpha(0f, 0f)
            };
            companyLabel = new UILabel()
            {
                TextAlignment = UITextAlignment.Left,
                Font = smallFont,
                TextColor = UIColor.DarkGray,
                BackgroundColor = UIColor.FromWhiteAlpha(0f, 0f)
            };

            image = new UIImageView();

            UpdateCell(showSpeaker);

            ContentView.Add(nameLabel);
            ContentView.Add(companyLabel);
            ContentView.Add(image);
        }
Example #21
0
        public async Task<SKProductsResponse> RequestProductData (params string[] productIds)
        {
            var array = new NSString[productIds.Length];
            for (var i = 0; i < productIds.Length; i++)
                array[i] = new NSString(productIds[i]);

            var tcs = new TaskCompletionSource<SKProductsResponse>();
            _productDataRequests.AddLast(tcs);

            try
            {
                var productIdentifiers = NSSet.MakeNSObjectSet<NSString>(array); //NSSet.MakeNSObjectSet<NSString>(array);​​​
                var productsRequest = new SKProductsRequest(productIdentifiers);
                productsRequest.ReceivedResponse += (sender, e) => tcs.SetResult(e.Response);
                productsRequest.RequestFailed += (sender, e) => tcs.SetException(new Exception(e.Error.LocalizedDescription));
                productsRequest.Start();
                if (await Task.WhenAny(tcs.Task, Task.Delay(TimeSpan.FromSeconds(30))) != tcs.Task)
                    throw new InvalidOperationException("Timeout waiting for Apple to respond");
                var ret = tcs.Task.Result;
                productsRequest.Dispose();
                return ret;
            }
            finally
            {
                _productDataRequests.Remove(tcs);
            }
        }
        public CustomRecCell(NSString cellId)
            : base(UITableViewCellStyle.Default, cellId)
        {
            SelectionStyle = UITableViewCellSelectionStyle.Gray;

            fileNameLabel = new UILabel () {
                Font = UIFont.FromName("AmericanTypewriter", 15f),
                BackgroundColor = UIColor.Clear
            };

            playerPlayButton = new UIButton ();
            playerPlayButton.SetTitle("Play", UIControlState.Normal);
            playerPlayButton.SetTitle("Playing", UIControlState.Selected);
            playerPlayButton.Font = UIFont.FromName ("AmericanTypewriter", 15f);
            playerPlayButton.TouchUpInside += playerPlayButtonTouchUpInside_Event;

            playerStopButton = new UIButton ();
            playerStopButton.SetTitle("Stop", UIControlState.Normal);
            playerStopButton.Font = UIFont.FromName ("AmericanTypewriter", 15f);
            playerStopButton.TouchUpInside += playerStopButtonTouchUpInside_Event;

            progressBar = new UISlider ();
            progressBar.Enabled = false;
            progressBar.SetThumbImage (UIImage.FromBundle("Images/slider_thumb"), UIControlState.Normal);

            ContentView.Add (fileNameLabel);
            ContentView.Add (playerPlayButton);
            ContentView.Add (playerStopButton);
            ContentView.Add (progressBar);
        }
 public static NSDictionary ToDictionary(this DropboxRace race)
 {
     var keys = new NSString[] {
         new NSString("Code"),
         new NSString("FullName"),
         new NSString("RaceDate"),
         new NSString("BoatsUpdated"),
         new NSString("DetailsUpdated"),
         new NSString("DatastoreID"),
         new NSString("IntermediateLocations"),
     };
     NSDate d1 = DateTime.SpecifyKind(race.Date, DateTimeKind.Utc);
     NSDate d2 = DateTime.SpecifyKind(race.BoatsUpdated, DateTimeKind.Utc);
     NSDate d3 = DateTime.SpecifyKind(race.DetailsUpdated, DateTimeKind.Utc);
     var values = new NSObject[] {
         new NSString(race.Code),
         new NSString(race.Name),
         d1, d2, d3,
         new NSString(race.DataStoreID),
         new NSString(race
             .Locations
             .Select(l => l.Name)
             .Aggregate((h,t) => string.Format("{0},{1}", h,t)))
     };
     return NSDictionary.FromObjectsAndKeys (values, keys);
 }
		public TripViewCell (NSString cellId) 
			: base(UITableViewCellStyle.Default, cellId)
		{
			_tripHeading = new UILabel () {

				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextAlignment = UITextAlignment.Left,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White
				, 
			};

			_tripDescription = new UILabel () {

				Font = UIFont.FromName("AvenirNext-Italic", 10f),
				TextAlignment = UITextAlignment.Left,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White

			};

			_tripPrice = new UILabel () {

				Font = UIFont.FromName("AvenirNext-Regular", 16f),
				TextAlignment = UITextAlignment.Right,
				BackgroundColor = UIColor.Clear,
				TextColor = UIColor.White
			};

			ContentView.Add (_tripHeading);
			ContentView.Add (_tripDescription);
			ContentView.Add (_tripPrice);


		}
Example #25
0
		const int buttonSpace = 45; //24;
		
		public SessionCell (UITableViewCellStyle style, NSString ident, Session showSession, string big, string small) : base (style, ident)
		{
			SelectionStyle = UITableViewCellSelectionStyle.Blue;
			
			titleLabel = new UILabel () {
				TextAlignment = UITextAlignment.Left,
				BackgroundColor = UIColor.FromWhiteAlpha (0f, 0f)
			};
			speakerLabel = new UILabel () {
				TextAlignment = UITextAlignment.Left,
				Font = smallFont,
				TextColor = UIColor.DarkGray,
				BackgroundColor = UIColor.FromWhiteAlpha (0f, 0f)
			};
			locationImageView = new UIImageView();
			locationImageView.Image = building;

			button = UIButton.FromType (UIButtonType.Custom);
			button.TouchDown += delegate {
				UpdateImage (ToggleFavorite ());
				if (AppDelegate.IsPad) {
					NSObject o = new NSObject();
					NSDictionary progInfo = NSDictionary.FromObjectAndKey(o, new NSString("FavUpdate"));

					NSNotificationCenter.DefaultCenter.PostNotificationName(
						"NotificationFavoriteUpdated", o, progInfo);
				}
			};
			UpdateCell (showSession, big, small);
			
			ContentView.Add (titleLabel);
			ContentView.Add (speakerLabel);
			ContentView.Add (button);
			ContentView.Add (locationImageView);
		}
Example #26
0
 public override void SetNilValueForKey(NSString key)
 {
     if (key.ToString() == "expectedRaise")
         ExpectedRaise = 0.0f;
     else
         base.SetNilValueForKey(key);
 }
 public MvxStandardTableViewCell(IEnumerable<MvxBindingDescription> bindingDescriptions,
                                 UITableViewCellStyle cellStyle, NSString cellIdentifier,
                                 UITableViewCellAccessory tableViewCellAccessory = UITableViewCellAccessory.None)
     : base(bindingDescriptions, cellStyle, cellIdentifier, tableViewCellAccessory)
 {
     this.InitializeImageLoader();
 }
		partial void AuthenticateMe (UIButton sender)
		{
			var context = new LAContext();
			NSError AuthError;
			var localizedReason = new NSString("To add a new chore");

			//Use canEvaluatePolicy method to test if device is TouchID enabled
			//Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
			if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)){
				replyHandler = new LAContextReplyHandler((success, error) => {
					//Make sure it runs on MainThread, not in Background
					this.InvokeOnMainThread(()=>{
						if(success){
							Console.WriteLine("You logged in!");
							PerformSegue("AuthenticationSegue", this);
						}
						else{
							//Show fallback mechanism here
							unAuthenticatedLabel.Text="Oh Noes";
							AuthenticateButton.Hidden= true;
						}
					});

				});
				//Use evaluatePolicy to start authentication operation and show the UI as an Alert view
				//Use the LocalAuthentication Policy DeviceOwnerAuthenticationWithBiometrics
				context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);
			};
		}
 public MvxBindableTableViewCell(IEnumerable<MvxBindingDescription> bindingDescriptions,
                                 UITableViewCellStyle cellStyle, NSString cellIdentifier,
                                 UITableViewCellAccessory tableViewCellAccessory = UITableViewCellAccessory.None)
     : base(bindingDescriptions, cellStyle, cellIdentifier, tableViewCellAccessory)
 {
     InitialiseImageHelper();
 }
Example #30
0
		public LichThiCell (NSString cellId,bool key) : base (UITableViewCellStyle.Default, cellId)
		{
			this.key = true;
			monthi = new UILabel () {
				Text="Môn Thi",
				Lines=2,
				TextAlignment= UITextAlignment.Center,
				BackgroundColor = LayoutHelper.ourDarkCyan,
				Font = UIFont.FromName("AmericanTypewriter", 15f)
			};
			thoigian = new UILabel () {
				Text="Thời Gian",
				Lines=2,
				TextAlignment= UITextAlignment.Center,
				BackgroundColor = LayoutHelper.ourDarkCyan,
				Font = UIFont.FromName("AmericanTypewriter", 15f)
			};
			phongthi = new UILabel () {
				Text="Phòng Thi",
				Lines=2,
				TextAlignment= UITextAlignment.Center,
				BackgroundColor = LayoutHelper.ourDarkCyan,
				Font = UIFont.FromName("AmericanTypewriter", 15f)
			};
			hasRM = new UIImageView ();

			ContentView.AddSubviews (new UIView[] { monthi,thoigian,phongthi });
		}