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


C# Button.AddActionListener方法代码示例

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


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

示例1: InformationPanel

        public InformationPanel(Rectangle boundingBox)
            : base(MediaRepository.Textures["Blank"], boundingBox, new Color(255, 255, 255, 50))
        {
            directionPanel = new Panel(new Rectangle(5, 5, 240, 140), new Color(255, 255, 255, 100));

            detailPanel = new Panel(new Rectangle(255, 5, 480, 140), new Color(0, 0, 0, 50));
            mapPanel = new Panel(new Rectangle(745, 5, 140, 140), new Color(255, 255, 255, 100));

            arrowPanel = new DirectionPanel(new Rectangle(20, 20, 200, 100), World.ChangeDirection);
            mirrorArrowPanel = new DirectionPanel(new Rectangle(20, 20, 200, 100), World.ChangeDirection, true);

            professionPanel = new ProfessionPanel(new Rectangle(285, -52, 320, 52));
            missionResultBox = new TextBox(new Rectangle(0, -40, 230, 40), "", Color.White, TextBox.AlignType.Center);

            personStatusPanel = new PersonPanel(new Rectangle(0, 0, 200, 140));
            buildingStatusPanel = new BuildingPanel(new Rectangle(0, 0, 200, 140));
            researchPanel = new ResearchPanel(new Rectangle(0, 0, 200, 140));

            shopButton = new Button(MediaRepository.Textures["Blank"], new Rectangle(800, -30, 90, 30), new Color(0, 0, 150, 100),
                "Shop", MediaRepository.Fonts["DefaultFont"], Color.White);
            shopButton.AddActionListener(this);

            itemsButton = new Button(MediaRepository.Textures["Blank"], new Rectangle(700, -30, 90, 30), new Color(0, 0, 150, 100),
                "Items", MediaRepository.Fonts["DefaultFont"], Color.White);
            itemsButton.AddActionListener(this);

            shopPanel = new ShopPanel(new Rectangle(5, 5, 880, 140), new Color(255, 255, 255, 100));
            shopPanel.Deactivate();

            itemsPanel = new ItemsPanel(new Rectangle(5, 5, 880, 140), new Color(255, 255, 255, 100));
            itemsPanel.Deactivate();

            AddComponent(directionPanel);
            AddComponent(detailPanel);
            AddComponent(mapPanel);

            AddComponent(missionResultBox);
            AddComponent(professionPanel);
            AddComponent(shopButton);
            AddComponent(itemsButton);
            AddComponent(shopPanel);
            AddComponent(itemsPanel);

            directionPanel.AddComponent(arrowPanel);
            directionPanel.AddComponent(mirrorArrowPanel);

            detailPanel.AddComponent(personStatusPanel);
            detailPanel.AddComponent(buildingStatusPanel);
            detailPanel.AddComponent(researchPanel);

            this.consumesMouseEvent = false;
        }
开发者ID:johnfn,项目名称:Illumination,代码行数:52,代码来源:InformationPanel.cs

示例2: ResearchPanel

        public ResearchPanel(Rectangle boundingBox)
            : base(MediaRepository.Textures["Blank"], boundingBox, Color.TransparentWhite)
        {
            title = new TextBox(new Rectangle(25, 10, 100, 25), "Research Center", Color.White, TextBox.AlignType.Left);
            demolishButton = new Button(new Rectangle(300, 10, 135, 25), "Demolish", MediaRepository.Fonts["DefaultFont"], Color.Red);
            demolishButton.AddActionListener(this);

            activateButton = new Button(MediaRepository.Textures["Blank"], new Rectangle(370, 10, 100, 25), new Color(100, 100, 255, 200), "Activate", MediaRepository.Fonts["Arial10"], Color.Black);
            abortButton = new Button(MediaRepository.Textures["Blank"], new Rectangle(370, 10, 100, 25), new Color(255, 100, 100, 200), "Abort", MediaRepository.Fonts["Arial10"], Color.Black);
            activateButton.AddActionListener(this);
            abortButton.AddActionListener(this);

            descriptionHeader = new TextBox(new Rectangle(Indent, DescriptionY, 10, LineHeight), "Description:", Color.White, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Left);
            descriptionText = new TextBox(new Rectangle(90, DescriptionY, 10, LineHeight), "description...", Color.Black, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Left);
            statusHeader = new TextBox(new Rectangle(Indent, DescriptionY + LineHeight, 10, LineHeight), "Status:", Color.White, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Left);
            statusText = new TextBox(new Rectangle(60, DescriptionY + LineHeight, 10, LineHeight), "status...", Color.Black, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Left);
            tasksHeader = new TextBox(new Rectangle(Indent, DescriptionY + 2 * LineHeight, 10, LineHeight), "Tasks:", Color.White, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Left);

            tasksDisplay = new LightSequenceBar[MaxTasksPerResearch];
            Point pivot = new Point(55, DescriptionY + 2 * LineHeight + 2);
            for (int index = 0; index < MaxTasksPerResearch; index++) {
                tasksDisplay[index] = new LightSequenceBar(new LightSequence(""), pivot, new Dimension(10, 10), 5);
                pivot = Geometry.Sum(pivot, new Point(0, LineHeight));
                AddComponent(tasksDisplay[index]);
            }

            schoolResearchButton_1 = new Button(MediaRepository.Textures["Blank"], new Rectangle(300, 50, 120, 30), new Color(255, 255, 255, 100), "School Research 1", MediaRepository.Fonts["Arial10"], Color.Black);
            schoolResearchButton_1.AddActionListener(this);
            AddComponent(schoolResearchButton_1);

            schoolResearchButton_2 = new Button(MediaRepository.Textures["Blank"], new Rectangle(300, 90, 120, 30), new Color(255, 255, 255, 100), "School Research 2", MediaRepository.Fonts["Arial10"], Color.Black);
            schoolResearchButton_2.AddActionListener(this);
            AddComponent(schoolResearchButton_2);

            AddComponent(title);
            AddComponent(demolishButton);
            AddComponent(descriptionHeader);
            AddComponent(descriptionText);
            AddComponent(statusHeader);
            AddComponent(statusText);
            AddComponent(tasksHeader);
            AddComponent(activateButton);
            AddComponent(abortButton);

            DeactivatePanel(true);
        }
开发者ID:johnfn,项目名称:Illumination,代码行数:46,代码来源:ResearchPanel.cs

示例3: BuildingPanel

        public BuildingPanel(Rectangle boundingBox)
            : base(MediaRepository.Textures["Blank"], boundingBox, Color.TransparentWhite)
        {
            title = new TextBox(new Rectangle(25, 10, 100, 25), "Building", Color.White, TextBox.AlignType.Left);
            demolishButton = new Button(new Rectangle(300, 10, 135, 25), "Demolish", MediaRepository.Fonts["DefaultFont"], Color.Red);
            demolishButton.AddActionListener(this);

            effectPanels = new Panel[4];
            effectButtons = new Button[4];
            sequenceBars = new LightSequenceBar[4];
            descriptions = new TextBox[4];
            unknownTexts = new TextBox[4];

            effectPanels[0] = new Panel(new Rectangle(Indent, FirstButtonY, ButtonWidth, ButtonHeight), new Color(255, 255, 255, 100));
            effectPanels[1] = new Panel(new Rectangle(Indent, FirstButtonY + ButtonHeight + Indent, ButtonWidth, ButtonHeight), new Color(255, 255, 255, 100));
            effectPanels[2] = new Panel(new Rectangle(ButtonWidth + 3 * Indent, FirstButtonY, ButtonWidth, ButtonHeight), new Color(255, 255, 255, 100));
            effectPanels[3] = new Panel(new Rectangle(ButtonWidth + 3 * Indent, FirstButtonY + ButtonHeight + Indent, ButtonWidth, ButtonHeight), new Color(255, 255, 255, 100));

            int index = 0;
            foreach (Panel p in effectPanels) {
                effectButtons[index] = new Button(MediaRepository.Textures["Blank"], new Rectangle(0, 0, ButtonWidth, ButtonHeight), Color.TransparentWhite);
                effectButtons[index].AddActionListener(this);

                sequenceBars[index] = new LightSequenceBar(new LightSequence(), new Point(InnerButtonIndent, SequenceBarY), SequenceTileSize, Indent);
                descriptions[index] = new TextBox(new Rectangle(InnerButtonIndent, DescriptionY, 10, 10), "", Color.Black, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Left);
                unknownTexts[index] = new TextBox(new Rectangle(0, 0, ButtonWidth, ButtonHeight), "Unknown", Color.Black, MediaRepository.Fonts["Arial10"], TextBox.AlignType.Center);

                p.AddComponent(effectButtons[index]);
                p.AddComponent(sequenceBars[index]);
                p.AddComponent(descriptions[index]);
                p.AddComponent(unknownTexts[index]);

                AddComponent(p);
                index++;
            }

            AddComponent(title);
            AddComponent(demolishButton);

            Deactivate();
        }
开发者ID:johnfn,项目名称:Illumination,代码行数:41,代码来源:BuildingPanel.cs

示例4: Initialize

        public void Initialize()
        {
            int buttonCount = (int)Person.ProfessionType.SIZE - 1;
            professionButtons = new Button[buttonCount];

            for (Person.ProfessionType profession = (Person.ProfessionType)1; profession < Person.ProfessionType.SIZE; profession++)
            {
                Button button = new Button(Person.GetTexture(profession), new Rectangle(ButtonWidth * ((int)profession - 1), 0, ButtonWidth, ButtonHeight), Color.White);
                professionButtons[(int)profession - 1] = button;
                AddComponent(button);
                button.AddActionListener(this);
            }
        }
开发者ID:johnfn,项目名称:Illumination,代码行数:13,代码来源:ProfessionPanel.cs


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