public static void AppendItem(this RtfBuilder rtfbld, string header, string body)
 {
     rtfbld.AppendBold(header);
     rtfbld.AppendLine();
     rtfbld.Append(body);
     //rtfbld.AppendLine ();
     rtfbld.AppendPara();
 }
Ejemplo n.º 2
0
 public void Write(string parsedSourceCode, IList <Scope> scopes, IStyleSheet styleSheet, TextWriter textWriter)
 {
     if (scopes.Any())
     {
         builder.SetForeColor(styleSheet.Styles[scopes.First().Name].Foreground).Append(parsedSourceCode);
     }
     else
     {
         builder.Append(parsedSourceCode);
     }
 }
Ejemplo n.º 3
0
        private async void EnterGame(string address, int port, string username, bool isHost)
        {
            StatusLabel.Visible   = true;
            StatusLabel.Text      = "Attempting Connection...";
            StatusLabel.ForeColor = SystemColors.ControlText;
            try
            {
                await ProtocolProcess.CreatePlayer(address, port);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                StatusLabel.Text      = "Unable to connect";
                StatusLabel.ForeColor = Color.Red;
                return;
            }
            ProtocolProcess.StartClient();
            PlayerSetting.Username = username;
            PlayerSetting.IsHost   = isHost;
            // If we are the host, we use RichTextFormatting to append bold-casing to our displayName.
            // This makes it easier for others in the lobby to visually see who is the host and who are the other players.
            //
            // Forseeably, this implementation can be used for nickname support, but would require more checks to prevent abuse.
            RtfBuilder builder = new RtfBuilder();

            if (isHost)
            {
                PlayerSetting.DisplayName = builder.AppendBold(username).ToRtf();
            }
            else
            {
                PlayerSetting.DisplayName = builder.Append(username).ToRtf();
            }
            ProtocolProcess.JoinGame(PlayerSetting.Username, PlayerSetting.DisplayName);

            StatusLabel.Visible = false;
            Hide();
            if (GamePanel == null)
            {
                // TODO: Manual Leaving caused me a lot of stress, and it just wasn't wanting to work with me.
                // Application.Exit() is able to do this job for now, but would need to be fixed later
                //
                // In this case, Manual Leaving requires Show to instead be ShowDialog + returning a dialog result in GamePanel_FormClosing
                // in order to provide the expected behavior. This note is mentioned here in case I decide to try it again.
                GamePanel = new GamePanel();
                GamePanel.Show();
            }
        }