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 }); }
public MvxBindableTableViewCell(IEnumerable<MvxBindingDescription> bindingDescriptions, UITableViewCellStyle cellStyle, NSString cellIdentifier, UITableViewCellAccessory tableViewCellAccessory = UITableViewCellAccessory.None) : base(bindingDescriptions, cellStyle, cellIdentifier, tableViewCellAccessory) { InitialiseImageHelper(); }
public MvxStandardTableViewCell(IEnumerable<MvxBindingDescription> bindingDescriptions, UITableViewCellStyle cellStyle, NSString cellIdentifier, UITableViewCellAccessory tableViewCellAccessory = UITableViewCellAccessory.None) : base(bindingDescriptions, cellStyle, cellIdentifier, tableViewCellAccessory) { this.InitializeImageLoader(); }
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); }
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); }
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); }
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 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 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 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 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); }
/// <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++); }
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}); }
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); }
public static NSCharacterSet CharacterSetWithCharactersInString(NSString aString) { NSMutableCharacterSet ms = (NSMutableCharacterSet)NSMutableCharacterSet.Alloc().Init(); ms.AddCharactersInString(aString); return ms; }
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); }; }
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 (); } }
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); }
public override void SetNilValueForKey(NSString key) { if (key.ToString() == "expectedRaise") ExpectedRaise = 0.0f; else base.SetNilValueForKey(key); }
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); }
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); }
void SetLayoutIdentifierForArray (NSString identifier, NSArray constraintsArray) { for (nuint i = 0; i < constraintsArray.Count; i++) { var constraint = constraintsArray.GetItem<NSLayoutConstraint> (i); constraint.SetIdentifier (identifier); } }
[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 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); }
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); }
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); }
void AddNotesCell() { var cellIdentifier = new NSString("addBeerNotesCell"); var cell = TableView.DequeueReusableCell(cellIdentifier) as AddBeerNotesCell ?? new AddBeerNotesCell(cellIdentifier); cells.Add(cell); }
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 static bool IsEqualToString(this NSString text, NSString text2) { if (text == null || text2 == null) return false; return text.Value.Equals(text2.Value); }
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(); }
private void AddButton(IntPtr alert, string title, DialogResult result) { IntPtr button = ObjC.Call(alert, "addButtonWithTitle:", NSString.Create(title)); ObjC.Call(button, "setTag:", new IntPtr((int)result)); }
public void UnknownPointTest() { using (var notKnownPoint = new NSString("nariz")) Assert.IsNull(ARSkeleton.CreateJointName(notKnownPoint)); }
public AppVersionImpl() { _buildKey = new NSString("CFBundleVersion"); _versionKey = new NSString("CFBundleShortVersionString"); }
public override string GetSubjectForActivity(UIActivityViewController activityViewController, NSString activityType) { return(subject); }
public override NSObject GetItemForActivity(UIActivityViewController activityViewController, NSString activityType) { return(item); }
public CocoaWebview(WebviewBridge bridge) { this.bridge = bridge ?? throw new ArgumentNullException(nameof(bridge)); IntPtr configuration = WebKit.Call("WKWebViewConfiguration", "new"); IntPtr manager = ObjC.Call(configuration, "userContentController"); callbackClass = CallbackClassDefinition.CreateInstance(this); schemeHandler = SchemeHandlerDefinition.CreateInstance(this); const string scheme = "spidereye"; customHost = new Uri(UriTools.GetRandomResourceUrl(scheme)); ObjC.Call(configuration, "setURLSchemeHandler:forURLScheme:", schemeHandler.Handle, NSString.Create(scheme)); ObjC.Call(manager, "addScriptMessageHandler:name:", callbackClass.Handle, NSString.Create("external")); IntPtr script = WebKit.Call("WKUserScript", "alloc"); ObjC.Call( script, "initWithSource:injectionTime:forMainFrameOnly:", NSString.Create(Resources.GetInitScript("Mac")), IntPtr.Zero, IntPtr.Zero); ObjC.Call(manager, "addUserScript:", script); Handle = WebKit.Call("WKWebView", "alloc"); ObjC.Call(Handle, "initWithFrame:configuration:", CGRect.Zero, configuration); ObjC.Call(Handle, "setNavigationDelegate:", callbackClass.Handle); IntPtr boolValue = Foundation.Call("NSNumber", "numberWithBool:", false); ObjC.Call(Handle, "setValue:forKey:", boolValue, NSString.Create("drawsBackground")); ObjC.Call(Handle, "addObserver:forKeyPath:options:context:", callbackClass.Handle, NSString.Create("title"), IntPtr.Zero, IntPtr.Zero); preferences = ObjC.Call(configuration, "preferences"); }
private static void UriSchemeStartCallback(CocoaWebview instance, IntPtr schemeTask) { try { IntPtr request = ObjC.Call(schemeTask, "request"); IntPtr url = ObjC.Call(request, "URL"); var uri = new Uri(NSString.GetString(ObjC.Call(url, "absoluteString"))); var host = new Uri(uri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)); if (host == instance.customHost) { using (var contentStream = Application.ContentProvider.GetStreamAsync(uri).GetAwaiter().GetResult()) { if (contentStream != null) { if (contentStream is UnmanagedMemoryStream unmanagedMemoryStream) { unsafe { long length = unmanagedMemoryStream.Length - unmanagedMemoryStream.Position; var data = (IntPtr)unmanagedMemoryStream.PositionPointer; FinishUriSchemeCallback(url, schemeTask, data, length, uri); return; } } else { byte[] data; long length; if (contentStream is MemoryStream memoryStream) { data = memoryStream.GetBuffer(); length = memoryStream.Length; } else { using (var copyStream = new MemoryStream()) { contentStream.CopyTo(copyStream); data = copyStream.GetBuffer(); length = copyStream.Length; } } unsafe { fixed(byte *dataPtr = data) { FinishUriSchemeCallback(url, schemeTask, (IntPtr)dataPtr, length, uri); return; } } } } } } FinishUriSchemeCallbackWithError(schemeTask, 404); } catch { FinishUriSchemeCallbackWithError(schemeTask, 500); } }
static string ToLower(this NSString str) { return(((string)str).ToLower()); }
public static object ToNativeFieldValue(this object fieldValue) { if (fieldValue == null) { return(new NSNull()); } switch (fieldValue) { case bool @bool: return(new NSNumber(@bool)); case byte @byte: return(new NSNumber(@byte)); case double @doble: return(new NSNumber(@doble)); case float @float: return(new NSNumber(@float)); case int @int: return(new NSNumber(@int)); case long @long: return(new NSNumber(@long)); case sbyte @sbyte: return(new NSNumber(@sbyte)); case short @short: return(new NSNumber(@short)); case uint @uint: return(new NSNumber(@uint)); case ulong @ulong: return(new NSNumber(@ulong)); case ushort @ushort: return(new NSNumber(@ushort)); case decimal @decimal: return(new NSNumber((double)@decimal)); case string @string: return(new NSString(@string)); case DateTime dateTime: return(new Timestamp(dateTime).ToNative()); case DateTimeOffset dateTimeOffset: return(new Timestamp(dateTimeOffset).ToNative()); case Timestamp timestamp: return(timestamp.ToNative()); case GeoPoint geoPoint: return(geoPoint.ToNative()); case DocumentReferenceWrapper documentReference: return((Firebase.CloudFirestore.DocumentReference)documentReference); case byte[] @byte: return(NSData.FromArray(@byte)); case Stream stream: using (var ms = new MemoryStream()) { stream.CopyTo(ms); return(NSData.FromArray(ms.ToArray())); } case IList list: { var array = new NSMutableArray(); foreach (var val in list) { array.Add((NSObject)val.ToNativeFieldValue()); } return(array); } case IDictionary dictionary: { var ndictionary = new NSMutableDictionary(); foreach (var key in dictionary.Keys) { ndictionary.Add(new NSString(key.ToString()), (NSObject)dictionary[key].ToNativeFieldValue()); } return(ndictionary); } case FieldValue firestoreFieldValue: return(firestoreFieldValue.ToNative()); case FieldPath fieldPath: return(fieldPath.ToNative()); default: { var type = fieldValue.GetType(); if (type.IsPrimitive) { throw new NotSupportedException($"{type.FullName} is not supported"); } var ndictionary = new NSMutableDictionary(); var properties = type.GetProperties(); foreach (var property in properties) { var(key, @object) = GetKeyAndObject(fieldValue, property); if (key != null) { var keyString = new NSString(key); if (ndictionary.ContainsKey(keyString)) { throw new ArgumentException($"An item with the same key has already been added. Key: {keyString}"); } ndictionary.Add(keyString, (NSObject)@object); } } return(ndictionary); } } }
static string JoinLower(this NSString str, string str2) { return((((string)str) + str2).ToLower()); }
public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) { SetNeedsLayout(); }
public static void RegisterDefaultSettings() { var path = Path.Combine(NSBundle.MainBundle.PathForResource(_settingsDir, _bundleName), _rootPlist); 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); } } } StandardUserDefaults.RegisterDefaults(registrationDictionary); Synchronize(); } }
public override void Draw(CGRect rect) { const int padright = 10; const int padtop = 10; float boxWidth = 60; CGSize ssize; nfloat fWidth = UIScreen.MainScreen.Bounds.Width; this.Frame = new CGRect(0, 0, fWidth, UIScreen.MainScreen.Bounds.Width); CGContext ctx = UIGraphics.GetCurrentContext(); const int offset = 5; nfloat bw = Bounds.Width - offset; int cols = (int)(bw / boxWidth); int rows = (int)(SpeedTestNames.Count() / cols); int height = 23; UIColor.Black.SetColor(); int counter = 0; int counterProg = 0; float x = offset, y = 0; for (int i = 0; i <= rows; i++) { y += height; counterProg = counter; for (int j = 0; j < cols; j++) { x = offset + j * boxWidth; if (counter < SpeedTestNames.Count()) { UIColor.White.SetFill(); ctx.SetLineWidth(1f); ctx.StrokeRect(new CGRect(x - 1, y, boxWidth, height)); UIColor.FromRGB(235, 231, 213).SetFill(); ctx.FillRect(new CGRect(x, y + 1, boxWidth - 2, height - 2)); UIColor.Black.SetFill(); NSString text = new NSString((SpeedTestSorted [counter] == null) ? "" : SpeedTestSorted [counter] + " MS"); text.DrawString(new CGPoint(x + offset, y + 2), boxWidth - offset - 2, font13b, UILineBreakMode.TailTruncation); counter++; } else { break; } } counter = counterProg; y += height; for (int j = 0; j < cols; j++) { x = offset + j * boxWidth; if (counter < SpeedTestNames.Count()) { UIColor.White.SetFill(); ctx.SetLineWidth(1f); ctx.StrokeRect(new CGRect(x - 1, y, boxWidth, height)); UIColor.FromRGB(207, 197, 161).SetFill(); ctx.FillRect(new CGRect(x, y + 1, boxWidth - 2, height - 2)); UIColor.Black.SetFill(); NSString text = new NSString(SpeedTestNames [counter]); text.DrawString(new CGPoint(x + offset, y + 2), boxWidth - offset, font13b, UILineBreakMode.TailTruncation); counter++; } else { break; } } } base.Draw(rect); }
public void LoadUrl(string url) { var encodedStringUrl = new NSString(url).CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8); LoadRequest(new NSUrlRequest(new NSUrl(encodedStringUrl))); }
public static string GetStringValue(this ICleverTapConfigValue This) { return(NSString.FromHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("stringValue")))); }
public void Compare_Null() { using (NSString s = new NSString("s")) { s.Compare(null); } }
static ValidationPopup() { ValidationColor = new UIColor(0.7f, 0, 0, 1); EmptyNSString = new NSString(string.Empty); }
public bool StopEnumerator(NSString tag, NSRange tokenRange, NSRange sentenceRange, ref bool stop) { words.Add(tag); stop = true; return(true); }
public PropertyPageRdpAdvancedPerformanceController(NSString nibNameOrNil, NSBundle nibBundleOrNil) : base("initWithNibName:bundle:", nibNameOrNil, nibBundleOrNil) { }
unsafe void Invoke(NSString arg1, NSError arg2) { invoker(blockPtr, arg1 == null ? IntPtr.Zero : arg1.Handle, arg2 == null ? IntPtr.Zero : arg2.Handle); }
public IncrementalTableViewSource(UITableView tableView, NSString cellIdentifier) : base(tableView, cellIdentifier) { }
void UpdatePosition(bool textOnly = false) { nfloat hudWidth = 100f; nfloat hudHeight = 100f; nfloat stringWidth = 0f; nfloat stringHeight = 0f; nfloat stringHeightBuffer = 20f; nfloat stringAndImageHeightBuffer = 80f; CGRect labelRect = new CGRect(); string @string = StringLabel.Text; // False if it's text-only bool imageUsed = (ImageView.Image != null) || (ImageView.Hidden); if (textOnly) { imageUsed = false; } if (imageUsed) { hudHeight = stringAndImageHeightBuffer + stringHeight; } else { hudHeight = (textOnly ? stringHeightBuffer : stringHeightBuffer + 40); } if (!string.IsNullOrEmpty(@string)) { int lineCount = Math.Min(10, @string.Split('\n').Length + 1); if (IsIOS7OrNewer) { var stringSize = new NSString(@string).GetBoundingRect(new CGSize(200, 30 * lineCount), NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes { Font = StringLabel.Font }, null); stringWidth = stringSize.Width; stringHeight = stringSize.Height; } else { var stringSize = new NSString(@string).StringSize(StringLabel.Font, new CGSize(200, 30 * lineCount)); stringWidth = stringSize.Width; stringHeight = stringSize.Height; } hudHeight += stringHeight; if (stringWidth > hudWidth) { hudWidth = (float)Math.Ceiling(stringWidth / 2) * 2; } float labelRectY = imageUsed ? 66 : 9; if (hudHeight > 100) { labelRect = new CGRect(12, labelRectY, hudWidth, stringHeight); hudWidth += 24; } else { hudWidth += 24; labelRect = new CGRect(0, labelRectY, hudWidth, stringHeight); } } // Adjust for Cancel Button var cancelRect = new CGRect(); string @cancelCaption = _cancelHud == null ? null : CancelHudButton.Title(UIControlState.Normal); if (!string.IsNullOrEmpty(@cancelCaption)) { const int gap = 20; if (IsIOS7OrNewer) { var stringSize = new NSString(@cancelCaption).GetBoundingRect(new CGSize(200, 300), NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes { Font = StringLabel.Font }, null); stringWidth = stringSize.Width; stringHeight = stringSize.Height; } else { var stringSize = new NSString(@cancelCaption).StringSize(StringLabel.Font, new CGSize(200, 300)); stringWidth = stringSize.Width; stringHeight = stringSize.Height; } if (stringWidth > hudWidth) { hudWidth = (float)Math.Ceiling(stringWidth / 2) * 2; } // Adjust for label nfloat cancelRectY = 0f; if (labelRect.Height > 0) { cancelRectY = labelRect.Y + labelRect.Height + (nfloat)gap; } else { if (string.IsNullOrEmpty(@string)) { cancelRectY = 76; } else { cancelRectY = (imageUsed ? 66 : 9); } } if (hudHeight > 100) { cancelRect = new CGRect(12, cancelRectY, hudWidth, stringHeight); labelRect = new CGRect(12, labelRect.Y, hudWidth, labelRect.Height); hudWidth += 24; } else { hudWidth += 24; cancelRect = new CGRect(0, cancelRectY, hudWidth, stringHeight); labelRect = new CGRect(0, labelRect.Y, hudWidth, labelRect.Height); } CancelHudButton.Frame = cancelRect; hudHeight += (cancelRect.Height + (string.IsNullOrEmpty(@string) ? 10 : gap)); } HudView.Bounds = new CGRect(0, 0, hudWidth, hudHeight); if (!string.IsNullOrEmpty(@string)) { ImageView.Center = new CGPoint(HudView.Bounds.Width / 2, 36); } else { ImageView.Center = new CGPoint(HudView.Bounds.Width / 2, HudView.Bounds.Height / 2); } StringLabel.Hidden = false; StringLabel.Frame = labelRect; if (!textOnly) { if (!string.IsNullOrEmpty(@string) || !string.IsNullOrEmpty(@cancelCaption)) { SpinnerView.Center = new CGPoint((float)Math.Ceiling(HudView.Bounds.Width / 2.0f) + 0.5f, 40.5f); if (_progress != -1) { BackgroundRingLayer.Position = RingLayer.Position = new CGPoint(HudView.Bounds.Width / 2, 36f); } } else { SpinnerView.Center = new CGPoint((float)Math.Ceiling(HudView.Bounds.Width / 2.0f) + 0.5f, (float)Math.Ceiling(HudView.Bounds.Height / 2.0f) + 0.5f); if (_progress != -1) { BackgroundRingLayer.Position = RingLayer.Position = new CGPoint(HudView.Bounds.Width / 2, HudView.Bounds.Height / 2.0f + 0.5f); } } } }
public static string SayHello() { return(NSString.FromHandle(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend(class_ptr, selSayHello))); }
public MyBeersTableViewCell(NSString cellId) : base(UITableViewCellStyle.Default, cellId) { }
/// <summary> /// Initializes a new instance of the <see cref="ReactiveTableViewSource{TSource}"/> class. /// </summary> /// <param name="tableView">The table view.</param> /// <param name="collection">The collection.</param> /// <param name="cellKey">The cell key.</param> /// <param name="sizeHint">The size hint.</param> /// <param name="initializeCellAction">The initialize cell action.</param> public ReactiveTableViewSource(UITableView tableView, INotifyCollectionChanged collection, NSString cellKey, float sizeHint, Action <UITableViewCell> initializeCellAction = null) : this(tableView) { Data = new[] { new TableSectionInformation <TSource, UITableViewCell>(collection, cellKey, sizeHint, initializeCellAction) }; }
static public bool MarkPortalOnline(string iface) { using (var nss = new NSString(iface)) { return(CNMarkPortalOnline(nss.Handle)); } }
public override void Draw(RectangleF rect) { var fontSize = BadgeView.fontSize; var text = new NSString(Text); var numberSize = text.StringSize(UIFont.BoldSystemFontOfSize(fontSize)); var radius = Radius; var bounds = new RectangleF(PointF.Empty, new SizeF(numberSize.Width + 12f, 18f)); UIColor color; if (Parent.SelectionStyle != UITableViewCellSelectionStyle.None && (Parent.Highlighted || Parent.Selected)) { color = HighlightColor; } else { color = Color; } bounds.X = (bounds.Width - numberSize.Width) / 2f + .5f; bounds.Y += 2f; CALayer badge = new CALayer(); badge.Frame = rect; var imageSize = badge.Frame.Size; // Render the image @x2 for retina people if (UIScreen.MainScreen.Scale == 2) { imageSize = new SizeF(imageSize.Width * 2, imageSize.Height * 2); badge.Frame = new RectangleF(badge.Frame.Location, new SizeF( badge.Frame.Width * 2, badge.Frame.Height * 2)); fontSize *= 2; bounds.X = ((bounds.Width * 2) - (numberSize.Width * 2)) / 2f + 1; bounds.Y += 3; bounds.Width *= 2; radius *= 2; } badge.BackgroundColor = color.CGColor; badge.CornerRadius = radius; UIGraphics.BeginImageContext(imageSize); var context = UIGraphics.GetCurrentContext(); context.SaveState(); badge.RenderInContext(context); context.RestoreState(); context.SetBlendMode(CGBlendMode.Clear); text.DrawString(bounds, UIFont.BoldSystemFontOfSize(fontSize), UILineBreakMode.Clip); context.SetBlendMode(CGBlendMode.Normal); var outputImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); outputImage.Draw(rect); if (Parent.SelectionStyle == UITableViewCellSelectionStyle.None && (Parent.Highlighted || Parent.Selected) && Shadow) { Layer.CornerRadius = radius; Layer.ShadowOffset = new SizeF(0f, 1f); Layer.ShadowRadius = 1f; Layer.ShadowOpacity = .8f; } else { Layer.CornerRadius = radius; Layer.ShadowOffset = SizeF.Empty; Layer.ShadowRadius = 0f; Layer.ShadowOpacity = 0f; } }
internal static AVMetadataObjectType ObjectToEnum(NSString obj) { if (obj == null) { return(AVMetadataObjectType.None); } else if (obj == AVMetadataObject.TypeFace) { return(AVMetadataObjectType.Face); } else if (obj == AVMetadataObject.TypeAztecCode) { return(AVMetadataObjectType.AztecCode); } else if (obj == AVMetadataObject.TypeCode128Code) { return(AVMetadataObjectType.Code128Code); } else if (obj == AVMetadataObject.TypeCode39Code) { return(AVMetadataObjectType.Code39Code); } else if (obj == AVMetadataObject.TypeCode39Mod43Code) { return(AVMetadataObjectType.Code39Mod43Code); } else if (obj == AVMetadataObject.TypeCode93Code) { return(AVMetadataObjectType.Code93Code); } else if (obj == AVMetadataObject.TypeEAN13Code) { return(AVMetadataObjectType.EAN13Code); } else if (obj == AVMetadataObject.TypeEAN8Code) { return(AVMetadataObjectType.EAN8Code); } else if (obj == AVMetadataObject.TypePDF417Code) { return(AVMetadataObjectType.PDF417Code); } else if (obj == AVMetadataObject.TypeQRCode) { return(AVMetadataObjectType.QRCode); } else if (obj == AVMetadataObject.TypeUPCECode) { return(AVMetadataObjectType.UPCECode); } else if (obj == AVMetadataObject.TypeInterleaved2of5Code) { return(AVMetadataObjectType.Interleaved2of5Code); } else if (obj == AVMetadataObject.TypeITF14Code) { return(AVMetadataObjectType.ITF14Code); } else if (obj == AVMetadataObject.TypeDataMatrixCode) { return(AVMetadataObjectType.DataMatrixCode); } else if (obj == AVMetadataObject.TypeCatBody) { return(AVMetadataObjectType.CatBody); } else if (obj == AVMetadataObject.TypeDogBody) { return(AVMetadataObjectType.DogBody); } else if (obj == AVMetadataObject.TypeHumanBody) { return(AVMetadataObjectType.HumanBody); } else if (obj == AVMetadataObject.TypeSalientObject) { return(AVMetadataObjectType.SalientObject); } else { throw new ArgumentOutOfRangeException(string.Format("Unexpected AVMetadataObjectType: {0}", obj)); } }
public static NSObject FocusedElement(string assistiveTechnologyIdentifier) { using (var s = new NSString(assistiveTechnologyIdentifier)) return(Runtime.GetNSObject(UIAccessibilityFocusedElement(s.Handle))); }
/// <inheritdoc /> public async void Show(NotificationRequest notificationRequest) { try { if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0) == false) { return; } if (notificationRequest is null) { return; } var allowed = await NotificationCenter.AskPermissionAsync().ConfigureAwait(false); if (allowed == false) { return; } var userInfoDictionary = new NSMutableDictionary(); if (string.IsNullOrWhiteSpace(notificationRequest.ReturningData) == false) { using var returningData = new NSString(notificationRequest.ReturningData); userInfoDictionary.SetValueForKey( string.IsNullOrWhiteSpace(notificationRequest.ReturningData) ? NSString.Empty : returningData, NotificationCenter.ExtraReturnDataIos); } using var content = new UNMutableNotificationContent { Title = notificationRequest.Title, Body = notificationRequest.Description, Badge = notificationRequest.BadgeNumber, UserInfo = userInfoDictionary, Sound = UNNotificationSound.Default }; if (string.IsNullOrWhiteSpace(notificationRequest.Sound) == false) { content.Sound = UNNotificationSound.GetSound(notificationRequest.Sound); } var repeats = notificationRequest.Repeats != NotificationRepeat.No; using var notifyTime = GetNsDateComponentsFromDateTime(notificationRequest); using var trigger = UNCalendarNotificationTrigger.CreateTrigger(notifyTime, repeats); var notificationId = notificationRequest.NotificationId.ToString(CultureInfo.CurrentCulture); var request = UNNotificationRequest.FromIdentifier(notificationId, content, trigger); await UNUserNotificationCenter.Current.AddNotificationRequestAsync(request) .ConfigureAwait(false); } catch (Exception ex) { Debug.WriteLine(ex); } }