public InGameMenu()
        {
            Size = new Vector2(250, 400);
            LargeWindow = true;

            FlowLayout leftButtons = new FlowLayout
            {
                HorizontalFill = true,
                AutoSize = true,
                Newline = false,
                Anchor = Graphics.Orientation.Left
            };
            bottomBar.AddChild(leftButtons);
            ButtonBase returnToMainMenu = new StoneButton
            {
                Text = Locale.Resource.GenQuit
            };
            returnToMainMenu.Click += new EventHandler(returnToMainMenu_Click);
            leftButtons.AddChild(returnToMainMenu);

            ButtonBase restart = new StoneButton
            {
                Text = Locale.Resource.GenRestart
            };
            restart.Click += new EventHandler(restart_Click);
            leftButtons.AddChild(restart);

            ButtonBase options = new StoneButton
            {
                Text = Locale.Resource.GenOptions
            };
            options.Click += new EventHandler(options_Click);
            leftButtons.AddChild(options);

            ButtonBase returnToGame = new LargeStoneButton
            {
                Text = Locale.Resource.GenResume,
                Anchor = global::Graphics.Orientation.Right,
                Hotkey = new KeyCombination { Key = System.Windows.Forms.Keys.Escape },
                Size = new Vector2(210, 62)
            };
            returnToGame.Click += new EventHandler(returnToGame_Click);
            bottomBar.AddChild(returnToGame);
            Result = InGameMenuResult.Resume;
        }
        protected override void OnConstruct()
        {
            Size = new Vector2(1000, 600);
            Padding = new System.Windows.Forms.Padding(20);
            Anchor = global::Graphics.Orientation.Center;
            Clickable = true;
            ControlBox = false;
            ClearChildren();

            var topBar = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Top,
                Size = new Vector2(0, 70),
                //Background = new StretchingImageGraphic
                //{
                //    Texture = new TextureConcretizer
                //    {
                //        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 0, 0))
                //    },
                //},
                Padding = new System.Windows.Forms.Padding(0, 0, 0, 5)
            };
            AddChild(topBar);

            Control topLeftBar = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Left,
                Size = new Vector2(500, 0)
            };
            topBar.AddChild(topLeftBar);
            var winLoseTextBox = new Label
            {
                Font = new Graphics.Content.Font
                {
                    SystemFont = Fonts.HugeSystemFont,
                    Color = System.Drawing.Color.Green,
                },
                AutoSize = AutoSizeMode.Full,
                TextAnchor = global::Graphics.Orientation.TopLeft,
                Dock = System.Windows.Forms.DockStyle.Top,
                Background = null,
                //Background = new StretchingImageGraphic
                //{
                //    Texture = new TextureConcretizer
                //    {
                //        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 0, 0))
                //    },
                //},
            };
            topLeftBar.AddChild(winLoseTextBox);

            if (GameState == GameState.Won)
            {
                winLoseTextBox.Text = Locale.Resource.ScoreVictory;
                winLoseTextBox.Font.Color = System.Drawing.Color.Green;
            }
            else
            {
                winLoseTextBox.Text = Locale.Resource.ScoreDefeat;
                winLoseTextBox.Font.Color = System.Drawing.Color.Red;
                topLeftBar.AddChild(new Label
                {
                    Font = new Font
                    {
                        SystemFont = Fonts.MediumSystemFont,
                        Color = System.Drawing.Color.White
                    },
                    Background = null,
                    Dock = System.Windows.Forms.DockStyle.Fill,
                    Text = LostGameReason,
                    TextAnchor = global::Graphics.Orientation.TopLeft,
                });
            }

            Control trPanel = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Right,
                Size = new Vector2(200, 40)
            };
            topBar.AddChild(trPanel);

            var gt = new DateTime(TimeSpan.FromSeconds(GameTime).Ticks);

            var timeLeftTextBox = new Label
            {
                Dock = System.Windows.Forms.DockStyle.Bottom,
                Background = null,
                Size = new Vector2(120, 20),
                TextAnchor = global::Graphics.Orientation.BottomRight,
            };
            timeLeftTextBox.Text = Locale.Resource.GenTime + ": " + gt.ToString("mm:ss");

            trPanel.AddChild(timeLeftTextBox);
            if (SilverEnabled)
            {
                Control silverTextContainer = new Control
                {
                    Dock = System.Windows.Forms.DockStyle.Bottom,
                    Size = new Vector2(0, 30),
                };
                trPanel.AddChild(silverTextContainer);
                silverTextContainer.AddChild(new SilverText
                {
                    Anchor = Orientation.BottomRight,
                    Size = new Vector2(120, 30),
                    Background = null,
                    SilverYield = SilverYield
                });
            }

            AddChild(new Control
            {
                Background = new StretchingImageGraphic
                {
                    Texture = new TextureConcretizer
                    {
                        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 255, 255))
                    },
                    SizeMode = SizeMode.AutoAdjust
                },
                Dock = System.Windows.Forms.DockStyle.Top,
                Size = new Vector2(0, 1)
            });

            Control bottomBar = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Bottom,
                Size = new Vector2(0, 50)
            };
            AddChild(bottomBar);

            FlowLayout leftBottomFlow = new FlowLayout
            {
                AutoSize = true,
                HorizontalFill = true,
                Newline = false,
                Anchor = Orientation.BottomLeft
            };
            bottomBar.AddChild(leftBottomFlow);

            FlowLayout rightBottomFlow = new FlowLayout
            {
                AutoSize = true,
                HorizontalFill = true,
                Newline = false,
                Anchor = Orientation.BottomRight,
                Origin = FlowOrigin.BottomRight,
                //Background = new StretchingImageGraphic
                //{
                //    Texture = new TextureConcretizer
                //    {
                //        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 0, 0))
                //    },
                //},
            };
            bottomBar.AddChild(rightBottomFlow);

            ButtonBase mainMenuButton = new StoneButton
            {
                AutoSize = AutoSizeMode.Horizontal,
                Padding = new System.Windows.Forms.Padding(5, 0, 5, 0)
            };
            if (FirstTimeCompletedMap)
                mainMenuButton.Text = Locale.Resource.GenContinue;
            else
                mainMenuButton.Text = Locale.Resource.GenMainMenu;
            rightBottomFlow.AddChild(mainMenuButton);
            mainMenuButton.Click += new EventHandler(mainMenuButton_Click);

            ButtonBase playAgainButton = new StoneButton
            {
                Text = Locale.Resource.GenPlayAgain,
                Visible = EarnedGoldCoins == 0,
                AutoSize = AutoSizeMode.Horizontal,
                Padding = new System.Windows.Forms.Padding(5, 0, 5, 0)
            };
            rightBottomFlow.AddChild(playAgainButton);
            playAgainButton.Click += new EventHandler(playAgainButton_Click);

            if (FirstTimeCompletedMap && Program.Settings.DisplayMapRatingDialog == MapRatingDialogSetup.Optional)
            {
                ButtonBase rateMapButton = new StoneButton
                {
                    Text = Locale.Resource.GenRateMap,
                    AutoSize = AutoSizeMode.Horizontal,
                    Padding = new System.Windows.Forms.Padding(5, 0, 5, 0)
                };
                rightBottomFlow.AddChild(rateMapButton);
                rateMapButton.Click += new EventHandler(rateMapButton_Click);
            }

            AddChild(new Control
            {
                Background = new StretchingImageGraphic
                {
                    Texture = new TextureConcretizer
                    {
                        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 255, 255))
                    },
                    SizeMode = SizeMode.AutoAdjust
                },
                Dock = System.Windows.Forms.DockStyle.Bottom,
                Size = new Vector2(0, 1)
            });

            Control main = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Fill
            };
            AddChild(main);

            //////////////////////////
            // STATS /////////////////
            //////////////////////////

            StatsControl stats = new StatsControl
            {
                Dock = System.Windows.Forms.DockStyle.Fill,
                Visible = false
            };
            stats.GameState = GameState;
            stats.LostGameReason = LostGameReason;
            stats.Statistics = Statistics;
            stats.Map = Map;
            main.AddChild(stats);

            //////////////////////////
            // REWARDS ///////////////
            //////////////////////////

            ResultsAndRewardsControl rewards = new ResultsAndRewardsControl
            {
                Dock = System.Windows.Forms.DockStyle.Fill,
                //Background = new StretchingImageGraphic
                //{
                //    Texture = new TextureConcretizer
                //    {
                //        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 0, 0))
                //    },
                //},
                Anchor = global::Graphics.Orientation.TopRight
            };
            rewards.GameState = GameState;
            rewards.EarnedGoldCoins = EarnedGoldCoins;
            rewards.NPlaythroughs = NPlaythroughs;
            rewards.AchievementsEarned = AchievementsEarned;
            rewards.SilverYield = SilverYield;
            rewards.PreviousMaxSilverYield = PreviousMaxSilverYield;
            rewards.FirstTimeCompletedMap = FirstTimeCompletedMap;
            rewards.CurrentStages = CurrentStages;
            rewards.BestStages = BestStages;
            rewards.Map = Map;
            main.AddChild(rewards);

            /////////////////////
            // Switch buttons
            /////////////////////

            CheckboxBase rnrButton = new StoneCheckbox
            {
                Text = Locale.Resource.ScoreRewardsAndResults,
                Font = new Font
                {
                    SystemFont = Fonts.MediumSystemFont,
                    Color = System.Drawing.Color.White,
                    Backdrop = System.Drawing.Color.Black
                },
                Checked = true,
                AutoCheck = false,
                Size = new Vector2(200, 38),
                AutoSize = AutoSizeMode.Horizontal,
                Padding = new System.Windows.Forms.Padding(5, 0, 5, 0)
            };
            leftBottomFlow.AddChild(rnrButton);

            CheckboxBase statsButton = new StoneCheckbox
            {
                Text = Locale.Resource.ScoreStats,
                Font = new Font
                {
                    SystemFont = Fonts.MediumSystemFont,
                    Color = System.Drawing.Color.White,
                    Backdrop = System.Drawing.Color.Black
                },
                Checked = false,
                AutoCheck = false,
                AutoSize = AutoSizeMode.Horizontal,
                Padding = new System.Windows.Forms.Padding(5, 0, 5, 0)
            };
            leftBottomFlow.AddChild(statsButton);

            if (HideStats)
            {
                leftBottomFlow.Visible = false;
                stats.Visible = false;
            }
            else
            {
                statsButton.Click += new EventHandler((o, e) =>
                {
                    rnrButton.Checked = rewards.Visible = false;
                    statsButton.Checked = stats.Visible = true;
                });
                rnrButton.Click += new EventHandler((o, e) =>
                {
                    rnrButton.Checked = rewards.Visible = true;
                    statsButton.Checked = stats.Visible = false;
                });
            }

            base.OnConstruct();
        }
        protected override void OnConstruct()
        {
            base.OnConstruct();
            ClearChildren();
            var parts = text.Split(new string[] { "#" }, StringSplitOptions.None);
            Control row = new FlowLayout
            {
                Newline = false,
                AutoSize = true,
            };
            foreach (var s in parts)
            {
                string str = s;
                System.Drawing.Color c = font.Color;
                string sc;
                if (s.Length >= 6)
                {
                    sc = s.Substring(0, 6);
                    int h;
                    if (int.TryParse(sc, System.Globalization.NumberStyles.HexNumber, null, out h))
                    {
                        c = System.Drawing.Color.FromArgb(h);
                        c = System.Drawing.Color.FromArgb(255, c);
                        str = s.Substring(6);
                    }
                }

                var lines = str.Split('\n');
                for(int i=0; i < lines.Length; i++)
                {
                    var line = lines[i];
                    row.AddChild(new Label
                    {
                        Text = line,
                        Font = new Font
                        {
                            SystemFont = font.SystemFont,
                            Color = c,
                            Backdrop = font.Backdrop
                        },
                        AutoSize = AutoSizeMode.Full,
                        Background = null,
                        Clickable = false
                    });
                    if (lines.Length > 1 && i < lines.Length - 1)
                    {
                        AddChild(row);
                        row = new FlowLayout
                        {
                            Newline = false,
                            AutoSize = true
                        };
                    }
                }
            }
            AddChild(row);
        }
        public ChallengeMapMenuControl()
        {
            Dock = System.Windows.Forms.DockStyle.Fill;
            AddChild(new ChallengeBackgroundControl());
            AddChild(new GameLogoChallengeImage
            {
                Anchor = Orientation.Top,
                Position = new Vector2(-15, 50)
            });

            Control profilePanel = new FlowLayout
            {
                HorizontalFill = true,
                Newline = false,
                AutoSize = true,
                Anchor = Orientation.BottomLeft,
                Position = new Vector2(10, 10),
                Size = new Vector2(400, 20),
                Origin = FlowOrigin.BottomRight
            };
            AddChild(profilePanel);
            Control changeProfile = new ClickableTextButton
            {
                Text = "(Change)",
                AutoSize = AutoSizeMode.Full,
                Background = null,
            };
            profilePanel.AddChild(changeProfile);
            changeProfile.Click += new EventHandler(profile_Click);
            profilePanel.AddChild(profileName);

            Control buttonsPanel = new Control
            {
                Background = InterfaceScene.DefaultFormBorder,
                Size = new Vector2(400, 150),
                Anchor = Orientation.Top,
                Position = new Vector2(0, 500),
                Padding = new System.Windows.Forms.Padding(10)
            };
            AddChild(buttonsPanel);

            if (!String.IsNullOrEmpty(Program.Settings.ChallengeSurveyLink))
            {
                var u = new Uri(Program.Settings.ChallengeSurveyLink);
                var s = u.ToString();
                if (!u.IsFile)
                {
                    //Control feedback = new Control
                    //{
                    //    Background = InterfaceScene.DefaultFormBorder,
                    //    Anchor = Orientation.Top,
                    //    Position = new Vector2(300, 500),
                    //    Size=  new Vector2(300, 100),
                    //    Padding = new System.Windows.Forms.Padding(10)
                    //};
                    //AddChild(feedback);
                    //feedback.AddChild(new TextBox
                    //{
                    //    Text = "Tell us what you think of the game!",
                    //    Clickable = false,
                    //    Background = null,
                    //    AutoSize = AutoSizeMode.Full,
                    //});
                    Control survey = new ClickableTextButton
                    {
                        Text = "Tell us what you think!",
                        Anchor = Orientation.Right,
                        AutoSize = AutoSizeMode.Full,
                        Background = null,
                        Position = new Vector2(25, 45)
                    };
                    survey.Click += new EventHandler((o, e) =>
                    {
                        Util.StartBrowser(s);
                    });
                    buttonsPanel.AddChild(survey);
                }
            }

            ButtonBase challenge = new LargeStoneButton
            {
                Anchor = Orientation.Right,
                Position = new Vector2(25, 0),
                Text = "Play"
            };
            buttonsPanel.AddChild(challenge);
            challenge.Click += new EventHandler(challenge_Click);

            ButtonBase tutorial = new StoneButton
            {
                Anchor = Orientation.TopLeft,
                Position = new Vector2(0, 0),
                Text = "Tutorial"
            };
            buttonsPanel.AddChild(tutorial);
            tutorial.Click += new EventHandler(tutorial_Click);

            ButtonBase options = new StoneButton
            {
                Anchor = Orientation.TopLeft,
                Position = new Vector2(0, 45),
                Text = "Options"
            };
            buttonsPanel.AddChild(options);
            options.Click += new EventHandler(options_Click);

            ButtonBase exit = new StoneButton
            {
                Anchor = Orientation.TopLeft,
                Position = new Vector2(0, 90),
                Text = "Exit"
            };
            buttonsPanel.AddChild(exit);
            exit.Click += new EventHandler(exit_Click);

            if (!String.IsNullOrEmpty(Program.Settings.HallOfFameAddress))
            {
                var u = new Uri(Program.Settings.HallOfFameAddress);
                var s = u.ToString();
                if (!u.IsFile)
                {
                    Control hof = new Button
                    {
                        Anchor = Orientation.Top,
                        Position = new Vector2(0, 655),
                        HoverTexture = new TextureFromFile("Interface/Common/HallOfFame2Mouseover1.png") { DontScale = true },
                        NormalTexture = new TextureFromFile("Interface/Common/HallOfFame2.png") { DontScale = true },
                        ClickTexture = new TextureFromFile("Interface/Common/HallOfFame2.png") { DontScale = true },
                        Background = new ImageGraphic
                        {
                        },
                        Size = new Vector2(260, 38)
                    };
                    hof.Click += new EventHandler((o, e) =>
                    {
                        Util.StartBrowser(s);
                    });
                    AddChild(hof);
                }
            }

            fader = new Fader { State = FadeState.FadedOut };
            AddChild(fader);
            Updateable = true;
        }
        public RatingBox()
        {
            ControlBox = false;
            Size = new Vector2(630, 300);
            Anchor = Orientation.Center;

            AddChild(headerTextBox);
            AddChild(difficultyRow);
            AddChild(lengthRow);
            AddChild(entertainmentRow);

            AddChild(new Label
            {
                Text = Locale.Resource.MapRatingCommentsLabel,
                Dock = System.Windows.Forms.DockStyle.Top,
                AutoSize = AutoSizeMode.Full,
                Margin = new System.Windows.Forms.Padding(0, 5, 0, 5)
            });
            AddChild(commentBox);

            FlowLayout bottom = new FlowLayout
            {
                Dock = System.Windows.Forms.DockStyle.Fill,
                Newline = false,
                HorizontalFill = true,
                AutoSize = true,
            };
            AddChild(bottom);
            bottom.AddChild(sendButton);
            sendButton.Click += new EventHandler(sendButton_Click);
            bottom.AddChild(resetButton);
            resetButton.Click += new EventHandler(resetButton_Click);
            if (Program.Settings.DisplayMapRatingDialog != MapRatingDialogSetup.Required)
            {
                bottom.AddChild(cancelButton);
                cancelButton.Click += new EventHandler(cancelButton_Click);
            }
        }
 public ProfileQuickbar()
 {
     Background = global::Graphics.Interface.InterfaceScene.DefaultSlimBorder;
     Clickable = true;
     Anchor = Orientation.TopLeft;
     Dock = System.Windows.Forms.DockStyle.Top;
     Size = new Vector2(0, 50);
     AddChild(profileNameLabel);
     FlowLayout buttons = new FlowLayout
     {
         HorizontalFill = true,
         AutoSize = true,
         Newline = false,
         Anchor = Orientation.TopRight
     };
     AddChild(buttons);
     buttons.AddChild(optionsButton);
     buttons.AddChild(logoutButton);
     logoutButton.Click += new EventHandler(logoutButton_Click);
     optionsButton.Click += new EventHandler(optionsButton_Click);
 }
        public SelectProfileControl()
        {
            Background = InterfaceScene.DefaultFormBorder;
            Size = new Vector2(500, 200);
            Padding = new System.Windows.Forms.Padding(20);
            Background.Alpha = 0.2f;

            Control right = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Fill
            };
            Control left = new Control
            {
                Dock = System.Windows.Forms.DockStyle.Left,
                Size = new Vector2(140, 0)
            };

            Control profileContainer = new Control
            {
                Size = new Vector2(243, 70),
                Anchor = Orientation.Top
            };
            profileContainer.AddChild(new Label
            {
                Text = Locale.Resource.GenProfile,
                AutoSize = AutoSizeMode.Full,
                Font = Fonts.Default,
                Anchor = Orientation.TopLeft,
                Background = null,
            });
            profiles = new StoneDropDownBar
            {
                Position = new Vector2(0, 15),
                Anchor = Orientation.TopLeft
            };
            profileContainer.AddChild(profiles);
            PopuplateProfiles();

            Control newRemoveFlow = new FlowLayout
            {
                HorizontalFill = true,
                Newline = false,
                AutoSize = true,
                Position = new Vector2(0, 45),
                Anchor = Orientation.TopRight,
            };
            profileContainer.AddChild(newRemoveFlow);

            var newProfile = new ClickableTextButton
            {
                Text = Locale.Resource.GenNew,
                AutoSize = AutoSizeMode.Full,
                TextAnchor = Orientation.Center,
                Margin = new System.Windows.Forms.Padding(3, 0, 3, 0)
            };
            newProfile.Click += new EventHandler(newProfile_Click);
            newRemoveFlow.AddChild(newProfile);

            var removeProfile = new ClickableTextButton
            {
                Text = Locale.Resource.GenRemove,
                AutoSize = AutoSizeMode.Full,
                TextAnchor = Orientation.Center,
                Margin = new System.Windows.Forms.Padding(3, 0, 3, 0)
            };
            removeProfile.Click += new EventHandler(removeProfile_Click);
            newRemoveFlow.AddChild(removeProfile);

            var start = new LargeStoneButton
            {
                Text = Locale.Resource.GenLogin,
                Position = new Vector2(0, 90),
                Anchor = Orientation.Top,
                Size = new Vector2(230, 62)
            };
            start.Click += new EventHandler(start_Click);
            right.AddChild(start);

            FlowLayout leftFlow = new FlowLayout
            {
                AutoSize = true,
                HorizontalFill = false,
                Newline = false,
                Anchor = Orientation.Center
            };
            left.AddChild(leftFlow);

            var support = new StoneButton
            {
                Text = Locale.Resource.GenSupport,
                Margin = new System.Windows.Forms.Padding(5)
            };
            support.Click += new EventHandler(support_Click);
            leftFlow.AddChild(support);

            var options = new StoneButton
            {
                Text = Locale.Resource.GenOptions,
                Margin = new System.Windows.Forms.Padding(5)
            };
            options.Click += new EventHandler(options_Click);
            leftFlow.AddChild(options);

            var quit = new StoneButton
            {
                Text = Locale.Resource.GenQuit,
                Margin = new System.Windows.Forms.Padding(5)
            };
            quit.Click += new EventHandler(quit_Click);
            leftFlow.AddChild(quit);

            right.AddChild(profileContainer);
            AddChild(left);

            AddChild(new Control
            {
                Background = new StretchingImageGraphic
                {
                    Texture = new TextureConcretizer
                    {
                        TextureDescription = new Graphics.Software.Textures.SingleColorTexture(System.Drawing.Color.FromArgb(50, 255, 255, 255))
                    },
                    SizeMode = SizeMode.AutoAdjust
                },
                Dock = System.Windows.Forms.DockStyle.Left,
                Size = new Vector2(1, 1)
            });

            AddChild(right);
        }