当前位置: 首页>>代码示例>>C#>>正文


C# TextBox.Initialize方法代码示例

本文整理汇总了C#中TextBox.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.Initialize方法的具体用法?C# TextBox.Initialize怎么用?C# TextBox.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextBox的用法示例。


在下文中一共展示了TextBox.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoginDialog

    public LoginDialog( Game game, GUIManager guiManager, Action toExecuteOnOK, Action toExecuteOnCancel )
        : base(game, guiManager)
    {
        #region set up the name label and its text field
        Label labelName = new Label( game, guiManager );
        this.Add( labelName );
        labelName.Text = "Name:";
        labelName.X = SPACING;
        labelName.Y = SPACING;
        labelName.Width = 75;
        labelName.Height = labelName.TextHeight;
        labelName.Color = Color.White;

        // Name textbox
        textBoxName = new TextBox( game, guiManager );
        Add( this.textBoxName );
        textBoxName.Initialize();
        textBoxName.X = labelName.X;  // lined up with its label
        textBoxName.Y = labelName.Y + labelName.Height + SPACING / 2;
        textBoxName.Color = Color.White;
        #endregion

        #region set up the password field and its text label
        Label labelPW = new Label( game, guiManager );
        this.Add( labelPW );
        labelPW.Text = "Password:";
        labelPW.X = labelName.X ;
        labelPW.Y = textBoxName.Y + 3 * SPACING;  // textboxname was previous
        labelPW.Width = 200;
        labelPW.Height = labelName.TextHeight;
        labelPW.Color = Color.White ;

        textBoxPW = new TextBox( game, guiManager );
        textBoxPW.IsPassword = true;
        Add( this.textBoxPW );
        textBoxPW.Initialize();
        textBoxPW.X = labelPW.X;
        textBoxPW.Y = labelPW.Y + labelPW.Height + SPACING;
        textBoxPW.Color = Color.White;
        #endregion

        // Set the window width to the default textbox width
        this.ClientWidth = textBoxName.Width + ( 2 * SPACING );

        // Cancel button
        #region set up the cancel and OK buttons
        buttonCancel = new TextButton( game, guiManager );
        Add( this.buttonCancel );
        buttonCancel.Text = "Cancel";
        buttonCancel.X = this.ClientWidth - this.buttonCancel.Width - SPACING;
        buttonCancel.Y = this.textBoxPW.Y + this.textBoxName.Height + SPACING;
        buttonCancel.Color = Color.White;

        buttonCancel.Click += new ClickHandler( buttonCancel_Click );
        if( toExecuteOnCancel != null )
          this.OnCancel = toExecuteOnCancel;

        // OK button
        buttonOK = new TextButton( game, guiManager );
        Add( this.buttonOK );
        buttonOK.Text = "OK";
        buttonOK.X = this.buttonCancel.X - SPACING - this.buttonOK.Width;
        buttonOK.Y = this.buttonCancel.Y;
        buttonOK.Color = Color.White;

        buttonOK.Click += new ClickHandler( buttonOK_Click );
        if( toExecuteOnOK != null )
          this.OnOK = toExecuteOnOK ;
        #endregion

        // Set the window height to the amount needed to show all controls
        this.ClientHeight = this.buttonOK.Y + this.buttonOK.Height + SPACING;

        // Set the window title
        this.TitleText = "Login!";
        this.Color = Color.White ;

        // This dialog does not need to be resized by the user
        this.Resizable = false;

        this.CenterWindow();
    }
开发者ID:superwills,项目名称:SPW_Classic,代码行数:82,代码来源:LoginDialog.cs


注:本文中的TextBox.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。