本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem.Dispose方法的具体用法?C# ToolStripMenuItem.Dispose怎么用?C# ToolStripMenuItem.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripMenuItem
的用法示例。
在下文中一共展示了ToolStripMenuItem.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateProfileMenu
private void PopulateProfileMenu()
{
var pm = new ToolStripMenuItem("Profile");
foreach (var trackingMode in (PXCMFaceConfiguration.TrackingModeType[])Enum.GetValues(typeof(PXCMFaceConfiguration.TrackingModeType)))
{
var pm1 = new ToolStripMenuItem(FaceMode2String(trackingMode), null, Profile_Item_Click);
pm.DropDownItems.Add(pm1);
if (trackingMode == PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR_PLUS_DEPTH) //3d = default
{
pm1.Checked = true;
}
}
try
{
MainMenu.Items.RemoveAt(3);
}
catch (NotSupportedException)
{
pm.Dispose();
throw;
}
MainMenu.Items.Insert(3, pm);
}
示例2: AddPluginAction
public override void AddPluginAction(PluginAction pa)
{
AddPluginActionForToolbar(pa);
ToolStripItem mi = new ToolStripMenuItem();
mi.Text = Utils.LanguageSupport.Instance.GetTranslation(pa.action);
mi.Tag = pa;
pa.Tag = mi;
mi.Click += new EventHandler(mi_Click);
var p = (from s in Core.ShortcutInfo where s.PluginType == pa.plugin.GetType().ToString() && s.PluginAction == pa.action && (s.PluginSubAction ?? "") == (pa.subaction ?? "") select s).FirstOrDefault();
if (p != null)
{
(mi as ToolStripMenuItem).ShortcutKeyDisplayString = p.ShortcutKeyString;
(mi as ToolStripMenuItem).ShortcutKeys = p.ShortcutKeys;
}
var tsp = (from t in _toolbarActionProperties where t.PluginType == pa.plugin.PluginType && t.Action == (pa.action ?? "") && t.SubAction == (pa.subaction ?? "") select t).FirstOrDefault();
if (tsp != null)
{
(mi as ToolStripMenuItem).Image = tsp.ButtonImage;
(mi as ToolStripMenuItem).ImageScaling = ToolStripItemImageScaling.None;
}
ToolStripMenuItem misub = null;
if (!string.IsNullOrEmpty(pa.subaction))
{
mi.Text = Utils.LanguageSupport.Instance.GetTranslation(pa.subaction);
misub = (from m in _pluginActionList
where m.action == pa.action && m.plugin == pa.plugin && string.IsNullOrEmpty(m.subaction)
select m.Tag as ToolStripMenuItem).FirstOrDefault();
if (misub == null)
{
//ok, parent does not exist, create
PluginAction parentPa = new PluginAction();
parentPa.action = pa.action;
parentPa.subaction = null;
parentPa.plugin = pa.plugin;
_pluginActionList.Add(parentPa);
misub = new ToolStripMenuItem();
misub.Text = Utils.LanguageSupport.Instance.GetTranslation(pa.action);
misub.Tag = pa;
parentPa.Tag = misub;
misub.DropDownItems.Add(mi);
mi = misub;
}
else
{
if (mi.Text == "-")
{
misub.DropDownItems.Add(new ToolStripSeparator());
mi.Dispose();
}
else
{
misub.DropDownItems.Add(mi);
}
return;
}
}
if (mi.Text == "-")
{
mi.Dispose();
mi = new ToolStripSeparator();
}
switch (pa.plugin.PluginType)
{
case Framework.PluginType.InternalStorage:
fileToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.LanguageSupport:
languageToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.ImportData:
importToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.ExportData:
exportToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.UIChildWindow:
windowToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.GeocacheSelectFilter:
searchToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.Action:
actionToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.Script:
scriptsToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.PluginManager:
pluginsToolStripMenuItem.DropDownItems.Add(mi);
break;
case Framework.PluginType.Debug:
windowToolStripMenuItem.DropDownItems.Add(mi);
//.........这里部分代码省略.........
示例3: PopulateColorResolutionMenu
public void PopulateColorResolutionMenu(string deviceName)
{
bool foundDefaultResolution = false;
var sm = new ToolStripMenuItem("Color");
foreach (var resolution in ColorResolutions[deviceName])
{
var resText = PixelFormat2String(resolution.Item1.format) + " " + resolution.Item1.width + "x"
+ resolution.Item1.height + " " + resolution.Item2.max + " fps";
var sm1 = new ToolStripMenuItem(resText, null);
var selectedResolution = resolution;
sm1.Click += (sender, eventArgs) =>
{
m_selectedColorResolution = selectedResolution;
ColorResolution_Item_Click(sender);
};
sm.DropDownItems.Add(sm1);
if (selectedResolution.Item1.format == PXCMImage.PixelFormat.PIXEL_FORMAT_YUY2 &&
selectedResolution.Item1.width == 640 && selectedResolution.Item1.height == 360 && selectedResolution.Item2.min == 30)
{
foundDefaultResolution = true;
sm1.Checked = true;
sm1.PerformClick();
}
}
if (!foundDefaultResolution && sm.DropDownItems.Count > 0)
{
((ToolStripMenuItem)sm.DropDownItems[0]).Checked = true;
((ToolStripMenuItem)sm.DropDownItems[0]).PerformClick();
}
try
{
MainMenu.Items.RemoveAt(1);
}
catch (NotSupportedException)
{
sm.Dispose();
throw;
}
MainMenu.Items.Insert(1, sm);
}
示例4: CreateContextMenu
/// <summary>
/// Function to create context menu
/// </summary>
private void CreateContextMenu()
{
this.contextMenuStrip = new ContextMenuStrip();
ToolStripMenuItem exitMenuItem = null;
try
{
exitMenuItem = new ToolStripMenuItem();
exitMenuItem.Text = Properties.Resources.ExitText;
exitMenuItem.Click += this.ExitMenuItem_Click;
this.contextMenuStrip.Items.Add(exitMenuItem);
exitMenuItem = null;
}
finally
{
if (exitMenuItem != null)
{
exitMenuItem.Dispose();
}
}
}
示例5: LoadPlugin
static private void LoadPlugin(Assembly assembly)
{
try
{
foreach (Type type in assembly.GetTypes())
{
if (!type.IsSubclassOf(typeof(ModToolPlugin)))
continue;
var plugin = type.GetConstructor(Type.EmptyTypes).Invoke(null) as ModToolPlugin;
if (type.IsSubclassOf(typeof(FileTypePlugin)))
{
var ftp = plugin as FileTypePlugin;
string[] exts = ftp.FileExtensions;
foreach (string ext in exts)
{
if (!FileTypePlugins.ContainsKey(ext.ToLower()))
FileTypePlugins.Add(ext.ToLower(), new List<FileTypePlugin>());
FileTypePlugins[ext.ToLower()].Add(ftp);
}
}
var pluginMenu = new ToolStripMenuItem(plugin.PluginName) { Name = type.FullName };
plugin.Init(new PluginEnvironment(pluginMenu.DropDownItems,
ModToolEnvironment.CombinedFileTreeContext,
ModToolEnvironment.VirtualFileTreeContext));
if (pluginMenu.DropDownItems.Count > 0)
ModToolEnvironment.PluginMenu.Add(pluginMenu);
else
pluginMenu.Dispose();
}
}
catch (ReflectionTypeLoadException e)
{
LoggingManager.SendMessage("PluginManager - Could not load plugin!");
LoggingManager.SendMessage("LoaderExceptions: ");
foreach (Exception exc in e.LoaderExceptions)
LoggingManager.HandleException(exc);
LoggingManager.HandleException(e);
UIHelper.ShowError("Could not load plugin " + assembly.FullName + ": " + e.Message);
}
catch (Exception e)
{
LoggingManager.SendMessage("PluginManager - Could not load plugin!");
LoggingManager.HandleException(e);
UIHelper.ShowError("Could not load plugin " + assembly.FullName + ": " + e.Message);
}
}
示例6: Main
public static void Main()
{
var iconPath = Path.Combine(Application.StartupPath, "csFiler.ico");
using (var icon = new Icon(iconPath))
using (var commandMenu = new ToolStripMenuItem("コマンド入力"))
using (var exitMenuItem = new ToolStripMenuItem("終了"))
using (var contextMenu = new ContextMenuStrip())
using (var taskTray = new NotifyIcon())
using (var hotKeyLoop = new HotKeyMessageLoop())
{
taskTray.Icon = icon;
taskTray.Text = "csFiler";
taskTray.ContextMenuStrip = contextMenu;
var openCommand = new HotKey(
new Action(() =>
{
var window = new FilerWindow();
window.WindowStartupLocation = Wpf.WindowStartupLocation.CenterScreen;
window.Show();
}),
Key.V, ModifierKeys.Windows);
hotKeyLoop.Add(openCommand);
contextMenu.Items.AddRange(
new ToolStripItem []
{
commandMenu,
exitMenuItem,
});
contextMenu.Click += (sender, e) => openCommand.Action.Invoke();
exitMenuItem.Click += (sender, e) => Wpf.Application.Current.Shutdown();
var application = new Wpf.Application()
{
ShutdownMode = Wpf.ShutdownMode.OnExplicitShutdown,
};
application.DispatcherUnhandledException += (sender, e) =>
{
MessageBox.Show(
string.Concat("想定外のエラーが発生しました。",
Environment.NewLine, e.Exception.Message), "csFiler");
e.Handled = true;
};
application.Exit += (sender, e) =>
{
hotKeyLoop.Dispose();
taskTray.Dispose();
contextMenu.Dispose();
exitMenuItem.Dispose();
commandMenu.Dispose();
icon.Dispose();
};
taskTray.Visible = true;
application.Run();
}
}
示例7: PopulateModuleMenu
private void PopulateModuleMenu()
{
PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
desc.cuids[0] = PXCMEmotion.CUID;
ToolStripMenuItem mm = new ToolStripMenuItem("Module");
for (int i = 0; ; i++)
{
PXCMSession.ImplDesc desc1;
if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
ToolStripMenuItem mm1 = new ToolStripMenuItem(desc1.friendlyName, null, new EventHandler(Module_Item_Click));
mm.DropDownItems.Add(mm1);
}
if (mm.DropDownItems.Count > 0)
(mm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
try
{
MainMenu.Items.RemoveAt(1);
}
catch
{
mm.Dispose();
}
MainMenu.Items.Insert(1, mm);
}