void ShowWindow() { if (window != null) { window.Close(); } window = new DXWindow(); if (enableEffect.IsChecked.HasValue) { window.BorderEffect = enableEffect.IsChecked.Value ? BorderEffect.Default : BorderEffect.None; } if (enableCustomization.IsChecked.Value) { SetBorderEffectCustomColors(); } rootWindow = LayoutHelper.GetRoot(this) as Window; if (rootWindow != null) { window.SetBounds(GetWindowSuggestedRect(rootWindow.GetBounds())); window.Icon = rootWindow.Icon; rootWindow.Closed += rootWindow_Closed; window.Owner = rootWindow; } window.Title = "DXWindow"; window.Topmost = true; window.Show(); }
private static void OpenViewInDialog(View view, View parent) { var container = new DXWindow { Width = 800, Height = 500, ShowInTaskbar = true, Title = view.GetText() ?? string.Empty, WindowStartupLocation = WindowStartupLocation.CenterScreen, Content = view.GetControl() }; if (parent != null) { container.ShowIcon = false; container.WindowState = WindowState.Normal; container.WindowStyle = WindowStyle.ToolWindow; // Закрытие диалога по нажатию на Escape container.PreviewKeyDown += (s, e) => { if (e.Key == Key.Escape) { container.Close(); } }; } else { container.ShowIcon = true; container.WindowState = WindowState.Maximized; container.WindowStyle = WindowStyle.SingleBorderWindow; container.Icon = ImageRepository.GetImage(view.GetImage()); } var closingHandling = false; var closeHandling = false; view.OnClosing += (c, a) => TryExecuteBlock(ref closingHandling, () => a.IsCancel = (a.IsCancel == true) || !CloseView(view)); view.OnClosed += (c, a) => TryExecuteBlock(ref closeHandling, container.Close); container.Closing += (c, a) => TryExecuteBlock(ref closeHandling, () => a.Cancel = a.Cancel || !view.Close()); var gotFocusHandling = false; view.OnGotFocus += (c, a) => TryExecuteBlock(ref gotFocusHandling, () => container.Focus()); container.GotFocus += (s, e) => TryExecuteBlock(ref gotFocusHandling, () => view.InvokeScript(view.OnGotFocus)); var lostFocusHandling = false; container.LostFocus += (s, e) => TryExecuteBlock(ref lostFocusHandling, () => view.InvokeScript(view.OnLostFocus)); view.OnTextChanged += (c, a) => container.Title = a.Value; container.ShowDialog(); }