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


C# Window.AddElement方法代码示例

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


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

示例1: InitToolBarWindow

        protected void InitToolBarWindow()
        {
            ToolBar = new Window(UI.GetInterface(Name), null, "Tools", TextOrientation.Center, Vector2.Zero, new Vector2(122, Game1.ScreenHeight - 21), true, false, true, true);
            ToolBar.MinimizedPosition = new Vector2(Game1.ScreenWidth - ToolBar.Size.X, 25);

            //Brush
            ToolBar.AddElement(new TextureButton(UI.GetInterface(Name), Content.Load<Texture2D>("UI/Textures/brush"),
                new Vector2(5, 5), new Vector2(50, 50), new Vector2(UI.BGOffset), origin, hover, pressed, false));
            //Bucket
            ToolBar.AddElement(new TextureButton(UI.GetInterface(Name), Content.Load<Texture2D>("UI/Textures/bucket"),
                new Vector2(60, 5), new Vector2(50, 50), new Vector2(UI.BGOffset), origin, hover, pressed, false));
            //Erasor
            ToolBar.AddElement(new TextureButton(UI.GetInterface(Name), Content.Load<Texture2D>("UI/Textures/bucket"),
                new Vector2(5, 60), new Vector2(50, 50), new Vector2(UI.BGOffset), origin, hover, pressed, false));

            ToolBar.AddElement(new Label(UI.GetInterface(Name), "Layer: base", 12, TextOrientation.Center, new Vector2(2, 200), new Vector2(117, 25), Color.Black, origin));
            ToolBar.AddElement(new Button(UI.GetInterface(Name), "<", 12, TextOrientation.Center, new Vector2(3, 230), new Vector2(25, 25), origin, hover, pressed));
            ToolBar.AddElement(new Button(UI.GetInterface(Name), ">", 12, TextOrientation.Center, new Vector2(33, 230), new Vector2(25, 25), origin, hover, pressed));
            ToolBar.AddElement(new Button(UI.GetInterface(Name), "+", 12, TextOrientation.Center, new Vector2(63, 230), new Vector2(25, 25), origin, hover, pressed));
            ToolBar.AddElement(new Button(UI.GetInterface(Name), "-", 12, TextOrientation.Center, new Vector2(93, 230), new Vector2(25, 25), origin, hover, pressed));
            ltlb = new ListBox(UI.GetInterface(Name), 12, TextOrientation.Left, new Vector2(5, 270), new Vector2(110, 200), Color.Black, Color.White, origin, hover);
            ltlb.Disable();
            ToolBar.AddElement(ltlb);

            ToolBar[0].Clicked += (sender) =>
            {
                Map.CurrentBrush.SetBrush(new BrushTool(Map.CurrentBrush.Tool.BaseTile, Map.CurrentBrush.Tool.BrushSize));
            };

            ToolBar[1].Clicked += (sender) =>
            {
                Map.CurrentBrush.SetBrush(new FillTool(Map.CurrentBrush.Tool.BaseTile));
            };

            ToolBar[2].Clicked += (sender) =>
            {
                Map.CurrentBrush.SetBrush(new BrushTool(Map.Settings.AccessibleTiles.PlaceholderTile, Map.CurrentBrush.Tool.BrushSize));
            };

            ToolBar[4].Clicked += (sender) =>
            {
                Map.SetActiveLayer(Map.ActiveLayerIndex - 1);
            };

            ToolBar[5].Clicked += (sender) =>
            {
                Map.SetActiveLayer(Map.ActiveLayerIndex + 1);
            };

            ToolBar[6].Clicked += (sender) =>
            {
                GameStateManager.TransitionState(GameStateManager.NewLayerPrefs);
            };

            ToolBar[7].Clicked += (sender) =>
            {
                Map.RemoveActiveLayer();
            };
        }
开发者ID:GaiiusBaltar,项目名称:XNA-Top-Down-Map-Editor,代码行数:59,代码来源:EditorView.cs

示例2: InitSizeWindow

        protected void InitSizeWindow()
        {
            InfoWindow = new Window(UI.GetInterface(Name), null, "Map Size", TextOrientation.Center, Vector2.Zero, new Vector2(450, 157), true, false, false, false);

            /*XSlider*/
            InfoWindow.AddElement(new Slider(UI.GetInterface(Name), new Vector2(10, 10), new Vector2(200, 50), xCount, 1, 0, 1000, 24, TextOrientation.Center, origin, pressed, true, true, true));
            /*YSlider*/
            InfoWindow.AddElement(new Slider(UI.GetInterface(Name), new Vector2(10, 70), new Vector2(200, 50), yCount, 1, 0, 1000, 24, TextOrientation.Center, origin, pressed, true, true, true));
            /*XInfo*/
            InfoWindow.AddElement(new Label(UI.GetInterface(Name), "Horizontal Tiles", 24, TextOrientation.Left, new Vector2(220, 10), new Vector2(200, 50), Color.Black, Color.Transparent));
            /*YInfo*/
            InfoWindow.AddElement(new Label(UI.GetInterface(Name), "Vertical Tiles", 24, TextOrientation.Left, new Vector2(220, 70), new Vector2(200, 50), Color.Black, Color.Transparent));
            InfoWindow.Open(new Vector2(Game1.ScreenWidth / 2.0f - InfoWindow.Size.X / 2.0f, Game1.ScreenHeight / 2.0f - InfoWindow.Size.Y / 2.0f));
        }
开发者ID:GaiiusBaltar,项目名称:XNA-Top-Down-Map-Editor,代码行数:14,代码来源:NewMapPreferencesView.cs

示例3: InitSaveBeforeQuitWindow

        protected void InitSaveBeforeQuitWindow()
        {
            SaveBeforeQuitWindow = new Window(UI.GetInterface(Name), null, "Save?", TextOrientation.Center, Vector2.Zero, new Vector2(642, 96), true, true, false, true);
            SaveBeforeQuitWindow.AddElement(new Button(UI.GetInterface(Name), "Yes", 24, TextOrientation.Center, new Vector2(10, 10), new Vector2(200, 50), origin, hover, pressed, ButtonListSide.LeftRight, true, true, true));
            SaveBeforeQuitWindow.AddElement(new Button(UI.GetInterface(Name), "No", 24, TextOrientation.Center, new Vector2(220, 10), new Vector2(200, 50), origin, hover, pressed, ButtonListSide.LeftRight, true, true, true));
            SaveBeforeQuitWindow.AddElement(new Button(UI.GetInterface(Name), "Cancel", 24, TextOrientation.Center, new Vector2(430, 10), new Vector2(200, 50), origin, hover, pressed, ButtonListSide.LeftRight, true, true, true));

            SaveBeforeQuitWindow[0].Clicked += (sender) =>
            {
                if (GameStateManager.PreviousState == GameStateManager.Playing)
                    Map.SavePlayable();
                else
                    Map.Save();
                SaveBeforeQuitWindow.Close();
                GameStateManager.TransitionState(GameStateManager.MainMenu);
            };

            SaveBeforeQuitWindow[1].Clicked += (sender) =>
            {
                SaveBeforeQuitWindow.Close();
                GameStateManager.TransitionState(GameStateManager.MainMenu);
            };

            SaveBeforeQuitWindow[2].Clicked += (sender) =>
            {
                SaveBeforeQuitWindow.Close();
            };
        }
开发者ID:GaiiusBaltar,项目名称:XNA-Top-Down-Map-Editor,代码行数:28,代码来源:PauseMenuView.cs

示例4: InitLayerSettingsWindow

        protected void InitLayerSettingsWindow()
        {
            LayerSettingsWindow = new Window(UI.GetInterface(Name), null, "Settings", TextOrientation.Center, Vector2.Zero, new Vector2(712, 500), true, false, false, false);

            LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Layer Name", 14, TextOrientation.Left, new Vector2(10, 10), new Vector2(200, 25), Color.Black, Color.Transparent));
            LayerSettingsWindow.AddElement(new TextBox(UI.GetInterface(Name), layerName, 14, 20, new Vector2(10, 40), new Vector2(200, 25), Color.Black, Color.White, origin, Color.Black));

            LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Available Traits", 14, TextOrientation.Left, new Vector2(10, 80), new Vector2(200, 50), Color.Black, Color.Transparent));
            LayerSettingsWindow.AddElement(new Label(UI.GetInterface(Name), "Contained Traits", 14, TextOrientation.Left, new Vector2(400, 80), new Vector2(200, 50), Color.Black, Color.Transparent));
            LayerSettingsWindow.AddElement(new Button(UI.GetInterface(Name), ">", 24, TextOrientation.Center, new Vector2(330, 230), new Vector2(50, 50), origin, hover, pressed));
            LayerSettingsWindow.AddElement(new Button(UI.GetInterface(Name), "<", 24, TextOrientation.Center, new Vector2(330, 290), new Vector2(50, 50), origin, hover, pressed));

            ListBox a = new ListBox(UI.GetInterface(Name), 14, TextOrientation.Left, new Vector2(10, 110), new Vector2(300, 350), Color.Black, Color.White, origin, hover);
            ListBox b = new ListBox(UI.GetInterface(Name), 14, TextOrientation.Left, new Vector2(400, 110), new Vector2(300, 350), Color.Black, Color.White, origin, hover);
            LayerSettingsWindow.AddElement(a);
            LayerSettingsWindow.AddElement(b);

            availableTraits.Add("Affects Movement Speed");
            availableTraits.Add("Cast Shadow");
            availableTraits.Add("Collision");
            availableTraits.Add("Function Layer");
            availableTraits.Add("Transparent");
            availableTraits.Add("Stainable");
            availableTraits.Add("Projectile Collision");
            availableTraits.Add("NPC Collision");
            availableTraits.Add("Item Collision");

            a.AddItem(availableTraits[0]);
            a.AddItem(availableTraits[1]);
            a.AddItem(availableTraits[2]);
            a.AddItem(availableTraits[3]);
            a.AddItem(availableTraits[4]);
            a.AddItem(availableTraits[5]);
            a.AddItem(availableTraits[6]);
            a.AddItem(availableTraits[7]);
            a.AddItem(availableTraits[8]);

            (LayerSettingsWindow[1] as TextBox).TextChanged += (sender) =>
            {
                TextBox tb = sender as TextBox;
                if (tb.Text != "")
                    layerName = tb.Text;
            };

            LayerSettingsWindow[4].Clicked += (sender) =>
            {
                if (a.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < a.SelectedItems.Count; i++)
                    {
                        b.AddItem(a.SelectedItems[i]);
                    }
                    a.RemoveSelectedItems();
                }
            };

            LayerSettingsWindow[5].Clicked += (sender) =>
            {
                if (b.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < b.SelectedItems.Count; i++)
                    {
                        a.AddItem(b.SelectedItems[i]);
                    }
                    b.RemoveSelectedItems();
                }
            };

            LayerSettingsWindow.Open(new Vector2(Game1.ScreenWidth / 2.0f - LayerSettingsWindow.Size.X / 2.0f, Game1.ScreenHeight / 2.0f - LayerSettingsWindow.Size.Y / 2.0f));
        }
开发者ID:GaiiusBaltar,项目名称:XNA-Top-Down-Map-Editor,代码行数:70,代码来源:NewLayerPreferencesView.cs


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