|
using System.ComponentModel.Composition;
using System.Windows;
using MediaAssistant.Controls.Dialog;
using MefBasic;
namespace MediaAssistant.Controls.MessageBox
{
[Export]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class MessageBoxPresenter:APresenter<MessageBoxView>, IDialogContentPresenter
{
[ImportingConstructor]
public MessageBoxPresenter(MessageBoxView view) : base(view)
{
}
public DialogResult Show(string message, string title)
{
var dialogPresenter = Resolve<IDialogPresenter>();
dialogPresenter.OkButtonCaption = OkButtonCaption;
dialogPresenter.CancelButtonCaption = CancelButtonCaption;
Message = message;
return dialogPresenter.ShowDialog(title, this);
}
public string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
public static readonly DependencyProperty MessageProperty =
DependencyProperty.Register("Message", typeof(string), typeof(MessageBoxPresenter), new UIPropertyMetadata(string.Empty));
#region Implementation of IDialogContentPresenter
public bool OnClosing(DialogResult dialogResult)
{
return true;
}
public string OkButtonCaption
{
get { return (string)GetValue(OkButtonCaptionProperty); }
set { SetValue(OkButtonCaptionProperty, value); }
}
public static readonly DependencyProperty OkButtonCaptionProperty =
DependencyProperty.Register("OkButtonCaption", typeof(string), typeof(MessageBoxPresenter), new UIPropertyMetadata("Ok"));
public string CancelButtonCaption
{
get { return (string)GetValue(CancelButtonCaptionProperty); }
set { SetValue(CancelButtonCaptionProperty, value); }
}
public static readonly DependencyProperty CancelButtonCaptionProperty =
DependencyProperty.Register("CancelButtonCaption", typeof(string), typeof(MessageBoxPresenter), new UIPropertyMetadata("Cancel"));
#endregion
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.