当前位置: 首页>>代码示例>>C#>>正文


C# Form.AddControl方法代码示例

本文整理汇总了C#中Form.AddControl方法的典型用法代码示例。如果您正苦于以下问题:C# Form.AddControl方法的具体用法?C# Form.AddControl怎么用?C# Form.AddControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Form的用法示例。


在下文中一共展示了Form.AddControl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public void Main(string ApplicationPath, string[] Args)
        {
            Form frmPacman = new Form("frmPacman");
            frmPacman.ButtonPressed += frmPacman_ButtonPressed;

            Bitmap bmpGame;
            Picturebox pbGame;

            bmpGame = new Bitmap(320, 240);

            if (Prompt.Show("Resolution Adjust", "Would you like to play at 640x480?", Fonts.Calibri18Bold, Fonts.Calibri14, PromptType.YesNo) == PromptResult.Yes)
            {
                pbGame = new Picturebox("pbGame", bmpGame, frmPacman.Width / 2 - 320, frmPacman.Height / 2 - 240, 640, 480, BorderStyle.BorderNone);
                pbGame.ScaleMode = ScaleMode.Stretch;
            }
            else
                pbGame = new Picturebox("pbGame", bmpGame, frmPacman.Width / 2 - 160, frmPacman.Height / 2 - 140, BorderStyle.BorderNone);

            pbGame.Background = Colors.Black;
            game = new PacmanGame(bmpGame, pbGame);
            frmPacman.AddControl(pbGame);

            Graphics.ActiveContainer = frmPacman;

            Thread.Sleep(100);
            if (joystick != null)
            {
                game.InputManager.AddInputProvider(joystick);
                game.Initialize();
            }
        }
开发者ID:joram,项目名称:Gadgeteer,代码行数:31,代码来源:Class1.cs

示例2: Home

        void Home()
        {
            frmMain = new Form("frmMain");
            frmMain.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.CP7Background);

            // Appbar
            frmMainAppbar = new Appbar("ab1", Fonts.Calibri9, Fonts.Calibri24);
            frmMainAppbar.AddMenuItems(new string[] { "Launch Pacman" });
            frmMainAppbar.AppMenuSelected += new OnAppMenuSelected((object sender, int id, string value) => new Thread(AppbarItemSelected).Start());
            frmMain.AddControl(frmMainAppbar);

            // Activate
            Graphics.ActiveContainer = frmMain;
        }
开发者ID:ianlee74,项目名称:Gadgeteer,代码行数:14,代码来源:Program.cs

示例3: AuthenticationForm

        private void AuthenticationForm()
        {
            var frm = new Form("authentication");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480)
                          {BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies)};
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Authentication is Required", _fntHuge, frm.Width / 2 - 175, frm.Height/2 - 5) { Color = Gadgeteer.Color.Red };
            pnl.AddControl(title);

            rfid.CardIDRecieved += (sender, id) =>
                                       {
                                           title.Text = "Welcome back, Mr. Lee.";
                                           Thread.Sleep(2000);
                                           ZombieCannonRemoteForm();
                                       };
            TinkrCore.ActiveContainer = frm;
        }
开发者ID:ianlee74,项目名称:Gadgetab,代码行数:24,代码来源:Program.cs

示例4: MainMenu

        public MainMenu(Rectangle screen, ContentManager content)
        {
            _background = content.Load<Texture2D>("Textures/UI/mars_bg");
            _background_f = content.Load<Texture2D>("Textures/UI/mars_bg_f");
            _backgroundSize = screen;

            Texture2D menuTexture = content.Load<Texture2D>("Textures/UI/menu");
            Point menuPos = new Point((screen.Width / 2) - (menuTexture.Width / 2), (screen.Height / 2) - (menuTexture.Height / 2));
            menuRectangle = new Rectangle(menuPos.X, menuPos.Y - 30, menuTexture.Width, menuTexture.Height);
            _menuForm = new Form("menuForm", "", menuRectangle, menuTexture, Fonts.Standard, Color.White);

            Texture2D buttonTexture = content.Load<Texture2D>("Textures/UI/button");
            Point buttonSize = new Point(240, 40);
            Point buttonPos = new Point(40, 40);
            SpriteFont buttonFont = Fonts.Get("Menu");

            // NEW GAME BUTTON
            Button _newGame = new Button("new_game", "New Game",
                new Rectangle(40, 90, buttonSize.X, buttonSize.Y),
                buttonTexture, buttonFont, Color.Black);

            _newGame.onClick += new EHandler(NewGame_Click);
            _newGame.onMouseEnter += new EHandler(Beep);
            _menuForm.AddControl(_newGame);

            // LOAD GAME BUTTON
            Button _loadGame = new Button("load_game", "Load Game",
                new Rectangle(40, 150, buttonSize.X, buttonSize.Y),
                buttonTexture, buttonFont, Color.Black);

            _loadGame.onClick += new EHandler(LoadGame_Click);
            _loadGame.onMouseEnter += new EHandler(Beep);
            _menuForm.AddControl(_loadGame);

            // SETTINGS BUTTON
            Button _settings = new Button("settings", "Settings",
                new Rectangle(40, 210, buttonSize.X, buttonSize.Y),
                buttonTexture, buttonFont, Color.Black);

            _settings.onClick += new EHandler(Settings_Click);
            _settings.onMouseEnter += new EHandler(Beep);
            _menuForm.AddControl(_settings);

            // EXIT BUTTON
            Button _exit = new Button("exit", "Exit",
                new Rectangle(40, 270, buttonSize.X, buttonSize.Y),
                buttonTexture, buttonFont, Color.Black);

            _exit.onClick += new EHandler(Exit_Click);
            _exit.onMouseEnter += new EHandler(Beep);
            _menuForm.AddControl(_exit);

            // VERSION LABEL
            Vector2 stringSizeVersion = Fonts.Get("Tiny").MeasureString(Version.GetVersion());
            Vector2 labelPosVersion = new Vector2(160 - (stringSizeVersion.X / 2), menuTexture.Height - 20);
            Label _labelVersion = new Label("version", Version.GetVersion(), labelPosVersion, Fonts.Get("Tiny"), Color.White, Version.GetVersion().Length, 0);
            _menuForm.AddControl(_labelVersion);

            // Quote
            string quote = "Copyright © DAM Games " + DateTime.Now.Year;
            string font = "Quote";
            float stringSize = Fonts.Get(font).MeasureString(quote).X;
            _quote = new Label("quote", quote, new Vector2((screen.Width / 2) - (stringSize / 2), screen.Height - 20), Fonts.Get(font), Color.White * 0.5f, quote.Length, 0);

            // Test music
            Audio.Repeat = true;
            Audio.PlayMusicTrack("main_menu");
        }
开发者ID:MitchJH,项目名称:BaseBuilder,代码行数:68,代码来源:MainMenu.cs

示例5: ZombieTwitForm

        private void ZombieTwitForm()
        {
            var tweets = new[]{
                                    @"@zombieHunter Zombies are coming!"
                                    , @"@zombieHunter Zombies are getting closer!"
                                    , @"@zombieHunter THEY'RE HERE!!!"
                                    , @"@zombieHunter Send the Gadgets!!!"
                                    , @"@zombieHunter Tell my wife and kids..."
                                    , @"@zombieHunter ...I'll eat them later!"
                                };

            var frm = new Form("zombie twit");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480);
            pnl.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies);
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Zombie Twit", _fntHuge, frm.Width / 2 - 100, 50) { Color = Gadgeteer.Color.Yellow };
            pnl.AddControl(title);

            // Add a listbox
            var lb = new Listbox("lb1", _fntArialBold11, frm.Width / 2 - 200, frm.Height / 2 - 100, 400, 200, null);
            pnl.AddControl(lb);

            TinkrCore.ActiveContainer = frm;

            byte lastTweet = 0;
            var timer = new GT.Timer(2000);
            timer.Tick += timer1 =>
                              {
                                  if(lastTweet >= tweets.Length)
                                  {
                                      timer.Stop();
                                      return;
                                  }
                                  //lb.InsertAt(tweets[lastTweet++], 1);
                                  lb.AddItem(tweets[lastTweet++]);
                              };
            timer.Start();
        }
开发者ID:ianlee74,项目名称:Gadgetab,代码行数:45,代码来源:Program.cs

示例6: ZombieHealthMonitorForm

        private void ZombieHealthMonitorForm()
        {
            var frm = new Form("zombie health monitor");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480);
            pnl.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies);
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Zombie Health Monitor", _fntHuge, frm.Width / 2 - 140, 30) { Color = Gadgeteer.Color.Yellow };
            pnl.AddControl(title);

            // Add Heart Rate Graph.
            var graph = new Picturebox("heartRateGraph", null, 100, 200, 600, 200);
               pnl.AddControl(graph);

            TinkrCore.ActiveContainer = frm;
        }
开发者ID:ianlee74,项目名称:Gadgetab,代码行数:22,代码来源:Program.cs

示例7: ZombieDistractorForm

        private void ZombieDistractorForm()
        {
            const int gameWidth = 320;
            const int gameHeight = 240;

            var frm = new Form("zombie distractor");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480);
            pnl.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies);
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Zombie Distractor", _fntHuge, frm.Width / 2 - 140, 30) { Color = Gadgeteer.Color.Yellow };
            pnl.AddControl(title);

            TinkrCore.ActiveContainer = frm;

            // Add Pacman.
            var surface = TinkrCore.Screen;
            _pacmanGame = new PacmanGame(surface, frm.Width/2 - gameWidth/2, frm.Height/2 - gameHeight/2);
            _pacmanGame.InputManager.AddInputProvider(new GhiJoystickInputProvider(joystick));
            _pacmanGame.Initialize();
        }
开发者ID:ianlee74,项目名称:Gadgetab,代码行数:27,代码来源:Program.cs

示例8: ZombieCannonRemoteForm

        private void ZombieCannonRemoteForm()
        {
            var frm = new Form("zombie cannon remote");

            // Add panel
            var pnl = new Skewworks.Tinkr.Controls.Panel("pnl1", 0, 0, 800, 480);
            pnl.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.Zombies);
            frm.AddControl(pnl);

            // Add the app bar.
            pnl.AddControl(BuildAppBar(frm.Name));

            // Add a title.
            var title = new Label("lblTitle", "Zombie Cannon Remote", _fntHuge, frm.Width/2 - 175, 30)
                            {Color = Gadgeteer.Color.Yellow};
            pnl.AddControl(title);

            // Add a fire button.
            //var pic1 = new Picturebox("launchBtn", Resources.GetBitmap(Resources.BitmapResources.LaunchButton), frm.Width / 2 - 150, frm.Height/2 - 150, 300, 300);
            //pic1.ButtonPressed += (sender, id) => Debug.Print("FIRE!");
            //pnl.AddControl(pic1);
            var pic1 = new Skewworks.Tinkr.Controls.Panel("launchBtn",frm.Width / 2 - 150, frm.Height/2 - 150, 300, 300);
            pic1.BackgroundImage = Resources.GetBitmap(Resources.BitmapResources.LaunchButton);
            pic1.Tap += (sender, id) => Debug.Print("FIRE!");
            pnl.AddControl(pic1);

            TinkrCore.ActiveContainer = frm;
        }
开发者ID:ianlee74,项目名称:Gadgetab,代码行数:28,代码来源:Program.cs


注:本文中的Form.AddControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。