Created
September 7, 2012 04:09
-
-
Save pinzolo/3663046 to your computer and use it in GitHub Desktop.
[WPF]ウィンドウをデスクトップの任意の位置に表示させる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// System.Windows.Forms と System.Drawing を参照設定に追加する必要がある。 | |
// この例では通知ウィンドウを右下に表示させるというシナリオ | |
/// <summary> | |
/// 通知ウィンドウ表示時の画面からのマージン | |
/// </summary> | |
private const int NOTIFICATION_WINDOW_DISPLAY_MARGIN = 5; | |
/// <summary> | |
/// 指定のメッセージをユーザーに知らせるダイアログを表示する。 | |
/// </summary> | |
/// <param name="message">通知メッセージ</param> | |
private void Notify(string message) | |
{ | |
var notificationWindow = new NotificationWindow(); | |
var desktop = System.Windows.Forms.Screen.PrimaryScreen.Bounds; | |
notificationWindow.Top = desktop.Height - (notificationWindow.Height + NOTIFICATION_WINDOW_DISPLAY_MARGIN); | |
notificationWindow.Left = desktop.Width - (notificationWindow.Width + NOTIFICATION_WINDOW_DISPLAY_MARGIN); | |
notificationWindow.Owner = this; | |
notificationWindow.Show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment