本文整理汇总了C#中XCore.ChoiceGroup.PopulateNow方法的典型用法代码示例。如果您正苦于以下问题:C# ChoiceGroup.PopulateNow方法的具体用法?C# ChoiceGroup.PopulateNow怎么用?C# ChoiceGroup.PopulateNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.ChoiceGroup
的用法示例。
在下文中一共展示了ChoiceGroup.PopulateNow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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);
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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_temporaryColleagueParam = temporaryColleagueParam; // Nulls are just fine.
m_sequencer = sequencer; // Nulls are just fine.
// TODO-Linux FWNX-345: Review - don't use TemporaryColleague's
// This needs to be done before PopulateNow
if (m_temporaryColleagueParam != null)
m_temporaryColleagueParam.Mediator.AddTemporaryColleague(m_temporaryColleagueParam.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.Tag = group;
group.ReferenceWidget = item;
group.PopulateNow();
CreateUIForChoiceGroup(group);
var contextMenu = new ContextMenuStrip();
foreach(ToolStripMenuItem menuItem in item.DropDown.Items)
{
contextMenu.Items.Add(menuItem as ToolStripMenuItem);
}
contextMenu.Show(location);
}