72 lines
3.0 KiB
C#
72 lines
3.0 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Interop;
|
|
|
|
namespace DTS.Common.Dialogs
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for NotificationWindow.xaml
|
|
/// </summary>
|
|
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)));
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of <see cref="NotificationWindow"/>
|
|
/// </summary>
|
|
public NotificationWindow()
|
|
{
|
|
// Hook the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
|
|
SourceInitialized += NotificationWindow_SourceInitialized;
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// The <see cref="DataTemplate"/> to apply when displaying <see cref="DTS.Common.Interactivity.InteractionRequest.Confirmation"/> data.
|
|
/// </summary>
|
|
public DataTemplate NotificationTemplate
|
|
{
|
|
get => (DataTemplate)GetValue(NotificationTemplateProperty);
|
|
set => SetValue(NotificationTemplateProperty, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the <see cref="Uri"/> for the notification image.
|
|
/// </summary>
|
|
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");
|
|
}
|
|
}
|
|
} |