本文整理汇总了C#中ListBox.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.AddItem方法的具体用法?C# ListBox.AddItem怎么用?C# ListBox.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListBox
的用法示例。
在下文中一共展示了ListBox.AddItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
//LISTBOX TEST
some_list = new ListBox(new Rect(10, 20, 110, 150), new Rect(0, 0, 90, 150), false, true);
some_list.AddItem("Text 1");
some_list.AddItem("Text 2");
some_list.AddItem("Text 3");
some_list.AddItem("Text 4");
some_list.InsertItem(2, icon);
//-------------
}
示例2: Initialize
public override void Initialize()
{
base.Initialize();
ListBox descriptions = new ListBox((int)Preferences.Width, 200);
descriptions.AddItem(new ListItem("Electronic Gadget"));
descriptions.AddItem(new ListItem("Plastic Guy"));
descriptions.AddItem(new ListItem("I-beleive-have-a-laser"));
descriptions.AddItem(new ListItem("My-helment-is-a-fishbowl"));
descriptions.AddItem(new ListItem("I-have-sort-of-wings"));
descriptions.AddItem(new ListItem("To-the-infinity-and-beyond"));
descriptions.AddItem(new ListItem("I-am-the-Andy's-second"));
AddComponent(descriptions, 0, 0);
}
示例3: Load
protected override void Load(EntityGUI.GUIFactory factory)
{
var font = this.Resourses.LoadAsset<Font>("Fonts\\Metro.fnt");
var bigfont = this.Resourses.LoadAsset<Font>("Fonts\\BigMetro.fnt");
this.Panel.BackgroundColor = Color.Black;
//Creates a textbox with maxlength 20
TextBox textBox0 = new TextBox(font, "", 20);
textBox0.Position = new OpenTK.Vector2(50, 50);
//It should be noted that a textbox height is always font.size + padding.y + padding.h since it would
//i did it this way since a textbox of any other height would look bad.
textBox0.Size = new OpenTK.Vector2(200, 20);
//A hint is displayed if the textbox is empty.
textBox0.Hint = "20 char text field!";
this.Panel.AddControl(textBox0);
//Creates a textbox with unlimited length.
TextBox textBox1 = new TextBox(font, "");
textBox1.BackgroundColor = Color.White;
textBox1.TextColor = Color.Red;
textBox1.Position = new OpenTK.Vector2(50, textBox0.Bounds.Bottom + 10);
textBox1.Size = new OpenTK.Vector2(200, 20);
textBox1.Hint = "Unlimited textbox.";
this.Panel.AddControl(textBox1);
//Creates a textbox with custom colors.
TextBox textBox2 = new TextBox(font, "");
textBox2.BackgroundColor = Color.Green;
textBox2.TextColor = Color.Gold;
textBox2.SelectedColor = Color.Red;
textBox2.HintColor = Color.RosyBrown;
textBox2.Position = new OpenTK.Vector2(50, textBox1.Bounds.Bottom + 10);
textBox2.Size = new OpenTK.Vector2(200, 20);
textBox2.Hint = "Unlimited textbox 2.";
this.Panel.AddControl(textBox2);
TextBox textBox3 = new TextBox(bigfont, "", 20);
textBox3.Position = new OpenTK.Vector2(50, textBox2.Bounds.Bottom + 10);
textBox3.Size = new OpenTK.Vector2(300, 20);
textBox3.Hint = "Unlimited textbox 2.";
this.Panel.AddControl(textBox3);
//Create a numberbox startvalue 100 min 0 max 255
NumberBox numberBox0 = new NumberBox(font, 100, byte.MinValue, byte.MaxValue);
numberBox0.Position = new OpenTK.Vector2(50, textBox3.Bounds.Bottom + 10);
numberBox0.Size = new OpenTK.Vector2(200, 20);
this.Panel.AddControl(numberBox0);
TextArea area = new TextArea(font);
area.Position = new OpenTK.Vector2(textBox3.Bounds.Right + 20, 50);
area.Size = new OpenTK.Vector2(400, 300);
area.Text = "This is a text area! This is not fully implemented! Yes true it is.";
this.Panel.AddControl(area);
ListBox<int> numbers = new ListBox<int>(font);
numbers.Position = new OpenTK.Vector2(area.Bounds.Right + 20, 50);
numbers.Size = new OpenTK.Vector2(400, 300);
for (int i = 0; i < 20; i++)
{
numbers.AddItem(i);
}
this.Panel.AddControl(numbers);
}
示例4: Initialize
public static void Initialize()
{
#region menu setup
menuLabel = new Text(P._Canvas);
menuLabel.SetPos(128, 28);
menuLabel.Font = P.GuiFontLarge;
menuLabel.String = "Books";
menu = new ListBox(P._Canvas);
foreach (Book b in activeBooks)
{
activeBookItems.Add(menu.AddItem(b.title));
}
menu.EnableScroll(true, true);
menu.SetSize(160, 2*P.ScreenSize.Y/3 - 36);
menu.SetPos(128,48);
menu.MouseInputEnabled = true;
for (int i = 0; i < activeBookItems.Count; i++)
{
activeBookItems[i].OnRowSelected += new Base.ControlCallback(Book_OnRowSelected);
activeBookItems[i].SetTextColor(System.Drawing.Color.Gray);
}
#endregion
bookTitle = new Text(P._Canvas);
bookTitle.String = "";
bookTitle.SetPos(300, 40);
bookTitle.Font = P.GuiFontLarge;
authorText = new Text(P._Canvas);
authorText.String = "";
authorText.SetPos(300, 64);
statusText = new Text(P._Canvas);
statusText.SetPos(300, 80);
statusText.String = "";
publishingProgress = new ProgressBar(P._Canvas);
publishingProgress.Value = 0;
publishingProgress.SetBounds(300, P.ScreenSize.Y/3-16, 200, 16);
publishingProgress.Hide();
GameManager.BookPageItems.Add(menuLabel);
GameManager.BookPageItems.Add(menu);
GameManager.BookPageItems.Add(bookTitle);
GameManager.BookPageItems.Add(authorText);
GameManager.BookPageItems.Add(publishingProgress);
GameManager.BookPageItems.Add(statusText);
}
示例5: InitLayerSettingsWindow
protected void InitLayerSettingsWindow()
{
LayerSettingsWindow = new Window(UI.GetInterface(Name), null, "Settings", TextOrientation.Center, Vector2.Zero, new Vector2(712, 500), true, false, false, false);
LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Layer Name", 14, TextOrientation.Left, new Vector2(10, 10), new Vector2(200, 25), Color.Black, Color.Transparent));
LayerSettingsWindow.AddElement(new TextBox(UI.GetInterface(Name), layerName, 14, 20, new Vector2(10, 40), new Vector2(200, 25), Color.Black, Color.White, origin, Color.Black));
LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Available Traits", 14, TextOrientation.Left, new Vector2(10, 80), new Vector2(200, 50), Color.Black, Color.Transparent));
LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Contained Traits", 14, TextOrientation.Left, new Vector2(400, 80), new Vector2(200, 50), Color.Black, Color.Transparent));
LayerSettingsWindow.AddElement(new Button(UI.GetInterface(Name), ">", 24, TextOrientation.Center, new Vector2(330, 230), new Vector2(50, 50), origin, hover, pressed));
LayerSettingsWindow.AddElement(new Button(UI.GetInterface(Name), "<", 24, TextOrientation.Center, new Vector2(330, 290), new Vector2(50, 50), origin, hover, pressed));
ListBox a = new ListBox(UI.GetInterface(Name), 14, TextOrientation.Left, new Vector2(10, 110), new Vector2(300, 350), Color.Black, Color.White, origin, hover);
ListBox b = new ListBox(UI.GetInterface(Name), 14, TextOrientation.Left, new Vector2(400, 110), new Vector2(300, 350), Color.Black, Color.White, origin, hover);
LayerSettingsWindow.AddElement(a);
LayerSettingsWindow.AddElement(b);
availableTraits.Add("Affects Movement Speed");
availableTraits.Add("Cast Shadow");
availableTraits.Add("Collision");
availableTraits.Add("Function Layer");
availableTraits.Add("Transparent");
availableTraits.Add("Stainable");
availableTraits.Add("Projectile Collision");
availableTraits.Add("NPC Collision");
availableTraits.Add("Item Collision");
a.AddItem(availableTraits[0]);
a.AddItem(availableTraits[1]);
a.AddItem(availableTraits[2]);
a.AddItem(availableTraits[3]);
a.AddItem(availableTraits[4]);
a.AddItem(availableTraits[5]);
a.AddItem(availableTraits[6]);
a.AddItem(availableTraits[7]);
a.AddItem(availableTraits[8]);
(LayerSettingsWindow[1] as TextBox).TextChanged += (sender) =>
{
TextBox tb = sender as TextBox;
if (tb.Text != "")
layerName = tb.Text;
};
LayerSettingsWindow[4].Clicked += (sender) =>
{
if (a.SelectedItems.Count > 0)
{
for (int i = 0; i < a.SelectedItems.Count; i++)
{
b.AddItem(a.SelectedItems[i]);
}
a.RemoveSelectedItems();
}
};
LayerSettingsWindow[5].Clicked += (sender) =>
{
if (b.SelectedItems.Count > 0)
{
for (int i = 0; i < b.SelectedItems.Count; i++)
{
a.AddItem(b.SelectedItems[i]);
}
b.RemoveSelectedItems();
}
};
LayerSettingsWindow.Open(new Vector2(Game1.ScreenWidth / 2.0f - LayerSettingsWindow.Size.X / 2.0f, Game1.ScreenHeight / 2.0f - LayerSettingsWindow.Size.Y / 2.0f));
}