public XamCore.CoreAnimation.CADisplayLink CreateDisplayLink(NSAction action) { if (action == null) throw new ArgumentNullException ("action"); var d = new NSActionDispatcher (action); return CreateDisplayLink (d, NSActionDispatcher.Selector); }
public ImageLoaderStringElement(string caption, NSAction tapped, NSUrl imageUrl, UIImage placeholder) : base(caption, tapped) { Placeholder = placeholder; ImageUrl = imageUrl; this.Accessory = UITableViewCellAccessory.None; }
public static void Transition(UIView fromView, UIView toView, double duration, UIViewAnimationOptions options, NSAction completion) { TransitionNotify (fromView, toView, duration, options, (x) => { if (completion != null) completion (); }); }
public FilterElement(IssuesFiltersViewModel.FilterModel filterModel, NSAction action, Action accessory) : base(filterModel.IssueModel.FilterName, action) { Accessory = UITableViewCellAccessory.DetailButton; AccessoryTapped += () => accessory(); FilterModel = filterModel; }
public static CADisplayLink Create (NSAction action) { var dispatcher = new NSActionDispatcher (action); var rv = Create (dispatcher, NSActionDispatcher.Selector); rv.dispatcher = dispatcher; return rv; }
public static void Invoke(NSAction action) { if (_app != null) { _app.InvokeOnMainThread(action); } }
public static NSSlider FromTarget(NSAction action) { var dispatcher = new NSActionDispatcher (action); var control = _FromTarget (dispatcher, NSActionDispatcher.Selector); control.dispatcher = dispatcher; return control; }
public static NSSlider FromValue(double value, double minValue, double maxValue, NSAction action) { var dispatcher = new NSActionDispatcher (action); var control = _FromValue (value, minValue, maxValue, dispatcher, NSActionDispatcher.Selector); control.dispatcher = dispatcher; return control; }
public void BeginSheet (NSWindow window, NSAction onEnded) { BeginSheetForResponse (window, r => { if (onEnded != null) onEnded (); }); }
public NSActionDispatcher(NSAction action) { if (action == null) throw new ArgumentNullException ("action"); this.action = action; }
public FlayoutNavigationItem(string caption, NSAction tapped, UIImage image, string controller) : base(caption, tapped, image) { Controller = controller; Image = image; Callback = tapped; }
public StyledElement(string caption, NSAction tapped, UIImage image) : base(caption, tapped) { Init(); Image = image; Accessory = UITableViewCellAccessory.DisclosureIndicator; }
public static void Animate(double duration, NSAction animation, NSAction completion) { // animation null check will be done in AnimateNotify AnimateNotify (duration, animation, (x) => { if (completion != null) completion (); }); }
public static void Animate(double duration, double delay, UIViewAnimationOptions options, NSAction animation, NSAction completion) { // animation null check will be done in AnimateNotify AnimateNotify (duration, delay, options, animation, (x) => { if (completion != null) completion (); }); }
public BikeElement(BikeLocation bike, NSAction action) : base("","",action) { Bike = bike; Caption = bike.Name; Value = GetValueString(); Accessory = UITableViewCellAccessory.DisclosureIndicator; }
public UIRaisedTabBar(UIImage normal, UIImage highlighted, NSAction tapped) : base() { normalState = normal; highlightedState = highlighted; if (tapped != null) Tapped += tapped; }
public Token AddTarget(NSAction action) { if (action == null) throw new ArgumentNullException ("action"); var t = new ParameterlessDispatch (action); RegisterTarget (t, Selector.GetHandle (tsel)); return t; }
public BadgeElement (UIImage badgeImage, string cellText, NSAction tapped) : base (cellText) { if (badgeImage == null) throw new ArgumentNullException ("badgeImage"); image = badgeImage; if (tapped != null) Tapped += tapped; }
public static NSThread Start(NSAction action) { if (action == null) { throw new ArgumentNullException ("action"); } var thread = new ActionThread (action); thread.Start (); return thread; }
public static void InvokeInBackground (NSAction action) { // using the parameterized Thread.Start to avoid capturing // the 'action' parameter (it'll needlessly create an extra // object). new System.Threading.Thread ((v) => { ((NSAction) v) (); }) { IsBackground = true, }.Start (action); }
public ButtonElement(string caption, NSAction tapped) : base(caption) { this.tapped = tapped; NormalColor = UIColor.Gray; NormalTextColor = UIColor.Black; HighlightedColor = UIColor.Blue; HighlightedTextColor = UIColor.White; DisabledColor = UIColor.Gray; DisabledTextColor = UIColor.DarkGray; }
public void AddAccount(DialogViewController dvc, NSAction action) { var oauth = new OAuthAuthorizer (TwitterAccount.OAuthConfig); if (useXauth) NewAccountXAuth (dvc, action); else { if (oauth.AcquireRequestToken ()){ oauth.AuthorizeUser (dvc, delegate { SetDefaultAccount (oauth); action (); }); } } }
public BadgeElement (UIImage badgeImage, string cellText, NSAction tapped) : base (cellText) { LineBreakMode = UILineBreakMode.TailTruncation; ContentMode = UIViewContentMode.Left; Lines = 1; Accessory = UITableViewCellAccessory.None; if (badgeImage == null) throw new ArgumentNullException ("badgeImage"); _image = badgeImage; if (tapped != null) Tapped += tapped; }
private RootElement GetRoot() { IList<Series> coll = AppManifest.Current.Collections; var root = new RootElement("Collections"); var section = new Section(); for(var i = 0; i < coll.Count; i++) { Series series = coll[i]; var rounded = ImageFactory.LoadRoundedThumbnail(series.Pieces[0]); var viewAction = new NSAction(() => { LoadSeries (series); }); var element = new StyledStringElement(series.Title, viewAction) { Image = rounded }; element.New = series.New.GetValueOrDefault(); section.Add(element); } root.Add(section); return root; }
private RootElement GetRoot() { IList<Piece> pieces = _parent.Series.Pieces; var root = new RootElement(""); _section = new Section(string.Concat(_parent.Series.Title, " (", _parent.Series.Years , ")")); for(var i = 0; i < pieces.Count; i++) { var page = i; var piece = pieces[page]; var viewAction = new NSAction(() => { GoToPage(page); }); var element = new StyledStringElement(piece.Title, viewAction); element.Activity = true; _section.Add(element); ThreadPool.QueueUserWorkItem(s => { var rounded = ImageFactory.LoadRoundedThumbnail(piece); InvokeOnMainThread(()=> { element.Image = rounded; element.Reload(); }); }); } // Set the default check box CheckPiece(0); root.Add(_section); View.SetNeedsDisplay(); return root; }
public StyledStringElement(string caption, NSAction tapped) : base(caption, tapped) { }
public Element(string caption, NSAction tapped) { this.Caption = caption; Tapped += tapped; }
public UITapGestureRecognizer(NSAction action) : base(action) { }
public override void HandleEventsForBackgroundUrl(UIApplication application, string sessionIdentifier, NSAction completionHandler) { Console.WriteLine("HandleEventsForBackgroundUrl"); BackgroundDownload.BackgroundSessionCompletionHandler = completionHandler; }
public Dispatcher(NSAction action) { this.action = action; }
public StyledStringElement(string caption, NSAction tapped) : base(caption, tapped) { style = UITableViewCellStyle.Value1; }
void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) { continue; } string caption = null; //string key = null; // l18n object [] attrs = mi.GetCustomAttributes(false); bool skip = false; bool localize = false; foreach (var attr in attrs) { if (attr is LocalizeAttribute) { localize = true; break; } } foreach (var attr in attrs) { if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute) { skip = true; } else if (attr is CaptionAttribute) { caption = ((CaptionAttribute)attr).Caption; if (localize) { caption = NSBundle.MainBundle.LocalizedString(caption, caption); } } else if (attr is SectionAttribute) { if (section != null) { root.Add(section); } var sa = attr as SectionAttribute; var header = sa.Caption; var footer = sa.Footer; if (localize) { header = NSBundle.MainBundle.LocalizedString(header, header); footer = NSBundle.MainBundle.LocalizedString(footer, footer); } section = new Section(header, footer); } } if (skip) { continue; } if (caption == null) { caption = MakeCaption(mi.Name); if (localize) { caption = NSBundle.MainBundle.LocalizedString(caption, caption); } } if (section == null) { section = new Section(); } Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; NSAction invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) { pa = attr as PasswordAttribute; } else if (attr is EntryAttribute) { ea = attr as EntryAttribute; } else if (attr is MultilineAttribute) { multi = true; } else if (attr is HtmlAttribute) { html = attr; } else if (attr is AlignmentAttribute) { align = attr as AlignmentAttribute; } if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) { throw new Exception("Did not find method " + mname); } invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object [0]); }; } } string value = (string)GetValue(mi, o); if (pa != null) { var placeholder = pa.Placeholder; if (localize) { placeholder = NSBundle.MainBundle.LocalizedString(placeholder, placeholder); } element = new EntryElement(caption, placeholder, value, true); } else if (ea != null) { var placeholder = ea.Placeholder; if (localize) { placeholder = NSBundle.MainBundle.LocalizedString(placeholder, placeholder); } element = new EntryElement(caption, placeholder, value) { KeyboardType = ea.KeyboardType, AutocapitalizationType = ea.AutocapitalizationType, AutocorrectionType = ea.AutocorrectionType, ClearButtonMode = ea.ClearButtonMode }; } else if (multi) { element = new MultilineElement(caption, value); } else if (html != null) { element = new HtmlElement(caption, value); } else { var selement = new StringElement(caption, value); element = selement; if (align != null) { selement.Alignment = align.Alignment; } } if (invoke != null) { ((StringElement)element).Tapped += invoke; } } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (float)GetValue(mi, o)); floatElement.Caption = caption; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) { checkbox = true; } } if (checkbox) { element = new CheckboxElement(caption, (bool)GetValue(mi, o)); } else { element = new BooleanElement(caption, (bool)GetValue(mi, o)); } } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) { asDate = true; } else if (attr is TimeAttribute) { asTime = true; } } if (asDate) { element = new DateElement(caption, dateTime); } else if (asTime) { element = new TimeElement(caption, dateTime); } else { element = new DateTimeElement(caption, dateTime); } } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) { selected = idx; } CaptionAttribute ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute; var cap = ca != null ? ca.Caption : MakeCaption(fi.Name); if (localize) { NSBundle.MainBundle.LocalizedString(cap, cap); } csection.Add(new RadioElement(cap)); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(UIImage)) { element = new ImageElement((UIImage)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) { throw new Exception("IEnumerable found, but no previous int found"); } foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } int selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) { selected = 0; } element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { foreach (object attr in attrs) { if (attr is RadioSelectionAttribute) { last_radio_index = mi; break; } } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) { continue; } section.Add(element); mappings [element] = new MemberAndInstance(mi, o); } root.Add(section); }
public UIRotationGestureRecognizer(NSAction action) : base(action) { }
public GameInstanceElement(NetworkBrowserModel.GameInstanceInfo gameInstanceInfo, NSAction tapped) : base(gameInstanceInfo.GameInstance.Name, tapped) { this.GameInstanceInfo = gameInstanceInfo; }
public void BeginSheet (string directory, string fileName, string []fileTypes, NSWindow modalForWindow, NSAction onEnded) { var obj = OneShotTracker.Create (onEnded); BeginSheet (directory, fileName, fileTypes, modalForWindow, obj, NSActionDispatcher.Selector, IntPtr.Zero); }
public UIPinchGestureRecognizer(NSAction action) : base(action) { }
public UIGestureRecognizer(NSAction action) : this(Selector.GetHandle(tsel), new ParameterlessDispatch(action)) { }
public static void SendMail(UIViewController parent, string to, string subject, MailAttachment attachment, string body, NSAction onDone) { if (MFMailComposeViewController.CanSendMail) { mailCompose = new MFMailComposeViewController(); mailCompose.SetSubject(subject); mailCompose.SetToRecipients(new string[] { to }); if (attachment != null) { NSData att = NSData.FromFile(attachment.Filename); mailCompose.AddAttachmentData(att, attachment.FileType, attachment.EmailFilename); } mailCompose.SetMessageBody(body, false); mailCompose.Finished += delegate(object sender, MFComposeResultEventArgs e) { mailCompose.DismissModalViewControllerAnimated(true); onDone(); }; parent.PresentModalViewController(mailCompose, true); } }
protected override Task <string> LoginAsyncOverride() { var tcs = new TaskCompletionSource <string>(); var auth = new WebRedirectAuthenticator(StartUri, EndUri); auth.ClearCookiesBeforeLogin = false; UIViewController c = auth.GetUI(); UIViewController controller = null; UIPopoverController popover = null; auth.Error += (o, e) => { NSAction completed = () => { Exception ex = e.Exception ?? new Exception(e.Message); tcs.TrySetException(ex); }; if (controller != null) { controller.DismissViewController(true, completed); } if (popover != null) { popover.Dismiss(true); completed(); } }; auth.Completed += (o, e) => { NSAction completed = () => { if (!e.IsAuthenticated) { tcs.TrySetException(new InvalidOperationException(Resources.IAuthenticationBroker_AuthenticationCanceled)); } else { tcs.TrySetResult(e.Account.Properties["token"]); } }; if (controller != null) { controller.DismissViewController(true, completed); } if (popover != null) { popover.Dismiss(true); completed(); } }; controller = view as UIViewController; if (controller != null) { controller.PresentViewController(c, true, null); } else { UIView v = view as UIView; UIBarButtonItem barButton = view as UIBarButtonItem; popover = new UIPopoverController(c); if (barButton != null) { popover.PresentFromBarButtonItem(barButton, UIPopoverArrowDirection.Any, true); } else { popover.PresentFromRect(rect, v, UIPopoverArrowDirection.Any, true); } } return(tcs.Task); }
public static Task <bool> AnimateAsync(double duration, NSAction animation) { return(AnimateNotifyAsync(duration, animation)); }
public void BeginSheet(string directory, string fileName, string [] fileTypes, NSWindow modalForWindow, NSAction onEnded) { var obj = OneShotTracker.Create(onEnded); BeginSheet(directory, fileName, fileTypes, modalForWindow, obj, NSActionDispatcher.Selector, IntPtr.Zero); }
public virtual void Invoke(NSAction action, TimeSpan delay) { var d = new NSAsyncActionDispatcher(action); d.PerformSelector(NSActionDispatcher.Selector, null, delay.TotalSeconds); }
public void BeginSheet(NSWindow sheet, NSWindow docWindow, NSAction onEnded) { var obj = OneShotTracker.Create(onEnded); BeginSheet(sheet, docWindow, obj, NSActionDispatcher.Selector, IntPtr.Zero); }
public virtual void Invoke(NSAction action, double delay) { var d = new NSAsyncActionDispatcher(action); d.PerformSelector(NSActionDispatcher.Selector, null, delay); }
void ShowMessage(string caption, string message, NSAction callback = null) { var alert = new UIAlertView(caption, message, null, "Ok"); if (callback != null) { alert.Dismissed += delegate { callback(); } } ; alert.Show(); } void SetupError(string msg) { ShowMessage("Setup Error", msg, () => { Environment.Exit(1); }); } // // This method merely validates that the basic components of a Facebook // app are complete, it should not be needed in a complete application, // but will help in the first stages of debugging your Facebook // interop // void ValidateSetup() { if (AppId == null) { SetupError("Missing AppId, You can not run the app until this is setup"); } // Validate the callback "fb[APPID]://authorize is in the Info.plist // which is what facebook uses to call us back bool urlFound = false; try { var arr = NSArray.FromArray <NSObject> (NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleURLTypes") as NSArray); if (arr != null && arr.Length > 0) { var dict = arr [0] as NSDictionary; arr = NSArray.FromArray <NSString> (dict [(NSString)"CFBundleURLSchemes"] as NSArray); if (arr != null && arr.Length > 0) { var fbvalue = arr [0].ToString(); if (fbvalue.StartsWith("fb" + AppId)) { urlFound = true; } } } else { SetupError("Missing fbXXXX URL handler in Info.plist's CFBundleURLTypes section"); } } catch { SetupError("Invalid contents of Info.plist file"); } if (!urlFound) { SetupError("Missing correct fbXXXX i the Info.plist's setup"); } // Check if the authorization callback will work if (!UIApplication.SharedApplication.CanOpenUrl(new NSUrl("fb" + AppId + "://authorize"))) { SetupError("Invalid or missing URL scheme. You cannot run the app until you set up a valid URL scheme in your .plist."); } }
public override void PresentViewController(UIViewController viewControllerToPresent, bool animated, NSAction completionHandler) { base.PresentViewController(viewControllerToPresent, animated, completionHandler); }
public CCTimer(NSAction target) : this(new NSActionDispatcher(target), NSActionDispatcher.Selector) { }
public UILongPressGestureRecognizer(NSAction action) : base(action) { }
public CCCallFunc(NSAction callback) : this(new NSActionDispatcher(callback), NSActionDispatcher.Selector) { }
public static void Transition(UIView withView, double duration, UIViewAnimationOptions options, NSAction animation, NSAction completion) { // animation null check will be done in AnimateNotify TransitionNotify(withView, duration, options, animation, (x) => { if (completion != null) { completion(); } }); }
public static void Transition(UIView fromView, UIView toView, double duration, UIViewAnimationOptions options, NSAction completion) { TransitionNotify(fromView, toView, duration, options, (x) => { if (completion != null) { completion(); } }); }
public static void Animate(double duration, double delay, UIViewAnimationOptions options, NSAction animation, NSAction completion) { // animation null check will be done in AnimateNotify AnimateNotify(duration, delay, options, animation, (x) => { if (completion != null) { completion(); } }); }
public UISwipeGestureRecognizer(NSAction action) : base(action) { }
protected ValueElement(string caption, NSAction tapped) : base(caption, tapped) { }
public void BeginSheet (NSPrintInfo printInfo, NSWindow docWindow, NSAction onEnded) { var obj = OneShotTracker.Create (onEnded); BeginSheet (printInfo, docWindow, obj, NSActionDispatcher.Selector, IntPtr.Zero); }
public UIScreenEdgePanGestureRecognizer(NSAction action) : base(action) { }
public CustomImageStringElement (string caption, NSAction tapped, UIImage image) : base (caption, tapped, image) { _image = image; }
internal ParameterlessDispatch(NSAction action) { this.action = action; }
public NSActionDispatcher(NSAction action) { this.action = action; }
public void TransitionOutCompletion(NSAction action) { switch (this.TransitionStyle) { case SIAlertViewTransitionStyle.SlideFromBottom: { RectangleF rect = this._ContainerView.Frame; var locationY = this.Bounds.Size.Height; rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height); UIView.Animate( duration: 0.3f, delay: 0f, options: UIViewAnimationOptions.CurveEaseIn, animation: () => { this._ContainerView.Frame = rect; }, completion: () => { if (action != null) { action.Invoke(); } }); } break; case SIAlertViewTransitionStyle.SlideFromTop: { RectangleF rect = this._ContainerView.Frame; var locationY = -rect.Size.Height; rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height); UIView.Animate( duration: 0.3f, delay: 0f, options: UIViewAnimationOptions.CurveEaseIn, animation: () => { this._ContainerView.Frame = rect; }, completion: () => { if (action != null) { action.Invoke(); } }); } break; case SIAlertViewTransitionStyle.Fade: { UIView.Animate( duration: 0.25f, delay: 0f, options: UIViewAnimationOptions.CurveEaseIn, animation: () => { this._ContainerView.Alpha = 0f; }, completion: () => { if (action != null) { action.Invoke(); } }); } break; //case SIAlertViewTransitionStyle,Bounce: //{ // CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; // animation.values = @[@(1), @(1.2), @(0.01)]; // animation.keyTimes = @[@(0), @(0.4), @(1)]; // animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; // animation.duration = 0.35; // animation.delegate = self; // [animation setValue:completion forKey:@"handler"]; // [self.containerView.layer addAnimation:animation forKey:@"bounce"]; // self.containerView.transform = CGAffineTransformMakeScale(0.01, 0.01); //} // break; case SIAlertViewTransitionStyle.DropDown: { PointF point = this._ContainerView.Center; PointF newPoint = new PointF(point.X, point.Y + this.Bounds.Size.Height); UIView.Animate( duration: 0.3f, delay: 0f, options: UIViewAnimationOptions.CurveEaseIn, animation: () => { this._ContainerView.Center = newPoint; float angle = GetRandomAngle(); this._ContainerView.Transform = CGAffineTransform.MakeRotation(angle); }, completion: () => { if (action != null) { action.Invoke(); } }); } break; default: break; } }