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


C# Grid.AddChild方法代码示例

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


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

示例1: Init

		protected override void Init ()
		{
			var rootGrid = new Grid {
				RowDefinitions = new RowDefinitionCollection
														  {
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
														 },
			};


			_mainContent = new ContentView { Content = new ScrollView { Content = new Label { Text = Description } } };
			rootGrid.AddChild (_mainContent, 0, 0);


			var buttons = new StackLayout { Orientation = StackOrientation.Horizontal };

			var button1A = new Button { Text = "View 1A" };
			button1A.Clicked += (sender, args) => ShowView (_view1A);
			buttons.Children.Add (button1A);

			var button1B = new Button { Text = "View 1B" };
			button1B.Clicked += (sender, args) => ShowView (_view1B);
			buttons.Children.Add (button1B);

			var button2 = new Button { Text = "View 2" };
			button2.Clicked += (sender, args) => ShowView (_view2);
			buttons.Children.Add (button2);

			rootGrid.AddChild (buttons, 0, 1);


			Content = rootGrid;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:34,代码来源:Bugzilla27642.cs

示例2: DeveloperMainMenuForm

        public DeveloperMainMenuForm()
        {
            Anchor = Orientation.Left;
            Position = new Vector2(40, 0);
            Size = new Vector2(500, 700);
            ControlBox = false;
            Moveable = true;

            var g = new Grid
            {
                Size = Size,
                NWidth = (int)(Size.X / 200),
                NHeight = (int)(Size.Y / 20),
                Position = new Vector2(0, 0),
                Anchor = Orientation.TopLeft
            };
            AddChild(g);

            foreach (String s in Common.FileSystem.Instance.DirectoryGetFiles("Maps", "*"))
                    if (s.EndsWith(".map"))
                    {
                        string map = s.Substring("Maps/".Length);
                        var button = new Button
                        {
                            Text = map.Substring(0, map.Length - 4),
                        };
                        button.Click += new EventHandler((o, e) =>
                        {
                            Program.Instance.ProgramState = new Game.Game("Maps/" + map);
                        });
                        g.AddChild(button);

                        if (Program.Settings.DisplayMapNamesInDeveloperMenu)
                        {
                            Game.Map.MapSettings gameMap;
                            if (!loadedMaps.TryGetValue(s, out gameMap) &&
                                global::Common.FileSystem.Instance.FileExists(s))
                            {
                                try
                                {
                                    gameMap = loadedMaps[s] = Client.Game.Map.MapPersistence.Instance.LoadSettings(s);
                                }
                                catch { }
                            }
                            if (gameMap != null)
                                Program.Instance.Tooltip.SetToolTip(button, gameMap.Name);
                        }
                    }
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:49,代码来源:DeveloperMainMenu.cs

示例3: TestMaps

        public TestMaps()
        {
            Anchor = Orientation.Right;
            Position = new Vector2(40, 0);
            Size = new Vector2(500, 700);
            ControlBox = false;
            Moveable = true;

            var g = new Grid
            {
                Size = Size,
                NWidth = (int)(Size.X / 200),
                NHeight = (int)(Size.Y / 20),
                Position = new Vector2(0, 0),
                Anchor = Orientation.TopLeft
            };

            SortedDictionary<String, System.Reflection.MethodInfo> ms = new SortedDictionary<string, System.Reflection.MethodInfo>();

            foreach (var v in typeof(Game.TestMaps).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public))
                ms.Add(v.Name, v);
            foreach (var k in ms)
            {
                var button = new Button
                {
                    Text = k.Value.Name,
                };
                string details = "";
                foreach (var a in Attribute.GetCustomAttributes(k.Value, true))
                    if (a is System.ComponentModel.DescriptionAttribute)
                    {
                        details = ((System.ComponentModel.DescriptionAttribute)a).Description;
                        break;
                    }
                var m = k.Value;
                button.Click += new EventHandler((o, e) =>
                {
                    Program.Instance.ProgramState = new Game.Game(
                        //() => { return
                            (Game.Map.Map)m.Invoke(null, new object[] { Program.Instance.Device9 })
                        //; }
                        );
                });
                button.MouseEnter += new EventHandler((o, e) =>
                {
                    detailsBox.Text = details;
                });
                button.MouseLeave += new EventHandler((o, e) =>
                {
                    detailsBox.Text = "";
                });
                g.AddChild(button);
            }
            AddChild(g);
            AddChild(detailsBox);
            detailsBox.Size = new Vector2(Size.X - 40, 200);
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:57,代码来源:DeveloperMainMenu.cs

示例4: Enter

        public override void Enter()
        {
            base.Enter();
            Program.Instance.Interface.AddChild(new Control
            {
                Background = new StretchingImageGraphic
                {
                    Texture = new TextureFromFile("mainmenubackground.png"),
                    Size = new Vector2(Program.Settings.GraphicsDeviceSettings.Resolution.Width, Program.Settings.GraphicsDeviceSettings.Resolution.Height)
                },
                Dock = System.Windows.Forms.DockStyle.Fill
            });

            if (Common.ProgramConfigurationInformation.Warnings.Count > 0)
                Program.Instance.Interface.AddChild(
                    new Graphics.Interface.ProgramConfigurationInformationControl
                    {
                        Position = new Vector2(0, 150)
                    });

            form = new DeveloperMainMenuForm();
            Program.Instance.Interface.AddChild(form);

            Program.Instance.Interface.AddChild(new TestMaps());

            var buttonsGrid = new Grid
            {
                Size = new Vector2(800, 200),
                Anchor = Orientation.BottomLeft,
                NWidth = 4,
                NHeight = 8
            };
            Program.Instance.Interface.AddChild(buttonsGrid);

            var videoSettings = new Button
            {
                Size = new Vector2(200, 20),
                Text = "Options",
                Position = new Vector2(200, 60)
            };
            buttonsGrid.AddChild(videoSettings);
            videoSettings.Click += new EventHandler(videoSettings_Click3);

            videoSettings = new Button
            {
                Text = "Fullscreen",
            };
            buttonsGrid.AddChild(videoSettings);
            videoSettings.Click += new EventHandler((o, e) => { Program.Settings.WindowMode = WindowMode.Fullscreen; Program.UpdateWindowMode(); });

            Button exitGameButton = new Button
            {
                Position = new Vector2(200, 40),
                Size = new Vector2(200, 20),
                Text = "Exit",
            };
            buttonsGrid.AddChild(exitGameButton);
            exitGameButton.Click += new EventHandler(exitGameButton_Click);

            Button ratingTestPopup = new Button
            {
                Position = new Vector2(200, 0),
                Size = new Vector2(200, 20),
                Text = "Rating Test"
            };
            buttonsGrid.AddChild(ratingTestPopup);
            ratingTestPopup.Click += new EventHandler((o, e) =>
            {
                Client.Game.Interface.ScoreScreenControl ssc = new Client.Game.Interface.ScoreScreenControl
                {
                    GameState = new Client.Game.GameState { },
                    Map = new Client.Game.Map.Map { Settings = new Client.Game.Map.MapSettings { Name = "asdf" } },
                    GameTime = 123,
                    Statistics = new Client.Game.Statistics { },
                    EarnedGoldCoins = 1,
                    SilverEnabled = Program.Settings.SilverEnabled,
                    HideStats = Program.Settings.HideStats
                };
                ssc.AddChild(new Client.Game.Interface.RatingBox { Anchor = Orientation.TopRight, Position = new Vector2(0, 45) });
                Program.Instance.Interface.AddChild(ssc);
            });

            Button helpPopup = new Button
            {
                Position = new Vector2(200, 40),
                Size = new Vector2(200, 20),
                Text = "Help",
            };
            buttonsGrid.AddChild(helpPopup);
            helpPopup.Click += new EventHandler(helpPopup_Click);

            Button button = new Button
            {
                Text = "NormalWindow",
            };
            buttonsGrid.AddChild(button);
            button.Click += new EventHandler((o, e) =>
            {
                Program.Instance.Interface.AddChild(
                new Window { Anchor = Orientation.Center, Moveable = true });
//.........这里部分代码省略.........
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:101,代码来源:DeveloperMainMenu.cs


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