77 lines
2.8 KiB
C#
77 lines
2.8 KiB
C#
using newcle.us.Utilities;
|
|
using System.ComponentModel;
|
|
|
|
namespace newcle.us.Forms
|
|
{
|
|
public partial class TextAreaForm : Form
|
|
{
|
|
public TextAreaForm() : this("Untitled") { }
|
|
public TextAreaForm(string formTitle)
|
|
{
|
|
InitializeComponent();
|
|
|
|
// Set DialogResult on buttons
|
|
Okay_Button.DialogResult = DialogResult.OK;
|
|
Cancel_Button.DialogResult = DialogResult.Cancel;
|
|
|
|
// Optional: Set default Accept/Cancel buttons
|
|
//this.AcceptButton = Okay_Button;
|
|
this.CancelButton = CancelButton;
|
|
this.StartPosition = FormStartPosition.CenterParent;
|
|
this.Text = formTitle;
|
|
|
|
Content_RichTextBox.Text = string.Empty;
|
|
Content_RichTextBox.BackColor = Color.White;
|
|
}
|
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
public string? BasicText { get { return Content_RichTextBox.Text; } set { Content_RichTextBox.Text = value; } }
|
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
public string? RichText { get { return Content_RichTextBox.Rtf; } set { Content_RichTextBox.Rtf = value; } }
|
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
public bool WordWrap { get { return Content_RichTextBox.WordWrap; } set { Content_RichTextBox.WordWrap = value; } }
|
|
|
|
public void ReadOnly()
|
|
{
|
|
Content_RichTextBox.ReadOnly = true;
|
|
Okay_Button.Visible = false;
|
|
Cancel_Button.Text = "Okay";
|
|
Text = string.Format("{0} [readonly]", Text);
|
|
}
|
|
|
|
private void Content_RichTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// Open the URL in the default browser
|
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
|
{
|
|
FileName = e.LinkText,
|
|
UseShellExecute = true
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(String.Format($"Failed to open link: {ex.Message}"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(BasicText)) { return; }
|
|
|
|
Clipboard.SetText(BasicText ?? "");
|
|
MessageBox.Show("Content successfully copied to clipboard", "Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
private void enableDisableWordWrapToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
Content_RichTextBox.WordWrap = !Content_RichTextBox.WordWrap;
|
|
}
|
|
}
|
|
|
|
|
|
}
|