当前位置: 首页>>代码示例>>C#>>正文


C# UIActionSheet.ShowFrom方法代码示例

本文整理汇总了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);
        }
开发者ID:darkice-matt-crombie,项目名称:MvxSpinnerTest,代码行数:34,代码来源:HackMvxMenuExtensionMethods.cs

示例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);
 }
开发者ID:Dexyon,项目名称:MvvmCross-Samples,代码行数:8,代码来源:BaseDynamicKittenTableView.cs

示例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);
		}
开发者ID:Coolerhino,项目名称:MvvmCross-Tutorials,代码行数:20,代码来源:CustomerView.cs

示例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);
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:22,代码来源:ReadmeView.cs

示例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);
		}
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:46,代码来源:CommitView.cs

示例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();
            };
        }
开发者ID:prashantvc,项目名称:DaysUntilXmas,代码行数:30,代码来源:MainViewController.cs

示例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);
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:41,代码来源:DocumentAppDelegate.cs

示例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;
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:47,代码来源:DocumentAppDelegate.cs

示例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;
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:50,代码来源:DocumentAppDelegate.cs

示例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);
			}
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:86,代码来源:ContextActionCell.cs

示例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);
//.........这里部分代码省略.........
开发者ID:RMDesenvolvimento,项目名称:Xamarin,代码行数:101,代码来源:DSDemoGridViewController.cs

示例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;
        }
开发者ID:spouliot,项目名称:airplay,代码行数:45,代码来源:Sample.cs

示例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 };
			}


		}
开发者ID:RMDesenvolvimento,项目名称:Xamarin,代码行数:54,代码来源:DSDemoViewWithGridController.cs

示例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);
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:36,代码来源:RepositoryView.cs

示例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);
        }
开发者ID:biteconsulting,项目名称:PinballScoreEntry,代码行数:20,代码来源:MasterViewController.cs


注:本文中的UIActionSheet.ShowFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。