/// <summary>Pushes a message on the users screen.</summary> public CsMessageWindow GetWindow(object content, CsMessage.Types type = CsMessage.Types.Information, string title = null, CsMessage.MessageButtons buttons = CsMessage.MessageButtons.Ok, [CallerMemberName] string methodName = null, [CallerFilePath] string classFilePath = null, [CallerLineNumber] int classLineNumber = 0) { if (Application.Current == null) return null; var w1 = new CsMessageWindow(new CsMessage(type, content, title, buttons, methodName, classFilePath, classLineNumber)); return w1; }
/// <summary>Pushes a message on the users screen.</summary> public CsMessage.MessageResults Push(object content, CsMessage.Types type = CsMessage.Types.Information, string title = null, CsMessage.MessageButtons buttons = CsMessage.MessageButtons.Ok, [CallerMemberName] string methodName = null, [CallerFilePath] string classFilePath = null, [CallerLineNumber] int classLineNumber = 0) { if (Application.Current == null) return CsMessage.MessageResults.Undefined; if (Application.Current.Dispatcher.Thread != Thread.CurrentThread) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { GetWindow(content, type, title, buttons, methodName, classFilePath, classLineNumber).ShowDialog(); })); return CsMessage.MessageResults.Undefined; } return GetWindow(content, type, title, buttons, methodName, classFilePath, classLineNumber).ShowDialog(); }
/// <summary>ctor</summary> public CsMessageWindow(CsMessage message) { Message = message; var activeWindow = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive); if (activeWindow != null) Owner = activeWindow; else if (Application.Current.MainWindow.IsInitialized && Application.Current.MainWindow.IsVisible) Owner = Application.Current.MainWindow; Topmost = true; this.LayoutTransform = new ScaleTransform(DefaultContentScaling, DefaultContentScaling, 0.5, 0.5); InitializeComponent(); }