The UserControl class is used as a base for a user control located on the terminal window. Each UserControl is linked with a ControlLayout and displays are made with the layout this UserControl is linked to. Generally, all UserControl objects have text, whether they are buttons, checkboxes, progress bars, string input, etc. When extending this class, note that the enter key is used in the BattleshipConsole for whole string inputs. Do not handle an enter key press (return false in KeyPress(ConsoleKeyInfo) if the input string is required for this control.
        private void DrawControl(UserControl ctrl)
        {
            switch (align)
            {
                case VerticalAlign.Left:
                    module.AlignToLine(module.CurrentY);
                    module.WriteText(ctrl.Text);
                    module.NewLine();
                    break;

                case VerticalAlign.Center:
                    module.WriteCenteredText(ctrl.Text);
                    module.NewLine();
                    break;

                case VerticalAlign.Right:
                    module.AlignToCoord(module.Width - ctrl.Text.Length - 1, module.CurrentY);
                    module.WriteText(ctrl.Text);
                    module.NewLine();
                    break;
            }
        }
 public void Add(UserControl ctrl)
 {
     controls.Add(ctrl);
 }
 protected virtual void DrawUnselected(UserControl ctrl)
 {
     module.AlignToLine(displayLine + controls.IndexOf(ctrl));
     ctrl.RequiresUpdate = false;
 }
Exemple #4
0
 protected override void DrawUnselected(UserControl ctrl)
 {
     //Do not draw anything.
 }