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


C# Connector.Alias方法代码示例

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


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

示例1: StartGui

        static void StartGui(Connector conn, Settings settings)
        {
            Gui.Start(x => {
            //if changes UI: have to use this
            Action<string, Action<CmdArg>> xRegister = (cmd, a) => conn.Register(cmd, x.InSTAThread(a));
            var help = @"Help:
            Type (messages) to line at bottom of window.
            Commands start with ':'.
            All messages are trimmed by default, so to write ':-)' just write ' :-)'.
            Use tab for command completion.

            :chat                    # show message board
            :server.start <port>     # starts server and DOES NOT connect to it
            :server.stop
            :ip                      # get local IP address(es)
            :wsdl                    # open server with wsdl description of service to access chans
            :connect <host:port>     # connect to a server; default port is " + settings.DefaultServerPort + @"
            :disconnect              # closes client
            :host <port>             # :server.start, :connect
            :join <host> <name>      # :connect <host>, :name <name>
            :name <new name>         # get or set; 'anon' by default
            :down, :d                # scroll to end of message board
            :exit, :quit
            :help, :h                # show this help
            :send <msg>              # send msg as it is; even just whitespace / nothing...
            :text <theText>          # ~= :send <trim($theText)>
                         # wouldn't send nothing

            if line doesn't start with ':': gets translated to: ':text <$line>'
            ";

            xRegister(Cmd.Help, _ => x.SwitchToHelp(help));
            xRegister(Cmd.Chat, _ => x.SwitchToChat());
            xRegister(Cmd.Exit, _ => x.Exit());
            xRegister(Cmd.ScrollDown, _ => x.ScrollToBottom());
            xRegister(Cmd.NotifyError, a => x.ShowError(a.Source, a.Text));
            xRegister(Cmd.NotifySystem, a => x.ShowNotifySystem(a.Source, a.Text));
            xRegister(Cmd.ReceivedMsg, a => x.ShowMessage(a.Source, a.Text));
            xRegister(Cmd.CmdAccepted, a => x.ClearCmdLineIfSame(a));
            xRegister(Cmd.CompletionResponse, a => x.PushCompletion(a, a.Source));

            conn.Alias("d", Cmd.ScrollDown);
            conn.Alias("h", Cmd.Help);
            conn.Alias("quit", Cmd.Exit);

            conn.Run(Cmd.Help);

            x.Command += line => conn.RunOrDefault(Cmd.CmdParseRun, line);
            x.CompletionRequest += line => conn.RunOrDefault(Cmd.CompletionRequest, line);
            x.BoardChanged += () => conn.Run(Cmd.Chat);

            conn.RunOrDefault(Cmd.AfterGuiLoaded);
              });
        }
开发者ID:Maartyl,项目名称:cs-chan,代码行数:54,代码来源:GuiChat.cs


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