partial void startStopPing(Foundation.NSObject sender) { if (task != null) { task.Interrupt(); } else { task = new NSTask(); task.LaunchPath = "/sbin/ping"; string[] args = { "-c10", hostField.StringValue }; task.Arguments = args; // Create a new pipe pipe = new NSPipe(); task.StandardOutput = pipe; NSFileHandle fh = pipe.ReadHandle; NSNotificationCenter nc = NSNotificationCenter.DefaultCenter; nc.RemoveObserver(this); nc.AddObserver(this, new Selector("dataReady:"), NSFileHandle.ReadCompletionNotification, fh); nc.AddObserver(this, new Selector("taskTerminated:"), NSTask.NSTaskDidTerminateNotification, task); task.Launch(); outputView.Value = ""; // Suspect = Obj-C example is [fh readInBackgroundAndNotify] - no arguments fh.ReadInBackground(); } }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); // Get the device object device = UIDevice.CurrentDevice; // Tell it to start monitoring the accelerometer for orientation device.BeginGeneratingDeviceOrientationNotifications(); device.ProximityMonitoringEnabled = true; // Get the notification center for the app NSNotificationCenter nc = NSNotificationCenter.DefaultCenter; // Add this as an observer nc.AddObserver(this, new Selector("orientationChanged:"), null, device); nc.AddObserver(this, new Selector("proximity:"), null, device); // If you have defined a root view controller, set it here: hvc = new HeavyViewController(); hvc.View.BackgroundColor = UIColor.White; window.RootViewController = hvc; // make the window visible window.MakeKeyAndVisible(); return(true); }
public override void AwakeFromNib() { // initialise resigned state iSessionResigned = false; // load some images from the bundle NSImage largeIcon = new NSImage(NSBundle.MainBundle.PathForImageResource("IconLarge.png")); // create the app helper iHelper = new Helper(Environment.GetCommandLineArgs()); iHelper.ProcessOptionsFileAndCommandLine(); // add a crash log dumper CrashLogDumperWindowController d = new CrashLogDumperWindowController(largeIcon, iHelper.Title, iHelper.Product, iHelper.Version); d.LoadWindow(); iHelper.AddCrashLogDumper(d); // create auto update view and helper iHelperAutoUpdate = new HelperAutoUpdate(iHelper, new Linn.Toolkit.Mac.ViewAutoUpdateStandard(largeIcon), new Invoker(), (s, e) => {}); iHelperAutoUpdate.Start(); // create the main songcast model iModel = new Model(new Invoker(), iHelper); iModel.EventEnabledChanged += ModelEnabledChanged; // create the preferences 'view' for communicating with the system preferences app iViewPreferences = new ViewPreferences(new Invoker(), iModel, iHelperAutoUpdate); // creating the status item with a length of -2 is equivalent to the call // [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] iStatusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(-2); iStatusItem.HighlightMode = false; iStatusItem.Target = this; iStatusItem.Action = new Selector("statusItemClicked:"); // setup system event notifications NSNotificationCenter center = NSWorkspace.SharedWorkspace.NotificationCenter; center.AddObserver(this, new Selector("willSleep:"), new NSString("NSWorkspaceWillSleepNotification"), null); center.AddObserver(this, new Selector("didWake:"), new NSString("NSWorkspaceDidWakeNotification"), null); center.AddObserver(this, new Selector("sessionDidResignActive:"), new NSString("NSWorkspaceSessionDidResignActiveNotification"), null); center.AddObserver(this, new Selector("sessionDidBecomeActive:"), new NSString("NSWorkspaceSessionDidBecomeActiveNotification"), null); // create the main window iMainWindow = new MainWindowController(); iMainWindow.LoadWindow(); iMainWindow.Window.DidResignKey += MainWindowDidResignKey; iMainWindow.Window.CollectionBehavior = NSWindowCollectionBehavior.CanJoinAllSpaces; // create the xapp controller and view iXappController = new XappController(iModel, new Invoker()); iXappController.MainPage.EventShowConfig += ShowConfig; iXappController.MainPage.EventShowHelp += ShowHelp; iViewer = new ViewerBrowser(iMainWindow.WebView, iXappController.MainPageUri); }
void registerForUIApplicationNotifications() { NSNotificationCenter notificationCenter = NSNotificationCenter.DefaultCenter; notificationCenter.AddObserver(UIApplication.WillResignActiveNotification, handleResigningActive, UIApplication.SharedApplication); notificationCenter.AddObserver(UIApplication.DidBecomeActiveNotification, handleBecomingActive, UIApplication.SharedApplication); }
public void StartListener() { observerList.Add(center.AddObserver(new NSString("com.swinsian.Swinsian-Track-Playing"), async obj => { var dict = obj.UserInfo; await Task.Run(() => { var npdict = new Dictionary <string, string>(); npdict.Add(nameof(SongInfo.Title), dict["title"] as NSString); //Can't get this property npdict.Add(nameof(SongInfo.AlbumArtist), ""); npdict.Add(nameof(SongInfo.Album), dict["album"] as NSString); //Can't get this property npdict.Add(nameof(SongInfo.TrackCount), "0"); npdict.Add(nameof(SongInfo.Artist), dict["artist"] as NSString); npdict.Add(nameof(SongInfo.Composer), dict["composer"] as NSString); npdict.Add(nameof(SongInfo.Year), dict["year"] as NSString); npdict.Add(nameof(SongInfo.Group), dict["grouping"] as NSString); var apath = dict["thumbnailPath"] as NSString; npdict.Add(nameof(SongInfo.AlbumArtPath), Path.GetDirectoryName(apath) + "/cover_512.png"); var songinfo = new SongInfo(npdict); }); })); observerList.Add(center.AddObserver(new NSString("com.apple.iTunes.playerInfo"), async obj => { var dict = obj.UserInfo; await Task.Run(() => { var npdict = new Dictionary <string, string>(); npdict.Add(nameof(SongInfo.Title), dict["Name"] as NSString); npdict.Add(nameof(SongInfo.AlbumArtist), dict["Album Artist"] as NSString); npdict.Add(nameof(SongInfo.Album), dict["Album"] as NSString); npdict.Add(nameof(SongInfo.TrackCount), dict["Play Count"] as NSString); npdict.Add(nameof(SongInfo.Artist), dict["Artist"] as NSString); //Can't get those property npdict.Add(nameof(SongInfo.Composer), ""); npdict.Add(nameof(SongInfo.Year), ""); npdict.Add(nameof(SongInfo.Group), ""); //get album art var itunes = SBApplication.FromBundleIdentifier("com.apple.iTunes"); var ctrack = itunes.ValueForKey(new NSString("currentTrack")); var front_artwork = ctrack.ValueForKey(new NSString("artworks")) as SBElementArray; if (front_artwork.Count > 0) { var aitem = front_artwork.Get()[0]; var raw_image = aitem.ValueForKey(new NSString("rawData")) as NSData; npdict.Add(nameof(SongInfo.AlbumArtBase64), raw_image.GetBase64EncodedString(NSDataBase64EncodingOptions.None)); } var songinfo = new SongInfo(npdict); }); })); }
public AsReaderGUNManager() { mAsReaderGUN = new AsReaderGUN("com.asreader.gun"); mAsreaderDelegate = new MyAsreaderDelegate(this); NSNotificationCenter center = NSNotificationCenter.DefaultCenter; NSString connectedStr = new NSString("AsReaderGUNConnected"); NSString disconnectedStr = new NSString("AsReaderGUNDisconnected"); center.AddObserver(connectedStr, AsReaderGUNConnected); center.AddObserver(disconnectedStr, AsReaderGUNDisconnected); }
public VolumeWatcherHelper(VolumeWatcher vw) { outer = vw; OSXUtils.ApplicationHelper.ExecuteWhenLaunched(delegate { using (NSAutoreleasePool pool = new NSAutoreleasePool()) { NSNotificationCenter nc = NSWorkspace.SharedWorkspace.NotificationCenter; nc.AddObserver(this, new Selector("ev_VolumeDidMount:"), new NSString("NSWorkspaceDidMountNotification"), null); nc.AddObserver(this, new Selector("ev_VolumeDidUnmount:"), new NSString("NSWorkspaceDidUnmountNotification"), null); nc.AddObserver(this, new Selector("ev_VolumeWillUnmount:"), new NSString("NSWorkspaceWillUnmountNotification"), null); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); NSNotificationCenter notficationCenter = NSNotificationCenter.DefaultCenter; // Register for inbox notication notficationCenter.AddObserver(AccengageIOS.Constants.BMA4SInBoxDataChanged, inboxChanged); // Register for cell notification notficationCenter.AddObserver(new NSString("RefreshInbox"), inboxRefresh); // Set Title // Ex : Inbox (3) if (inbox != null) { if (inbox.UnreadMessageCount == 0) { Title = "Inbox"; } else { Title = "Inbox (" + inbox.UnreadMessageCount.ToString() + ")"; } } // Initialize the refresh controll refreshControl = new UIRefreshControl(); refreshControl.BackgroundColor = UIColor.FromWhiteAlpha(0, 0.1f); refreshControl.AddTarget((sender, e) => { reloadData(); }, UIControlEvent.ValueChanged); InBoxTableView.AddSubview(refreshControl); InvokeOnMainThread(delegate { refreshControl.BeginRefreshing(); refreshControl.EndRefreshing(); }); // Add Edit Button UIBarButtonItem rigthButton = new UIBarButtonItem("edit", UIBarButtonItemStyle.Plain, startEditing); if (NavigationItem != null) { NavigationItem.RightBarButtonItem = rigthButton; } InBoxTableView.Delegate = new InBoxTableViewDelegate(this); reloadData(); }
// Updated Xam.Mac doesn't have an initWithCoder constructor for NSDocument. // // Called when created directly from a XIB file // [Export("initWithCoder:")] // public MyDocument(NSCoder coder) : base(coder) // { // Initialize(); // } // Shared initialization code void Initialize() { NSNotificationCenter nc = NSNotificationCenter.DefaultCenter; nc.AddObserver(this, new Selector("handleColorChange:"), DefaultStrings.RMColorChangedNotification, null); Console.WriteLine("{0}: Registered with notification center", this); }
public static NSObject NotifyTerminated( this NSTask task, NSNotificationCenter notificationCenter, Action <NSTask> handler) { if (task == null) { throw new ArgumentNullException(nameof(task)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } NSObject observer = null; observer = notificationCenter.AddObserver( NSTask.NSTaskDidTerminateNotification, notification => { if (notification.Object == task) { notificationCenter.RemoveObserver(observer); handler(task); } }); return(observer); }
public override void ViewDidLoad() { base.ViewDidLoad(); SetUpTableView(); this.View.BackgroundColor = UIColor.FromRGB(245f, 245f, 245f); if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad) { NSNotificationCenter defaultCenter = NSNotificationCenter.DefaultCenter; defaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardNotification); defaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification); defaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification); } UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(); tapRecognizer.AddTarget(() => { if (_keyboardVisible) { DismissKeyboardAction(); } }); tapRecognizer.NumberOfTapsRequired = 1; tapRecognizer.NumberOfTouchesRequired = 1; EncapsulatingView.AddGestureRecognizer(tapRecognizer); SubmitButton.SetTitleColor(UIColor.Black, UIControlState.Application); SubmitButton.TouchUpInside += (sender, ev) => { MakePayment(); }; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { FormClose.TouchUpInside += (sender, ev) => { this.DismissViewController(true, null); }; } SubmitButton.Disable(); detailCell.ccTextOutlet.BecomeFirstResponder(); SecureWebView.SetupWebView(_paymentService, successCallback, failureCallback); }
protected void OnLoad(object sender, EventArgs e) { try { flagsChangedHandler = flagsChanged; windowWillUseFullScreenHandler = windowWillUseFullScreen; windowDidEnterFullScreenHandler = windowDidEnterFullScreen; windowDidExitFullScreenHandler = windowDidExitFullScreen; windowShouldZoomToFrameHandler = windowShouldZoomToFrame; const BindingFlags instance_member = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; var fieldImplementation = typeof(NativeWindow).GetField("implementation", instance_member); Debug.Assert(fieldImplementation != null, "Reflection is broken!"); var nativeWindow = fieldImplementation.GetValue(Implementation); Debug.Assert(nativeWindow != null, "Reflection is broken!"); var typeCocoaNativeWindow = nativeWindow.GetType(); Debug.Assert(typeCocoaNativeWindow.Name == "CocoaNativeWindow", "Reflection is broken!"); var fieldWindowClass = typeCocoaNativeWindow.GetField("windowClass", instance_member); Debug.Assert(fieldWindowClass != null, "Reflection is broken!"); var windowClassValue = fieldWindowClass.GetValue(nativeWindow); Debug.Assert(windowClassValue != null); var windowClass = (IntPtr)windowClassValue; // register new methods Class.RegisterMethod(windowClass, flagsChangedHandler, "flagsChanged:", "v@:@"); Class.RegisterMethod(windowClass, windowWillUseFullScreenHandler, "window:willUseFullScreenPresentationOptions:", "I@:@I"); Class.RegisterMethod(windowClass, windowDidEnterFullScreenHandler, "windowDidEnterFullScreen:", "v@:@"); Class.RegisterMethod(windowClass, windowDidExitFullScreenHandler, "windowDidExitFullScreen:", "v@:@"); // replace methods that currently break Class.RegisterMethod(windowClass, windowShouldZoomToFrameHandler, "windowShouldZoom:toFrame:", "b@:@{NSRect={NSPoint=ff}{NSSize=ff}}"); NSNotificationCenter.AddObserver(WindowInfo.Handle, Selector.Get("windowDidEnterFullScreen:"), NSNotificationCenter.WINDOW_DID_ENTER_FULL_SCREEN, IntPtr.Zero); NSNotificationCenter.AddObserver(WindowInfo.Handle, Selector.Get("windowDidExitFullScreen:"), NSNotificationCenter.WINDOW_DID_EXIT_FULL_SCREEN, IntPtr.Zero); var methodKeyDown = typeCocoaNativeWindow.GetMethod("OnKeyDown", instance_member); Debug.Assert(methodKeyDown != null, "Reflection is broken!"); actionKeyDown = (Action <osuTK.Input.Key, bool>)methodKeyDown.CreateDelegate(typeof(Action <osuTK.Input.Key, bool>), nativeWindow); var methodKeyUp = typeCocoaNativeWindow.GetMethod("OnKeyUp", instance_member); Debug.Assert(methodKeyUp != null, "Reflection is broken!"); actionKeyUp = (Action <osuTK.Input.Key>)methodKeyUp.CreateDelegate(typeof(Action <osuTK.Input.Key>), nativeWindow); var methodInvalidateCursorRects = typeCocoaNativeWindow.GetMethod("InvalidateCursorRects", instance_member); Debug.Assert(methodInvalidateCursorRects != null, "Reflection is broken!"); actionInvalidateCursorRects = (Action)methodInvalidateCursorRects.CreateDelegate(typeof(Action), nativeWindow); } catch { Logger.Log("Window initialisation couldn't complete, likely due to the SDL backend being enabled.", LoggingTarget.Runtime, LogLevel.Important); Logger.Log("Execution will continue but keyboard functionality may be limited.", LoggingTarget.Runtime, LogLevel.Important); } }
public override void ViewDidLoad() { base.ViewDidLoad(); NSNotificationCenter defaultCenter = new NSNotificationCenter(); defaultCenter.AddObserver(null, ContentSizeDidChangeNotification, this); //defaultCenter.PerformSelector(MonoTouch.ObjCRuntime.Selector, ContentSizeDidChangeNotification); }
public override void ViewDidLoad() { base.ViewDidLoad(); SetUpTableView(); this.View.BackgroundColor = UIColor.FromRGB(245f, 245f, 245f); if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad) { NSNotificationCenter defaultCenter = NSNotificationCenter.DefaultCenter; defaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardNotification); defaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification); defaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification); } UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(); tapRecognizer.AddTarget(() => { if (KeyboardVisible) { DismissKeyboardAction(); } }); tapRecognizer.NumberOfTapsRequired = 1; tapRecognizer.NumberOfTouchesRequired = 1; EncapsulatingView.AddGestureRecognizer(tapRecognizer); RegisterButton.SetTitleColor(UIColor.White, UIControlState.Application); RegisterButton.TouchUpInside += (sender, ev) => { PreAuthCard(); }; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { FormClose.TouchUpInside += (sender, ev) => { this.DismissViewController(true, null); }; } RegisterButton.Disable(); SWebView.ScrollView.MinimumZoomScale = 2.0f; SWebView.SetupWebView(_paymentService, successCallback, failureCallback); }
public override void ViewDidLoad() { base.ViewDidLoad(); var castButton = new UICastButton(new CGRect(0, 0, 24, 24)); NavigationItem.RightBarButtonItem = new UIBarButtonItem(castButton); NSNotificationCenter aNotificationCenter = NSNotificationCenter.DefaultCenter; aNotificationCenter.AddObserver(this, new ObjCRuntime.Selector("castDidChangeState:"), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance); //setup fairplay stuffs var fairPlayAuthProxy = new BCOVFPSBrightcoveAuthProxy(null, null); var fps = sDKManager.CreateFairPlaySessionProviderWithAuthorizationProxy(fairPlayAuthProxy, null); //Create the playback controller playbackController = sDKManager.CreateFairPlayPlaybackControllerWithAuthorizationProxy(fairPlayAuthProxy); playbackController.SetAutoPlay(true); playbackController.SetAutoAdvance(false); playbackController.Delegate = new BCPlaybackControllerDelegate(); //USING CUSTOM GoogleCastManager GoogleCastManager googleCastManager = new GoogleCastManager(); googleCastManager.gcmDelegate = new XamGoogleCastManagerDelegate(playbackController); var gcmPlaybackSession = new XamBCPlaybackSessionConsumer(googleCastManager); playbackController.AddSessionConsumer(gcmPlaybackSession); // Set up our player view. Create with a standard VOD layout. var options = new BCOVPUIPlayerViewOptions() { ShowPictureInPictureButton = true }; var playerView = new BCOVPUIPlayerView(playbackController, options, BCOVPUIBasicControlView.BasicControlViewWithVODLayout()); playerView.Delegate = new BCUIPlaybackViewController(); playbackService.FindVideoWithVideoID(videoID: videoId, parameters: new NSDictionary(), completionHandler: (arg0, arg1, arg2) => { if (arg0 != null) { playbackController.SetVideos(NSArray.FromObjects(arg0)); } else { Debug.WriteLine($"View Controller Debug - Error retrieving video : {arg2.LocalizedDescription} "); } }); playerView.PlaybackController = playbackController; playerView.Frame = new CGRect(0, 100, 375, 207.5); playerView.ControlsView.ProgressSlider.MinimumTrackTintColor = UIColor.Green; View.AddSubview(playerView); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); NSNotificationCenter notification = NSNotificationCenter.DefaultCenter; //notification.AddObserver(this, new Selector("newMessageHandler"), // (NSString) "newMessageNotification",null); this.UreadCount.Text = "Unread count : " + ALChatManager.GetUreadCount(); notification.AddObserver((NSString)"newMessageNotification", NewMessageHandler); }
void StartMetadataQuery() { if (documentMetadataQuery == null) { NSMetadataQuery metadataQuery = new NSMetadataQuery { SearchScopes = new NSObject[] { NSMetadataQuery.UbiquitousDocumentsScope }, Predicate = NSPredicate.FromFormat("(%K.pathExtension = %@)", NSMetadataQuery.ItemFSNameKey, (NSString)AppConfig.ListerFileExtension) }; documentMetadataQuery = metadataQuery; NSNotificationCenter notificationCenter = NSNotificationCenter.DefaultCenter; // TODO: use typed overload https://trello.com/c/1RyX6cJL finishGatheringToken = notificationCenter.AddObserver(NSMetadataQuery.DidFinishGatheringNotification, HandleMetadataQueryUpdates, metadataQuery); updateToken = notificationCenter.AddObserver(NSMetadataQuery.DidUpdateNotification, HandleMetadataQueryUpdates, metadataQuery); } documentMetadataQuery.StartQuery(); }
public static void Initialize() { CodeBrixViewModelBase.DeviceViewOrientationChecker = () => { lock (orientationLocker) { _lastOrientation = UIDevice.CurrentDevice.Orientation; switch (_lastOrientation) { case UIDeviceOrientation.Portrait: return(DeviceViewOrientation.PortraitNormal); //break; case UIDeviceOrientation.PortraitUpsideDown: return(DeviceViewOrientation.PortraitUpsideDown); //break; case UIDeviceOrientation.LandscapeLeft: return(DeviceViewOrientation.LandscapeLeft); //break; case UIDeviceOrientation.LandscapeRight: return(DeviceViewOrientation.LandscapeRight); //break; case UIDeviceOrientation.Unknown: case UIDeviceOrientation.FaceUp: case UIDeviceOrientation.FaceDown: default: break; //Going to return Unknown for all of these } return(DeviceViewOrientation.Unknown); } }; _notificationCenter = NSNotificationCenter.DefaultCenter; _notificationCenter.AddObserver(UIApplication.DidChangeStatusBarOrientationNotification, DeviceOrientationDidChange); UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications(); CodeBrixViewModelBase.OnOrientationChange(CodeBrixViewModelBase.DeviceViewOrientationChecker.Invoke()); SubscribeToPageScreenSizeNotifications(); _initialized = true; }
public override void ViewDidLoad() { base.ViewDidLoad(); _notificationCenter.AddObserver(this, new Selector("photoImageUpdatedWithNotification:"), new NSString(PhotoViewControllerPhotoImageUpdatedNotification), null); ScalingImageView.Frame = View.Bounds; View.AddSubview(ScalingImageView); if (LoadingView != null) { View.AddSubview(LoadingView); LoadingView.SizeToFit(); } View.AddGestureRecognizer(DoubleTapGestureRecognizer); View.AddGestureRecognizer(_longPressGestureRecognizer); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); NSNotificationCenter notification = NSNotificationCenter.DefaultCenter; //notification.AddObserver(this, new Selector("newMessageHandler"), // (NSString) "newMessageNotification",null); this.UreadCount.Text = "Unread count : " + ALChatManager.GetUreadCount(); notification.AddObserver((NSString)"newMessageNotification", NewMessageHandler); if (this.NavigationController != null) { this.NavigationItem.SetLeftBarButtonItem( new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) => { this.DismissViewController(true, () => { }); }) , false); } }
void StartQuery() { if (documentMetadataQuery == null) { documentMetadataQuery = new NSMetadataQuery(); documentMetadataQuery.SearchScopes = new NSObject[] { NSMetadataQuery.UbiquitousDocumentsScope }; string todayListName = AppConfig.SharedAppConfiguration.TodayDocumentNameAndExtension; documentMetadataQuery.Predicate = NSPredicate.FromFormat("(%K = %@)", NSMetadataQuery.ItemFSNameKey, (NSString)todayListName); NSNotificationCenter notificationCenter = NSNotificationCenter.DefaultCenter; // TODO: subscribtion https://trello.com/c/1RyX6cJL finishGatheringToken = notificationCenter.AddObserver(NSMetadataQuery.DidFinishGatheringNotification, HandleMetadataQueryUpdates, documentMetadataQuery); } documentMetadataQuery.StartQuery(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. UIImage image = UIImage.FromBundle("tvBgImage.png"); TableView.BackgroundView = new UIImageView(image); BNRItemStore.loadItemsFromDatabase(); NSNotificationCenter nc = NSNotificationCenter.DefaultCenter; nc.AddObserver(this, new Selector("clearImageCache:"), UIApplication.DidReceiveMemoryWarningNotification, null); // HomepwnerItemCell UINib nib = UINib.FromName("HomepwnerItemCell", null); // Register this NIB which contains the cell TableView.RegisterNibForCellReuse(nib, "HomepwnerItemCell"); //TableView.SeparatorInset = new UIEdgeInsets(0, 0, 0, 0); }
protected void OnLoad(object sender, EventArgs e) { try { flagsChangedHandler = flagsChanged; windowWillUseFullScreenHandler = windowWillUseFullScreen; windowDidEnterFullScreenHandler = windowDidEnterFullScreen; windowDidExitFullScreenHandler = windowDidExitFullScreen; windowShouldZoomToFrameHandler = windowShouldZoomToFrame; var fieldImplementation = typeof(NativeWindow).GetRuntimeFields().Single(x => x.Name == "implementation"); var typeCocoaNativeWindow = typeof(NativeWindow).Assembly.GetTypes().Single(x => x.Name == "CocoaNativeWindow"); var fieldWindowClass = typeCocoaNativeWindow.GetRuntimeFields().Single(x => x.Name == "windowClass"); nativeWindow = fieldImplementation.GetValue(Implementation); var windowClass = (IntPtr)fieldWindowClass.GetValue(nativeWindow); // register new methods Class.RegisterMethod(windowClass, flagsChangedHandler, "flagsChanged:", "v@:@"); Class.RegisterMethod(windowClass, windowWillUseFullScreenHandler, "window:willUseFullScreenPresentationOptions:", "I@:@I"); Class.RegisterMethod(windowClass, windowDidEnterFullScreenHandler, "windowDidEnterFullScreen:", "v@:@"); Class.RegisterMethod(windowClass, windowDidExitFullScreenHandler, "windowDidExitFullScreen:", "v@:@"); // replace methods that currently break Class.RegisterMethod(windowClass, windowShouldZoomToFrameHandler, "windowShouldZoom:toFrame:", "b@:@{NSRect={NSPoint=ff}{NSSize=ff}}"); NSNotificationCenter.AddObserver(WindowInfo.Handle, Selector.Get("windowDidEnterFullScreen:"), NSNotificationCenter.WINDOW_DID_ENTER_FULL_SCREEN, IntPtr.Zero); NSNotificationCenter.AddObserver(WindowInfo.Handle, Selector.Get("windowDidExitFullScreen:"), NSNotificationCenter.WINDOW_DID_EXIT_FULL_SCREEN, IntPtr.Zero); methodKeyDown = nativeWindow.GetType().GetRuntimeMethods().Single(x => x.Name == "OnKeyDown"); methodKeyUp = nativeWindow.GetType().GetRuntimeMethods().Single(x => x.Name == "OnKeyUp"); methodInvalidateCursorRects = nativeWindow.GetType().GetRuntimeMethods().Single(x => x.Name == "InvalidateCursorRects"); } catch { Logger.Log("Window initialisation couldn't complete, likely due to the SDL backend being enabled.", LoggingTarget.Runtime, LogLevel.Important); Logger.Log("Execution will continue but keyboard functionality may be limited.", LoggingTarget.Runtime, LogLevel.Important); } }
public override void ViewDidLoad() { base.ViewDidLoad(); //Google Cast button var castButton = new UICastButton(new CGRect(0, 0, 24, 24)); NavigationItem.RightBarButtonItem = new UIBarButtonItem(castButton); //NSNotificationCenter.DefaultCenter.AddObserver(this, castDidChangeState(), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance); sessionManager = CastContext.SharedInstance.SessionManager; CastContext.SharedInstance.SessionManager.AddListener(this); NSNotificationCenter aNotificationCenter = NSNotificationCenter.DefaultCenter; aNotificationCenter.AddObserver(this, new ObjCRuntime.Selector("castDidChangeState:"), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance); videoController = new UIView(); videoController.BackgroundColor = UIColor.Red; videoController.Frame = new CGRect(0, 100, 375, 207.5); //table = new UITableView(); // defaults to Plain style //table.Frame = new CGRect(0, 335, View.Frame.Width, View.Frame.Height - 215); //string[] tableItems = new string[] { "Basic Video", "DRM Video" }; //table.Source = new TableSource(tableItems, this); //playbackController Setup playbackController = sDKManager.CreatePlaybackController(); playbackController.SetAutoPlay(true); playbackController.SetAutoAdvance(true); playbackController.Delegate = new BCPlaybackControllerDelegate(); BCOVGoogleCastManager googleCastManager = new BCOVGoogleCastManager(); googleCastManager.Delegate = new BCGoogleCastManagerDelegate(playbackController); playbackController.AddSessionConsumer(googleCastManager); //playerView Setup var options = new BCOVPUIPlayerViewOptions() { PresentingViewController = this }; var playerView = new BCOVPUIPlayerView(playbackController, options, BCOVPUIBasicControlView.BasicControlViewWithVODLayout()); playerView.Frame = new CGRect(0, 0, 375, 207.5); playbackService.FindVideoWithVideoID(videoID: videoId, parameters: new NSDictionary(), completionHandler: (arg0, arg1, arg2) => { if (arg0 != null) { playbackController.SetVideos(NSArray.FromObjects(arg0)); } else { Debug.WriteLine($"View Controller Debug - Error retrieving video : {arg2.LocalizedDescription} "); } }); playerView.PlaybackController = playbackController; videoController.AddSubview(playerView); View.AddSubview(videoController); //View.AddSubview(table); }
public override void ViewDidLoad() { base.ViewDidLoad(); TableView.SeparatorColor = UIColor.Clear; if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Pad) { NSNotificationCenter defaultCenter = NSNotificationCenter.DefaultCenter; defaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardNotification); defaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification); } if (String.IsNullOrEmpty(tokenPayment.Token)) { DispatchQueue.MainQueue.DispatchAfter(DispatchTime.Now, () => { UIAlertView _error = new UIAlertView("Missing Token", "No Card Token found. Please provide application with token via Pre-Authentication or Payment", null, "ok", null); _error.Show(); _error.Clicked += (sender, args) => { PaymentButton.Disable(); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { this.DismissViewController(true, null); } else { this.NavigationController.PopViewController(true); } }; }); } else { SetUpTableView(); UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(); tapRecognizer.AddTarget(() => { if (KeyboardVisible) { DismissKeyboardAction(); } }); tapRecognizer.NumberOfTapsRequired = 1; tapRecognizer.NumberOfTouchesRequired = 1; EncapsulatingView.AddGestureRecognizer(tapRecognizer); PaymentButton.Disable(); PaymentButton.SetTitleColor(UIColor.Black, UIControlState.Application); PaymentButton.TouchUpInside += (sender, ev) => { MakeTokenPayment(); }; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { FormClose.TouchUpInside += (sender, ev) => { this.DismissViewController(true, null); }; } } }
private void SetupButtons(){ this.center = NSNotificationCenter.DefaultCenter; center.AddObserver( UIKeyboard.WillHideNotification, (notify) => { try{ var keyboardBounds = (NSValue)notify.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey); var keyboardSize = keyboardBounds.RectangleFValue; if((nameInput.Text != this.appDelegate.contactListView.name) || (emailInput.Text != this.appDelegate.contactListView.email) || (mobileInput.Text != this.appDelegate.contactListView.mobile)){ SetEditing(false,false); UpdateContact(); } }catch(Exception ex){ Console.Write(ex.Message); } } ); this.killKeyboardButton.AllTouchEvents += (sender, e) => { DismissKeyboard(); }; this.emailInput.EditingDidEnd += (sender, e) => { ResignFirstResponder(); DismissKeyboard(); }; this.inviteButton.TouchUpInside += (sender, e) => { ShowInviteOptions(); }; this.nameInput.Ended += (sender, e) => { // if((nameInput.Text != this.appDelegate.contactListView.name) || // (emailInput.Text != this.appDelegate.contactListView.email) || // (mobileInput.Text != this.appDelegate.contactListView.mobile)){ // SetEditing(false,false); // UpdateContact(); // } }; this.processingCancelButton.TouchUpInside += (sender, e) => { this.processingView.Hidden = true; }; }
public override void ViewDidLoad() { this.appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; NavigationItem.SetRightBarButtonItem(lockButton, false); this.center = NSNotificationCenter.DefaultCenter; EndEditing(); SetupButtons(); InitExpandableTextView(); AddExpandableAccessoryView(); SetExpandableTextViewSize(); var g = new UITapGestureRecognizer(() => View.EndEditing(true)); View.AddGestureRecognizer(g); center.AddObserver( UIKeyboard.WillHideNotification, (notify) => { try { isKeyboardVisible = false; var keyboardBounds = (NSValue)notify.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey); var keyboardSize = keyboardBounds.RectangleFValue; this.keyboardHeight = keyboardSize.Height; SetTableSize(); AnimateToolbar(); } catch (Exception ex) { Console.Write(ex.Message); } } ); center.AddObserver( UIKeyboard.WillShowNotification, (notify) => { try { this.toolbarFakeMessage.Hidden = true; this.accessoryTextView.BecomeFirstResponder(); isKeyboardVisible = true; var keyboardBounds = (NSValue)notify.UserInfo.ObjectForKey(UIKeyboard.BoundsUserInfoKey); var keyboardSize = keyboardBounds.RectangleFValue; this.keyboardHeight = keyboardSize.Height; CheckEmptyTextView(); SetTableSize(); this.accessoryTextView.BecomeFirstResponder(); } catch (Exception ex) { Console.Write(ex.Message); } } ); }
public override void ViewDidLoad(){ base.ViewDidLoad (); NSNotificationCenter defaultCenter = new NSNotificationCenter (); defaultCenter.AddObserver (null, ContentSizeDidChangeNotification, this); //defaultCenter.PerformSelector(MonoTouch.ObjCRuntime.Selector, ContentSizeDidChangeNotification); }
/// <summary> /// Notificationses the specified notification key. /// </summary> /// <param name="notificationCenter">The notification center.</param> /// <param name="notificationKey">The notification key.</param> /// <returns>An observable sequence of NSNotifications.</returns> public static IObservable <NSNotification> Notifications(this NSNotificationCenter notificationCenter, NSString notificationKey) => Observable.Create <NSNotification>(obs => { var nsObserver = notificationCenter.AddObserver(notificationKey, obs.OnNext); return(Disposable.Create(() => notificationCenter.RemoveObserver(nsObserver))); });