|
using System;
using System.Windows;
using System.Windows.Controls;
namespace TaskManagerDemo.Controls
{
public partial class InputDialog : UserControl
{
public EventHandler<EventArgs> OK;
public EventHandler<EventArgs> Cancelled;
public InputDialog()
{
InitializeComponent();
}
private void InputDialog_SizeChanged(object sender, SizeChangedEventArgs e)
{
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
if (OK != null)
OK(this, EventArgs.Empty);
}
public void CloseDialog()
{
if (OK != null)
OK(this, EventArgs.Empty);
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
if (Cancelled != null)
Cancelled(this, EventArgs.Empty);
}
public void AppendText(string text)
{
TextBox.Text += text;
}
public void SetButtonsContent(string OKContent, string CancelContent, string text, double width, double height)
{
if (string.IsNullOrEmpty(CancelContent))
{
btnCancel.Visibility = Visibility.Collapsed;
btnOK.HorizontalAlignment = HorizontalAlignment.Center;
}
btnOK.Content = OKContent;
btnCancel.Content = CancelContent;
//Message.Text = text;
scrollContent.Width = width - 20;
TextBox.MaxWidth = scrollContent.Width - 10;
scrollContent.Height = height - 45;
scrollContent.Visibility = Visibility.Visible;
TextBox.Text = !string.IsNullOrEmpty(text) ? text : string.Empty;
if (OKContent != "OK")
btnOK.Width = OKContent.Length * 9 + 4;
if (CancelContent != "Cancel")
btnCancel.Width = CancelContent.Length * 9 + 4;
this.UpdateLayout();
}
public void SetButtonsContentAsymmetric(string okContent, string cancelContent, string text, double okWidth, double cancelWidth)
{
double width = 400;
double height = 120;
btnOK.Content = okContent;
btnOK.Width = okWidth;
btnCancel.Content = cancelContent;
btnCancel.Width = cancelWidth;
scrollContent.Width = width - 20;
TextBox.MaxWidth = scrollContent.Width - 10;
scrollContent.Height = height - 45;
scrollContent.Visibility = Visibility.Visible;
TextBox.Text = !string.IsNullOrEmpty(text) ? text : string.Empty;
this.UpdateLayout();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
George Henry has worked as a software developer for more than 20 years. He is currently employed by Concur in Bellevue, Washington, USA.