本文整理汇总了C#中IMenuItem.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IMenuItem.ToString方法的具体用法?C# IMenuItem.ToString怎么用?C# IMenuItem.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMenuItem
的用法示例。
在下文中一共展示了IMenuItem.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnContextItemSelected
public override Boolean OnContextItemSelected(IMenuItem item)
{
int itemid = item.ItemId;
string itemtext = item.ToString();
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
return base.OnContextItemSelected(item);
}
示例2: OnOptionsItemSelected
public override bool OnOptionsItemSelected(IMenuItem item)
{
var vm = this.DataContext as SessionDetailViewModel;
if (vm != null)
{
switch (item.ToString())
{
case "Add to Schedule":
Task.Run(() => vm.ToggleFavoriteAsync());
break;
}
}
return false;
}
示例3: OnOptionsItemSelected
public override bool OnOptionsItemSelected(IMenuItem item)
{
var vm = this.DataContext as ConferenceDetailSessionsViewModel;
if (vm != null)
{
switch (item.ToString())
{
case "Add to Schedule":
//Task.Factory.StartNew(() => vm.RefreshAsync().Wait());
break;
}
}
return false;
}
示例4: OnOptionsItemSelected
public override bool OnOptionsItemSelected (IMenuItem item)
{
var vm = this.DataContext as ConferenceDetailViewModel;
if (vm != null) {
switch (item.ToString ()) {
case "Refresh":
Task.Run (async () => await vm.RefreshAsync ());
break;
case "Settings":
vm.ShowSettingsCommand.Execute (null);
break;
}
}
return false;
}
示例5: OnOptionsItemSelected
public override bool OnOptionsItemSelected(IMenuItem item)
{
var vm = this.DataContext as ConferencesViewModel;
if (vm != null)
{
switch (item.ToString())
{
case "Refresh":
Task.Factory.StartNew(() => vm.RefreshAsync().Wait());
break;
case "Settings":
vm.ShowSettingsCommand.Execute (null);
break;
case "Sort By Date":
Task.Factory.StartNew(() => vm.SortByDateAsync().Wait());
break;
case "Sort By Name":
Task.Factory.StartNew(() => vm.SortByNameAsync().Wait());
break;
}
}
return false;
}
示例6: OnOptionsItemSelected
public override bool OnOptionsItemSelected (IMenuItem item)
{
Intent intent;
if (item.ItemId == 16908332) {
Finish ();
return false;
}
//This uses the imported MenuItem from ActionBarSherlock
switch(item.ItemId) {
case Resource.Id.menu_detail_save:
if (String.IsNullOrEmpty (cart.Filename)) {
cart.Filename = System.IO.Path.Combine (((MainApp)Application).Path, cart.WGCode);
var pd = ProgressDialog.Show(this, "Download", "Please Wait...", false);
((MainApp)Application).Cartridges.DownloadCartridge (cart, ((MainApp)Application).Path, new FileStream (cart.Filename, FileMode.Create));
pd.Hide ();
}
break;
case Resource.Id.menu_detail_delete:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle(Strings.GetString("Delete"));
builder.SetMessage(Strings.GetStringFmt("Would you delete the cartridge {0} and all log/save files?", cart.Name));
builder.SetCancelable(true);
builder.SetPositiveButton(Strings.GetString("Yes"), delegate {
if (!String.IsNullOrEmpty(cart.Filename) && File.Exists (cart.Filename))
File.Delete (cart.Filename);
if (!String.IsNullOrEmpty(cart.SaveFilename) && File.Exists (cart.SaveFilename))
File.Delete (cart.SaveFilename);
if (!String.IsNullOrEmpty(cart.LogFilename) && File.Exists (cart.LogFilename))
File.Delete (cart.LogFilename);
});
// TODO: Works this also on devices with API < 14 (Pre 4.0)
// var test = Build.VERSION.SdkInt;
// builder.SetNeutralButton(Resource.String.screen_save_before_quit_cancel, delegate { });
builder.SetNegativeButton(Strings.GetString("No"), delegate { });
builder.Show();
break;
case Resource.Id.menu_detail_start:
intent = new Intent (this, typeof(ScreenController));
intent.PutExtra ("cartridge", cart.Filename);
intent.PutExtra ("restore", false);
Start(intent);
break;
case Resource.Id.menu_detail_resume:
intent = new Intent (this, typeof(ScreenController));
intent.PutExtra ("cartridge", cart.Filename);
intent.PutExtra ("restore", true);
Start(intent);
break;
default:
Toast.MakeText (this, "Got click: " + item.ToString (), ToastLength.Long).Show ();
break;
}
menuSave.SetVisible (!File.Exists (cart.Filename));
menuDelete.SetVisible (File.Exists (cart.Filename));
menuResume.SetVisible (true);
menuResume.SetEnabled(File.Exists (cart.SaveFilename));
menuResume.Icon.SetAlpha(menuResume.IsEnabled ? 255 : 96);
menuStart.SetVisible (true);
menuStart.SetEnabled(File.Exists (cart.Filename));
menuStart.Icon.SetAlpha(menuStart.IsEnabled ? 255 : 96);
return true;
}
示例7: OnOptionsItemSelected
public override bool OnOptionsItemSelected (IMenuItem item)
{
Intent intent;
if (item.ItemId == 16908332) {
Finish ();
return false;
}
// This uses the imported MenuItem from action bar
switch(item.ItemId) {
case Resource.Id.menu_detail_save:
if (String.IsNullOrEmpty (_cart.Filename)) {
_cart.Filename = System.IO.Path.Combine (Main.Path, _cart.WGCode);
var pd = ProgressDialog.Show(this, "Download", "Please Wait...", false);
MainApp.Cartridges.DownloadCartridge (_cart, Main.Path, new FileStream (_cart.Filename, FileMode.Create));
pd.Hide ();
}
break;
case Resource.Id.menu_detail_delete:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle(Catalog.GetString("Delete"));
builder.SetMessage(Catalog.Format(Catalog.GetString("Would you delete the cartridge {0} and all log/save files?"), _cart.Name));
builder.SetCancelable(true);
builder.SetPositiveButton(Catalog.GetString("Yes"), delegate {
if (!String.IsNullOrEmpty(_cart.Filename) && File.Exists (_cart.Filename))
File.Delete (_cart.Filename);
if (!String.IsNullOrEmpty(_cart.SaveFilename) && File.Exists (_cart.SaveFilename))
File.Delete (_cart.SaveFilename);
if (!String.IsNullOrEmpty(_cart.LogFilename) && File.Exists (_cart.LogFilename))
File.Delete (_cart.LogFilename);
});
// TODO: Works this also on devices with API < 14 (Pre 4.0)
// var test = Build.VERSION.SdkInt;
// builder.SetNeutralButton(Resource.String.screen_save_before_quit_cancel, delegate { });
builder.SetNegativeButton(Catalog.GetString("No"), delegate { });
builder.Show();
break;
case Resource.Id.menu_detail_navigate:
if (_cart.StartingLocationLatitude != 360.0 && _cart.StartingLocationLongitude != 360.0)
StartRouting(_cart.StartingLocationLatitude, _cart.StartingLocationLongitude);
break;
case Resource.Id.menu_detail_start:
intent = new Intent (this, typeof(GameController));
intent.PutExtra ("cartridge", _cart.Filename);
intent.PutExtra ("restore", false);
try {
Start(intent);
}
catch (Exception ex) {
AlertDialog.Builder adb = new AlertDialog.Builder(this);
adb.SetTitle(Catalog.GetString("Error"));
adb.SetMessage(ex.Message);
adb.SetPositiveButton(Catalog.GetString("Ok"), (sender, args) =>
{
// Do something when this button is clicked.
});
adb.Show();
}
break;
case Resource.Id.menu_detail_resume:
intent = new Intent (this, typeof(GameController));
intent.PutExtra ("cartridge", _cart.Filename);
intent.PutExtra ("restore", true);
try {
Start(intent);
}
catch (Exception ex) {
AlertDialog.Builder adb = new AlertDialog.Builder(this);
adb.SetTitle(Catalog.GetString("Error"));
adb.SetMessage(ex.Message);
adb.SetPositiveButton(Catalog.GetString("Ok"), (sender, args) =>
{
// Do something when this button is clicked.
});
adb.Show();
}
break;
default:
Toast.MakeText (this, "Got click: " + item.ToString (), ToastLength.Long).Show ();
break;
}
_menuSave.SetVisible (!File.Exists (_cart.Filename));
_menuDelete.SetVisible (File.Exists (_cart.Filename));
if (_cart.StartingLocationLatitude != 360.0 && _cart.StartingLocationLongitude != 360.0 && HasRouting()) {
_menuNavigate.SetEnabled(true, this, Resource.Id.menu_detail_navigate);
} else {
_menuNavigate.SetEnabled(false, this, Resource.Id.menu_detail_navigate);
}
_menuNavigate.Icon.SetAlpha(_menuNavigate.IsEnabled ? 204 : 96);
_menuResume.SetVisible (true);
_menuResume.SetEnabled(File.Exists (_cart.SaveFilename), this, Resource.Id.menu_detail_resume);
_menuResume.Icon.SetAlpha(_menuResume.IsEnabled ? 204 : 96);
_menuStart.SetVisible (true);
_menuStart.SetEnabled(File.Exists (_cart.Filename));
_menuStart.Icon.SetAlpha(_menuStart.IsEnabled ? 204 : 96);
return true;
}
示例8: OnOptionsItemSelected
public override Boolean OnOptionsItemSelected(IMenuItem item)
{
int itemid = item.ItemId;
string itemtext = item.ToString();
if (itemid == Resource.Id.menuopt_move)
{
mGLView.gMitcRender.TransState = !mGLView.gMitcRender.TransState;
if (mGLView.gMitcRender.TransState)
{
mGLView.gMitcRender.RotAState = mGLView.gMitcRender.ScaleState = false;
}
itemtext += mGLView.gMitcRender.TransState ? "(开)" : "(关)";
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
//mGLView.gMitcRender.OnZoomReset(false);
//mGLView.gMitcRender.OnZoomFitAll(false);
}
else if (itemid == Resource.Id.menuopt_rota)
{
mGLView.gMitcRender.RotAState = !mGLView.gMitcRender.RotAState;
if (mGLView.gMitcRender.RotAState)
{
mGLView.gMitcRender.TransState = mGLView.gMitcRender.ScaleState = false;
}
itemtext += mGLView.gMitcRender.RotAState ? "(开)" : "(关)";
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
//mGLView.gMitcRender.OnZoomReset(false);
//mGLView.gMitcRender.OnZoomFitAll(false);
}
else if (itemid == Resource.Id.menuopt_scale)
{
mGLView.gMitcRender.ScaleState = !mGLView.gMitcRender.ScaleState;
if (mGLView.gMitcRender.ScaleState)
{
mGLView.gMitcRender.TransState = mGLView.gMitcRender.RotAState = false;
}
itemtext += mGLView.gMitcRender.ScaleState ? "(开)" : "(关)";
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
//mGLView.gMitcRender.OnZoomReset(false);
//mGLView.gMitcRender.OnZoomFitAll(false);
}
else if (itemid == Resource.Id.menuopt_fitall)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.OnZoomFitAll(true);
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomFitAll(false);
}
else if (itemid == Resource.Id.menuopt_reset)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.OnZoomReset(true);
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomReset(false);
}
else if (itemid == Resource.Id.menuopt_front)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.SpecialView = true;
mGLView.gMitcRender.ViewIndex[0] = true;
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomReset(false);
}
else if (itemid == Resource.Id.menuopt_back)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.SpecialView = true;
mGLView.gMitcRender.ViewIndex[1] = true;
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomReset(false);
}
else if (itemid == Resource.Id.menuopt_left)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.SpecialView = true;
mGLView.gMitcRender.ViewIndex[2] = true;
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomReset(false);
}
else if (itemid == Resource.Id.menuopt_right)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.SpecialView = true;
mGLView.gMitcRender.ViewIndex[3] = true;
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomReset(false);
}
else if (itemid == Resource.Id.menuopt_top)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.SpecialView = true;
mGLView.gMitcRender.ViewIndex[4] = true;
mGLView.RequestRender();
//mGLView.gMitcRender.OnZoomReset(false);
}
else if (itemid == Resource.Id.menuopt_bot)
{
Toast.MakeText(this, itemtext, ToastLength.Long).Show();
mGLView.gMitcRender.SpecialView = true;
//.........这里部分代码省略.........
示例9: OnMenuItemSelected
public override bool OnMenuItemSelected (int featureId, IMenuItem item)
{
// Pass the selected item to the MainUIManager
_className = item.ToString ();
_mainUIManager.OnMenuItemSelected (_className);
return true;
}