本文整理汇总了C#中System.Windows.Controls.ContextMenu.TranslatePoint方法的典型用法代码示例。如果您正苦于以下问题:C# ContextMenu.TranslatePoint方法的具体用法?C# ContextMenu.TranslatePoint怎么用?C# ContextMenu.TranslatePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.TranslatePoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGraphCanvasContextMenu
private ContextMenu CreateGraphCanvasContextMenu()
{
ContextMenu result = new ContextMenu();
MenuItem menuItemAddActionNode = new MenuItem {
Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/XRouter.Gui;component/Resources/Actions-tool-animator-icon.png")), Height = 20 },
Header = new TextBlock { Text = "Action", FontSize = 14, FontWeight = FontWeights.Bold }
};
menuItemAddActionNode.Click += delegate {
AddNode("Action", result, delegate {
ActionNodeConfiguration newActionNode = new ActionNodeConfiguration();
#region Add a default action
ActionType actionType = ConfigManager.Configuration.GetActionTypes().First();
ActionConfiguration action = new ActionConfiguration(actionType.Name) {
Configuration = new SerializableXDocument(new XDocument(new XElement(XName.Get("objectConfig"))))
};
newActionNode.Actions.Add(action);
#endregion
return newActionNode;
});
};
MenuItem menuItemAddCbrNode = new MenuItem {
Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/XRouter.Gui;component/Resources/nfs-unmount-icon.png")), Height = 20 },
Header = new TextBlock { Text = "CBR", FontSize = 14, FontWeight = FontWeights.Bold }
};
menuItemAddCbrNode.Click += delegate {
AddNode("CBR", result, delegate { return new CbrNodeConfiguration(); });
};
MenuItem menuItemAddTerminatorNode = new MenuItem {
Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/XRouter.Gui;component/Resources/Button-exit-icon.png")), Height = 20 },
Header = new TextBlock { Text = "Terminator", FontSize = 14, FontWeight = FontWeights.Bold }
};
menuItemAddTerminatorNode.Click += delegate {
Point menuLocationOnCanvas = result.TranslatePoint(new Point(), graphCanvas.Canvas);
AddNode("Terminator", result, delegate { return new TerminatorNodeConfiguration(); });
};
MenuItem menuItemAdd = new MenuItem {
Header = new TextBlock { Text = "Add node...", FontSize = 14 }
};
menuItemAdd.Items.Add(menuItemAddActionNode);
menuItemAdd.Items.Add(menuItemAddCbrNode);
menuItemAdd.Items.Add(menuItemAddTerminatorNode);
result.Items.Add(menuItemAdd);
return result;
}
示例2: AddNode
private void AddNode(string baseName, ContextMenu menu, Func<NodeConfiguration> nodeFactory)
{
NodeConfiguration node = nodeFactory();
#region Set unique name
int index = 1;
string[] existingNames = Messageflow.Nodes.Select(n => n.Name).ToArray();
while (existingNames.Contains(baseName + index.ToString())) {
index++;
}
node.Name = baseName + index.ToString();
#endregion
Point menuLocationOnCanvas = menu.TranslatePoint(new Point(), graphCanvas.Canvas);
node.Location = menuLocationOnCanvas - graphCanvas.CanvasLocationOffset;
Messageflow.Nodes.Add(node);
MessageflowGraphPresenter.RaiseGraphChanged();
ThreadUtils.InvokeLater(TimeSpan.FromSeconds(0.5), delegate {
NodeSelectionManager.SelectNode(node);
});
}