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


C# ScrollPanelWidget.Bind方法代码示例

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


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

示例1: GlobalChatLogic

        public GlobalChatLogic(Widget widget)
        {
            historyPanel = widget.Get<ScrollPanelWidget>("HISTORY_PANEL");
            historyTemplate = historyPanel.Get<LabelWidget>("HISTORY_TEMPLATE");
            nicknamePanel = widget.Get<ScrollPanelWidget>("NICKNAME_PANEL");
            nicknameTemplate = nicknamePanel.Get("NICKNAME_TEMPLATE");

            historyPanel.Bind(Game.GlobalChat.History, MakeHistoryWidget, HistoryWidgetEquals, true);
            nicknamePanel.Bind(Game.GlobalChat.Users, MakeUserWidget, UserWidgetEquals, false);

            inputBox = widget.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            inputBox.IsDisabled = () => Game.GlobalChat.ConnectionStatus != ChatConnectionStatus.Joined;
            inputBox.OnEnterKey = EnterPressed;

            // Set a random default nick
            if (Game.Settings.Chat.Nickname == new ChatSettings().Nickname)
                Game.Settings.Chat.Nickname += Game.CosmeticRandom.Next(100, 999);

            var nicknameBox = widget.Get<TextFieldWidget>("NICKNAME_TEXTFIELD");
            nicknameBox.Text = Game.GlobalChat.SanitizedName(Game.Settings.Chat.Nickname);
            nicknameBox.OnTextEdited = () =>
            {
                nicknameBox.Text = Game.GlobalChat.SanitizedName(nicknameBox.Text);
            };

            var connectPanel = widget.Get("GLOBALCHAT_CONNECT_PANEL");
            connectPanel.IsVisible = () => Game.GlobalChat.ConnectionStatus == ChatConnectionStatus.Disconnected;

            var disconnectButton = widget.Get<ButtonWidget>("DISCONNECT_BUTTON");
            disconnectButton.OnClick = Game.GlobalChat.Disconnect;

            var connectAutomaticallyCheckBox = connectPanel.Get<CheckboxWidget>("CONNECT_AUTOMATICALLY_CHECKBOX");
            connectAutomaticallyCheckBox.IsChecked = () => Game.Settings.Chat.ConnectAutomatically;
            connectAutomaticallyCheckBox.OnClick = () => { Game.Settings.Chat.ConnectAutomatically ^= true; Game.Settings.Save(); };

            var connectButton = connectPanel.Get<ButtonWidget>("CONNECT_BUTTON");
            connectButton.IsDisabled = () => !Game.GlobalChat.IsValidNickname(nicknameBox.Text);
            connectButton.OnClick = () =>
            {
                Game.Settings.Chat.Nickname = nicknameBox.Text;
                Game.Settings.Save();
                Game.GlobalChat.Connect();
            };

            var mainPanel = widget.Get("GLOBALCHAT_MAIN_PANEL");
            mainPanel.IsVisible = () => Game.GlobalChat.ConnectionStatus != ChatConnectionStatus.Disconnected;

            mainPanel.Get<LabelWidget>("CHANNEL_TOPIC").GetText = () => Game.GlobalChat.Topic;

            if (Game.Settings.Chat.ConnectAutomatically && Game.GlobalChat.IsValidNickname(Game.Settings.Chat.Nickname))
                Game.GlobalChat.Connect();
        }
开发者ID:RRRlizhen,项目名称:OpenRA,代码行数:52,代码来源:GlobalChatLogic.cs


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