示例#1
0
    void AddServer(ServerPageWidget serverWidget)
    {
        ServersNotebook.AppendPage(serverWidget, serverWidget.PageLabel);
        ServersNotebook.ShowAll();



        // select server page
    }
示例#2
0
    protected void ServersNotebook_SwitchPage(object o, SwitchPageArgs args)
    {
        ServerPageWidget widg = GetSelectedServerWidget();

        if (widg != null)
        {
            widg.UpdateLabels();
        }
    }
示例#3
0
    protected void ConnectButton_Click(object sender, EventArgs e)
    {
        string host = "127.0.0.1";
        int    port = 1337;

        if (serverEntry.Text.Contains(":"))
        {
            string[] parts = serverEntry.Text.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length != 2)
            {
                // invalid address format
                // TODO: show error
                return;
            }
            else
            {
                host = parts[0];
                if (!int.TryParse(parts[1], out port))
                {
                    // bad port format
                    // TODO: show error
                    return;
                }
            }
        }
        else if (!String.IsNullOrEmpty(serverEntry.Text))
        {
            host = serverEntry.Text;
        }

        try
        {
            ServerPageWidget serverWidget = new ServerPageWidget(usernameEntry.Text, host, port);

            AddServer(serverWidget);
        }
        catch (Exception ex)
        {
            // error connecting
            // TODO: show error
            throw ex;
        }
    }