public override void Set(AaxFileItem fileItem) { textBoxTitle.Text = fileItem.BookTitle; var rtfbld = new RtfBuilder(); rtfbld.AppendItem(R.HdrAuthor, fileItem.Author); rtfbld.AppendItem(R.HdrNarrator, fileItem.Narrator); rtfbld.AppendItem(R.HdrSize, $"{fileItem.FileSize / (1024 * 1024)} MB"); rtfbld.AppendItem(R.HdrDuration, fileItem.Duration.ToStringHMS()); rtfbld.AppendItem(R.HdrYear, fileItem.PublishingDate?.Year.ToString()); rtfbld.AppendItem(R.HdrPublisher, fileItem.Publisher); rtfbld.AppendItem(R.HdrCopyright, fileItem.Copyright); string rtf = rtfbld.ToRtf(); richTextBoxMeta.Clear(); richTextBoxMeta.Rtf = rtf; var converter = new ImageConverter(); pictureBox.Image = converter.ConvertFrom(fileItem.Cover) as Image; richTextBoxAbstract.Clear(); richTextBoxAbstract.Text = fileItem.Abstract; }
public static void AppendItem(this RtfBuilder rtfbld, string header, string body) { rtfbld.AppendBold(header); rtfbld.AppendLine(); rtfbld.Append(body); //rtfbld.AppendLine (); rtfbld.AppendPara(); }
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(); } }