本文整理汇总了C#中UIActionSheet.ShowFrom方法的典型用法代码示例。如果您正苦于以下问题:C# UIActionSheet.ShowFrom方法的具体用法?C# UIActionSheet.ShowFrom怎么用?C# UIActionSheet.ShowFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIActionSheet
的用法示例。
在下文中一共展示了UIActionSheet.ShowFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowOptionsMenu
public static void ShowOptionsMenu(this UIViewController vc, IParentMenu parentMenu)
{
if (parentMenu == null)
{
return;
}
var actionSheet = new UIActionSheet();
#warning TODO - make this OO - let the _parentMenu render itself...
var actions = new List<ICommand>();
foreach (var child in parentMenu.Children)
{
var childCast = child as CaptionAndIconMenu;
#warning More to do here - e.g. check for null!
actionSheet.AddButton(childCast.Caption);
actions.Add(childCast.Command);
}
actionSheet.Clicked += (object sender, UIButtonEventArgs e) =>
{
if (e.ButtonIndex >= 0)
{
actions[e.ButtonIndex].Execute(null);
}
};
#warning More to do here - e.g. check for null!
//if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
// actionSheet.ShowFromToolbar(NavigationController.Toolbar);
//else
actionSheet.ShowFrom(vc.NavigationItem.RightBarButtonItem, true);
}
示例2: HandleRightButtonClicked
private void HandleRightButtonClicked(object sender, EventArgs e)
{
var sheet = new UIActionSheet("Actions");
sheet.AddButton("Add");
sheet.AddButton("Kill");
sheet.Clicked += HandleActionSheetButtonClicked;
sheet.ShowFrom(_rightButton, true);
}
示例3: ActionMenu
void ActionMenu()
{
//_actionSheet = new UIActionSheet("");
UIActionSheet actionSheet = new UIActionSheet (
"Customer Actions", null, "Cancel", "Delete Customer",
new string[] {"Change Customer"});
actionSheet.Style = UIActionSheetStyle.Default;
actionSheet.Clicked += delegate(object sender, UIButtonEventArgs args) {
switch (args.ButtonIndex)
{
case 0: DeleteCustomer(); break;
case 1: ChangeCustomer(); break;
}
};
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
actionSheet.ShowFromToolbar(NavigationController.Toolbar);
else
actionSheet.ShowFrom(NavigationItem.RightBarButtonItem, true);
}
示例4: ShareButtonPress
private void ShareButtonPress()
{
var sheet = new UIActionSheet();
var shareButton = sheet.AddButton("Share");
var showButton = sheet.AddButton("Show in Bitbucket");
var cancelButton = sheet.AddButton("Cancel");
sheet.CancelButtonIndex = cancelButton;
sheet.DismissWithClickedButtonIndex(cancelButton, true);
sheet.Dismissed += (s, e) => {
BeginInvokeOnMainThread(() =>
{
if (e.ButtonIndex == showButton)
ViewModel.GoToGitHubCommand.Execute(null);
else if (e.ButtonIndex == shareButton)
ViewModel.ShareCommand.Execute(null);
});
sheet.Dispose();
};
sheet.ShowFrom(NavigationItem.RightBarButtonItem, true);
}
示例5: ShowExtraMenu
private void ShowExtraMenu()
{
var changeset = ViewModel.Commits;
if (changeset == null)
return;
var sheet = new UIActionSheet();
var addComment = sheet.AddButton("Add Comment");
var copySha = sheet.AddButton("Copy Sha");
// var shareButton = sheet.AddButton("Share");
//var showButton = sheet.AddButton("Show in GitHub");
var cancelButton = sheet.AddButton("Cancel");
sheet.CancelButtonIndex = cancelButton;
sheet.DismissWithClickedButtonIndex(cancelButton, true);
sheet.Dismissed += (s, e) => {
BeginInvokeOnMainThread(() =>
{
// Pin to menu
if (e.ButtonIndex == addComment)
{
AddCommentTapped();
}
else if (e.ButtonIndex == copySha)
{
UIPasteboard.General.String = ViewModel.Node;
}
// else if (e.ButtonIndex == shareButton)
// {
// var item = UIActivity.FromObject (ViewModel.Changeset.Url);
// var activityItems = new MonoTouch.Foundation.NSObject[] { item };
// UIActivity[] applicationActivities = null;
// var activityController = new UIActivityViewController (activityItems, applicationActivities);
// PresentViewController (activityController, true, null);
// }
// else if (e.ButtonIndex == showButton)
// {
// ViewModel.GoToHtmlUrlCommand.Execute(null);
// }
});
sheet.Dispose();
};
sheet.ShowFrom(NavigationItem.RightBarButtonItem, true);
}
示例6: AddButtons
void AddButtons()
{
settingsButton.TouchUpInside += (object sender, EventArgs e) => {
if(UserInterfaceIdiomIsPhone)
{
actionSheet = new UIActionSheet("Settings", null, "Cancel", null, new [] { "Music", "About"});
actionSheet.Style = UIActionSheetStyle.BlackTranslucent;
actionSheet.Clicked += (object sheetSender, UIButtonEventArgs eve) => {
switch(eve.ButtonIndex)
{
case 0:
DisplayMusicOptions();
break;
case 1:
DisplaySettingsOptions();
break;
case 2:
break;
}
};
actionSheet.ShowFrom(musicButton.Frame, View, true);
} else {
DisplaySettingsOptions();
}
};
musicButton.TouchUpInside += (object sender, EventArgs e) => {
DisplayMusicOptions();
};
}
示例7: DeleteOpenedDocument
public void DeleteOpenedDocument (UIBarButtonItem deleteButton)
{
if (DismissSheetsAndPopovers ())
return;
var docIndex = OpenedDocIndex;
var docRef = Docs [docIndex];
ActionSheet = new UIActionSheet ();
ActionSheet.AddButton ("Delete " + App.DocumentBaseName);
ActionSheet.AddButton ("Cancel");
ActionSheet.DestructiveButtonIndex = 0;
ActionSheet.CancelButtonIndex = 1;
ActionSheet.Clicked += async (ss, se) => {
if (se.ButtonIndex != 0) return;
if (docIndex >= 0) {
await CloseOpenedDoc (reloadThumbnail: false);
}
await DeleteDocs (new[]{docRef.File.Path});
if (Docs.Count > 0) {
var newIndex = Math.Min (Docs.Count - 1, Math.Max (0, docIndex));
await OpenDocument (newIndex, true);
} else if (FileSystem.IsWritable) {
await AddAndOpenDocRef (await DocumentReference.New (
CurrentDocumentListController.Directory,
App.DocumentBaseName,
App.DefaultExtension,
ActiveFileSystem,
App.CreateDocument
));
}
};
ActionSheet.ShowFrom (deleteButton, true);
}
示例8: DeleteDocuments
public async Task<bool> DeleteDocuments (IFile[] files, UIBarButtonItem deleteButton)
{
if (DismissSheetsAndPopovers ())
return false;
if (files.Length == 0)
return false;
//
// Ask if we should delete
//
var tcs = new TaskCompletionSource<int> ();
ActionSheet = new UIActionSheet ();
ActionSheet.AddButton ("Delete " + DescribeFiles (files));
ActionSheet.AddButton ("Cancel");
ActionSheet.DestructiveButtonIndex = 0;
ActionSheet.CancelButtonIndex = 1;
ActionSheet.Clicked += (ss, se) => {
try {
tcs.SetResult ((int)se.ButtonIndex);
} catch (Exception ex) {
Log.Error (ex);
}
};
ActionSheet.ShowFrom (deleteButton, true);
var button = await tcs.Task;
if (button != 0)
return false;
//
// Perform the delete
//
try {
await DeleteDocs (files.Select(x => x.Path).ToArray());
foreach (var f in files) {
InvalidateThumbnail (f, deleteThumbnail: true, reloadThumbnail: false);
}
} catch (Exception ex) {
Console.WriteLine (ex);
}
return true;
}
示例9: DuplicateDocuments
public async Task<bool> DuplicateDocuments (IFile[] files, UIBarButtonItem duplicateButton)
{
if (DismissSheetsAndPopovers ())
return false;
if (files.Length == 0)
return false;
//
// If there is only 1 file, just do it
//
if (files.Length == 1) {
await DuplicateFile (files [0]);
return true;
}
//
// Ask if we should Dup
//
var tcs = new TaskCompletionSource<int> ();
ActionSheet = new UIActionSheet ();
var msg = "Duplicate " + DescribeFiles (files);
ActionSheet.AddButton (msg);
ActionSheet.AddButton ("Cancel");
ActionSheet.CancelButtonIndex = 1;
ActionSheet.Clicked += (ss, se) => {
try {
tcs.SetResult ((int)se.ButtonIndex);
} catch (Exception ex) {
Log.Error (ex);
}
};
ActionSheet.ShowFrom (duplicateButton, true);
var button = await tcs.Task;
if (button != 0)
return false;
//
// Perform the dup
//
foreach (var p in files) {
await DuplicateFile (p);
}
return true;
}
示例10: ActivateMore
void ActivateMore()
{
var displayed = new HashSet<nint>();
for (var i = 0; i < _buttons.Count; i++)
{
var tag = _buttons[i].Tag;
if (tag >= 0)
displayed.Add(tag);
}
var frame = _moreButton.Frame;
if (!Forms.IsiOS8OrNewer)
{
var container = _moreButton.Superview;
frame = new RectangleF(container.Frame.X, 0, frame.Width, frame.Height);
}
var x = frame.X - _scroller.ContentOffset.X;
var path = _tableView.IndexPathForCell(this);
var rowPosition = _tableView.RectForRowAtIndexPath(path);
var sourceRect = new RectangleF(x, rowPosition.Y, rowPosition.Width, rowPosition.Height);
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
var actionSheet = new MoreActionSheetController();
for (var i = 0; i < _cell.ContextActions.Count; i++)
{
if (displayed.Contains(i))
continue;
var item = _cell.ContextActions[i];
var weakItem = new WeakReference<MenuItem>(item);
var action = UIAlertAction.Create(item.Text, UIAlertActionStyle.Default, a =>
{
_scroller.SetContentOffset(new PointF(0, 0), true);
MenuItem mi;
if (weakItem.TryGetTarget(out mi))
mi.Activate();
});
actionSheet.AddAction(action);
}
var controller = GetController();
if (controller == null)
throw new InvalidOperationException("No UIViewController found to present.");
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
{
var cancel = UIAlertAction.Create(StringResources.Cancel, UIAlertActionStyle.Cancel, null);
actionSheet.AddAction(cancel);
}
else
{
actionSheet.PopoverPresentationController.SourceView = _tableView;
actionSheet.PopoverPresentationController.SourceRect = sourceRect;
}
controller.PresentViewController(actionSheet, true, null);
}
else
{
var d = new MoreActionSheetDelegate { Scroller = _scroller, Items = new List<MenuItem>() };
var actionSheet = new UIActionSheet(null, d);
for (var i = 0; i < _cell.ContextActions.Count; i++)
{
if (displayed.Contains(i))
continue;
var item = _cell.ContextActions[i];
d.Items.Add(item);
actionSheet.AddButton(item.Text);
}
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
{
var index = actionSheet.AddButton(StringResources.Cancel);
actionSheet.CancelButtonIndex = index;
}
actionSheet.ShowFrom(sourceRect, _tableView, true);
}
}
示例11: ViewWillAppear
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
if (this.ParentViewController.NavigationController != null)
{
var aButton = new UIBarButtonItem (UIBarButtonSystemItem.Action);
aButton.Clicked += (object sender, EventArgs e) => {
var alert = new UIActionSheet ("Themes");
alert.AddButton ("Default");
alert.AddButton ("New");
alert.AddButton ("iTunes");
alert.AddButton ("Cancel");
alert.CancelButtonIndex = 3;
alert.Clicked += (object action, UIButtonEventArgs e2) => {
DSGridTheme newtheme = null;
switch (e2.ButtonIndex)
{
case 0:
{
//Use default
newtheme = new DSGridDefaultTheme ();
}
break;
case 1:
{
//Create a theme progratically
newtheme = new DSGridDefaultTheme () {
HeaderStyle = GridHeaderStyle.Standard,
HeaderHeight = 75.0f,
CellBackground = DSColor.Black,
CellBackground2 = DSColor.Black,
CellTextForeground = DSColor.White,
CellTextForeground2 = DSColor.White,
CellBackgroundHighlight = DSColor.Gray,
CellTextHighlight = DSColor.Red,
};
}
break;
case 2:
{
//Use subclass
newtheme = new ItunesTheme ();
}
break;
}
if (newtheme != null)
{
//set the current theme - grid will reload
DSGridTheme.Current = newtheme;
//reload the grid
//GridView.ReloadData ();
}
};
alert.ShowFrom ((UIBarButtonItem)sender, true);
};
var aButton2 = new UIBarButtonItem (UIBarButtonSystemItem.Action);
aButton2.Clicked += (object sender, EventArgs e) => {
var alert = new UIActionSheet ("Scroll To: 30");
alert.AddButton ("Top");
alert.AddButton ("Middle");
alert.AddButton ("Bottom");
alert.AddButton ("Cancel");
alert.CancelButtonIndex = 3;
alert.Clicked += (object action, UIButtonEventArgs e2) => {
switch (e2.ButtonIndex)
{
case 0:
{
//top
this.GridView.SelectRow (30, Mode: ScrollToMode.Top);
}
break;
case 1:
{
//Middle
this.GridView.SelectRow (30, Mode: ScrollToMode.Middle, AdditonalOffset: 54.0f);
}
break;
case 2:
{
//Bottom
this.GridView.SelectRow (30, Mode: ScrollToMode.Bottom, AdditonalOffset: 54.0f);
}
break;
}
};
alert.ShowFrom ((UIBarButtonItem)sender, true);
//.........这里部分代码省略.........
示例12: ImageViewController
public ImageViewController()
{
Title = "AirPic Demo";
// on iOS 8.x we delegate the AirPlay feature to our Action extension
bool ios8 = UIDevice.CurrentDevice.CheckSystemVersion (8,0);
// the action extension will do the browsing for airplay capable devices
AirPlayBrowser.Enabled = !ios8;
var bounds = UIScreen.MainScreen.Bounds;
image_view = new UIImageView (bounds);
image_view.Image = UIImage.FromFile ("687px-Leontopithecus_rosalia_-_Copenhagen_Zoo_-_DSC09082.JPG");
image_view.Image.Scale (bounds.Size);
Add (image_view);
UIBarButtonItem action = null;
action = new UIBarButtonItem (UIBarButtonSystemItem.Action, delegate {
if (image_view.Image == null)
return;
// UIActivity is only for iOS6+ but that should not limit us :-)
if (UIDevice.CurrentDevice.CheckSystemVersion (6,0)) {
var activities = AirPlayBrowser.Enabled ? UIAirPlayActivity.GetCurrentActivities () : null;
var a = new UIActivityViewController (new [] { image_view.Image }, activities);
if (AppDelegate.RunningOnIPad) {
popup = new UIPopoverController (a);
popup.PresentFromBarButtonItem (action, UIPopoverArrowDirection.Up, true);
} else {
PresentViewController (a, true, null);
}
} else {
var devices = AirPlayBrowser.GetDeviceNames ();
var a = new UIActionSheet (null, null, "Cancel", null, devices);
a.Clicked += (sender, e) => {
nint index = e.ButtonIndex;
// ignore Cancel button
if (index < devices.Length) {
var device = AirPlayBrowser.GetDevice (devices [index]);
if (device != null) // they can disappear anytime
device.SendTo (image_view.Image, null);
}
};
a.ShowFrom (NavigationItem.RightBarButtonItem, true);
}
});
NavigationItem.RightBarButtonItem = action;
}
示例13: ViewWillAppear
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
if (this.ParentViewController.NavigationController != null)
{
var aButton = new UIBarButtonItem (UIBarButtonSystemItem.Action);
aButton.Clicked += (object sender, EventArgs e) => {
var alert = new UIActionSheet ("Switch DataSets");
alert.AddButton ("Example 1");
alert.AddButton ("Example 2");
alert.AddButton ("Cancel");
alert.CancelButtonIndex = 2;
alert.Clicked += (object action, UIButtonEventArgs e2) => {
var curName = mGridView.TableName;
var newName = String.Empty;
switch (e2.ButtonIndex)
{
case 0:
{
newName = ((DSDataSet)mGridView.DataSource).Tables [0].Name;
}
break;
case 1:
{
newName = ((DSDataSet)mGridView.DataSource).Tables [1].Name;
}
break;
}
if (String.IsNullOrWhiteSpace (newName))
return;
//check if the new name is different to the old name
if (curName != newName)
{
mGridView.TableName = newName;
mGridView.ReloadData ();
}
};
alert.ShowFrom ((UIBarButtonItem)sender, true);
};
this.ParentViewController.NavigationItem.LeftBarButtonItem = null;
this.ParentViewController.NavigationItem.RightBarButtonItems = new UIBarButtonItem[]{ aButton };
}
}
示例14: ShowExtraMenu
private void ShowExtraMenu(object o, EventArgs args)
{
var repoModel = ViewModel.Repository;
if (repoModel == null)
return;
var sheet = new UIActionSheet();
var pinButton = sheet.AddButton(ViewModel.IsPinned ? "Unpin from Slideout Menu" : "Pin to Slideout Menu");
var forkButton = sheet.AddButton("Fork Repository");
var showButton = sheet.AddButton("Show in Bitbucket");
var cancelButton = sheet.AddButton("Cancel");
sheet.CancelButtonIndex = cancelButton;
sheet.DismissWithClickedButtonIndex(cancelButton, true);
sheet.Dismissed += (s, e) => {
BeginInvokeOnMainThread(() => {
// Pin to menu
if (e.ButtonIndex == pinButton)
{
ViewModel.PinCommand.Execute(null);
}
else if (e.ButtonIndex == forkButton)
{
ViewModel.ForkCommand.Execute(null);
}
// Show in Bitbucket
else if (e.ButtonIndex == showButton)
{
ViewModel.GoToUrlCommand.Execute(ViewModel.HtmlUrl);
}
});
sheet.Dispose();
};
sheet.ShowFrom(NavigationItem.RightBarButtonItem, true);
}
示例15: SHowRounds
void SHowRounds(object sender, EventArgs args)
{
if (actionSheet != null)
if (actionSheet.Visible) {
actionSheet.DismissWithClickedButtonIndex (0, true);
return;
}
actionSheet = new UIActionSheet("Choose round:");
int i = 0;
string[] names = new string[Rounds.Count];
foreach (var round in Rounds)
names [i++] = round.Name;
foreach (string name in names)
actionSheet.AddButton (name);
var idx = actionSheet.AddButton ("Cancel");
actionSheet.DestructiveButtonIndex = idx;
actionSheet.Clicked += ChangeRound;
actionSheet.ShowFrom(NavigationItem.RightBarButtonItem, true);
}