public ScreenSolarSystem(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "Solar System";
            label.SetPosition(30, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;


            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "OK";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(300, 500, 200, 50);
            buttonOK.Clicked += onButtonOKClick;


            Gwen.Control.Button buttonPlanet = new Gwen.Control.Button(this);
            buttonPlanet.Text = "Planet";
            buttonPlanet.Font = Program.fontButtonLabels;
            buttonPlanet.SetBounds(550, 500, 200, 50);
            buttonPlanet.Clicked += onButtonPlanetClick;
        }
示例#2
0
        public ScreenPlanet(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "Planet";
            label.SetPosition(30, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            int width;
            int height;

            Gwen.Control.WindowControl settingsWindow = new Gwen.Control.WindowControl(this);
            settingsWindow.Width             = parent.Width / 2;
            settingsWindow.Height            = parent.Height / 2;
            settingsWindow.SetPosition(width = parent.Width / 2 - settingsWindow.Width / 2, height = parent.Height / 2 - settingsWindow.Height / 2);

            Gwen.Control.Button buttonBack = new Gwen.Control.Button(settingsWindow);
            buttonBack.Text = "Back";
            buttonBack.Font = Program.fontButtonLabels;
            buttonBack.SetBounds(width / 100 * 8, height / 100 * 8, width / 3, height / 3);
            buttonBack.Clicked += onButtonBackClick;
        }
示例#3
0
        public Screen_TechTree(Base parent)
            : base(parent)
        {
            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "Back";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(500, 500, 50, 50);
            buttonOK.Clicked += onButtonOKClick;

            Tech.Inint();
            SetSize(parent.Width, parent.Height);

            label      = new Gwen.Control.Label(this);
            label.Text = "Tech_Tree Probe";
            label.SetPosition(Program.percentW(85), Program.percentH(85));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            img = new Gwen.Control.ImagePanel(this);


            updateDrawing();

            img.SetPosition(Program.percentW(0), Program.percentH(0));
            img.SetSize(Program.percentW(80), Program.percentH(80));
            //img.Clicked += new GwenEventHandler<ClickedEventArgs>(img_Clicked);
            img.MouseMoved += new GwenEventHandler <MovedEventArgs>(img_MouseMoved);
            img.MouseDown  += new GwenEventHandler <ClickedEventArgs>(img_MouseDown);
            img.MouseUp    += new GwenEventHandler <ClickedEventArgs>(img_MouseUp);
        }
示例#4
0
        public TextureRefBox(Base parent, FSTextureReference Texture)
            : base(parent)
        {
            this.Texture = Texture;
            this.SetSize(160, 75);

            TextureName = new Label(this);
            TextureName.AutoSizeToContents = true;
            TextureName.SetPosition(10, 0);

            Defined = new LabeledCheckBox(this);
            Defined.Text = "Defined";
            Defined.SetPosition(10, 20);
            Defined.CheckChanged += new GwenEventHandler<EventArgs>(Defined_CheckChanged);

            panel = new GLImpTexturePanel(this);
            panel.SetSize(50, 50);
            panel.SetPosition(85, 0);
            panel.Clicked += delegate(Base sender, ClickedEventArgs args) {
                OpenTextureWindow otw = new OpenTextureWindow(SetTexture);
                otw.Show();
            };

            RefreshAll();
        }
        public Screen_GameScreen(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            label      = new Gwen.Control.Label(this);
            label.Text = "GAME!!!";
            label.SetPosition(Program.percentW(5), Program.percentH(5));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            img = new Gwen.Control.ImagePanel(this);


            galaxyImage = new Bitmap(Program.percentW(100), Program.percentH(80), PixelFormat.Format32bppArgb);
            DrawControl = new DrawController(galaxyImage);

            updateDrawing();

            img.SetPosition(Program.percentW(0), Program.percentH(20));
            img.SetSize(Program.percentW(100), Program.percentH(80));
            //img.Clicked += new GwenEventHandler<ClickedEventArgs>(img_Clicked);
            img.MouseMoved += new GwenEventHandler <MovedEventArgs>(img_MouseMoved);
            img.MouseDown  += new GwenEventHandler <ClickedEventArgs>(img_MouseDown);
            img.MouseUp    += new GwenEventHandler <ClickedEventArgs>(img_MouseUp);

            Gwen.Control.Button buttonTech = new Gwen.Control.Button(this);
            buttonTech.Text = "Tech Tree";
            buttonTech.Font = Program.fontButtonLabels;
            buttonTech.SetBounds(Program.percentW(80), Program.percentH(84), Program.percentW(20), Program.percentH(8));
            buttonTech.Clicked += onButtonTechClick;

            Gwen.Control.Button buttonMenu = new Gwen.Control.Button(this);
            buttonMenu.Text = "Menu";
            buttonMenu.Font = Program.fontButtonLabels;
            buttonMenu.SetBounds(Program.percentW(0), Program.percentH(0), Program.percentW(13), Program.percentH(8));
            buttonMenu.Clicked += onButtonMenuClick;

            Gwen.Control.Button buttonSolarSystem = new Gwen.Control.Button(this);
            buttonSolarSystem.Text = "Solar System";
            buttonSolarSystem.Font = Program.fontButtonLabels;
            buttonSolarSystem.SetBounds(Program.percentW(0), Program.percentH(92), Program.percentW(19), Program.percentH(8));
            buttonSolarSystem.Clicked += onSolarSystemClick;

            Gwen.Control.Button buttonStep = new Gwen.Control.Button(this);
            buttonStep.Text = "Step";
            buttonStep.Font = Program.fontButtonLabels;
            buttonStep.SetBounds(Program.percentW(90), Program.percentH(92), Program.percentW(10), Program.percentH(8));
            buttonStep.Clicked += onSolarSystemClick;

            buttonCombat      = new Gwen.Control.Button(this);
            buttonCombat.Text = "Combat";
            buttonCombat.Font = Program.fontButtonLabels;
            buttonCombat.SetBounds(Program.percentW(19), Program.percentH(92), Program.percentW(18), Program.percentH(8));
            buttonCombat.Clicked += onCombatClick;
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuItem"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public MenuItem(Base parent)
            : base(parent)
        {
            m_OnStrip = false;
            IsTabable = false;
            IsCheckable = false;
            IsChecked = false;

            m_Accelerator = new Label(this);
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuItem"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public MenuItem(Base parent)
            : base(parent)
        {
            AutoSizeToContents = true;
            m_OnStrip = false;
            IsTabable = false;
            IsCheckable = false;
            IsChecked = false;

            m_Accelerator = new Label(this);
        }
示例#8
0
        public PlayerView(Vector2u displaySize)
            : base(displaySize)
        {
            BackgroundColor = new Color(40,40,40);

            playerBox = new GroupBox(GuiCanvas);
            playerBox.SetBounds(20, 20, displaySize.X - 40, displaySize.Y - 40);

            playerNameLabel = new GroupBox(playerBox);
            playerNameLabel.SetBounds(20, 20, 256, 32);
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyRow"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="prop">Property control associated with this row.</param>
        public PropertyRow(Base parent, Property.Base prop)
            : base(parent)
        {
            PropertyRowLabel label = new PropertyRowLabel(this);
            label.Dock = Pos.Left;
            label.Alignment = Pos.Left | Pos.Top;
            label.Margin = new Margin(2, 2, 0, 0);
            m_Label = label;

            m_Property = prop;
            m_Property.Parent = this;
            m_Property.Dock = Pos.Fill;
            m_Property.ValueChanged += OnValueChanged;
        }
示例#10
0
        public Screen_Combat(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            imgCombatMap = new Gwen.Control.ImagePanel(this);

            tacticState.New(ref seed);
            ShipsCounter.ShipsCount(ref seed);
            pictureMap.Width  = Program.percentW(100);
            pictureMap.Height = Program.percentH(82);
            tacticDraw.New(pictureMap, seed, tacticState);

            UpdateDrawing();

            imgCombatMap.SetPosition(Program.percentW(0), Program.percentH(0));
            imgCombatMap.SetSize(pictureMap.Width, pictureMap.Height);
            imgCombatMap.MouseDown += new GwenEventHandler <ClickedEventArgs>(imgCombatMap_MouseDown);

            buttonStep      = new Gwen.Control.Button(this);
            buttonStep.Text = "Step";
            buttonStep.Font = Program.fontButtonLabels;
            buttonStep.SetBounds(Program.percentW(82), Program.percentH(82), Program.percentW(18), Program.percentH(6));
            buttonStep.Clicked += onStepClick;

            buttonConcede      = new Gwen.Control.Button(this);
            buttonConcede.Text = "Concede";
            buttonConcede.Font = Program.fontButtonLabels;
            buttonConcede.SetBounds(Program.percentW(82), Program.percentH(88), Program.percentW(18), Program.percentH(6));
            buttonConcede.Clicked += onConcedeClick;

            buttonAutoBattle      = new Gwen.Control.Button(this);
            buttonAutoBattle.Text = "Auto Battle";
            buttonAutoBattle.Font = Program.fontButtonLabels;
            buttonAutoBattle.SetBounds(Program.percentW(82), Program.percentH(94), Program.percentW(18), Program.percentH(6));
            buttonAutoBattle.Clicked += onAutoBattleClick;

            labelStep           = new Gwen.Control.Label(this);
            labelStep.Text      = "Ходит 1-й игрок";
            labelStep.Font      = Program.fontText;
            labelStep.TextColor = Color.GreenYellow;
            labelStep.SetBounds(Program.percentW(65), Program.percentH(90), Program.percentW(20), Program.percentH(8));

            labelDescription           = new Gwen.Control.Label(this);
            labelDescription.Text      = "";
            labelDescription.Font      = Program.fontText;
            labelDescription.TextColor = Color.GreenYellow;
            labelDescription.SetBounds(Program.percentW(0), Program.percentH(82), Program.percentW(50), Program.percentH(18));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LabeledCheckBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public LabeledCheckBox(Base parent)
            : base(parent)
        {
            SetSize(200, 19);
            m_CheckBox = new CheckBox(this);
            m_CheckBox.Dock = Pos.Left;
            m_CheckBox.Margin = new Margin(0, 2, 2, 2);
            m_CheckBox.IsTabable = false;
            m_CheckBox.CheckChanged += OnCheckChanged;

            m_Label = new Label(this);
            m_Label.Dock = Pos.Fill;
			m_Label.Clicked += delegate(Base Control, ClickedEventArgs args) { m_CheckBox.Press(Control); };
            m_Label.IsTabable = false;

            IsTabable = false;
        }
示例#12
0
        public ConnectingWindow()
            : base(MainCanvas.GetCanvas())
        {
            this.SetSize(400, 100);
            this.IsClosable = false;
            this.DisableResizing();
            this.ClampMovement = true;
            Label message = new Label(this);
            message.Text = "Downloading Content";
            message.AutoSizeToContents = true;
            message.SetPosition(10, 10);

            bar = new ProgressBar(this);
            bar.SetPosition(10, 40);
            bar.SetSize(300, 20);
            bar.IsHorizontal = true;
            bar.AutoLabel = true;
        }
示例#13
0
        private Base CreateAddRemoveButton(Base parent, string labelText, int labelMaxWidth, int valueLabelMaxWidth, int minValue, int maxValue, Action onAdd, Action onRemove)
        {
            Base b = new Base(parent);
            b.Dock = Pos.Top;
            b.Padding = new Padding(0, 0, 0, 4);

            //Base r = new Base(b);
            //r.Dock = Pos.Right;
            //r.Padding = new Padding(0, 0, 0, 0);

            //Base l = new Base(b);
            //l.Dock = Pos.Left;
            //l.Padding = new Padding(0, 0, 0, 0);

            Label label = new Label(b);
            label.Text = labelText;
            label.Dock = Pos.Left;
            label.Padding = new Padding(0, 0, Math.Max(0, labelMaxWidth - label.Width), 0);

            Label valueLabel = new Label(b);
            valueLabel.Dock = Pos.Left;
            valueLabel.Text = "0";
            valueLabel.Padding = new Padding(Math.Max(0, valueLabelMaxWidth - valueLabel.Width), 0, 0, 0);

            Button addButton = new Button(b);
            addButton.Text = "+";
            addButton.Height = 20;
            addButton.Width = 20;
            addButton.Dock = Pos.Right;
            addButton.Released += (s, e) => onAdd();
            addButton.Released += (s, e) => valueLabel.Text = Math.Min(maxValue, int.Parse(valueLabel.Text) + 1).ToString();

            Button removeButton = new Button(b);
            removeButton.Text = "-";
            removeButton.Height = 20;
            removeButton.Width = 20;
            removeButton.Dock = Pos.Right;
            removeButton.Released += (s, e) => onRemove();
            removeButton.Released += (s, e) => valueLabel.Text = Math.Max(minValue, int.Parse(valueLabel.Text) - 1).ToString();

            b.SizeToChildren();

            return b;
        }
示例#14
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;
        }
示例#15
0
        public PackageEditor(Package package)
            : base(DevelopmentMenu.Instance)
        {
            this.Resource = package;
            this.SetPosition((int)MouseManager.GetMousePositionWindows().X, (int)MouseManager.GetMousePositionWindows().Y);

            Label lblName = new Label(this);
            lblName.AutoSizeToContents = true;
            lblName.Text = "Name";
            lblName.SetPosition(10, 10);

            TextBox tbName = new TextBox(this);
            tbName.SetPosition(50, 10);
            tbName.SetSize(150, 20);
            tbName.Text = Resource.Name;
            tbName.TextChanged += tbName_TextChanged;

            this.SetSize(220, 80);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LabeledRadioButton"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public LabeledRadioButton(Base parent)
            : base(parent)
        {
			MouseInputEnabled = true;
            SetSize(100, 20);

            m_RadioButton = new RadioButton(this);
            //m_RadioButton.Dock = Pos.Left; // no docking, it causes resizing
            //m_RadioButton.Margin = new Margin(0, 2, 2, 2);
            m_RadioButton.IsTabable = false;
            m_RadioButton.KeyboardInputEnabled = false;

            m_Label = new Label(this);
            m_Label.Alignment = Pos.CenterV | Pos.Left;
            m_Label.Text = "Radio Button";
			m_Label.Clicked += delegate(Base control, ClickedEventArgs args) { m_RadioButton.Press(control); };
            m_Label.IsTabable = false;
            m_Label.KeyboardInputEnabled = false;
        }
示例#17
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);
        }
示例#18
0
        private void EndCombat(int win)
        {
            Gwen.Control.WindowControl windowEnd = new Gwen.Control.WindowControl(this);
            windowEnd.Width  = this.Width / 2;
            windowEnd.Height = this.Height / 2;
            windowEnd.SetPosition(this.Width / 2 - windowEnd.Width / 2, this.Height / 2 - windowEnd.Height / 2);

            Gwen.Control.Label labelWin = new Gwen.Control.Label(windowEnd);
            labelWin.Text = "Win Player " + win.ToString();
            labelWin.Font = Program.fontLogo;
            labelWin.SetBounds(windowEnd.Width / 2 - labelWin.Width / 2, windowEnd.Height / 2 - labelWin.Height, windowEnd.Width, windowEnd.Height * 15 / 100);

            Gwen.Control.Button buttonOK = new Gwen.Control.Button(windowEnd);
            buttonOK.Text = "OK";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(windowEnd.Width / 2 - buttonOK.Width / 2, windowEnd.Height * 70 / 100, windowEnd.Width * 25 / 100, windowEnd.Height * 15 / 100);
            buttonOK.Clicked += onOKClick;

            windowEnd.IsClosable = false;
        }
示例#19
0
        public void Initialize()
        {
            Status = new Label(MainCanvas.Instance);
            Status.SetPosition(10, 10);
            Status.SetText("Waiting for opponent...");
            Status.MakeColorBright();

            Button cancel = new Button(MainCanvas.Instance);
            cancel.SetText("Cancel");
            cancel.SetPosition(10, 40);
            cancel.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.SwitchState(new MainMenu());
            };

            NetPeerConfiguration Configuration = new NetPeerConfiguration("Xanatos");
            Configuration.Port = 54987;
            Configuration.MaximumConnections = 1;
            Program.Connection = new NetServer(Configuration);
            Program.Connection.Start();
            Message.RegisterServer(Program.Connection);
        }
示例#20
0
        public Screen_MainMenu(Base parent) : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "GalaxyConquest";
            label.SetPosition(70, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;


            Gwen.Control.Button buttonNewGame = new Gwen.Control.Button(this);
            buttonNewGame.Text = "New game";
            buttonNewGame.Font = Program.fontButtonLabels;
            buttonNewGame.SetBounds(300, 200, 200, 50);
            buttonNewGame.Pressed += onButtonNewGameClick;

            Gwen.Control.Button buttonLoadGame = new Gwen.Control.Button(this);
            buttonLoadGame.Text = "Load game";
            buttonLoadGame.Disable();
            buttonLoadGame.Font = Program.fontButtonLabels;
            buttonLoadGame.SetBounds(300, 260, 200, 50);

            Gwen.Control.Button buttonSettings = new Gwen.Control.Button(this);
            buttonSettings.Text = "Settings";
            buttonSettings.Font = Program.fontButtonLabels;
            buttonSettings.SetBounds(300, 320, 200, 50);
            buttonSettings.Pressed += onButtonSettingsClick;

            Gwen.Control.Button buttonCredits = new Gwen.Control.Button(this);
            buttonCredits.Text = "Credits";
            buttonCredits.Font = Program.fontButtonLabels;
            buttonCredits.SetBounds(300, 380, 200, 50);

            Gwen.Control.Button buttonQuit = new Gwen.Control.Button(this);
            buttonQuit.Text = "Quit";
            buttonQuit.Font = Program.fontButtonLabels;
            buttonQuit.SetBounds(300, 440, 200, 50);
            buttonQuit.Pressed += onButtonQuitClick;
        }
示例#21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowControl"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        /// <param name="caption">Window caption.</param>
        /// <param name="modal">Determines whether the window should be modal.</param>
        public WindowControl(GUIControl parent, String caption, bool modal)
            : base(parent)
        {
            m_TitleBar = new Dragger(this);
            m_TitleBar.Height = 24;
            m_TitleBar.Padding = Gwen.Padding.Zero;
            m_TitleBar.Margin = new Margin(0, 0, 0, 4);
            m_TitleBar.Target = this;
            m_TitleBar.Dock = Pos.Top;

            m_Caption = new Label(m_TitleBar);
            m_Caption.Alignment = Pos.Left | Pos.CenterV;
            m_Caption.Text = caption;
            m_Caption.Dock = Pos.Fill;
            m_Caption.Padding = new Padding(8, 0, 0, 0);
            m_Caption.TextColor = Skin.Colors.Window.TitleInactive;

            m_CloseButton = new CloseButton(m_TitleBar, this);
            //m_CloseButton.Text = String.Empty;
            m_CloseButton.SetSize(24, 24);
            m_CloseButton.Dock = Pos.Right;
            m_CloseButton.Clicked += CloseButtonPressed;
            m_CloseButton.IsTabable = false;
            m_CloseButton.Name = "closeButton";

            //Create a blank content control, dock it to the top - Should this be a ScrollControl?
            m_InnerPanel = new GUIControl(this);
            m_InnerPanel.Dock = Pos.Fill;
            GetResizer(8).Hide();
            BringToFront();
            IsTabable = false;
            Focus();
            MinimumSize = new Point(100, 40);
            ClampMovement = true;
            KeyboardInputEnabled = false;

            if (modal)
                MakeModal(false);
        }
示例#22
0
        public Screen_NewGame(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);


            label      = new Gwen.Control.Label(this);
            label.Text = "New game";
            label.SetPosition(Program.percentW(5), Program.percentH(5));
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            Gwen.Control.Button buttonBack = new Gwen.Control.Button(this);
            buttonBack.Text = "Back";
            buttonBack.Font = Program.fontButtonLabels;
            buttonBack.SetBounds(Program.percentW(5), Program.percentH(87), Program.percentW(18), Program.percentH(8));
            buttonBack.Clicked += onButtonBackClick;

            Gwen.Control.Button buttonNewGame = new Gwen.Control.Button(this);
            buttonNewGame.Text = "New game";
            buttonNewGame.Font = Program.fontButtonLabels;
            buttonNewGame.SetBounds(Program.percentW(77), Program.percentH(87), Program.percentW(18), Program.percentH(8));
            buttonNewGame.Clicked += onButtonNewGameClick;

            imageGalaxyType       = new Gwen.Control.ImagePanel(this);
            imageGalaxyType.Image = Properties.Resources.icon_newgame_spiral;
            imageGalaxyType.SetBounds(Program.percentW(20), Program.percentH(20), Program.percentW(25), Program.percentH(25));

            Gwen.Control.Button buttonGalaxyTypeLeft = new Gwen.Control.Button(this);
            buttonGalaxyTypeLeft.Text = "<";
            buttonGalaxyTypeLeft.SetBounds(Program.percentW(20), Program.percentH(40), Program.percentW(5), Program.percentH(5));
            buttonGalaxyTypeLeft.Clicked += onButtonGalaxyTypeLeftClick;

            Gwen.Control.Button buttonGalaxyTypeRight = new Gwen.Control.Button(this);
            buttonGalaxyTypeRight.Text = ">";
            buttonGalaxyTypeRight.SetBounds(Program.percentW(40), Program.percentH(40), Program.percentW(5), Program.percentH(5));
            buttonGalaxyTypeRight.Clicked += onButtonGalaxyTypeRightClick;
        }
示例#23
0
        private Base CreateSliderOption(Base parent, string labelText, float min, float max, float value, string valueStringFormat, int labelMaxWidth, int valueLabelMaxWidth, Action<float> onChange)
        {
            Base b = new Base(parent);
            b.Dock = Pos.Top;
            b.Padding = new Padding(0, 0, 0, 4);

            Label label = new Label(b);
            label.Text = labelText;
            label.Dock = Pos.Left;
            label.Padding = new Padding(0, 0, Math.Max(0, labelMaxWidth - label.Width), 0);

            Label valueLabel = new Label(b);
            valueLabel.Dock = Pos.Right;

            HorizontalSlider slider = new HorizontalSlider(b);
            slider.Dock = Pos.Fill;
            slider.Height = 20;
            slider.Min = min;
            slider.Max = max;
            slider.Value = value;

            slider.ValueChanged += (s, e) =>
            {
                int prevWidth = valueLabel.Width;
                valueLabel.Text = slider.Value.ToString(valueStringFormat);
                valueLabel.Padding = new Padding(valueLabel.Padding.Left - (valueLabel.Width - prevWidth), 0, 0, 0);
            };
            slider.ValueChanged += (s, e) => onChange(slider.Value);

            valueLabel.Text = value.ToString(valueStringFormat);
            valueLabel.Padding = new Padding(Math.Max(0, valueLabelMaxWidth - valueLabel.Width), 0, 0, 0);
            onChange(value);

            b.SizeToChildren();

            return b;
        }
示例#24
0
        public void Initialize()
        {
            Base MainPage = new Base(MainCanvas.Instance);
            MainPage.Dock = Gwen.Pos.Fill;

            Label Title = new Label(MainPage);
            Title.Font = new Gwen.Font(MainCanvas.Renderer, "Consolas", 144);
            Title.Text = "Xanatos";
            Title.MakeColorBright();

            Button StartServer = new Button(MainPage);
            StartServer.SetPosition(10, 300);
            StartServer.Text = "Start Server";
            StartServer.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.SwitchState(new GameState.Hosting());
            };

            Button Connect = new Button(MainPage);
            Connect.SetPosition(10, 330);
            Connect.Text = "Connect";
            Connect.Clicked += delegate(Base sender, ClickedEventArgs args) {
                Program.SwitchState(new GameState.Connect());
            };
        }
示例#25
0
        public override void InitUi(Canvas canvas) {
            _canvas = canvas;
            Game.BackgroundColor = Color.Black;

            var windowAction = new WindowControl(canvas, "Options", false);
            windowAction.DisableResizing();
            windowAction.IsClosable = false;
            windowAction.SetSize(200, 150);
            windowAction.SetPosition(0, 0);

            var addScriptButton = new Button(windowAction);
            addScriptButton.SetText("Ajouter un script");
            addScriptButton.Clicked += (sender, arguments) => ShowAddScriptWindow(canvas);
            Align.CenterHorizontally(addScriptButton);


            // Fenêtre sur les informations du script sélectionné 
            _windowInfoScript = new WindowControl(canvas, "Paramètres du script");
            _windowInfoScript.DisableResizing();
            _windowInfoScript.IsClosable = false;
            _windowInfoScript.SetSize(200, 300);
            _windowInfoScript.SetPosition(Game.GetWindowSize().X - _windowInfoScript.Width, 0);

            var labelX = new Label(_windowInfoScript);
            labelX.SetPosition(0, 10);
            labelX.SetText("X :");

            _uiInfoTextBoxPosX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosX.SetSize(100, _uiInfoTextBoxPosX.Height);
            _uiInfoTextBoxPosX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f((int) _uiInfoTextBoxPosX.Value,
                        _selectScript.RectShape.Position.Y);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosX, labelX, 10);

            var labelY = new Label(_windowInfoScript);
            labelY.SetText("Y :");
            Align.PlaceDownLeft(labelY, labelX, 10);

            _uiInfoTextBoxPosY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxPosY.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxPosY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Position = new Vector2f(_selectScript.RectShape.Position.X,
                        (int) _uiInfoTextBoxPosY.Value);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxPosY, labelY, 10);

            var labelSizeX = new Label(_windowInfoScript);
            labelSizeX.SetText("Largeur :");
            Align.PlaceDownLeft(labelSizeX, labelY, 10);

            _uiInfoTextBoxSizeX = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeX.SetSize(100, _uiInfoTextBoxPosY.Height);
            _uiInfoTextBoxSizeX.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f((int)_uiInfoTextBoxSizeX.Value,
                        _selectScript.RectShape.Size.Y);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeX, labelSizeX, 10);

            var labelSizeY = new Label(_windowInfoScript);
            labelSizeY.SetText("Hauteur :");
            Align.PlaceDownLeft(labelSizeY, labelSizeX, 10);

            _uiInfoTextBoxSizeY = new TextBoxNumeric(_windowInfoScript);
            _uiInfoTextBoxSizeY.SetSize(100, _uiInfoTextBoxSizeY.Height);
            _uiInfoTextBoxSizeY.TextChanged += (sender, arguments) => {
                if (_selectScript != null) {
                    _selectScript.RectShape.Size = new Vector2f(_selectScript.RectShape.Size.X,
                        (int)_uiInfoTextBoxSizeY.Value);
                    _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2);
                }
            };
            Align.PlaceRightBottom(_uiInfoTextBoxSizeY, labelSizeY, 10);

            _uiInfoScriptImage = new ImagePanel(_windowInfoScript);
            _uiInfoScriptImage.SetSize(75, 75);
            _uiInfoScriptImage.Hide();

            Align.PlaceDownLeft(_uiInfoScriptImage, _uiInfoTextBoxSizeY, 10);
            Align.CenterHorizontally(_uiInfoScriptImage);

            UnSelect_SelectScript();
        }
示例#26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HSVColorPicker"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public HSVColorPicker(Base parent)
            : base(parent)
        {
            MouseInputEnabled = true;
            SetSize(256, 128);
            //ShouldCacheToTexture = true;

            m_LerpBox = new ColorLerpBox(this);
            m_LerpBox.ColorChanged += ColorBoxChanged;
            m_LerpBox.Dock = Pos.Left;

            m_ColorSlider = new ColorSlider(this);
            m_ColorSlider.SetPosition(m_LerpBox.Width + 15, 5);
            m_ColorSlider.ColorChanged += ColorSliderChanged;
            m_ColorSlider.Dock = Pos.Left;

            m_After = new ColorDisplay(this);
            m_After.SetSize(48, 24);
            m_After.SetPosition(m_ColorSlider.X + m_ColorSlider.Width + 15, 5);

            m_Before = new ColorDisplay(this);
            m_Before.SetSize(48, 24);
            m_Before.SetPosition(m_After.X, 28);

            int x = m_Before.X;
            int y = m_Before.Y + 30;

            {
                Label label = new Label(this);
                label.SetText("R:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "RedBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("G:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "GreenBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            y += 20;

            {
                Label label = new Label(this);
                label.SetText("B:");
                label.SizeToContents();
                label.SetPosition(x, y);

                TextBoxNumeric numeric = new TextBoxNumeric(this);
                numeric.Name = "BlueBox";
                numeric.SetPosition(x + 15, y - 1);
                numeric.SetSize(26, 16);
                numeric.SelectAllOnFocus = true;
                numeric.TextChanged += NumericTyped;
            }

            SetColor(DefaultColor);
        }
示例#27
0
        internal void setDescriptionLabel(string text, int height = 4)
        {
            var texts = text.Split('\n');
            var y = imagePanel.Height + height;

            if (labels != null)
            {
                foreach (var l in labels)
                {
                    l.DelayedDelete();
                }
            }

            labels = new Label[texts.Length];
            int i = 0;
            foreach (var t in texts)
            {
                labels[i] = new Label(itemInfoFrame);
                labels[i].Width = itemInfoFrame.Width;
                labels[i].Y = y;
                labels[i].Text = t;
                y += labels[i].Height + height;
                i++;
            }
        }
示例#28
0
        public void SetAccelerator(string acc)
        {
            if (m_Accelerator != null)
            {
                //m_Accelerator.DelayedDelete(); // to prevent double disposing
                m_Accelerator = null;
            }

            if (acc == String.Empty)
                return;

            m_Accelerator = new Label(this);
            m_Accelerator.Dock = Pos.Right;
            m_Accelerator.Alignment = Pos.Right | Pos.CenterV;
            m_Accelerator.Text = acc;
            m_Accelerator.Margin = new Margin(0, 0, 16, 0);
            // todo
        }
示例#29
0
        protected void CreateLabel(String text, TextBlock block, ref int x, ref int y, ref int lineHeight, bool noSplit)
        {
            // Use default font or is one set?
            Font font = Skin.DefaultFont;
            if (block.Font != null)
                font = block.Font;

            // This string is too long for us, split it up.
            Point p = Skin.Renderer.MeasureText(font, text);

            if (lineHeight == -1)
            {
                lineHeight = p.Y;
            }

            if (!noSplit)
            {
                if (x + p.X > Width)
                {
                    SplitLabel(text, font, block, ref x, ref y, ref lineHeight);
                    return;
                }
            }

            // Wrap
            if (x + p.X >= Width)
            {
                CreateNewline(ref x, ref y, lineHeight);
            }

            Label label = new Label(this);
            label.SetText(x == 0 ? text.TrimStart(' ') : text);
            label.TextColor = block.Color;
            label.Font = font;
            label.SizeToContents();
            label.SetPosition(x, y);

            //lineheight = (lineheight + pLabel.Height()) / 2;			

            x += label.Width;

            if (x >= Width)
            {
                CreateNewline(ref x, ref y, lineHeight);
            }
        }
示例#30
0
		public static void Main(string[] args) {
			g_testEntries = AllTests.GetTests();
			testCount = g_testEntries.Count();

			testIndex = Math.Max(0, Math.Min(testIndex, testCount - 1));
			testSelection = testIndex;

			entry = g_testEntries[testIndex];
			test = entry.createFcn();

			GraphicsManager.SetWindowState(OpenTK.WindowState.Maximized);
			string title = String.Format("Box2D Version {0}.{1}.{2}", Settings._version.major, Settings._version.minor, Settings._version.revision);
			GraphicsManager.SetTitle(title);

			camera = new Camera2D();
			camera.OnRender += SimulationLoop;

			camera.SetZoom(12);
			camera.CenterOnTarget(true);
			camera.SetLocation(0, 0);

			GraphicsManager.Update += new GraphicsManager.Updater(GraphicsManager_Update);

			WindowControl glui = new WindowControl(MainCanvas.GetCanvas());
			glui.Dock = Gwen.Pos.Left;

			Label text = new Label(glui);
			text.Text = "Tests";
			text.SetPosition(10, 10);

			testList = new ListBox(glui);
			testList.RowSelected += delegate(Base sender, ItemSelectedEventArgs tlargs) {
				testSelection = testList.SelectedRowIndex;
			};
			foreach (TestEntry e in g_testEntries) {
				testList.AddRow(e.name, "", e);
			}
			testList.SelectedRowIndex = testSelection;
			testList.SetPosition(10, 30);
			testList.SetSize(170, 180);

			//glui.add_separator();
			Base SettingsBox = new Base(glui);
			SettingsBox.SetSize(200, 185);
			SettingsBox.SetPosition(0, 250);
			{
				NumericUpDown spinner = new NumericUpDown(SettingsBox);
				spinner.Text = "Vel Iters";
				spinner.Min = 1;
				spinner.Max = 500;
				spinner.ValueChanged += delegate(Base sender, EventArgs vcargs) {
					settings.velocityIterations = (int)spinner.Value;
				};
				spinner.Value = settings.velocityIterations;
				spinner.SetPosition(10, 10);

				NumericUpDown posSpinner = new NumericUpDown(SettingsBox);
				posSpinner.Min = 0;
				posSpinner.Max = 100;
				posSpinner.Text = "Pos Iters";
				posSpinner.ValueChanged += delegate(Base sender, EventArgs psargs) {
					settings.positionIterations = (int)posSpinner.Value;
				};
				posSpinner.Value = settings.positionIterations;
				posSpinner.SetPosition(10, 35);

				NumericUpDown hertzSpinner = new NumericUpDown(SettingsBox);
				hertzSpinner.Text = "Hertz";
				hertzSpinner.Min = 5;
				hertzSpinner.Max = 200;
				hertzSpinner.ValueChanged += delegate(Base sender, EventArgs hargs) {
					settingsHz = hertzSpinner.Value;
				};
				hertzSpinner.Value = settingsHz;
				hertzSpinner.SetPosition(10, 60);

				LabeledCheckBox scb = new LabeledCheckBox(SettingsBox);
				scb.Text = "Sleep";
				scb.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableSleep = scb.IsChecked;
				};
				scb.IsChecked = settings.enableSleep;
				scb.SetPosition(10, 85);

				LabeledCheckBox wsu = new LabeledCheckBox(SettingsBox);
				wsu.Text = "Warm Starting";
				wsu.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableWarmStarting = wsu.IsChecked;
				};
				wsu.IsChecked = settings.enableWarmStarting;
				wsu.SetPosition(10, 110);

				LabeledCheckBox toi = new LabeledCheckBox(SettingsBox);
				toi.Text = "Time of Impact";
				toi.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableContinuous = toi.IsChecked;
				};
				toi.IsChecked = settings.enableContinuous;
				toi.SetPosition(10, 135);

				LabeledCheckBox ssb = new LabeledCheckBox(SettingsBox);
				ssb.Text = "Sub-Stepping";
				ssb.CheckChanged += delegate(Base sender, EventArgs argsscb) {
					settings.enableSubStepping = ssb.IsChecked;
				};
				ssb.IsChecked = settings.enableSubStepping;
				ssb.SetPosition(10, 160);
			}

			Base drawPanel = new Base(glui);
			drawPanel.Dock = Gwen.Pos.Bottom;
			drawPanel.SetSize(200, 225);
			{
				LabeledCheckBox cbShapes = new LabeledCheckBox(drawPanel);
				cbShapes.Text = "Shapes";
				cbShapes.IsChecked = settings.drawShapes;
				cbShapes.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawShapes = cbShapes.IsChecked;
				};
				cbShapes.SetPosition(10, 10);



				//glui.add_checkbox_to_panel(drawPanel, "Joints", &settings.drawJoints);
				LabeledCheckBox cbJoints = new LabeledCheckBox(drawPanel);
				cbJoints.Text = "Joints";
				cbJoints.IsChecked = settings.drawJoints;
				cbJoints.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawJoints = cbJoints.IsChecked;
				};
				cbJoints.SetPosition(10, 30);



				//glui.add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs);
				LabeledCheckBox cbAABBs = new LabeledCheckBox(drawPanel);
				cbAABBs.Text = "AABBs";
				cbAABBs.IsChecked = settings.drawAABBs;
				cbAABBs.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawAABBs = cbAABBs.IsChecked;
				};
				cbAABBs.SetPosition(10, 50);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Points", &settings.drawContactPoints);
				LabeledCheckBox cbPoints = new LabeledCheckBox(drawPanel);
				cbPoints.Text = "Contact Points";
				cbPoints.IsChecked = settings.drawContactPoints;
				cbPoints.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactPoints = cbPoints.IsChecked;
				};
				cbPoints.SetPosition(10, 70);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Normals", &settings.drawContactNormals);
				LabeledCheckBox cbNormals = new LabeledCheckBox(drawPanel);
				cbNormals.Text = "Contact Normals";
				cbNormals.IsChecked = settings.drawContactNormals;
				cbNormals.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactNormals = cbNormals.IsChecked;
				};
				cbNormals.SetPosition(10, 90);



				//glui.add_checkbox_to_panel(drawPanel, "Contact Impulses", &settings.drawContactImpulse);
				LabeledCheckBox cbImpulses = new LabeledCheckBox(drawPanel);
				cbImpulses.Text = "Contact Impulses";
				cbImpulses.IsChecked = settings.drawContactImpulse;
				cbImpulses.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawContactImpulse = cbImpulses.IsChecked;
				};
				cbImpulses.SetPosition(10, 110);



				//glui.add_checkbox_to_panel(drawPanel, "Friction Impulses", &settings.drawFrictionImpulse);
				LabeledCheckBox cbFriction = new LabeledCheckBox(drawPanel);
				cbFriction.Text = "Friction Impulses";
				cbFriction.IsChecked = settings.drawFrictionImpulse;
				cbFriction.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawFrictionImpulse = cbFriction.IsChecked;
				};
				cbFriction.SetPosition(10, 130);



				//glui.add_checkbox_to_panel(drawPanel, "Center of Masses", &settings.drawCOMs);
				LabeledCheckBox cbMasses = new LabeledCheckBox(drawPanel);
				cbMasses.Text = "Center of Masses";
				cbMasses.IsChecked = settings.drawCOMs;
				cbMasses.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawCOMs = cbMasses.IsChecked;
				};
				cbMasses.SetPosition(10, 150);



				//glui.add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats);
				LabeledCheckBox cbStatistics = new LabeledCheckBox(drawPanel);
				cbStatistics.Text = "Statistics";
				cbStatistics.IsChecked = settings.drawStats;
				cbStatistics.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawStats = cbStatistics.IsChecked;
				};
				cbStatistics.SetPosition(10, 170);



				//glui.add_checkbox_to_panel(drawPanel, "Profile", &settings.drawProfile);
				LabeledCheckBox cbProfile = new LabeledCheckBox(drawPanel);
				cbProfile.Text = "Profile";
				cbProfile.IsChecked = settings.drawProfile;
				cbProfile.CheckChanged += delegate(Base cbshapes, EventArgs eacbshapes) {
					settings.drawProfile = cbProfile.IsChecked;
				};
				cbProfile.SetPosition(10, 190);
			}


			Base Buttons = new Base(glui);
			Buttons.Dock = Gwen.Pos.Bottom;
			Buttons.Height = 100;
			{
				Button btnPause = new Button(Buttons);
				btnPause.Text = "Pause";
				btnPause.IsToggle = true;
				btnPause.SetPosition(10, 10);
				btnPause.ToggleState = settings.pause;
				btnPause.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					settings.pause = btnPause.ToggleState;
				};

				Button btnSS = new Button(Buttons);
				btnSS.Text = "Single Step";
				btnSS.SetPosition(10, 40);
				btnSS.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					SingleStep();
				};

				Button btnRestart = new Button(Buttons);
				btnRestart.Text = "Restart";
				btnRestart.SetPosition(10, 70);
				btnRestart.Clicked += delegate(Base sender, ClickedEventArgs evargs) {
					Restart();
				};
			}

			glui.SetSize(200, 300);			
			GraphicsManager.Start();
		}
示例#31
0
        public Screen_Settings(Base parent)
            : base(parent)
        {
            SetSize(parent.Width, parent.Height);

            Gwen.Control.Label label = new Gwen.Control.Label(this);
            label.Text = "Settings";
            label.SetPosition(30, 30);
            label.TextColor = Color.FromArgb(200, 80, 0, 250);
            label.Font      = Program.fontLogo;

            Gwen.Control.WindowControl settingsWindow = new Gwen.Control.WindowControl(this);
            settingsWindow.Width  = parent.Width / 2;
            settingsWindow.Height = parent.Height / 2;
            settingsWindow.SetPosition(parent.Width / 2 - settingsWindow.Width / 2, parent.Height / 2 - settingsWindow.Height / 2);

            Gwen.Control.Label musicLabel = new Gwen.Control.Label(settingsWindow);
            musicLabel.Text = "Music:";
            musicLabel.SetPosition(parent.Width / 10, parent.Height / 10);
            musicLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            musicLabel.Font      = Program.fontText;

            Gwen.Control.HorizontalSlider musicSlider = new Gwen.Control.HorizontalSlider(settingsWindow);
            musicSlider.SetPosition(parent.Width / 5, parent.Height / 10);
            musicSlider.SetSize(parent.Width / 10, musicLabel.Height);

            Gwen.Control.Label sfxLabel = new Gwen.Control.Label(settingsWindow);
            sfxLabel.Text = "SFX:";
            sfxLabel.SetPosition(parent.Width / 10, musicLabel.Y + musicLabel.Height);
            sfxLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            sfxLabel.Font      = Program.fontText;

            Gwen.Control.CheckBox sfxCheckBox = new Gwen.Control.CheckBox(settingsWindow);
            sfxCheckBox.SetPosition(parent.Width / 5, musicLabel.Y + musicLabel.Height);

            Gwen.Control.Label fpsLabel = new Gwen.Control.Label(settingsWindow);
            fpsLabel.Text = "FPS Limit:";
            fpsLabel.SetPosition(parent.Width / 10, sfxLabel.Y + sfxLabel.Height);
            fpsLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            fpsLabel.Font      = Program.fontText;

            Gwen.Control.HorizontalSlider fpsSlider = new Gwen.Control.HorizontalSlider(settingsWindow);
            fpsSlider.SetPosition(parent.Width / 5, sfxLabel.Y + sfxLabel.Height);
            fpsSlider.SetSize(parent.Width / 10, sfxLabel.Height);

            Gwen.Control.Label resolutionLabel = new Gwen.Control.Label(settingsWindow);
            resolutionLabel.Text = "Resolution:";
            resolutionLabel.SetPosition(parent.Width / 10, fpsLabel.Y + fpsLabel.Height);
            resolutionLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            resolutionLabel.Font      = Program.fontText;

            Gwen.Control.ComboBox resolution = new ComboBox(settingsWindow);
            resolution.AddItem("800x600");
            resolution.AddItem("1024x768");
            resolution.SetPosition(parent.Width / 5, fpsLabel.Y + fpsLabel.Height);
            resolution.SetSize(parent.Width / 10, resolutionLabel.Height);

            Gwen.Control.Label fullScreenLabel = new Gwen.Control.Label(settingsWindow);
            fullScreenLabel.Text = "Full screen:";
            fullScreenLabel.SetPosition(parent.Width / 10, resolutionLabel.Y + resolutionLabel.Height);
            fullScreenLabel.TextColor = Color.FromArgb(255, 0, 0, 0);
            fullScreenLabel.Font      = Program.fontText;

            Gwen.Control.CheckBox fullScreenCheckBox = new Gwen.Control.CheckBox(settingsWindow);
            fullScreenCheckBox.SetPosition(parent.Width / 5, resolutionLabel.Y + resolutionLabel.Height);
            if (fullScreen == true)
            {
                fullScreenCheckBox.Toggle();
            }
            fullScreenCheckBox.Checked   += fullScreenEnable;
            fullScreenCheckBox.UnChecked += fullScreenDisable;

            Gwen.Control.Button buttonOK = new Gwen.Control.Button(this);
            buttonOK.Text = "OK";
            buttonOK.Font = Program.fontButtonLabels;
            buttonOK.SetBounds(550, 500, 200, 50);
            buttonOK.Clicked += onButtonOKClick;
        }
示例#32
0
        public SettingsMenu (Application app, Base parent, CompositorColorCorrectionNode colorCorrectionNode)
        {
            this.application = app;
            this.parent = parent;
            this.colorCorrectionNode = colorCorrectionNode;
            window = new WindowControl (parent);
            window.DisableResizing();
            window.Title = Localizer.Instance.GetValueForName("settings");
            window.Hide();

            float gamma = (float) ConfigManager.Instance["freezing_archer"].GetDouble("general", "gamma");
            colorCorrectionNode.Gamma = gamma;
            string language = ConfigManager.Instance["freezing_archer"].GetString("general", "language");
            Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), language);

            languageLabel = new Label (window);
            languageLabel.AutoSizeToContents = true;
            languageLabel.Y = 10;
            languageLabel.Text = Localizer.Instance.GetValueForName("language");

            languageDropdown = new ComboBox (window);
            languageDropdown.Width = CONTROL_WIDTH;
            languageDropdown.Y = 10;
            foreach (var lang in Localizer.Instance.Locales)
            {
                var item = languageDropdown.AddItem(Localizer.Instance.GetValueForName(lang.Key.ToString()), lang.Key.ToString());
                item.AutoSizeToContents = false;
                item.Width = CONTROL_WIDTH;
            }
            languageDropdown.SelectByText(Localizer.Instance.GetValueForName(Localizer.Instance.CurrentLocale.ToString()));
            languageDropdown.ItemSelected += handleSelect;

            gammaSlider = new HorizontalSlider (window);
            gammaSlider.SnapToNotches = false;
            gammaSlider.Min = 0;
            gammaSlider.Max = 3;
            gammaSlider.Value = gamma;
            gammaSlider.ValueChanged += (sender, arguments) => {
                var slider = sender as HorizontalSlider;
                ConfigManager.Instance["freezing_archer"].SetDouble("general", "gamma", slider.Value);
                if (slider != null)
                    this.colorCorrectionNode.Gamma = slider.Value;
            };
            gammaSlider.Width = CONTROL_WIDTH;
            gammaSlider.Height = 20;
            gammaSlider.Y = 10 + languageDropdown.Y + languageDropdown.Height;

            gammaLabel = new Label (window);
            gammaLabel.AutoSizeToContents = true;
            gammaLabel.Y = 10 + languageLabel.Y + languageLabel.Height;
            gammaLabel.Text = Localizer.Instance.GetValueForName("gamma");

            int max_width = languageLabel.Width > gammaLabel.Width ? languageLabel.Width : gammaLabel.Width;

            languageLabel.X = 10 + max_width - languageLabel.Width;
            gammaLabel.X = 10 + max_width - gammaLabel.Width;
            languageDropdown.X = 10 + max_width + 5;
            gammaSlider.X = 10 + max_width + 5;

            window.Width = 40 + max_width + CONTROL_WIDTH;

            resetButton = new Button (window);
            resetButton.Text = Localizer.Instance.GetValueForName("reset");
            resetButton.Width = (window.Width / 2) - 20;
            resetButton.X = 10;
            resetButton.Y = gammaSlider.Y + gammaSlider.Height + 10;
            resetButton.Clicked += (sender, arguments) => {
                var general = ConfigManager.DefaultConfig.B.FirstOrDefault (a => a.Key == "general");
                var gamma_pair = general.Value.FirstOrDefault(a => a.Key == "gamma");
                
                float _gamma = (float) gamma_pair.Value.Double;
                gammaSlider.Value = _gamma;
                colorCorrectionNode.Gamma = _gamma;

                var language_pair = general.Value.FirstOrDefault(a => a.Key == "language");

                string lang = language_pair.Value.String;
                Localizer.Instance.CurrentLocale = (LocaleEnum) Enum.Parse(typeof (LocaleEnum), lang);
            };

            saveButton = new Button (window);
            saveButton.Text = Localizer.Instance.GetValueForName("save");
            saveButton.Width = (window.Width / 2) - 20;
            saveButton.X = resetButton.X + resetButton.Width + 10;
            saveButton.Y = gammaSlider.Y + gammaSlider.Height + 10;
            saveButton.Clicked += (sender, arguments) => ConfigManager.Instance.SaveAll();

            window.Height += languageDropdown.Height + gammaSlider.Height + 50;
            window.X = (parent.Width - window.Width) / 2;
            window.Y = (parent.Height - window.Height) / 2;

            ValidMessages = new[] { (int) MessageId.UpdateLocale };
            application.MessageManager += this;
        }
示例#33
0
        public void ConsumeMessage (IMessage msg)
        {
            if (msg.MessageId == (int) MessageId.GameEnded || msg.MessageId == (int)MessageId.GameEndedDied)
            {
                Application.Window.ReleaseMouse ();

                Canvas = Renderer.Canvas;
                Canvas.DeleteAllChildren();

                minuteCount = (float) (DateTime.Now - MazeTest.StartTime).TotalMinutes;

                exitButton = new Button (Canvas);
                exitButton.Text = Localizer.Instance.GetValueForName("quit_game");
                exitButton.Width = 300;
                exitButton.X = (Canvas.Width - exitButton.Width) / 2;
                exitButton.Y = Canvas.Height - exitButton.Height - 20;
                exitButton.Clicked += (sender, arguments) => Application.Window.Close ();

                surviveTimeLabel = new Label (Canvas);
                surviveTimeLabel.AutoSizeToContents = true;
                surviveTimeLabel.Text = string.Format("{0} {1:0.##} {2}", Localizer.Instance.GetValueForName("you_survived"),
                    minuteCount, Localizer.Instance.GetValueForName("minutes"));
                surviveTimeLabel.X = (Canvas.Width - surviveTimeLabel.Width) / 2;
                surviveTimeLabel.Y = exitButton.Y - surviveTimeLabel.Height - 40;

                labelWin = new ImagePanel (Canvas);
                labelWin.Width = 1211;
                labelWin.Height = 170;
                labelWin.X = (Canvas.Width - labelWin.Width) / 2;
                labelWin.Y = 100;
                labelWin.ImageName = "Content/YouEscapedTheMaze.png";
                labelWin.Hide();

                labelWin_de = new ImagePanel (Canvas);
                labelWin_de.Width = 1211;
                labelWin_de.Height = 170;
                labelWin_de.X = (Canvas.Width - labelWin_de.Width) / 2;
                labelWin_de.Y = 100;
                labelWin_de.ImageName = "Content/YouEscapedTheMaze_de.png";
                labelWin_de.Hide();

                labelLoose = new ImagePanel (Canvas);
                labelLoose.Width = 845;
                labelLoose.Height = 168;
                labelLoose.X = (Canvas.Width - labelLoose.Width) / 2;
                labelLoose.Y = 100;
                labelLoose.ImageName = "Content/YouAreDead.png";
                labelLoose.Hide();
                labelLoose_de = new ImagePanel (Canvas);
                labelLoose_de.Width = 845;
                labelLoose_de.Height = 168;
                labelLoose_de.X = (Canvas.Width - labelLoose_de.Width) / 2;
                labelLoose_de.Y = 100;
                labelLoose_de.ImageName = "Content/YouAreDead_de.png";
                labelLoose_de.Hide();
               
                if (msg.MessageId == (int) MessageId.GameEndedDied)
                {
                    if (Localizer.Instance.CurrentLocale == LocaleEnum.de_DE)
                    {
                        labelLoose_de.Show();
                    }
                    else
                    {
                        labelLoose.Show();
                    }
                    win = false;
                }
                else
                {
                    if (Localizer.Instance.CurrentLocale == LocaleEnum.de_DE)
                    {
                        labelWin_de.Show();
                    }
                    else
                    {
                        labelWin.Show();
                    }
                    win = true;
                }
            }

            if (msg.MessageId == (int) MessageId.WindowResize)
            {
                if (exitButton != null)
                {
                    exitButton.X = (Canvas.Width - exitButton.Width) / 2;
                    exitButton.Y = Canvas.Height - exitButton.Height - 20;
                }

                if (surviveTimeLabel != null)
                {
                    surviveTimeLabel.X = (Canvas.Width - surviveTimeLabel.Width) / 2;
                    surviveTimeLabel.Y = exitButton.Y - surviveTimeLabel.Height - 40;
                }

                if (labelWin != null)
                    labelWin.X = (Canvas.Width - labelWin.Width) / 2;

                if (labelWin_de != null)
                    labelWin_de.X = (Canvas.Width - labelWin_de.Width) / 2;

                if (labelLoose != null)
                    labelLoose.X = (Canvas.Width - labelLoose.Width) / 2;

                if (labelLoose_de != null)
                    labelLoose_de.X = (Canvas.Width - labelLoose_de.Width) / 2;
            }

            if (msg.MessageId == (int) MessageId.UpdateLocale)
            {
                surviveTimeLabel.Text = string.Format("{0} {1:#.##} {2}", Localizer.Instance.GetValueForName("you_survived"),
                    minuteCount, Localizer.Instance.GetValueForName("minutes"));
                exitButton.Text = Localizer.Instance.GetValueForName("quit_game");

                if (Localizer.Instance.CurrentLocale == LocaleEnum.de_DE)
                {
                    if (win && labelWin != null && labelWin_de != null)
                    {
                        labelWin.Hide();
                        labelWin_de.Show();
                    }
                    else if (labelLoose != null && labelLoose_de != null)
                    {
                        labelLoose.Hide();
                        labelLoose_de.Show();
                    }
                }
                else
                {
                    if (win && labelWin != null && labelWin_de != null)
                    {
                        labelWin_de.Hide();
                        labelWin.Show();
                    }
                    else if (labelLoose != null && labelLoose_de != null)
                    {
                        labelLoose_de.Hide();
                        labelLoose.Show();
                    }
                }
            }
        }
示例#34
0
        private void InitializeUI()
        {
            settings = NavMeshGenerationSettings.Default;
            areaSettings = new AreaIdGenerationSettings();

            DockBase dock = new DockBase(gwenCanvas);
            dock.Dock = Pos.Fill;
            dock.SetSize(Width, Height);
            dock.RightDock.Width = 280;
            dock.BottomDock.Height = 150;

            statusBar = new StatusBar(gwenCanvas);

            Label genTime = new Label(statusBar);
            genTime.Name = "GenTime";
            genTime.Text = "Generation Time: 0ms";
            genTime.Dock = Pos.Left;

            LabeledCheckBox catchCheckBox = new LabeledCheckBox(statusBar);
            catchCheckBox.Text = "Intercept and log exceptions";
            catchCheckBox.Dock = Pos.Right;
            catchCheckBox.CheckChanged += (s, e) => interceptExceptions = catchCheckBox.IsChecked;
            catchCheckBox.IsChecked = true;

            Base genBase = new Base(dock);
            dock.RightDock.TabControl.AddPage("NavMesh Generation", genBase);

            Button generateButton = new Button(genBase);
            generateButton.Text = "Generate!";
            generateButton.Height = 30;
            generateButton.Dock = Pos.Top;
            generateButton.Released += (s, e) => GenerateNavMesh();

            GroupBox displaySettings = new GroupBox(genBase);
            displaySettings.Text = "Display";
            displaySettings.Dock = Pos.Top;
            displaySettings.Height = 60;

            Base levelCheckBase = new Base(displaySettings);
            levelCheckBase.Dock = Pos.Top;

            Label levelCheckLabel = new Label(levelCheckBase);
            levelCheckLabel.Text = "Level";
            levelCheckLabel.Dock = Pos.Left;

            CheckBox levelCheckBox = new CheckBox(levelCheckBase);
            levelCheckBox.Dock = Pos.Right;
            levelCheckBox.Checked += (s, e) => displayLevel = true;
            levelCheckBox.UnChecked += (s, e) => displayLevel = false;
            levelCheckBox.IsChecked = true;

            levelCheckBase.SizeToChildren();

            Base displayModeBase = new Base(displaySettings);
            displayModeBase.Dock = Pos.Top;
            displayModeBase.Padding = new Padding(0, 4, 0, 0);

            Label displayModeLabel = new Label(displayModeBase);
            displayModeLabel.Text = "Generation Step";
            displayModeLabel.Dock = Pos.Left;
            displayModeLabel.Padding = new Padding(0, 0, 4, 0);

            ComboBox displayModes = new ComboBox(displayModeBase);
            displayModes.Dock = Pos.Top;
            displayModes.AddItem("None", "", DisplayMode.None);
            displayModes.AddItem("Heightfield", "", DisplayMode.Heightfield);
            displayModes.AddItem("Compact Heightfield", "", DisplayMode.CompactHeightfield);
            displayModes.AddItem("Distance Field", "", DisplayMode.DistanceField);
            displayModes.AddItem("Regions", "", DisplayMode.Regions);
            displayModes.AddItem("Contours", "", DisplayMode.Contours);
            displayModes.AddItem("Polygon Mesh", "", DisplayMode.PolyMesh);
            displayModes.AddItem("Polygon Mesh Detail", "", DisplayMode.PolyMeshDetail);
            displayModes.AddItem("NavMesh", "", DisplayMode.NavMesh);
            displayModes.AddItem("Pathfinding", "", DisplayMode.Pathfinding);
            displayModes.ItemSelected += (s, e) => displayMode = (DisplayMode)e.SelectedItem.UserData;

            displayModes.SelectByUserData(DisplayMode.PolyMeshDetail);

            displayModeBase.SizeToChildren();
            displayModeBase.Height += 4; //accounts for the padding, GWEN.NET should do this

            const int leftMax = 125;
            const int rightMax = 20;

            GroupBox areaSetting = new GroupBox(genBase);
            areaSetting.Text = "Area";
            areaSetting.Dock = Pos.Top;
            areaSetting.Height = 90;

            var levelTris = level.GetTriangles();
            BBox3 bounds = TriangleEnumerable.FromTriangle(levelTris, 0, levelTris.Length).GetBoundingBox();

            Base maxTriSlope = CreateSliderOption(areaSetting, "Max Tri Slope:", 0.0001f, 3.14f, 3.14f, "N2", leftMax, rightMax, v => areaSettings.MaxTriSlope = v);
            Base minLevelHeight = CreateSliderOption(areaSetting, "Min Height:", bounds.Min.Y, bounds.Max.Y, bounds.Min.Y, "N0", leftMax, rightMax, v => areaSettings.MinLevelHeight = v);
            Base maxLevelHeight = CreateSliderOption(areaSetting, "Max Height:", bounds.Min.Y, bounds.Max.Y, bounds.Max.Y, "N0", leftMax, rightMax, v => areaSettings.MaxLevelHeight = v);

            GroupBox rsSettings = new GroupBox(genBase);
            rsSettings.Text = "Rasterization";
            rsSettings.Dock = Pos.Top;
            rsSettings.Height = 90;

            Base cellSizeSetting = CreateSliderOption(rsSettings, "Cell Size:", 0.1f, 2.0f, 0.3f, "N2", leftMax, rightMax, v => settings.CellSize = v);
            Base cellHeightSetting = CreateSliderOption(rsSettings, "Cell Height:", 0.1f, 2f, 0.2f, "N2", leftMax, rightMax, v => settings.CellHeight = v);

            GroupBox agentSettings = new GroupBox(genBase);
            agentSettings.Text = "Agent";
            agentSettings.Dock = Pos.Top;
            agentSettings.Height = 115;

            Base maxSlopeSetting = CreateSliderOption(agentSettings, "Max Climb:", 0.1f, 5.0f, 0.9f, "N0", leftMax, rightMax, v => settings.MaxClimb = v);
            Base maxHeightSetting = CreateSliderOption(agentSettings, "Height:", 0.1f, 5.0f, 2.0f, "N0", leftMax, rightMax, v => settings.AgentHeight = v);
            Base erodeRadius = CreateSliderOption(agentSettings, "Radius:", 0.0f, 5.0f, 0.6f, "N1", leftMax, rightMax, v => { settings.AgentRadius = v; agentCylinder.Radius = v; });
            Base addRemoveAgent = CreateAddRemoveButton(agentSettings, "Count", leftMax, rightMax, 0, MAX_AGENTS, () => { numActiveAgents++; GenerateCrowd(); }, () => { numActiveAgents--; GenerateCrowd(); });

            GroupBox regionSettings = new GroupBox(genBase);
            regionSettings.Text = "Region";
            regionSettings.Dock = Pos.Top;
            regionSettings.Height = 65;

            Base minRegionSize = CreateSliderOption(regionSettings, "Min Region Size:", 0f, 150f, 8f, "N0", leftMax, rightMax, v => settings.MinRegionSize = (int)Math.Round(v));
            Base mrgRegionSize = CreateSliderOption(regionSettings, "Merged Region Size:", 0f, 150f, 20f, "N0", leftMax, rightMax, v => settings.MergedRegionSize = (int)Math.Round(v));

            GroupBox navMeshSettings = new GroupBox(genBase);
            navMeshSettings.Text = "NavMesh";
            navMeshSettings.Dock = Pos.Top;
            navMeshSettings.Height = 90;

            Base maxEdgeLength = CreateSliderOption(navMeshSettings, "Max Edge Length:", 0f, 50f, 12f, "N0", leftMax, rightMax, v => settings.MaxEdgeLength = (int)Math.Round(v));
            Base maxEdgeErr = CreateSliderOption(navMeshSettings, "Max Edge Error:", 0f, 3f, 1.8f, "N1", leftMax, rightMax, v => settings.MaxEdgeError = v);
            Base vertsPerPoly = CreateSliderOption(navMeshSettings, "Verts Per Poly:", 3f, 12f, 6f, "N0", leftMax, rightMax, v => settings.VertsPerPoly = (int)Math.Round(v));

            GroupBox navMeshDetailSettings = new GroupBox(genBase);
            navMeshDetailSettings.Text = "NavMeshDetail";
            navMeshDetailSettings.Dock = Pos.Top;
            navMeshDetailSettings.Height = 65;

            Base sampleDistance = CreateSliderOption(navMeshDetailSettings, "Sample Distance:", 0f, 16f, 6f, "N0", leftMax, rightMax, v => settings.SampleDistance = (int)Math.Round(v));
            Base maxSampleError = CreateSliderOption(navMeshDetailSettings, "Max Sample Error:", 0f, 16f, 1f, "N0", leftMax, rightMax, v => settings.MaxSampleError = (int)Math.Round(v));

            Base logBase = new Base(dock);
            dock.BottomDock.TabControl.AddPage("Log", logBase);

            ListBox logBox = new ListBox(logBase);
            logBox.Dock = Pos.Fill;
            logBox.AllowMultiSelect = false;
            logBox.EnableScroll(true, true);
            Console.SetOut(new GwenTextWriter(logBox));
        }
示例#35
0
        private void setupUi()
        {
            renderer = new Gwen.Renderer.OpenTK();
            Gwen.Skin.Base skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png");
            canvas = new Canvas(skin);
            canvas.SetSize(Width, Height);

            gwenInput = new Gwen.Input.OpenTK(this);
            gwenInput.Initialize(canvas);

            Mouse.ButtonDown += Mouse_ButtonDown;
            Mouse.ButtonUp += Mouse_ButtonUp;
            Mouse.Move += Mouse_Move;
            Mouse.WheelChanged += Mouse_Wheel;

            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor = System.Drawing.Color.FromArgb(122, 150, 170, 170);

            // controls
            radioCamera = new RadioButtonGroup(canvas);
            radioCamera.AutoSizeToContents = true;
            radioCamera.SetText("Тип камеры");
            radioCamera.AddOption("Свободная", "free");
            radioCamera.AddOption("Привязанная", "bound");
            radioCamera.SetSelection(0);
            radioCamera.SelectionChanged += radioCamera_SelectionChanged;

            // coord
            GroupBox posGroup = new GroupBox(canvas);
            posGroup.SetText("Позиция камеры");
            posGroup.SizeToChildren();
            posGroup.SetSize(150, 120);
            Gwen.Align.PlaceDownLeft(posGroup, radioCamera, 45);

            labelPosX = new Label(posGroup);
            labelPosY = new Label(posGroup);
            labelPosZ = new Label(posGroup);
            labelPosX.SetText("X: 0.0");
            labelPosY.SetText("Y: 1.0");
            labelPosZ.SetText("Z: 2.0");
            Gwen.Align.PlaceDownLeft(labelPosY, labelPosX, 5);
            Gwen.Align.PlaceDownLeft(labelPosZ, labelPosY, 5);

            // reset button
            Button resetCameraButton = new Gwen.Control.Button(posGroup);
            resetCameraButton.SetText("Сбросить позицию\nкамеры");
            resetCameraButton.Clicked += cameraReset_Clicked;
            resetCameraButton.SizeToContents();
            Gwen.Align.PlaceDownLeft(resetCameraButton, labelPosZ, 5);

            labelSpeed = new Label(canvas);
            Gwen.Align.PlaceDownLeft(labelSpeed, posGroup, 5);

            labelTips = new Label(canvas);
            labelTips.SetText(freeCameraTip + "\n\n" + nodeTransformTip);
            labelTips.SizeToContents();
            Gwen.Align.PlaceDownLeft(labelTips, labelSpeed, 15);

            statusBar = new Gwen.Control.StatusBar(canvas);
            statusBar.Dock = Gwen.Pos.Bottom;
        }
示例#36
0
        void updateTutorialText (string text = null)
        {
            if (text != null && textLabels != null)
            {
                foreach (var line in textLabels)
                {
                    foreach (var word in line)
                    {
                        word.Parent.RemoveChild(word, true);
                    }
                }
            }

            if (textLabels == null || text != null)
            {
                RegexOptions options = RegexOptions.Multiline;
                var regex = new Regex(@"(.+)(\n*)\n", options);     
                var m = regex.Matches(text);
                string new_text = "";
                foreach (Match match in m)
                {
                    new_text += match.Groups[1] + " " + match.Groups[2];
                }

                regex = new Regex (@"\n(.)$", options);
                new_text += regex.Match(text).Groups[1];
                text = new_text;

                textLabels = new List<List<Label>>();
                var lines = text.Split('\n');

                string[] words;
                Label label = null;
                List<Label> labelLine = null;
                foreach (var line in lines)
                {
                    labelLine = new List<Label>();
                    words = line.Split(' ');
                    foreach (var word in words)
                    {
                        if (word.Length == 0)
                            continue;

                        label = new Label(scrollFrame);
                        label.AutoSizeToContents = true;
                        label.Text = word;
                        labelLine.Add(label);
                    }
                    textLabels.Add(labelLine);
                }
            }

            int maxWidth = scrollFrame.Width;

            if (scrollFrame.CanScrollV)
            {
                maxWidth -= 16;
            }

            int y = 0, x = 0;
            const int paragraphHeight = 8;
            foreach (var line in textLabels)
            {
                foreach (var word in line)
                {
                    word.Y = y;
                    word.X = x;
                        
                    x += word.Width;

                    if (x >= maxWidth)
                    {
                        y += word.Height;
                        word.Y = y;
                        word.X = 0;
                        x = word.Width;
                    }
                }

                y += textLabels[0][0].Height + paragraphHeight;
                x = 0;
            }
        }
示例#37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuItem"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public MenuItem(ZGE.Components.ZComponent parent)
            : base(parent)
        {
            m_OnStrip = false;
            IsTabable = false;
            IsCheckable = false;
            IsChecked = false;

            m_Accelerator = new Label(this);
        }