本文整理汇总了C#中NSNotification类的典型用法代码示例。如果您正苦于以下问题:C# NSNotification类的具体用法?C# NSNotification怎么用?C# NSNotification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSNotification类属于命名空间,在下文中一共展示了NSNotification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemDidExpand
public override void ItemDidExpand (NSNotification notification)
{
TreeDataNode node = notification.UserInfo ["NSObject"] as TreeDataNode;
if (node != null) {
Console.WriteLine("Finished Expanding: " + node.Data.NodeDisplay);
}
}
示例2: ShowDetailTargetDidChange
public void ShowDetailTargetDidChange (NSNotification notification)
{
foreach (var cell in TableView.VisibleCells) {
NSIndexPath indexPath = TableView.IndexPathForCell (cell);
WillDisplay (TableView, cell, indexPath);
}
}
示例3: DeviceOrientationDidChange
/// <summary>
/// Devices the orientation did change.
/// </summary>
/// <param name="notification">Notification.</param>
public static void DeviceOrientationDidChange (NSNotification notification)
{
var orientation = UIDevice.CurrentDevice.Orientation;
bool isPortrait = orientation == UIDeviceOrientation.Portrait
|| orientation == UIDeviceOrientation.PortraitUpsideDown;
SendOrientationMessage(isPortrait);
}
示例4: DidFinishLaunching
public override void DidFinishLaunching(NSNotification notification)
{
suupdater.AutomaticallyChecksForUpdates = true;
suupdater.CheckForUpdatesInBackground ();
NewHandler (this);
}
示例5: KeyboardWillShow
void KeyboardWillShow (NSNotification notification)
{
var nsValue = notification.UserInfo.ObjectForKey (UIKeyboard.BoundsUserInfoKey) as NSValue;
if (nsValue == null) return;
var kbdBounds = nsValue.RectangleFValue;
Scroll.Frame = ComputeComposerSize (kbdBounds);
}
示例6: DataReloaded
void DataReloaded (NSNotification notification)
{
doc = (MonkeyDocument)notification.Object;
alertText.Text = string.Format ("{0} dataReloaded: notification", DateTime.Now.ToString ("H:mm:ss"));
// we just overwrite whatever was being typed, no conflict resolution for now
docText.Text = doc.DocumentString;
}
示例7: queryNotification
public void queryNotification (NSNotification note)
{
// the NSMetadataQuery will send back a note when updates are happening. By looking at the [note name], we can tell what is happening
// the query has just started
if (note.Name == NSMetadataQuery.DidStartGatheringNotification) {
Console.WriteLine ("search: started gathering");
progressSearch.Hidden = false;
progressSearch.StartAnimation (this);
progressSearchLabel.StringValue = "Searching....";
}
// at this point, the query will be done. You may recieve an update later on.
if (note.Name == NSMetadataQuery.DidFinishGatheringNotification) {
Console.WriteLine ("search: finished gathering");
progressSearch.Hidden = true;
progressSearch.StopAnimation (this);
loadResultsFromQuery (note);
}
// the query is still gathering results...
if (note.Name == NSMetadataQuery.GatheringProgressNotification){
Console.WriteLine ("search: progressing....");
progressSearch.StartAnimation (this);
}
// an update will happen when Spotlight notices that a file as added, removed, or modified that affected the search results.
if (note.Name == NSMetadataQuery.DidUpdateNotification)
Console.WriteLine ("search: an updated happened.");
}
示例8: DidFinishLaunching
public override void DidFinishLaunching(NSNotification notification)
{
// Start the progress indicator animation.
loadingProgressIndicator.StartAnimation (this);
gameLogo.Image = new NSImage (NSBundle.MainBundle.PathForResource ("logo", "png"));
archerButton.Image = new NSImage (NSBundle.MainBundle.PathForResource ("button_archer", "png"));
warriorButton.Image = new NSImage (NSBundle.MainBundle.PathForResource ("button_warrior", "png"));
// The size for the primary scene - 1024x768 is good for OS X and iOS.
var size = new CGSize (1024, 768);
// Load the shared assets of the scene before we initialize and load it.
scene = new AdventureScene (size);
scene.LoadSceneAssetsWithCompletionHandler (() => {
scene.Initialize ();
scene.ScaleMode = SKSceneScaleMode.AspectFill;
SKView.PresentScene (scene);
loadingProgressIndicator.StopAnimation (this);
loadingProgressIndicator.Hidden = true;
NSAnimationContext.CurrentContext.Duration = 2.0f;
((NSButton)archerButton.Animator).AlphaValue = 1.0f;
((NSButton)warriorButton.Animator).AlphaValue = 1.0f;
scene.ConfigureGameControllers();
});
SKView.ShowsFPS = true;
SKView.ShowsDrawCount = true;
SKView.ShowsNodeCount = true;
}
示例9: SelectionDidChange
public override void SelectionDidChange (NSNotification notification)
{
Console.WriteLine (notification);
var table = notification.Object as NSTableView;
var row = table.SelectedRow;
// Anything to process
if (row < 0)
return;
// Get current values from the data source
var name = table.DataSource.GetObjectValue (table, new NSTableColumn("name"), row) + "";
var id = table.DataSource.GetObjectValue (table, new NSTableColumn("id"), row) + "";
// Confirm deletion of a todo item
var alert = new NSAlert () {
AlertStyle = NSAlertStyle.Critical,
InformativeText = "Do you want to delete row " + name + "?",
MessageText = "Delete Todo",
};
alert.AddButton ("Cancel");
alert.AddButton ("Delete");
alert.BeginSheetForResponse (windowController.Window, async (result) => {
Console.WriteLine ("Alert Result: {0}", result);
if (result == 1001) {
await windowController.Delete(id);
}
table.DeselectAll(this);
});
}
示例10: DidFinishLaunching
public override void DidFinishLaunching (NSNotification notification)
{
// Create a Status Bar Menu
NSStatusBar statusBar = NSStatusBar.SystemStatusBar;
var item = statusBar.CreateStatusItem (NSStatusItemLength.Variable);
item.Title = "Text";
item.HighlightMode = true;
item.Menu = new NSMenu ("Text");
var address = new NSMenuItem ("Address");
address.Activated += (sender, e) => {
phrasesAddress(address);
};
item.Menu.AddItem (address);
var date = new NSMenuItem ("Date");
date.Activated += (sender, e) => {
phrasesDate(date);
};
item.Menu.AddItem (date);
var greeting = new NSMenuItem ("Greeting");
greeting.Activated += (sender, e) => {
phrasesGreeting(greeting);
};
item.Menu.AddItem (greeting);
var signature = new NSMenuItem ("Signature");
signature.Activated += (sender, e) => {
phrasesSignature(signature);
};
item.Menu.AddItem (signature);
}
示例11: OnWillRotate
protected void OnWillRotate(NSNotification notification)
{
if (!this.IsViewLoaded) return;
if (notification == null) return;
var o1 = notification.UserInfo.ValueForKey(new NSString("UIApplicationStatusBarOrientationUserInfoKey"));
int o2 = Convert.ToInt32(o1.ToString());
UIInterfaceOrientation toOrientation = (UIInterfaceOrientation)o2;
var notModal = !(this.TabBarController.ModalViewController == null);
var isSelectedTab = (this.TabBarController.SelectedViewController == this);
//ConsoleD.WriteLine ("toOrientation:"+toOrientation);
//ConsoleD.WriteLine ("isSelectedTab:"+isSelectedTab);
var duration = UIApplication.SharedApplication.StatusBarOrientationAnimationDuration;
if (!isSelectedTab || !notModal)
{
base.WillRotate(toOrientation, duration);
UIViewController master = this.ViewControllers[0];
var theDelegate = this.Delegate;
//YOU_DONT_FEEL_QUEAZY_ABOUT_THIS_BECAUSE_IT_PASSES_THE_APP_STORE
UIBarButtonItem button = base.ValueForKey(new NSString("_barButtonItem")) as UIBarButtonItem;
if (toOrientation == UIInterfaceOrientation.Portrait
|| toOrientation == UIInterfaceOrientation.PortraitUpsideDown)
{
if (theDelegate != null && theDelegate.RespondsToSelector(new Selector("splitViewController:willHideViewController:withBarButtonItem:forPopoverController:")))
{
try
{
UIPopoverController popover = base.ValueForKey(new NSString("_hiddenPopoverController")) as UIPopoverController;
theDelegate.WillHideViewController(this, master, button, popover);
}
catch (Exception e)
{
Console.WriteLine("There was a nasty error while notifyng splitviewcontrollers of a portrait orientation change: " + e.Message);
}
}
}
else
{
if (theDelegate != null && theDelegate.RespondsToSelector(new Selector("splitViewController:willShowViewController:invalidatingBarButtonItem:")))
{
try
{
theDelegate.WillShowViewController(this, master, button);
}
catch (Exception e)
{
Console.WriteLine("There was a nasty error while notifyng splitviewcontrollers of a landscape orientation change: " + e.Message);
}
}
}
}
}
示例12: docStateChanged
public void docStateChanged(NSNotification notification)
{
DocChange change = notification.object_().To<DocChange>();
m_document = change.Document;
m_exponent.setEnabled(!NSObject.IsNullOrNil(m_document));
if (!NSObject.IsNullOrNil(m_document))
{
if ((change.Type & ChangeType.Palette) == ChangeType.Palette)
{
window().setTitle(NSString.Create(m_document.Palette.Name));
}
if ((change.Type & ChangeType.PaletteExponent) == ChangeType.PaletteExponent)
{
m_exponent.setFloatValue(m_document.PaletteExponent);
}
}
else
{
m_exponent.setFloatValue(0.0f);
window().setTitle(NSString.Create("Palette"));
}
}
示例13: DidFinishLaunching
public override void DidFinishLaunching (NSNotification notification)
{
var menu = new NSMenu ();
var menuItem = new NSMenuItem ();
menu.AddItem (menuItem);
var appMenu = new NSMenu ();
var quitItem = new NSMenuItem ("Quit", "q", (s, e) => NSApplication.SharedApplication.Terminate (menu));
appMenu.AddItem (quitItem);
menuItem.Submenu = appMenu;
NSApplication.SharedApplication.MainMenu = menu;
m_window = new NSWindow (
new CGRect (0, 0, 1024, 720),
NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.TexturedBackground,
NSBackingStore.Buffered,
false) {
Title = "Bluebird WkBrowser",
ReleasedWhenClosed = false,
ContentMinSize = new CGSize (1024, 600),
CollectionBehavior = NSWindowCollectionBehavior.FullScreenPrimary
};
m_window.Center ();
m_window.MakeKeyAndOrderFront (null);
var viewController = new ViewController ();
m_window.ContentView = viewController.View;
m_window.ContentViewController = viewController;
viewController.View.Frame = m_window.ContentView.Bounds;
}
示例14: HandleKeyboardAppearing
private void HandleKeyboardAppearing(NSNotification notification, bool movedDown)
{
if (movedDown)
{
float offset = _lastOffset*-1;
MoveView(notification, offset);
_lastOffset = 0;
}
else if (_lastOffset == 0)
{
var frame = (NSValue) notification.UserInfo.ObjectForKey(UIKeyboard.FrameEndUserInfoKey);
float offset = frame.RectangleFValue.Height;
float screenHeight = UIScreen.MainScreen.Bounds.Height;
float position = GetPositionToMove();
if (position > screenHeight - offset)
{
offset = offset + position - screenHeight;
MoveView(notification, offset);
_lastOffset = offset;
}
else
{
_lastOffset = 0;
}
}
}
示例15: DidFinishLaunching
public override void DidFinishLaunching (NSNotification notification)
{
mainWindowController = new MainWindowController ();
// We create a tab control to insert both examples into, and set it to take the entire window and resize
CGRect frame = mainWindowController.Window.ContentView.Frame;
NSTabView tabView = new NSTabView (frame) {
AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable
};
NSTabViewItem firstTab = new NSTabViewItem () {
View = new CustomDrawRectView (tabView.ContentRect),
Label = "CustomDrawRectView"
};
tabView.Add (firstTab);
NSTabViewItem secondTab = new NSTabViewItem () {
View = new CustomLayerBasedView (tabView.ContentRect),
Label = "CustomLayerBasedView"
};
tabView.Add (secondTab);
mainWindowController.Window.ContentView.AddSubview (tabView);
mainWindowController.Window.MakeKeyAndOrderFront (this);
}