本文整理汇总了C#中Label.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Label.Init方法的具体用法?C# Label.Init怎么用?C# Label.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Label
的用法示例。
在下文中一共展示了Label.Init方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExitDialog
////////////////////////////////////////////////////////////////////////////
public ExitDialog(Manager manager)
: base(manager, DialogPanelsVisible.BothPanels)
{
string msg = "Do you really want to exit " + Manager.Game.Window.Title + "?";
ClientWidth = (int)Manager.Skin.Controls["Label"].Layers[0].Text.Font.Resource.MeasureString(msg).X + 48 + 16 + 16 + 16;
ClientHeight = 120;
TopPanel.Visible = false;
IconVisible = true;
Resizable = false;
Text = Manager.Game.Window.Title;
Center();
imgIcon = new ImageBox(Manager);
imgIcon.Init();
imgIcon.Image = Manager.Skin.Images["Icon.Question"].Resource;
imgIcon.Left = 16;
imgIcon.Top = 16;
imgIcon.Width = 48;
imgIcon.Height = 48;
imgIcon.SizeMode = SizeMode.Stretched;
lblMessage = new Label(Manager);
lblMessage.Init();
lblMessage.Left = 80;
lblMessage.Top = 16;
lblMessage.Width = ClientWidth - lblMessage.Left;
lblMessage.Height = 48;
lblMessage.Alignment = Alignment.TopLeft;
lblMessage.Text = msg;
btnYes = new Button(Manager);
btnYes.Init();
btnYes.Left = (BottomPanel.ClientWidth / 2) - btnYes.Width - 4;
btnYes.Top = 8;
btnYes.Text = "Yes";
btnYes.ModalResult = ModalResult.Yes;
btnNo = new Button(Manager);
btnNo.Init();
btnNo.Left = (BottomPanel.ClientWidth / 2) + 4;
btnNo.Top = 8;
btnNo.Text = "No";
btnNo.ModalResult = ModalResult.No;
Add(imgIcon);
Add(lblMessage);
BottomPanel.Add(btnYes);
BottomPanel.Add(btnNo);
DefaultControl = btnNo;
}
示例2: Initialize
public override void Initialize() {
base.Initialize();
mDialog = new Window(WindowManager);
mDialog.Init();
mDialog.Width = mWidth;
mDialog.Height = mHeight;
mDialog.Text = mTitle;
mDialog.Visible = true;
mDialog.Resizable = false;
mDialog.Closed += new WindowClosedEventHandler(mDialog_Closed);
Label lbl = new Label(WindowManager);
lbl.Init();
lbl.Width = mDialog.ClientWidth - 10;
lbl.Height = mDialog.ClientHeight - 40;
lbl.Left = 5;
lbl.Top = 5;
lbl.Text = mMessage;
lbl.Alignment = EAlignment.TopCenter;
mDialog.Add(lbl);
Panel pnl = new Panel(WindowManager);
pnl.Height = 40;
pnl.Top = mDialog.ClientHeight - pnl.Height;
pnl.BevelBorder = EBevelBorder.Top;
pnl.BevelMargin = 1;
pnl.BackColor = new Color(16, 16, 16);
pnl.Anchor = EAnchors.Bottom | EAnchors.Horizontal;
pnl.Width = mDialog.ClientWidth;
mDialog.Add(pnl);
/*
* wont work oO
Button btnOK = new Button( WindowManager );
btnOK.Init();
//btnOK.Width = 20;
btnOK.Height = 24;
btnOK.Text = "OK";
btnOK.Click += new WindowLibrary.Controls.EventHandler( btnOK_Click );
pnl.Controls.Add( btnOK );
*/
AddWindow(mDialog);
}
示例3: Dialog
/// <summary>
/// Creates a new dialog window.
/// </summary>
/// <param name="manager">GUI manager for the dialog window.</param>
public Dialog(Manager manager)
: base(manager)
{
// Create the top panel control.
pnlTop = new Panel(manager);
pnlTop.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
pnlTop.Init();
pnlTop.Parent = this;
pnlTop.Width = ClientWidth;
pnlTop.Height = 64;
pnlTop.BevelBorder = BevelBorder.Bottom;
// Create the caption label and add it to the top panel.
lblCapt = new Label(manager);
lblCapt.Init();
lblCapt.Parent = pnlTop;
lblCapt.Width = lblCapt.Parent.ClientWidth - 16;
lblCapt.Text = "Caption";
lblCapt.Left = 8;
lblCapt.Top = 8;
lblCapt.Alignment = Alignment.TopLeft;
lblCapt.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
// Create the description label and add it to the top panel.
lblDesc = new Label(manager);
lblDesc.Init();
lblDesc.Parent = pnlTop;
lblDesc.Width = lblDesc.Parent.ClientWidth - 16;
lblDesc.Left = 8;
lblDesc.Text = "Description text.";
lblDesc.Alignment = Alignment.TopLeft;
lblDesc.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
// Create the bottom panel control.
pnlBottom = new Panel(manager);
pnlBottom.Init();
pnlBottom.Parent = this;
pnlBottom.Width = ClientWidth;
pnlBottom.Height = 24 + 16;
pnlBottom.Top = ClientHeight - pnlBottom.Height;
pnlBottom.BevelBorder = BevelBorder.Top;
pnlBottom.Anchor = Anchors.Left | Anchors.Bottom | Anchors.Right;
}
示例4: Dialog
public Dialog(Manager manager)
: base(manager) {
pnlTop = new Panel(manager);
pnlTop.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
pnlTop.Init();
pnlTop.Parent = this;
pnlTop.Width = ClientWidth;
pnlTop.Height = 64;
pnlTop.BevelBorder = EBevelBorder.Bottom;
lblCapt = new Label(manager);
lblCapt.Init();
lblCapt.Parent = pnlTop;
lblCapt.Width = lblCapt.Parent.ClientWidth - 16;
lblCapt.Text = "Caption";
lblCapt.Left = 8;
lblCapt.Top = 8;
lblCapt.Alignment = EAlignment.TopLeft;
lblCapt.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
lblDesc = new Label(manager);
lblDesc.Init();
lblDesc.Parent = pnlTop;
lblDesc.Width = lblDesc.Parent.ClientWidth - 16;
lblDesc.Left = 8;
lblDesc.Text = "Description text.";
lblDesc.Alignment = EAlignment.TopLeft;
lblDesc.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
pnlBottom = new Panel(manager);
pnlBottom.Init();
pnlBottom.Parent = this;
pnlBottom.Width = ClientWidth;
pnlBottom.Height = 24 + 16;
pnlBottom.Top = ClientHeight - pnlBottom.Height;
pnlBottom.BevelBorder = EBevelBorder.Top;
pnlBottom.Anchor = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
}
示例5: UpdateDisplayedFps
private static void UpdateDisplayedFps()
{
if (fps_display == null || fps_display.Manager != GnomanEmpire.Instance.GuiManager.Manager)
{
/*
var r = new Random();
var s = 4096 * 2;
//var s = 4096;
var tex = new Microsoft.Xna.Framework.Graphics.Texture2D(GnomanEmpire.Instance.GraphicsDevice, s, s, false, Microsoft.Xna.Framework.Graphics.SurfaceFormat.Color);
tex.SetData(Enumerable.Repeat(1, s * s).Select(foo => new Color(r.Next(256), r.Next(256), r.Next(256))).ToArray());
*/
fps_display = new Label(GnomanEmpire.Instance.GuiManager.Manager);
fps_display.Init();
fps_display.Anchor = Anchors.Bottom | Anchors.Left;
fps_display.Width = 250;
fps_display.Height = 25;
fps_display.Top = GnomanEmpire.Instance.GuiManager.Manager.ScreenHeight - fps_display.Height;
fps_display.Left = 10;
//fps_display.Color = ;
fps_display.TextColor = Color.LightGreen;
/*fps_display.Draw += new DrawEventHandler((sender, args) =>
{
args.Renderer.SpriteBatch.Draw(tex, Vector2.Zero, Color.White);
});*/
GnomanEmpire.Instance.GuiManager.Add(fps_display);
}
fps_display.Text = shortRec.Text + " FPS (" + longRec.Text + " avg)";
}
示例6: AboutModsPanel
public AboutModsPanel(Panel containingPanel, IModManager modManager, int desiredHeight = 500, int desiredWidth = 750)
{
_modManager = modManager;
ModListBox = new ListBox(containingPanel.Manager);
ModListBox.Init();
ModListBox.Top = ModListBox.Margins.Top;
ModListBox.Left = ModListBox.Margins.Left;
ModListBox.Width = 250;
ModListBox.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModListBox.Top - ModListBox.Margins.Bottom;
ModListBox.HideSelection = false;
ModListBox.c81fb310624c15a101535d14adc9ec383.Add("Gnomodia");
ModListBox.ItemIndexChanged += ModListBoxOnItemIndexChanged;
foreach (var modMetadata in modManager.ModMetadata)
{
ModListBox.c81fb310624c15a101535d14adc9ec383.Add(modMetadata.Name);
}
containingPanel.Add(ModListBox);
ModInfoPanel = new LoweredPanel(containingPanel.Manager);
ModInfoPanel.Init();
ModInfoPanel.Left = ModListBox.Left + ModListBox.Width + ModListBox.Margins.Right + ModInfoPanel.Margins.Left;
ModInfoPanel.Top = ModInfoPanel.Margins.Top;
ModInfoPanel.Width = desiredWidth - ModInfoPanel.Left - ModInfoPanel.Margins.Right;
ModInfoPanel.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModInfoPanel.Top - ModInfoPanel.Margins.Bottom;
ModInfoPanel.AutoScroll = true;
ModInfoPanel.HorizontalScrollBarEnabled = false;
ModInfoPanel.VerticalScrollBarShow = true;
containingPanel.Add(this.ModInfoPanel);
_titleLabel = new Label(containingPanel.Manager);
_titleLabel.Init();
_titleLabel.Top = _titleLabel.Margins.Top;
_titleLabel.Left = _titleLabel.Margins.Left;
_titleLabel.Height = 14;
_titleLabel.Width = ModInfoPanel.ClientWidth - _titleLabel.Margins.Horizontal;
_titleLabel.Text = "";
ModInfoPanel.Add(_titleLabel);
_versionLabel = new Label(containingPanel.Manager);
_versionLabel.Init();
_versionLabel.Left = _versionLabel.Margins.Left;
_versionLabel.Height = 14;
_versionLabel.Width = ModInfoPanel.Width - _versionLabel.Margins.Horizontal;
_versionLabel.Top = _titleLabel.Top + _titleLabel.Height + _titleLabel.Margins.Bottom + _versionLabel.Margins.Top;
_versionLabel.Text = "";
ModInfoPanel.Add(_versionLabel);
_authorLabel = new Label(containingPanel.Manager);
_authorLabel.Init();
_authorLabel.Left = _authorLabel.Margins.Left;
_authorLabel.Height = 14;
_authorLabel.Width = ModInfoPanel.Width - _authorLabel.Margins.Horizontal;
_authorLabel.Top = _versionLabel.Top + _versionLabel.Height + _versionLabel.Margins.Bottom + _authorLabel.Margins.Top;
_authorLabel.Text = "";
ModInfoPanel.Add(_authorLabel);
_infoLabel = new MultilineLabel(containingPanel.Manager);
_infoLabel.Left = _infoLabel.Margins.Left;
_infoLabel.Height = 0;
_infoLabel.Top = _authorLabel.Top + _authorLabel.Height + _authorLabel.Margins.Bottom + _infoLabel.Margins.Top;
_infoLabel.Width = ModInfoPanel.ClientWidth - _infoLabel.Margins.Horizontal;
_infoLabel.Anchor = Anchors.Top | Anchors.Left | Anchors.Right;
_infoLabel.Alignment = Alignment.TopLeft;
ModInfoPanel.Add(_infoLabel);
ModListBox.ItemIndex = 0;
}
示例7: AddMainMenuModButton
public void AddMainMenuModButton(MainMenuWindow mainMenu, Manager manager)
{
Panel buttonPanel = (Panel)MainMenuWindowPanelField.GetValue(mainMenu);
Button exitButton;
if (!buttonPanel.FindControlRecursive(out exitButton, b => b.Text == "Exit"))
return;
Button modsButton = new Button(manager);
modsButton.Init();
modsButton.Width = 200;
modsButton.Top = exitButton.Top;
modsButton.Left = (buttonPanel.Width - modsButton.Width) / 2;
modsButton.Margins = new Margins(0, 2, 0, 2);
modsButton.Text = "Mods";
buttonPanel.Height += modsButton.Height + 4;
modsButton.Click += MainMenuModsButtonClick;
buttonPanel.Add(modsButton);
exitButton.Top = modsButton.Top + modsButton.Height + modsButton.Margins.Bottom + exitButton.Margins.Top;
if (!mainMenu.FindControlRecursive(out _gnomoriaVersionLabel, l => l.Text.StartsWith("v")))
return;
_gnomoriaVersionLabel.Text = "Gnomoria " + _gnomoriaVersionLabel.Text;
_gnomodiaVersionLabel = new Label(manager);
_gnomodiaVersionLabel.Init();
_gnomodiaVersionLabel.Alignment = Alignment.MiddleRight;
_gnomodiaVersionLabel.Text = "Gnomodia v" + typeof(ModDialog).Assembly.GetInformationalVersion();
mainMenu.Add(_gnomodiaVersionLabel);
Reset(mainMenu, null, null);
}
示例8: Initialize
public override void Initialize() {
base.Initialize();
Window win = new Window(WindowManager);
win.Init();
win.Text = "Account Login";
win.Width = 350;
win.Height = 150;
win.Center();
win.Resizable = false;
win.Movable = false;
win.StayOnTop = true;
win.Shadow = false;
win.CloseButtonVisible = false;
win.IconVisible = false;
win.FocusLost += delegate(object sender, WindowLibrary.Controls.EventArgs e) {
win.Focused = true;
};
win.Visible = true;
Label lbl = new Label(WindowManager);
lbl.Init();
lbl.Parent = win;
lbl.Text = "Name";
lbl.Left = 20;
lbl.Top = 20;
win.Add(lbl);
mUsername = new TextBox(WindowManager);
mUsername.Init();
mUsername.Parent = win;
mUsername.Left = 80;
mUsername.Top = 20;
mUsername.Width = win.ClientWidth - 160;
mUsername.Focused = true;
mUsername.KeyPress += new KeyEventHandler(txt_KeyPress);
win.Add(mUsername);
lbl = new Label(WindowManager);
lbl.Init();
lbl.Parent = win;
lbl.Text = "Passwort";
lbl.Left = 20;
lbl.Top = 40;
win.Add(lbl);
mPassword = new TextBox(WindowManager);
mPassword.Init();
mPassword.Parent = win;
mPassword.Left = 80;
mPassword.Top = 40;
mPassword.Width = win.ClientWidth - 160;
mPassword.PasswordChar = '*';
mPassword.Mode = ETextBoxMode.Password;
mPassword.KeyPress += new KeyEventHandler(txt_KeyPress);
win.Add(mPassword);
mSubmitButton = new Button(WindowManager);
mSubmitButton.Init();
mSubmitButton.Parent = win;
mSubmitButton.Text = "Login";
mSubmitButton.Width = 72;
mSubmitButton.Height = 24;
mSubmitButton.Left = win.ClientWidth - 74;
mSubmitButton.Top = win.ClientHeight - 26;
mSubmitButton.Anchor = EAnchors.Bottom | EAnchors.Right;
mSubmitButton.Click += new WindowLibrary.Controls.EventHandler(mSubmitButton_Click);
win.Add(mSubmitButton);
AddWindow(win);
}
示例9: AddNews
private void AddNews(string author, string date, string title, string message, int num) {
GroupPanel newsPnl = ScreenManager.MainWindow.ClientArea.Controls["InsaneRO News"] as GroupPanel;
Panel pnl = new Panel(WindowManager);
pnl.Init();
pnl.Text = "News_" + num;
pnl.Tag = num;
pnl.Width = newsPnl.ClientWidth - 20;
pnl.Height = 210;
pnl.Left = 10;
pnl.Top = (num * 10) + (num * 210) + 10;
pnl.BevelBorder = EBevelBorder.All;
pnl.BevelMargin = 1;
pnl.BevelStyle = EBevelStyle.Flat;
pnl.Color = Color.Transparent;
pnl.Passive = true;
Label lblTitle = new Label(WindowManager);
lblTitle.Init();
lblTitle.Skin.Layers[0].Text.Font.Resource = WindowManager.Skin.Fonts[WindowManager.Skin.Controls["Dialog"].Layers["TopPanel"].Attributes["CaptFont"].Value].Resource;
lblTitle.Text = "'" + title + "' - Von " + author + " (" + date + ")";
lblTitle.TextColor = new Color(81, 172, 232);
lblTitle.Top = 5;
lblTitle.Left = 5;
lblTitle.Width = pnl.ClientWidth - 15;
lblTitle.Height = 24;
lblTitle.Alignment = EAlignment.TopLeft;
pnl.Add(lblTitle);
Label lblMessage = new Label(WindowManager);
lblMessage.Init();
lblMessage.Text = "";
lblMessage.TextLines.AddRange(message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None));
lblMessage.Top = 5 + 5 + 24;
lblMessage.Left = 10;
lblMessage.Width = pnl.ClientWidth - 20;
lblMessage.Height = pnl.ClientHeight - 15 - 24;
lblMessage.Ellipsis = false;
lblMessage.Alignment = EAlignment.TopLeft;
lblMessage.Autosize = true;
lblMessage.Draw += new DrawEventHandler(lblMessage_Draw);
pnl.Add(lblMessage);
newsPnl.Add(pnl);
}
示例10: TaskControls
public TaskControls(Manager manager)
: base(manager) {
MinimumWidth = 340;
MinimumHeight = 140;
Height = 480;
Center();
Text = "Controls Test";
TopPanel.Visible = true;
Caption.Text = "Information";
Description.Text = "Demonstration of various controls available in Window Library";
Caption.TextColor = Description.TextColor = new Color(96, 96, 96);
grpEdit = new GroupPanel(Manager);
grpEdit.Init();
grpEdit.Parent = this;
grpEdit.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
grpEdit.Width = ClientWidth - 200;
grpEdit.Height = 160;
grpEdit.Left = 8;
grpEdit.Top = TopPanel.Height + 8;
grpEdit.Text = "EditBox";
pnlControls = new Panel(Manager);
pnlControls.Init();
pnlControls.Passive = true;
pnlControls.Parent = this;
pnlControls.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right;
pnlControls.Left = 8;
pnlControls.Top = grpEdit.Top + grpEdit.Height + 8;
pnlControls.Width = ClientWidth - 200;
pnlControls.Height = BottomPanel.Top - 32 - pnlControls.Top;
pnlControls.BevelBorder = EBevelBorder.All;
pnlControls.BevelMargin = 1;
pnlControls.BevelStyle = EBevelStyle.Etched;
pnlControls.Color = Color.Transparent;
lblEdit = new Label(manager);
lblEdit.Init();
lblEdit.Parent = grpEdit;
lblEdit.Left = 16;
lblEdit.Top = 8;
lblEdit.Text = "Testing field:";
lblEdit.Width = 128;
lblEdit.Height = 16;
txtEdit = new TextBox(manager);
txtEdit.Init();
txtEdit.Parent = grpEdit;
txtEdit.Left = 16;
txtEdit.Top = 24;
txtEdit.Width = grpEdit.ClientWidth - 32;
txtEdit.Height = 20;
txtEdit.Anchor = EAnchors.Left | EAnchors.Top | EAnchors.Right | EAnchors.Bottom;
txtEdit.Text = "Text";
rdbNormal = new RadioButton(manager);
rdbNormal.Init();
rdbNormal.Parent = grpEdit;
rdbNormal.Left = 16;
rdbNormal.Top = 52;
rdbNormal.Width = grpEdit.ClientWidth - 32;
rdbNormal.Anchor = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
rdbNormal.Checked = true;
rdbNormal.Text = "Normal mode";
rdbNormal.ToolTip.Text = "Enables normal mode for TextBox control.";
rdbNormal.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(ModeChanged);
rdbPassword = new RadioButton(manager);
rdbPassword.Init();
rdbPassword.Parent = grpEdit;
rdbPassword.Left = 16;
rdbPassword.Top = 68;
rdbPassword.Width = grpEdit.ClientWidth - 32;
rdbPassword.Anchor = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
rdbPassword.Checked = false;
rdbPassword.Text = "Password mode";
rdbPassword.ToolTip.Text = "Enables password mode for TextBox control.";
rdbPassword.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(ModeChanged);
chkBorders = new CheckBox(manager);
chkBorders.Init();
chkBorders.Parent = grpEdit;
chkBorders.Left = 16;
chkBorders.Top = 96;
chkBorders.Width = grpEdit.ClientWidth - 32;
chkBorders.Anchor = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
chkBorders.Checked = false;
chkBorders.Text = "Borderless mode";
chkBorders.ToolTip.Text = "Enables or disables borderless mode for TextBox control.";
chkBorders.CheckedChanged += new GodLesZ.Library.XNA.WindowLibrary.Controls.EventHandler(chkBorders_CheckedChanged);
chkReadOnly = new CheckBox(manager);
chkReadOnly.Init();
chkReadOnly.Parent = grpEdit;
chkReadOnly.Left = 16;
chkReadOnly.Top = 110;
chkReadOnly.Width = grpEdit.ClientWidth - 32;
chkReadOnly.Anchor = EAnchors.Left | EAnchors.Bottom | EAnchors.Right;
chkReadOnly.Checked = false;
//.........这里部分代码省略.........
示例11: InitStats
private void InitStats() {
pnlStats = new SideBarPanel(Manager);
pnlStats.Init();
pnlStats.Passive = true;
pnlStats.Parent = sidebar;
pnlStats.Left = 16;
pnlStats.Width = sidebar.Width - pnlStats.Left;
pnlStats.Height = 64;
pnlStats.Top = ClientHeight - 16 - pnlStats.Height;
pnlStats.Anchor = EAnchors.Left | EAnchors.Bottom;
pnlStats.CanFocus = false;
lblObjects = new Label(Manager);
lblObjects.Init();
lblObjects.Parent = pnlStats;
lblObjects.Left = 8;
lblObjects.Top = 8;
lblObjects.Height = 16;
lblObjects.Width = pnlStats.Width - lblObjects.Left * 2;
;
lblObjects.Alignment = EAlignment.MiddleLeft;
lblAvgFps = new Label(Manager);
lblAvgFps.Init();
lblAvgFps.Parent = pnlStats;
lblAvgFps.Left = 8;
lblAvgFps.Top = 24;
lblAvgFps.Height = 16;
lblAvgFps.Width = pnlStats.Width - lblObjects.Left * 2;
lblAvgFps.Alignment = EAlignment.MiddleLeft;
lblFps = new Label(Manager);
lblFps.Init();
lblFps.Parent = pnlStats;
lblFps.Left = 8;
lblFps.Top = 40;
lblFps.Height = 16;
lblFps.Width = pnlStats.Width - lblObjects.Left * 2;
lblFps.Alignment = EAlignment.MiddleLeft;
}