Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FriendsForm"/> class.
        /// </summary>
        /// <param name="userInfo">The user info.</param>
        /// <param name="parent">The parent.</param>
        /// <exception cref="ArgumentNullException"><paramref name="userInfo" /> is <c>null</c>.</exception>
        public FriendsForm(UserInfo userInfo, Control parent)
            : base(parent, Vector2.Zero, new Vector2(225, 400))
        {
            if (userInfo == null)
                throw new ArgumentNullException("userInfo");

            AddBtn = new Button(this, new Vector2(30, 300), new Vector2(30, 25)) { Text = "Add" };
            AddBtn.Clicked += AddBtn_Clicked;

            RemoveBtn = new Button(this, new Vector2(90, 300), new Vector2(30, 25)) { Text = "Remove" };
            RemoveBtn.Clicked += RemoveBtn_Clicked;

            SendBtn = new Button(this, new Vector2(150, 300), new Vector2(30, 25)) { Text = "Send" };
            SendBtn.Clicked += SendBtn_Clicked;

            // Create the input and output TextBoxes
            InputTextBox = new TextBox(this, new Vector2(10, 270), new Vector2(120, 25))
            {
                IsMultiLine = false,
                IsEnabled = true,
                Font = GameScreenHelper.DefaultChatFont,
                BorderColor = new Color(255, 255, 255, 100)
            };

            _userInfo = userInfo;

            for (int i = 0; i < 50; i++)
            {
                var position = new Vector2(10, (30 + 15 * i));

                FriendsCollection[i] = new Label(this, position) { Text = "", CanFocus = false, Tag = i, Font = GameScreenHelper.DefaultChatFont };
                FriendsCollection[i].MouseDown += Friend_Clicked;
            }
        }
Ejemplo n.º 2
0
        void CreateControls()
        {
            var buttonSize = new Vector2(100, 20);

            _lblName = new Label(this, Vector2.Zero);

            _btnJoinLeave = new Button(this, Vector2.Zero, buttonSize);
            _btnMembers = new Button(this, Vector2.Zero, buttonSize) { Text = "Members" };
            _btnOnline = new Button(this, Vector2.Zero, buttonSize) { Text = "Online" };

            _btnJoinLeave.Clicked += _btnJoinLeave_Clicked;
            _btnMembers.Clicked += btnMembers_Clicked;
            _btnOnline.Clicked += btnOnline_Clicked;

            var formSize = new Vector2(200, 200);
            _frmOnline = new GuildOnlineMembersForm(Parent, new Vector2(200, 200), formSize) { GuildInfo = GuildInfo, IsVisible = false };
            _frmMembers = new GuildMembersForm(Parent, new Vector2(250, 250), formSize) { GuildInfo = GuildInfo, IsVisible = false };

            RelocateControls();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            BasicConfigurator.Configure(_logger);

            ScreenManager.Updated -= ScreenManager_Updated;
            ScreenManager.Updated += ScreenManager_Updated;

            _consoleFont = ScreenManager.Content.LoadFont("Font/Courier New", 14, ContentLevel.GameScreen);

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize) { Border = ControlBorder.Empty };

            // The main console output textbox
            _txtOutput = new TextBox(_cScreen, Vector2.Zero, _cScreen.Size)
            {
                Font = _consoleFont,
                Size = _cScreen.Size,
                Border = ControlBorder.Empty,
                MaxBufferSize = 200,
                BufferTruncateSize = 80,
                CanFocus = false,
                CanDrag = false,
                IsMultiLine = true,
                IsEnabled = false
            };
            _txtOutput.Resized += delegate { UpdateConsoleBufferSize(); };
            _txtOutput.FontChanged += delegate { UpdateConsoleBufferSize(); };

            // Create the panel that holds the settings options
            var settingsButtonSize = _consoleFont.MeasureString("Show Settings") + new Vector2(10, 4);
            _btnShowSettings = new Button(_cScreen, new Vector2(_cScreen.Size.X, 0), settingsButtonSize) { Font = _consoleFont, Text = "Hide Settings" };
            _btnShowSettings.Position += new Vector2(-4, 4);
            _btnShowSettings.Clicked += btnShowSettings_Clicked;

            var settingsPanelSize = new Vector2(400, 400);
            _cSettingsPanel = new Panel(_cScreen, new Vector2(_cScreen.Size.X - settingsPanelSize.X - 4, _btnShowSettings.Position.Y + _btnShowSettings.Size.Y + 8), settingsPanelSize) 
                { IsVisible = true, CanDrag = false };

            // Create the logging level checkboxes
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Fatal, 0));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Error, 1));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Warn, 2));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Info, 3));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Debug, 4));

            // Disable debug by default
            _logLevelCheckBoxes.First(x => (Level)x.Tag == Level.Debug).Value = false;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            topForm = new Form(GUIManager, new Vector2(5, 5), new Vector2(700, 550)) { Text = "Primary form" };

            var tb = new TextBox(topForm, new Vector2(10, 10), new Vector2(150, 300));

            _textBox = new TextBox(topForm, new Vector2(350, 10), new Vector2(200, 200))
            { Font = GUIManager.Font, Text = "abcdef\nghi\r\njklj\n" };

            for (var i = 0; i < 150; i++)
            {
                var c = new Color((byte)rnd.Next(0, 256), (byte)rnd.Next(256), (byte)rnd.Next(256), 255);
                _textBox.Append(new StyledText(i + " ", c));
            }

            var styledTexts = new List<StyledText>
            {
                new StyledText("Black ", Color.Black),
                new StyledText("Red ", Color.Red),
                new StyledText("Green ", Color.Green),
                new StyledText("Yellow ", Color.Yellow),
                new StyledText("Voilet ", Color.Violet),
                new StyledText("Orange ", Color.Orange),
                new StyledText("Tomato ", Color.Tomato),
                new StyledText("DarkRed ", Color.DarkRed),
            };

            tb.Append(styledTexts);

            var form = new Form(topForm, new Vector2(50, 50), new Vector2(200, 200)) { Text = "My form" };

            var b = new Button(form, new Vector2(20, 20), new Vector2(80, 30)) { Text = "Press me" };
            b.Clicked += b_Clicked;

            new CheckBox(form, new Vector2(20, 200)) { Text = "Checkbox" };

            var f2 = new Form(topForm, new Vector2(200, 250), new Vector2(275, 270)) { Text = "My form 2" };
            var f3 = new Form(f2, Vector2.Zero, new Vector2(200, 200)) { Text = "form 3" };
            var f4 = new Form(f3, Vector2.Zero, new Vector2(100, 100)) { Text = "form 4" };

            var testLabelF4 = new Label(f4, Vector2.Zero) { Text = "Click me" };
            testLabelF4.Clicked += testLabelF4_Clicked;

            _dragLbl = new Label(topForm, topForm.Size - new Vector2(75, 30));

            topForm.BeginDrag += DragControl;
            topForm.EndDrag += DragControl;
            form.BeginDrag += DragControl;
            form.EndDrag += DragControl;
            f2.BeginDrag += DragControl;
            f2.EndDrag += DragControl;
            f3.BeginDrag += DragControl;
            f3.EndDrag += DragControl;
            f4.BeginDrag += DragControl;
            f4.EndDrag += DragControl;

            // Set up the tooltips
            foreach (var c in GUIManager.GetAllControls())
            {
                if (c.GetType() == typeof(Button))
                    c.Tooltip = Tooltip_Button;
                else if (c.GetType() == typeof(Label))
                    c.Tooltip += Tooltip_Label;
            }

            // Paged list
            var items = new List<string>();
            for (var i = 0; i < 100; i++)
            {
                items.Add(i.ToString());
            }

            new ListBox<string>(topForm, new Vector2(500, 250), new Vector2(100, 100)) { Items = items, ShowPaging = true };
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates the children controls for this form.
        /// </summary>
        void CreateChildren()
        {
            _lblAvailableQuests = new Label(this, Vector2.Zero) { Text = "Available Quests:" };

            _lstQuests = new QuestDescriptionListBox(this, Vector2.Zero, new Vector2(32), _hasStartQuestReqs, _hasFinishQuestReqs) 
            { Items = _emptyQuests, ShowPaging = false };
            _lstQuests.SelectedIndexChanged += lstQuests_SelectedIndexChanged;

            _lblQuestInfo = new Label(this, Vector2.Zero) { Text = "Quest Information:" };

            _txtQuestInfo = new TextBox(this, Vector2.Zero, new Vector2(32)) { IsMultiLine = true, IsEnabled = false };

            _btnAccept = new Button(this, Vector2.Zero, new Vector2(90, 18)) { Text = "Accept Quest" };
            _btnAccept.Clicked += btnAccept_Clicked;

            _btnClose = new Button(this, Vector2.Zero, new Vector2(60, 18)) { Text = "Close" };
            _btnClose.Clicked += btnClose_Clicked;

            RepositionChildren();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the buttons.
        /// </summary>
        /// <param name="types">The types of the buttons to create.</param>
        /// <returns>The created buttons.</returns>
        IEnumerable<Button> CreateButtons(MessageBoxButton types)
        {
            var ret = new List<Button>();

            // Create the buttons
            var typesInt = (int)types;
            foreach (var possibleType in _validButtonCreationTypes)
            {
                // Check if the flag for the value is set
                if (((int)possibleType & typesInt) == 0)
                    continue;

                var text = possibleType.ToString();
                var fontSize = Font.MeasureString(text);
                var btn = new Button(this, Vector2.Zero, fontSize + new Vector2(6))
                { Text = text, Tag = possibleType, Font = Font };
                btn.Clicked += Button_Clicked;
                ret.Add(btn);
            }

            // Resize all buttons to equal the size of the largest button (looks better when consistently sized)
            var greatestSize = new Vector2(ret.Max(x => x.ClientSize.X), ret.Max(x => x.ClientSize.Y));
            foreach (var btn in ret)
            {
                btn.ClientSize = greatestSize;
            }

            return ret;
        }