예제 #1
0
파일: ToolBar.cs 프로젝트: akumetsuv/flood
 public void AddTool(string name /* Image image */, Action onSelect)
 {
     var pButton = new Gwen.Control.Button(pTileLayout);
     pButton.SetSize(20, 20);
     pButton.SetToolTipText(name);
     pButton.ShouldDrawBackground = true;
     pButton.Clicked += new Gwen.Control.Base.GwenEventHandler(
         b => onSelect.Invoke());
 }
예제 #2
0
        Base ConstructFindGame()
        {
            Base FindGame = new Base(MainCanvas.GetCanvas());
            FindGame.SetSize(300, 300);

            Label EnterIP = new Label(FindGame);
            EnterIP.AutoSizeToContents = true;
            EnterIP.SetText("Enter an IP:");
            EnterIP.SetPosition(10, 10);

            TextBox IPAddress = new TextBox(FindGame);
            IPAddress.SetText("127.0.0.1");
            IPAddress.SetPosition(10, 40);
            IPAddress.SetSize(260, 20);

            TextBox Port = new TextBox(FindGame);
            Port.SetText("54987");
            Port.SetPosition(10, 70);
            Port.SetSize(260, 20);

            Button Connect = new Button(FindGame);
            Connect.SetText("Connect");
            Connect.SetPosition(10, 200);
            Connect.SetSize(200, 20);
            Connect.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.Connect(IPAddress.Text, Int32.Parse(Port.Text));
                MainMenu.Hide();
                FindGame.Hide();

                Connecting.Show();
            };

            Button Back = new Button(FindGame);
            Back.SetText("Back");
            Back.SetPosition(10, 225);
            Back.SetSize(200, 20);
            Back.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Mode = MenuMode.MainMenu;
                MainMenu.Show();
                FindGame.Hide();
            };

            return FindGame;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="text">Message to display.</param>
        /// <param name="caption">Window caption.</param>
        public MessageBox(Base parent, string text, string caption = "")
            : base(parent, caption, true)
        {
            DeleteOnClose = true;

            m_Label           = new Label(m_InnerPanel);
            m_Label.Text      = text;
            m_Label.Margin    = Margin.Five;
            m_Label.Dock      = Pos.Top;
            m_Label.Alignment = Pos.Center;

            m_Button          = new Button(m_InnerPanel);
            m_Button.Text     = "OK"; // todo: parametrize buttons
            m_Button.Clicked += CloseButtonPressed;
            m_Button.Clicked += DismissedHandler;
            m_Button.Margin   = Margin.Five;
            m_Button.SetSize(50, 20);

            Align.Center(this);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="text">Message to display.</param>
        /// <param name="caption">Window caption.</param>
        public MessageBox(Base parent, string text, string caption = "") 
            : base(parent, caption, true)
        {
            DeleteOnClose = true;

            m_Label = new Label(m_InnerPanel);
            m_Label.Text = text;
            m_Label.Margin = Margin.Five;
            m_Label.Dock = Pos.Top;
            m_Label.Alignment = Pos.Center;

            m_Button = new Button(m_InnerPanel);
            m_Button.Text = "OK"; // todo: parametrize buttons
            m_Button.Clicked += CloseButtonPressed;
            m_Button.Clicked += DismissedHandler;
            m_Button.Margin = Margin.Five;
            m_Button.SetSize(50, 20);

            Align.Center(this);
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="text">Message to display.</param>
        /// <param name="caption">Window caption.</param>
        public MessageBox(ControlBase parent, string text, string caption = "")
            : base(parent, caption, true)
        {
            DeleteOnClose = true;

            label           = new Label(innerPanel);
            label.Text      = text;
            label.Margin    = Margin.Five;
            label.Dock      = Pos.Top;
            label.Alignment = Pos.Center;

            button          = new Button(innerPanel);
            button.Text     = "OK"; // todo: parametrize buttons
            button.Clicked += closeButtonPressed;
            button.Clicked += dismissedHandler;
            button.Margin   = Margin.Five;
            button.SetSize(50, 20);

            base.DisableResizing();

            Align.Center(this);
        }
예제 #6
0
        private void ShowSelectLevelUi(Canvas canvas)
        {
            var window = new WindowControl(canvas, "Choisir un niveau", true);
            window.DisableResizing();
            window.SetSize(300, 400);
            window.SetPosition(Game.GetWindowSize().X /2 - window.Width / 2, Game.GetWindowSize().Y / 2 - window.Height / 2);

            var listLevel = new ListBox(window);
            listLevel.SetSize(window.Width / 2, window.Height - 40);
            if (Directory.Exists(_levelsPath)) {
                foreach (var file in Directory.EnumerateFiles(_levelsPath)) {
                    var fileInfo = new FileInfo(file);
                    if (fileInfo.Extension.Equals(".mtrlvl")) {
                        listLevel.AddRow(fileInfo.Name.Remove(fileInfo.Name.LastIndexOf('.')), fileInfo.Name, file);
                    }
                }
            }

            var widthButton = window.Width - listLevel.Width - 30;

            var playButton = new Button(window);
            playButton.SetText("Jouer");
            playButton.SetPosition(listLevel.Width + 10, 0);
            playButton.SetSize(widthButton, playButton.Height);
            playButton.Clicked += (sender, arguments) => {
               LoadLevel(listLevel, canvas, false);
            };

            var deleteLevelButton = new Button(window);
            deleteLevelButton.SetText("Supprimer");
            deleteLevelButton.SetSize(widthButton, deleteLevelButton.Height);
            deleteLevelButton.Clicked += (sender, arguments) => {
                if (listLevel.SelectedRowIndex == -1)
                    new MessageBox(canvas, "Aucun niveau n'a été sélectionné !", "Erreur !").Show();
                else {
                    var path = listLevel.SelectedRow.UserData.ToString();
                    try {
                        File.Delete(path);
                        listLevel.RemoveRow(listLevel.SelectedRowIndex);
                        listLevel.SelectedRow = null;
                        Log.WriteInfo("Le niveau : " + path + " a été supprimé !");
                    }
                    catch (IOException e) {
                        new MessageBox(canvas, "Impossible de supprimer le niveau sélectionné ! Erreur : " + e.Message, "Erreur !").Show();
                    }
                }
            };
            Align.PlaceDownLeft(deleteLevelButton, playButton, 10);

            var editLevelButton = new Button(window);
            editLevelButton.SetText("Editer le niveau");
            editLevelButton.SetSize(widthButton, editLevelButton.Height);
            editLevelButton.Clicked += (sender, arguments) => {
                LoadLevel(listLevel, canvas, true);
            };
            Align.PlaceDownLeft(editLevelButton, deleteLevelButton, 10);

            var newLevelButton = new Button(window);
            newLevelButton.SetText("Nouveau niveau");
            newLevelButton.SetSize(widthButton, newLevelButton.Height);
            Align.PlaceDownLeft(newLevelButton, editLevelButton, 10);
        }
예제 #7
0
        Base ConstructMainMenu()
        {
            Base MainMenu = new Base(MainCanvas.GetCanvas());
            MainMenu.SetSize(300, 300);
            MainMenu.Dock = Gwen.Pos.Center;

            Button SinglePlayer = new Button(MainMenu);
            SinglePlayer.SetText("Single Player");
            SinglePlayer.SetPosition(10, 10);
            SinglePlayer.SetSize(220, 20);
            //SinglePlayer.Clicked += delegate(Base caller) {
            //    Mode = SINGLEPLAYER;
            //    MainMenu.Hide();
            //};
            SinglePlayer.Disable();

            Button JoinGame = new Button(MainMenu);
            JoinGame.SetText("Join Game");
            JoinGame.SetPosition(10, 70);
            JoinGame.SetSize(220, 20);
            JoinGame.Clicked += delegate(Base sender, ClickedEventArgs args) {
                MainMenu.Hide();
                FindGame.Show();

                Mode = MenuMode.JoiningGame;
            };

            Button Quit = new Button(MainMenu);
            Quit.SetText("Quit");
            Quit.SetPosition(10, 100);
            Quit.SetSize(220, 20);
            Quit.Clicked += delegate(Base sender, ClickedEventArgs args) {
                MainCanvas.Dispose();
                Environment.Exit(0);
            };

            return MainMenu;
        }