本文整理汇总了C#中XCore.ChoiceGroup类的典型用法代码示例。如果您正苦于以下问题:C# ChoiceGroup类的具体用法?C# ChoiceGroup怎么用?C# ChoiceGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChoiceGroup类属于XCore命名空间,在下文中一共展示了ChoiceGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateComboBox
protected ToolStripComboBox CreateComboBox(ChoiceGroup choice, bool wantsSeparatorBefore)
{
UIItemDisplayProperties display = choice.GetDisplayProperties();
string label = display.Text;
choice.PopulateNow();
if (label == null)
label = AdapterStrings.ErrorGeneratingLabel;
if (!display.Visible)
return null;
label = label.Replace("_", "&");
ToolStripComboBox combo = new ToolStripComboBox();
combo.Text = label;
//foreach(ChoiceBase s in choice)
//{
// item.Items.Add(s.Label);
//}
//item.Tag = choice;
choice.ReferenceWidget = combo;
combo.Tag = choice;
FillCombo(choice);
combo.SelectedIndexChanged += new EventHandler(OnSelectedIndexChanged);
combo.Enabled = display.Enabled;
combo.Visible = display.Visible;
return combo;
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:35,代码来源:BarAdapterBase.cs
示例2: ChoiceGroup
/// -----------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="ControlGroup"/> class.
/// </summary>
/// -----------------------------------------------------------------------------------
public ChoiceGroup(Mediator mediator, IUIAdapter adapter, XmlNode configurationNode, ChoiceGroup parent)
: base(mediator, adapter, configurationNode)
{
m_parent = parent;
//allow for a command to be attached to a group (todo: should be for tree groups only)
//as it doesn't make sense for some menus or command bars to have an associated command.
//for now, leave it to the schema to prevent anything but the right element from having the command attribute.
if (XmlUtils.GetAttributeValue(m_configurationNode,"command") != null)
{
m_treeGroupCommandChoice = new CommandChoice(mediator, configurationNode, adapter, this);
}
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:18,代码来源:ChoiceGroup.cs
示例3: MakeMenu
protected MenuItem MakeMenu (Menu parent, ChoiceGroup group)
{
string label = group.Label.Replace("_", "&");
MenuItem menu = new MenuItem(label);
group.ReferenceWidget = menu;
//although we put off populating the menu until it is actually displayed,
//we have to put a dummy menu item in there in order to get the system to fire the right event.
menu.MenuItems.Add(new MenuItem("dummy"));
parent.MenuItems.Add(menu);
//needed for mousing around
menu.Popup += new System.EventHandler(group.OnDisplay);
#if DEBUG
//needed for unit testing
menu.Click += new System.EventHandler(group.OnDisplay);
#endif
return menu;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:19,代码来源:MenuAdapter.cs
示例4: CreateUIForChoiceGroup
/// <summary>
/// do a limited update of the toolbar
/// </summary>
/// <remarks>when the user's cursor is hovering over a button and we do a redraw,
/// this method is called. This allows us to update the enabled state of the button
/// without getting flashing tool tips,
/// which is what we get if we were to clear the toolbar and rebuild the buttons,
/// as is normally done at idle time.
/// </remarks>
/// <summary>
/// Create or update the toolbar or a combobox owned by the toolbar
/// </summary>
/// <param name="group">
/// The group that is the basis for this toolbar.
/// </param>
public override void CreateUIForChoiceGroup(ChoiceGroup group)
{
// The following two if clauses may be testing the same thing
ToolStrip toolbar = group.ReferenceWidget as ToolStrip;
if(toolbar.Focused)
return;
//don't refresh the toolbar if the mouse is hovering over the toolbar. Doing that caused the tool tips to flash.
if (toolbar.Bounds.Contains(m_window.PointToClient(Control.MousePosition))
|| InCombo(toolbar))
{
//UpdateToolbar(group);
return;
}
//FillToolbar(group, toolbar);
FillToolbar(group, group.ReferenceWidget as ToolStrip);
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:34,代码来源:ToolbarAdapter.cs
示例5: Make
/// <summary>
/// Factory method. Will make the appropriate class, based on the configurationNode.
/// </summary>
static public ChoiceBase Make( Mediator mediator, XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
{
if (XmlUtils.GetAttributeValue(configurationNode, "command","") == "")
{
if (XmlUtils.GetAttributeValue(configurationNode, "boolProperty", "") != "")
return new BoolPropertyChoice( mediator, configurationNode, adapter, parent);
else if (XmlUtils.GetAttributeValue(configurationNode, "label", "") == "-")
return new SeparatorChoice( mediator, configurationNode, adapter, parent);
//the case where we want a choice based on a single member of the list
//e.g. a single view in a list of views, to use on the toolbar.
else if (XmlUtils.GetAttributeValue(configurationNode, "property", "") != "")
{
return MakeListPropertyChoice(mediator, configurationNode, adapter, parent);
}
else
throw new ConfigurationException("Don't know what to do with this item. At least give it a dummy 'boolProperty='foo''.", configurationNode);
}
else
return new CommandChoice( mediator, configurationNode, adapter, parent);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:25,代码来源:Choice.cs
示例6: MakeTree
/// <summary>
/// Create a tree view for the sidebar.
/// </summary>
/// <param name="group">The definition for the tree view.</param>
/// <param name="label"></param>
/// <param name="panelItem"></param>
protected void MakeTree(ChoiceGroup group, string label, ref SideBarPanelItem panelItem)
{
// TODO: This tree isn't the right size, when the window opens.
// Figure out how to make it right.
TreeView tree = new TreeView();
tree.Tag = group;
tree.AfterSelect += new TreeViewEventHandler(OnTreeNodeSelected);
ControlContainerItem containerItem = new ControlContainerItem(group.Id, label);
containerItem.AllowItemResize = true;
containerItem.Control = tree;
panelItem.SubItems.Add(containerItem);
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:18,代码来源:SidebarAdapter.cs
示例7: PopulateList
/// <summary>
/// Populate a control to show, for example, the list of tools, or the list of filters.
/// </summary>
/// <param name="group"></param>
protected void PopulateList(ChoiceGroup group)
{
bool wasSuspended = m_suspendEvents;
m_suspendEvents = true;
if(m_populatingList)
return;
m_populatingList=true;
ListView list = (ListView) group.ReferenceWidget;
// if(list.Items.Count == group.Count)
// UpdateList(group);
// else
{
list.BeginUpdate();
list.Clear();
m_choiceGroupCache.Add(group); // cache group to defer adding it to the sidepane until we definitely have tabs already
list.EndUpdate();
}
m_populatingList=false;
m_suspendEvents = wasSuspended;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:28,代码来源:NavBarAdapter.cs
示例8: LoadAreaButtons
/// <summary>
/// Create tabs on sidebar
/// </summary>
protected void LoadAreaButtons(ChoiceGroup group)
{
foreach (ChoiceRelatedClass tab in group)
{
//Debug.Assert(item is ChoiceBase, "Only things that can be made into buttons should be appearing here.");
Debug.Assert(tab is ListPropertyChoice, "Only things that can be made into buttons should be appearing here.");
MakeAreaButton((ListPropertyChoice)tab);
}
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:12,代码来源:NavBarAdapter.cs
示例9: CreateUIForChoiceGroup
public void CreateUIForChoiceGroup (ChoiceGroup group)
{
foreach(ChoiceRelatedClass item in group)
{
CommandBar toolbar = (CommandBar)group.ReferenceWidget;
Debug.Assert( toolbar != null);
if(item is SeparatorChoice)
{
toolbar.Items.Add(new CommandBarSeparator());
}
else if(item is ChoiceBase)
{
ChoiceBase control=(ChoiceBase) item;
//System.Windows.Forms.Keys shortcut = System.Windows.Forms.Keys.
UIItemDisplayProperties display = control.GetDisplayProperties();
display.Text = display.Text .Replace("_", "");
Image image =m_smallImages.GetImage(display.ImageLabel);
CommandBarButton button = new CommandBarButton(image,display.Text, new EventHandler(OnClick));
UpdateDisplay(display, button);
button.Tag = control;
control.ReferenceWidget = button;
toolbar.Items.Add(button);
button.IsEnabled = true;
}
//if this is a submenu
/*
* I started playing with being able to have been used in here, but it. Complicated fast because
* we would need to be referring over to the menubar adapter to fill in the menu items.
* else if(item is ChoiceGroup)
{
if(((ChoiceGroup)item).IsSubmenu)
{
string label = item.Label.Replace("_", "&");
CommandBarMenu submenu = new CommandBarMenu(label);// menu.Items.AddMenu(label);
toolbar.Items.Add(submenu);
submenu.Tag = item;
item.ReferenceWidget = submenu;
//submenu.IsEnabled= true;
//the drop down the event seems to be ignored by the submenusof this package.
//submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay);
//therefore, we need to populate the submenu right now and not wait
((ChoiceGroup)item).OnDisplay(this, null);
//this was enough to make the menu enabled, but not enough to trigger the drop down event when chosen
//submenu.Items.Add(new CommandBarSeparator());
}
// else if(((ChoiceGroup)item).IsInlineChoiceList)
// {
// ((ChoiceGroup)item).PopulateNow();
// foreach(ChoiceRelatedClass inlineItem in ((ChoiceGroup)item))
// {
// Debug.Assert(inlineItem is ChoiceBase, "It should not be possible for a in line choice list to contain anything other than simple items!");
// menu.Items.Add(CreateMenuItem ((ChoiceBase)inlineItem));
// }
// }
}
*/ }
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:61,代码来源:ReBarAdapter.cs
示例10: ListPropertyChoice
static bool m_fHandlingClick = false; // prevent multiple simultaneous OnClick operations.
#endregion Fields
#region Constructors
public ListPropertyChoice( Mediator mediator, ListItem listItem, IUIAdapter adapter, ChoiceGroup parent)
: base(mediator, adapter, parent)
{
m_listItem = listItem;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:11,代码来源:Choice.cs
示例11: CommandChoice
/// <summary>
///
/// </summary>
/// <param name="mediator"></param>
/// <param name="listSet"></param>
/// <param name="configurationNode"></param>
/// <param name="adapter"></param>
/// <param name="parent"></param>
public CommandChoice( Mediator mediator, XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
: base(mediator, configurationNode, adapter, parent)
{
m_idOfCorrespondingCommand = XmlUtils.GetAttributeValue(m_configurationNode, "command");
StringTable tbl = null;
if (mediator != null && mediator.HasStringTable)
tbl = mediator.StringTbl;
m_defaultLabelOverride = XmlUtils.GetLocalizedAttributeValue(tbl,
m_configurationNode, "label", null);
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:18,代码来源:Choice.cs
示例12: ChoiceBase
public ChoiceBase( Mediator mediator, IUIAdapter adapter, ChoiceGroup parent)
: base(mediator, adapter,null)
{
m_parent = parent;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:5,代码来源:Choice.cs
示例13: CreateUIForChoiceGroup
/// <summary>
/// Populate a main menu, directly contained by the menubar.
/// This is called by the OnDisplay() method of some ChoiceGroup
/// </summary>
/// <param name="group">The group that is the basis for this menu</param>
public void CreateUIForChoiceGroup (ChoiceGroup group)
{
MenuItem menu = (MenuItem) group.ReferenceWidget;
menu.MenuItems.Clear();
foreach(ChoiceRelatedClass item in group)
{
if(item is ChoiceBase)
CreateControlWidget (menu, (ChoiceBase)item);
//if this is a submenu
else if(item is ChoiceGroup)
{
MakeMenu (menu, (ChoiceGroup)item);
//Notice that we do not need to populate this menu now; it will be populated when its contents are displayed.
//NO! PopulateMenu(group);
}
}
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:23,代码来源:MenuAdapter.cs
示例14: FillToolbar
/// <summary>
/// returns true if it made any changes.
/// </summary>
private void FillToolbar(ChoiceGroup choiceGroup, ToolStrip toolStrip)
{
bool wantsSeparatorBefore = false;
choiceGroup.PopulateNow();
if (!DoesToolStripNeedRegenerating(choiceGroup, toolStrip))
return;
// Don't let the GC run dispose.
for(int i = toolStrip.Items.Count - 1; i >= 0; --i)
{
toolStrip.Items[i].Dispose();
}
toolStrip.Items.Clear();
foreach(ChoiceRelatedClass item in choiceGroup)
{
if(item is SeparatorChoice)
{
wantsSeparatorBefore = true;
}
else if (item is ChoiceBase)
{
UIItemDisplayProperties displayProperties = item.GetDisplayProperties();
bool reallyVisible;
ToolStripItem toolStripItem = CreateButtonItem(item as ChoiceBase, out reallyVisible);
//toolStripItem.ToolTipText = item.Label; // TODO-Linux: add shortcut accessolrator here. // choiceBase.Shortcut. //maybe this should be done by CreateButtonItem?
toolStripItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
if (wantsSeparatorBefore && displayProperties != null && displayProperties.Visible)
{
var separator = new ToolStripSeparator();
separator.AccessibilityObject.Name = "separator";
// separator.GetType().Name;
toolStrip.Items.Add(separator);
}
wantsSeparatorBefore = false;
toolStrip.Items.Add(toolStripItem);
}
else if (item is ChoiceGroup)
{
ToolStripComboBox toolStripItem = CreateComboBox(item as ChoiceGroup, true);
toolStrip.Items.Add(toolStripItem);
}
else
{
//debugging
continue;
}
}
toolStrip.PerformLayout();
return;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:65,代码来源:ToolbarAdapter.cs
示例15: DoesToolStripNeedRegenerating
/// <summary>
/// The ToolStrip is out of date if it doesn't match the ChoiceGroup
/// eg. are the number of visible items different?
///
/// A better way of doing this would be asking the choiceGroup if it has changed
/// or deep coping storing the choicegroup and caching it in the UI adapter, then
/// comparing the difference.
/// </summary>
/// <returns>
/// Returns true if the ToolStrip is out of date.
/// </returns>
private bool DoesToolStripNeedRegenerating(ChoiceGroup choiceGroup, ToolStrip toolStrip)
{
if (m_fullRengenerateRequired)
{
m_fullRengenerateRequired = false;
return true;
}
if (toolStrip == null)
return true;
int counter = 0;
foreach(ChoiceRelatedClass item in choiceGroup)
{
UIItemDisplayProperties displayProperties = null;
if (item is SeparatorChoice == false)
displayProperties = item.GetDisplayProperties();
// toolStrip has less items then visiable items in the ChoiceGroup so regenerate
if (toolStrip.Items.Count <= counter)
return true;
// skip over seperators
// Note: sepeartors contained in the ChoiceGroup are only always added to the ToolStrip
// if they are followed by a visiable non sepeartor item.
// So a missing sepeartor doesn't necessary mean the toolbar needs regenerating.
if (displayProperties == null)
{
if (toolStrip.Items[counter] is ToolStripSeparator)
{
counter++;
}
continue;
}
// InVisible items are not added to the toolStrip
//if (displayProperties.Visible == false)
// continue;
var toolStripItem = toolStrip.Items[counter];
if (displayProperties.Enabled != toolStripItem.Enabled)
return true;
// if the text doesn't match then needs regenerating
// TODO duplicating Text.Replace here and in (CreateButtonItem)BarAdapterBase.cs is a bit horrible.
if (item is ChoiceGroup)
{
ChoiceGroup group = item as ChoiceGroup;
group.PopulateNow();
string groupPropValue = group.SinglePropertyValue;
foreach (ChoiceRelatedClass candidate in group)
{
if (candidate is SeparatorChoice)
{
//TODO
}
else if (candidate is ChoiceBase)
{
if (groupPropValue == (candidate as ListPropertyChoice).Value)
{
if (candidate.ToString() != toolStripItem.Text)
return true;
}
}
}
// This handles displaying a blank value in the toolbar Styles combobox when
// the selection covers multiple Style settings. Without it, the last valid
// style setting is still shown when the selection is extended to include
// another style. See FWR-824.
if (groupPropValue == displayProperties.Text &&
displayProperties.Text != toolStripItem.Text)
{
return true;
}
}
else
{
if (displayProperties.Text.Replace("_", "&") != toolStripItem.Text)
return true;
}
counter++;
}
// nothing has been detected that needs changing.
return false;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:98,代码来源:ToolbarAdapter.cs
示例16: FillTreeNodes
/// <summary>
/// Add the nodes to the tree.
/// </summary>
/// <remarks>The first time this is called, the group will be the
/// maikn element of the sidebar.
/// It will then be called recursively for each node that contains other nodes.</remarks>
/// <param name="nodes">Collections of tree view nodes.</param>
/// <param name="group">Definition of current set of nodes.</param>
protected void FillTreeNodes(TreeNodeCollection nodes, ChoiceGroup group)
{
if (nodes.Count > 0)//hack...without this, we were losing expansion during OnIdle()
return;
nodes.Clear();
group.PopulateNow();
foreach(ChoiceRelatedClass item in group)
{
TreeNode node = MakeTreeNode(item);
nodes.Add(node);
if (item is ChoiceGroup)
FillTreeNodes(node.Nodes, (ChoiceGroup)item);
}
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:22,代码来源:SidebarAdapter.cs
示例17: FillCombo
/// <summary>
/// populate a combo box on the toolbar
/// </summary>
/// <param name="choice">The group that is the basis for this combo box.</param>
private void FillCombo(ChoiceGroup choice)
{
UIItemDisplayProperties groupDisplay = choice.GetDisplayProperties();
ToolStripComboBox combo = choice.ReferenceWidget as ToolStripComboBox;
if (combo.Focused)
return;//don't mess while we're in the combo
// Disable if needed, but still show what's current, as for unicode fields where you can't change it, but you want to see what it is set to.
combo.Enabled = groupDisplay.Enabled;
ArrayList newItems = new ArrayList();
bool fDifferent = false;
var selectedItem = (ChoiceBase) null;
foreach (ChoiceRelatedClass item in choice)
{
if (item is SeparatorChoice)
{
//TODO
}
else if (item is ChoiceBase)
{
newItems.Add(item);
//if (groupDisplay.Checked)
// selectedItem = (ChoiceBase) item;
if (choice.SinglePropertyValue == (item as ListPropertyChoice).Value)
selectedItem = (ChoiceBase) item;
if (combo.Items.Count < newItems.Count || combo.Items[newItems.Count - 1] != item)
fDifferent = true;
}
}
// let it take the default
// combo.AccessibleName = choice.Label;
if (fDifferent || selectedItem != (combo.SelectedItem))
{
//combo.Click -= new EventHandler(OnComboClick); //don't generate clicks (which end up being onpropertychanged() calls)
combo.Items.Clear();
combo.Items.AddRange(newItems.ToArray());
combo.DropDownStyle = ComboBoxStyle.DropDownList;
combo.SelectedItem = selectedItem;
//combo.SuspendLayout = false;
}
////Set the ComboWidth of the combo box so that is is wide enough to show
////the text of all items in the list.
//int maxStringLength = 0;
//for (int i = 0; i < combo.Items.Count; i++)
//{
// if (combo.Items[i].ToString().Length > maxStringLength)
// {
// maxStringLength = combo.Items[i].ToString().Length;
// }
//}
//int factor = 6;
//if (maxStringLength > 0 && combo.ComboWidth < maxStringLength * factor)
// combo.ComboWidth = maxStringLength * factor;
//combo.Tooltip = combo.ToString();
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:70,代码来源:BarAdapterBase.cs
示例18: MakeListPropertyChoice
/// <summary>
/// find the matching list and list item referred to buy this note, and create a ListPropertyChoice
/// to access that item. This is used in the special case where we want a toolbar button or two
/// instead of showing every item in the list.
/// </summary>
/// <param name="mediator"></param>
/// <param name="configurationNode"></param>
/// <param name="adapter"></param>
/// <returns></returns>
public static StringPropertyChoice MakeListPropertyChoice(Mediator mediator, XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
{
//string listId=XmlUtils.GetAttributeValue(configurationNode, "list", "");
// ListItem item = new ListItem();
// item.label = "xxxxxx";
// item.value = XmlUtils.GetAttributeValue(configurationNode, "value", "");
// item.imageName = XmlUtils.GetAttributeValue(configurationNode, "icon", "default");
//item.parameterNode = parameterNode;
return new StringPropertyChoice(mediator,configurationNode, adapter, parent);
// if(li!=null)
// return new ListPropertyChoice( mediator, li, adapter, parent);
// else
// throw new ConfigurationException ("Could not find the list item for '"+val+"' in a list with the id '"+listId+"'.",configurationNode);
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:24,代码来源:Choice.cs
示例19: QueryDisplayProperties
/// <summary>
///
/// </summary>
/// <param name="group">This provides more context for colleagues to know whether to add a command to a menu.
/// colleagues who want to support short-cut keys should be able to handle <c>null</c>, apart from a context menu group.</param>
/// <param name="mediator"></param>
/// <param name="command"></param>
/// <param name="defaultVisible"></param>
/// <param name="label"></param>
/// <returns></returns>
private static UIItemDisplayProperties QueryDisplayProperties(ChoiceGroup group, Mediator mediator, Command command, bool defaultVisible, string label)
{
// Let the default be that it is enabled if we know that it has
//at least one potential receiver, based on the method signatures of the
//current set of colleagues.
//If one of those colleagues thinks that it should be disabled at the moment,
//then it needs to implement the corresponding Display method
//and disable it from there.
bool hasReceiver = mediator.HasReceiver(command.MessageString);
UIItemDisplayProperties display = new UIItemDisplayProperties(group, label, hasReceiver, command.IconName, defaultVisible);
//OK, this is a little non-obvious
//first we allow anyone who knows about this specific command to influence how it is displayed
//why was it this way? m_mediator.SendMessage("Display"+this.m_idOfCorrespondingCommand, CommandObject, ref display);
mediator.SendMessage("Display" + command.Id, command, ref display);
//but then, we also allow anyone who knows about this specific message that would be sent
//to control how it is displayed. What's the difference?
//Well, it is not uncommon for a single message, e.g. "InsertRecord", to be associated with
//multiple commands, e.g. "CmdInsertPersonRecord", "CmdInsertCompanyRecord".
//And in this case, there may not be any actual code which knows about one of these commands,
//instead the code may be written to just listen for the "InsertRecord" message and then act
//upon its arguments which, in this example, would cause it to either insert a person or a company.
mediator.SendMessage("Display" + command.MessageString, command, ref display);
return display;
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:36,代码来源:Choice.cs
示例20: ShowContextMenu
/// <summary>
///
/// </summary>
/// <param name="group"></param>
/// <param name="location"></param>
/// <param name="temporaryColleagueParam"></param>
/// <param name="sequencer"></param>
public void ShowContextMenu(ChoiceGroup group, Point location,
TemporaryColleagueParameter temporaryColleagueParam,
MessageSequencer sequencer)
{
// Store optional parameter values.
m_TemporaryColleagueParameter = temporaryColleagueParam; // Nulls are just fine.
// TODO-Linux FWNX-345: Review - don't use TemporaryColleague's
// This needs to be done before PopulateNow
if (m_TemporaryColleagueParameter != null)
m_TemporaryColleagueParameter.Mediator.AddTemporaryColleague(m_TemporaryColleagueParameter.TemporaryColleague);
// item is used in calling CreateUIForChoiceGroup to attach the choiceGroup
// menu items to. It is not added to the shown contextMenu.
ToolStripMenuItem item = new ToolStripMenuItem();
item.AccessibilityObject.Name = group.Id;
//item.GetType().Name;
item.Tag = group;
group.ReferenceWidget = item;
group.PopulateNow();
CreateUIForChoiceGroup(group);
// NOTE: we intentionally leave contextMenu undisposed. If we dispose it after
// contextMenu.Show then the mouse clicks on the menu items don't get handled.
// We would have to add an Application.DoEvents() after the Show (which might
// causes other problems), or implement IDisposable.
var contextMenu = new ContextMenuStrip();
contextMenu.AccessibilityObject.Name = group.Id;
// Without building this collection first, somehow we modify the Items collection while
// iterating.
var items = new System.Collections.Generic.List<ToolStripItem>();
foreach (var menuItem in item.DropDown.Items)
{
if (menuItem is ToolStripMenuItem )
items.Add(menuItem as ToolStripMenuItem);
else if ( menuItem is ToolStripButton)
items.Add(menuItem as ToolStripButton);
else if (menuItem is ToolStripSeparator)
items.Add(menuItem as ToolStripSeparator);
}
foreach (var menuItem in items)
{
contextMenu.Items.Add(menuItem);
}
MakeAcceleratorsVisible(contextMenu);
contextMenu.Show(location);
}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:55,代码来源:MenuAdapter.cs
注:本文中的XCore.ChoiceGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论