本文整理汇总了C#中System.Windows.Controls.ContextMenuEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ContextMenuEventArgs类的具体用法?C# ContextMenuEventArgs怎么用?C# ContextMenuEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContextMenuEventArgs类属于System.Windows.Controls命名空间,在下文中一共展示了ContextMenuEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnContextMenuOpening
protected override void OnContextMenuOpening(ContextMenuEventArgs e)
{
var treeNode = this.SelectedItem as ModelCollectionTreeNode;
if (treeNode != null) {
treeNode.ShowContextMenu();
}
}
示例2: DataGridContextMenuOpening
private void DataGridContextMenuOpening(object sender, ContextMenuEventArgs e)
{
var element = e.OriginalSource as FrameworkElement;
var dg = (MultiSelector)sender;
if (element != null && element.DataContext is ITrack)
{
var commandbar = new CommandBar();
if (dg.SelectedItems.Count == 1)
{
var track = (ITrack)dg.SelectedItems[0];
_eventAggregator.GetEvent<TrackCommandBarEvent>().Publish(new TrackCommandBarModel(track, commandbar));
}
else if (dg.SelectedItems.Count > 1)
{
var tracks = dg.SelectedItems.Cast<ITrack>();
_eventAggregator.GetEvent<TracksCommandBarEvent>().Publish(new TracksCommandBarModel(tracks, commandbar));
}
dg.ContextMenu = new CommandBarContextMenu
{
ItemsSource = commandbar.ChildMenuItems
};
}
}
示例3: RichTextBoxContextMenuClosing
private void RichTextBoxContextMenuClosing(object sender, ContextMenuEventArgs e)
{
foreach (Control menuItem in dynamicContextMenuItems)
{
contextMenu.Items.Remove(menuItem);
}
}
示例4: listView2_ContextMenuOpening
private void listView2_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
if (listView2.SelectedItems == null || listView2.SelectedItems.Count == 0)
{
e.Handled = true;
return;
}
System.Windows.Controls.ListBox src = e.Source as System.Windows.Controls.ListBox;
src.ContextMenu.Items.Clear();
MenuItem m = new MenuItem();
m.Foreground = Brushes.Black;
m.Header = "Download selected items";
m.Command = Model.Download;
m.CommandParameter = listView2.SelectedItems;
src.ContextMenu.Items.Add(m);
/* m = new MenuItem();
m.Foreground = Brushes.Black;
m.Header = "View in share";
m.Command = Model.ViewShare;
m.CommandParameter = listView2.SelectedItems;
src.ContextMenu.Items.Add(m);*/
}
示例5: treeView_ContextMenuOpening
void treeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
SharpTreeNode[] selectedNodes = treeView.GetTopLevelSelection().ToArray();
if (selectedNodes.Length == 0)
return;
ContextMenu menu = new ContextMenu();
foreach (var category in entries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.Category)) {
if (menu.Items.Count > 0) {
menu.Items.Add(new Separator());
}
foreach (var entryPair in category) {
IContextMenuEntry entry = entryPair.Value;
if (entry.IsVisible(selectedNodes)) {
MenuItem menuItem = new MenuItem();
menuItem.Header = entryPair.Metadata.Header;
if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) {
menuItem.Icon = new Image {
Width = 16,
Height = 16,
Source = Images.LoadImage(entry, entryPair.Metadata.Icon)
};
}
if (entryPair.Value.IsEnabled(selectedNodes)) {
menuItem.Click += delegate {
entry.Execute(selectedNodes);
};
}
menu.Items.Add(menuItem);
}
}
}
if (menu.Items.Count > 0)
treeView.ContextMenu = menu;
}
示例6: OnContextMenuOpening
protected override void OnContextMenuOpening(ContextMenuEventArgs e)
{
this.SelectedLink = boxOutput.SelectedLink;
if (!string.IsNullOrEmpty(this.SelectedLink))
{
if (Constants.UrlRegex.IsMatch(this.SelectedLink))
{
boxOutput.ContextMenu = this.Resources["cmHyperlink"] as ContextMenu;
}
else
{
if (this.Type == ChatPageType.DccChat)
{
return;
}
this.SelectedLink = this.GetNickWithoutLevel(this.SelectedLink);
boxOutput.ContextMenu = this.Resources["cmNickname"] as ContextMenu;
}
boxOutput.ContextMenu.IsOpen = true;
e.Handled = true;
}
else
{
boxOutput.ContextMenu = this.GetDefaultContextMenu();
if (this.IsServer && boxOutput.ContextMenu != null)
{
boxOutput.ContextMenu.Items.Refresh();
}
}
base.OnContextMenuOpening(e);
}
示例7: listFilters_ContextMenuOpening
private void listFilters_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
if (listFilters.SelectedIndex==-1)
{
e.Handled = true;
}
}
示例8: ContextMenu_Showing
private static void ContextMenu_Showing(SystemOptionsView systemOptionsView, object sender, ContextMenuEventArgs e)
{
if (e.ContextMenuGroupCollection.Any(c => c.Type == ContextMenuGroupType.Custom))
{
return;
}
var cmd = new Telerik.Windows.Documents.RichTextBoxCommands.InsertPictureCommand(systemOptionsView.HTMLRichTextBox);
var insertImageMenuItem = new RadMenuItem
{
Header = "Insert Image...",
Command = cmd,
Icon = new Image()
{
Source = new BitmapImage(new Uri("/Cebos.Veyron.Common.SL;component/Assets/Icons/presentation.png", UriKind.Relative)),
//// This is valid too, if the image is within the same assembly
//Source = new BitmapImage(new Uri("Images/MenuIcons/Clear.png", UriKind.Relative)),
Stretch = Stretch.Fill
}
};
var customContextMenuGroup = new ContextMenuGroup { insertImageMenuItem };
e.ContextMenuGroupCollection.Add(customContextMenuGroup);
var textFormatting = e.ContextMenuGroupCollection.FirstOrDefault(x => x.Type == ContextMenuGroupType.FloatingBlockCommands);
if (textFormatting != null)
{
e.ContextMenuGroupCollection.Remove(textFormatting);
}
}
示例9: MainWindowContextMenuOpening
private void MainWindowContextMenuOpening(object sender, ContextMenuEventArgs e)
{
var fe = sender as FrameworkElement;
var _scriptingUIHelper = CompositionManager.Get<IScriptingUIHelper>();
var _scriptingConfiguration = CompositionManager.Get<IScriptingConfiguration>();
if (fe == null)
return;
var newcontextualmenu = new ContextMenu();
if (_scriptingUIHelper != null)
{
List<object> menu = _scriptingUIHelper.CreateContextMenusFromScripts(false,
_scriptingConfiguration.
MainWindowContextMenuEntryPoint,
MenuItemClick);
if (menu != null)
{
foreach (object i in menu)
newcontextualmenu.Items.Add(i);
}
}
fe.ContextMenu = newcontextualmenu;
}
示例10: OnContextMenuOpening
protected override void OnContextMenuOpening(ContextMenuEventArgs e)
{
this.ContextMenu.ItemsSource = ContextMenuOptions;
if (this.ContextMenu.Items.Count == 0)
e.Handled = true;
base.OnContextMenuOpening(e);
}
示例11: _OnContextMenuOpening
private void _OnContextMenuOpening(object sender, ContextMenuEventArgs e)
{
try
{
// _UpdateContextMenuItemsStatus(sender as Button);
}
catch
{ }
}
示例12: contextMenuSelectedTextOpening
private void contextMenuSelectedTextOpening(object sender, ContextMenuEventArgs e)
{
var fe = sender as FrameworkElement;
var newcontextualmenu = new ContextMenu();
var _scriptingUIHelper = CompositionManager.Get<IScriptingUIHelper>();
var _scriptingConfiguration = CompositionManager.Get<IScriptingConfiguration>();
var ewf = Keyboard.FocusedElement as UIElement; // this retrieves the current textbox that has selection
if (ewf is CompositionTextBox) // if it is a compositiontextbox
{
var tbwf = ewf as RichTextBox;
var spellingSuggestions = tbwf.GetSpellingError(tbwf.CaretPosition);
if (spellingSuggestions != null)
{
if (spellingSuggestions.Suggestions.HasItems())
{
foreach (string str in spellingSuggestions.Suggestions)
{
var mi = new MenuItem
{
Header = str,
FontWeight = FontWeights.Bold,
Command = EditingCommands.CorrectSpellingError,
CommandParameter = str,
CommandTarget = tbwf
};
newcontextualmenu.Items.Add(mi);
}
}
else
{
var mi = new MenuItem
{Header = "No Suggestions", FontWeight = FontWeights.Bold, IsEnabled = false};
newcontextualmenu.Items.Add(mi);
}
newcontextualmenu.Items.Add(new Separator());
}
}
if (_scriptingUIHelper != null)
{
_scriptingUIHelper.createCCPContextualMenus(newcontextualmenu, contextMenuItem_StandardCCP);
var menu =
_scriptingUIHelper.CreateContextMenusFromScripts(true,
_scriptingConfiguration.
ComposeTextContextMenuEntryPoint,
mi_TextSelect_Click);
if (menu != null)
{
foreach (object i in menu)
newcontextualmenu.Items.Add(i);
}
}
if (fe != null) fe.ContextMenu = newcontextualmenu;
}
示例13: OnContextMenuOpening
//Not Needed anymore since WindowChrome is Doing the Job now
protected override void OnContextMenuOpening(ContextMenuEventArgs e)
{
//if (e.Handled)
// return;
//var source = PresentationSource.FromVisual(this) as HwndSource;
//if (source != null)
// ModernChromeWindow.ShowWindowMenu(source, this, Mouse.GetPosition(this), RenderSize);
//e.Handled = true;
}
示例14: OnContextMenuOpening
private void OnContextMenuOpening(object sender, ContextMenuEventArgs e)
{
var commit = GetCurrentSelectedCommit();
if (commit == null)
{
e.Handled = true;
return;
}
}
示例15: FrameworkElement_ContextMenuOpening
void FrameworkElement_ContextMenuOpening(object sender, ContextMenuEventArgs e) {
if (IsIgnored(sender, e))
return;
bool? b = menuService.ShowContextMenu(e, element, ctxMenuGuid, ctxMenuGuid, new GuidObject(guid, element), provider, initCtxMenu, e.CursorLeft == -1 && e.CursorTop == -1);
if (b == null)
return;
if (!b.Value)
e.Handled = true;
}