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


C# ListBox.RemoveSelectedItems方法代码示例

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


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

示例1: 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


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