64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using newcle.us.Utilities;
|
|
using System.ComponentModel;
|
|
|
|
namespace newcle.us.Forms
|
|
{
|
|
public partial class TextAreaForm : Form
|
|
{
|
|
public TextAreaForm() : this("Edit Content") { }
|
|
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? Content { get { return Content_RichTextBox.Text; } set { Content_RichTextBox.Text = 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)
|
|
{
|
|
DialogExtensions.GenericError(String.Format($"Failed to open link: {ex.Message}"));
|
|
}
|
|
}
|
|
|
|
private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
Clipboard.SetText(Content ?? "");
|
|
DialogExtensions.GenericSuccess("Content successfully copied to clipboard");
|
|
}
|
|
}
|
|
|
|
|
|
}
|