99 lines
2.5 KiB
C#
99 lines
2.5 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Markup;
|
|
|
|
namespace BeWo.View
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für ConfirmDemoDialog.xaml
|
|
/// </summary>
|
|
public partial class MessageDialog : Window
|
|
{
|
|
public MessageDialog()
|
|
{
|
|
InitializeComponent();
|
|
DataContext = this;
|
|
|
|
}
|
|
|
|
private ICommand openBrowserCommand;
|
|
public ICommand OpenBrowserCommand
|
|
{
|
|
get
|
|
{
|
|
if (openBrowserCommand == null)
|
|
{
|
|
openBrowserCommand = new OpenBrowserCommandImpl();
|
|
}
|
|
|
|
return openBrowserCommand;
|
|
}
|
|
}
|
|
|
|
public class OpenBrowserCommandImpl : ICommand
|
|
{
|
|
public bool CanExecute(object parameter)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
public void Execute(object parameter)
|
|
{
|
|
if (parameter != null)
|
|
{
|
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(parameter.ToString()));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetXaml(String xamlCode)
|
|
{
|
|
try
|
|
{
|
|
UIElement element = XamlReader.Parse(xamlCode) as UIElement;
|
|
if (element != null)
|
|
{
|
|
txtMessage.Visibility = Visibility.Collapsed;
|
|
rootGrid.Children.Add(element);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//ignore
|
|
}
|
|
|
|
}
|
|
|
|
public String Message
|
|
{
|
|
get { return txtMessage.Text; }
|
|
set { txtMessage.Text = value; }
|
|
}
|
|
|
|
|
|
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
//DialogResult = true;
|
|
Close();
|
|
}
|
|
private void OpenBrowserCommand_Executed(object sender, ExecutedRoutedEventArgs e)
|
|
{
|
|
if (e.OriginalSource is Hyperlink)
|
|
{
|
|
System.Diagnostics.Process.Start(
|
|
new System.Diagnostics.ProcessStartInfo((e.OriginalSource as Hyperlink).NavigateUri.ToString()));
|
|
}
|
|
}
|
|
|
|
private void OpenBrowserCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
|
|
{
|
|
e.CanExecute = true;
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
}
|