using System;
using System.Windows;
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace DTS.Common.Dialogs
{
///
/// Interaction logic for NotificationWindow.xaml
///
public partial class NotificationWindow : Window
{
public static readonly DependencyProperty NotificationTemplateProperty = DependencyProperty.Register("NotificationTemplate", typeof(DataTemplate), typeof(NotificationWindow), new PropertyMetadata(null));
public static readonly DependencyProperty ImageUriProperty = DependencyProperty.Register("ImageUri", typeof(Uri), typeof(NotificationWindow), new PropertyMetadata(new Uri("pack://application:,,,/" + System.Reflection.Assembly.GetExecutingAssembly() + ";component/RibbonControl/Images/warning_48.png", UriKind.RelativeOrAbsolute)));
///
/// Creates a new instance of
///
public NotificationWindow()
{
// Hook the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
SourceInitialized += NotificationWindow_SourceInitialized;
InitializeComponent();
}
///
/// The to apply when displaying data.
///
public DataTemplate NotificationTemplate
{
get => (DataTemplate)GetValue(NotificationTemplateProperty);
set => SetValue(NotificationTemplateProperty, value);
}
///
/// Gets or sets the for the notification image.
///
public Uri ImageUri
{
get => (Uri)GetValue(ImageUriProperty);
set => SetValue(ImageUriProperty, value);
}
void NotificationWindow_SourceInitialized(object sender, EventArgs e)
{
// Removing the Close Button on a WPF window.
// The key here is hooking the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
var wih = new WindowInteropHelper(this);
var style = GetWindowLong(wih.Handle, GWL_STYLE);
SetWindowLong(wih.Handle, GWL_STYLE, style & ~WS_SYSMENU);
}
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x00080000;
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hwnd, int index, int value);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hwnd, int index);
public void Connect(int connectionId, object target)
{
}
private void CoppyToClibord_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText("Hello, clipboard");
}
}
}