/// <summary> /// Show Add/Edit Popup Window /// </summary> /// <param name="type">Window Type</param> /// <param name="viewModel">The viewmodel that will be bound to window data context</param> /// <param name="windowStyleName">Window style name</param> public void ShowAddEditWindow(PopupTypeEnum type, PopupViewModelBase viewModel, string windowStyleName) { try { Style windowStyle = Application.Current.FindResource(windowStyleName) as Style; AddEditPopupWindow popupModernWindow = new AddEditPopupWindow() { Title = type.ToString(), DataContext = viewModel, Style = windowStyle, WindowStartupLocation = WindowStartupLocation.CenterOwner, Owner = Application.Current.MainWindow }; viewModel.CloseAssociatedWindow = () => { popupModernWindow.Close(); }; popupModernWindow.Closing += (s, e) => { viewModel.Closing(); }; popupModernWindow.Loaded += popupModernWindow_Loaded; popupModernWindow.ShowDialog(); } catch (Exception ex) { throw; } }
public Task <TResult> ShowPopup <TResult>( PopupViewModelBase <TResult> element, string title = null, PopupType popupType = PopupType.None, bool closable = true, bool trasnparent = true) { return(Application.Current.Dispatcher.Invoke(async() => { if (element.View.Parent != null) { ((Border)element.View.Parent).Child = null; //.Clear(); } var modal = trasnparent ? new ModalPopup(Window.GetWindow(this)) : new ModalPopup(Window.GetWindow(this), CaptureScreen(this)); modal.Closed += (oo, ee) => element.Close(); modal.PopupContent = element.View; element.Closable = closable; modal.DataContext = element; modal.PopupType = popupType; modal.Title = title ?? ""; if (!_popedElements.ContainsKey(element)) { _popedElements.Add(element, modal); } modal.Show(); var res = await element.GetTask(); HidePopup(element); return res; })); //return modal; }
void ShowMessage(DisplayMessageData obj, PopupViewModelBase <object> content) { if (_core.TryGetUiManager(out IUiManager ui)) { if (obj.StartInFullScreen) { ui.Navigate(content); if (!obj.AllowClose) { ui.EnableFullscreen(); } if (obj.AllowCloseAfter > 0) { var t = new Timer { Interval = obj.AllowCloseAfter * 1000 }; t.Elapsed += (ooo, eee) => { t.Stop(); t.Enabled = false; Application.Current.Dispatcher.BeginInvoke(new Action(() => { ui.DisableFullscreen(); })); }; t.Start(); } if (obj.MaxDisplayTime != 0) { var t = new Timer(); t.Interval = obj.MaxDisplayTime * 1000; t.Elapsed += (ooo, eee) => { t.Stop(); t.Enabled = false; Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (ui.CurrentPage == content) { if (!obj.AllowClose && obj.AllowCloseAfter == 0) { ui.DisableFullscreen(); } ui.GoBack(); } })); }; t.Start(); } } else { var shownPopup = ui.ShowPopup(content, null, PopupType.Information, obj.AllowClose && obj.AllowCloseAfter == 0); if (obj.AllowCloseAfter > 0) { var t = new Timer { Interval = obj.AllowCloseAfter * 1000 }; t.Elapsed += (ooo, eee) => { t.Stop(); t.Enabled = false; Application.Current.Dispatcher.BeginInvoke(new Action(() => { content.Closable = true; })); }; t.Start(); } if (obj.MaxDisplayTime != 0) { var t = new Timer { Interval = obj.MaxDisplayTime * 1000 }; t.Elapsed += (ooo, eee) => { t.Stop(); t.Enabled = false; Application.Current.Dispatcher.BeginInvoke(new Action(() => { ui.HidePopup(content); })); }; t.Start(); } } } }