如何将 PopUpWindow 设置为与应用程序在同一台显示器上? (xaf)
How to set PopUpWindow to be on the same monitor as the application? (xaf)
用户经常在显示器之间移动我的 XAF Winforms 应用程序。
但是 PopUpWindowShowAction 调用的对话框仍保留在旧监视器上
这个问题可以在 Dev Express 的主要演示中重复出现(尽管要在那里调试它我认为我需要进入 API 代码)。
- 运行 主演示并将应用程序 window 移动到第二台显示器。
- Select 用户,右键单击用户并 select 打印预览。
打印预览将出现在第一台显示器上。
在我的类似情况下,我的控制器是
public partial class JobHeadFilterController : ViewController, IClassicController
{
public JobHeadFilterController()
{
InitializeComponent();
TargetViewNesting = Nesting.Root;
}
protected override void OnActivated()
{
base.OnActivated();
popupWindowShowFilterAction.QuickAccess = true;
}
private void popupWindowShowFilterAction_CustomizePopupWindowParams(object sender,
CustomizePopupWindowParamsEventArgs e)
{
var holder = new JobHeadFilterHolder();
var npProvider = new NonPersistentObjectSpaceProvider(XafTypesInfo.Instance, null);
var os = (NonPersistentObjectSpace)npProvider.CreateObjectSpace();
var view = Application.CreateDetailView(os, holder);
e.View = view;
}
我已尝试浏览 CustomizePopupWindowParamsEventArgs 的属性,但看不到要设置的内容。
我可以使用
获取主窗体
var mainform = Application.MainWindow.Template as Form;
我想我需要在里面做类似下面的事情 popupWindowShowFilterAction_CustomizePopupWindowParams
var template = e.Application.MainWindow.Template;
var window = new Window(Application, ); // having trouble figuring out the parameters
e.DialogController.SetWindow(window);
正在学习the docs
[更新]
我试过了
var window = e.Application.MainWindow;
e.DialogController.SetWindow(window);
但出现错误
The 'DevExpress.ExpressApp.SystemModule.DialogController' controller
is active.
我尝试制作自己的继承自 Dev DevExpress.ExpressApp.SystemModule.DialogController 的对话框控制器,但遇到了同样的错误。
using System;
using System.Windows.Forms;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Templates;
using DevExpress.ExpressApp.Win.Templates;
namespace MyNameSpace;
public partial class CustomizeFormsWindowController : WindowController
{
public CustomizeFormsWindowController()
{
InitializeComponent();
TargetWindowType = WindowType.Child;
}
protected override void OnActivated()
{
base.OnActivated();
Window.TemplateChanged += WindowsTemplateChanged;
}
private void WindowsTemplateChanged(object sender, EventArgs e)
{
if (Window.Template is Form &&
Window.Template is ISupportStoreSettings)
((ISupportStoreSettings)Window.Template).SettingsReloaded +=
OnFormReadyForCustomizations;
}
private void OnFormReadyForCustomizations(object sender, EventArgs e)
{
if (sender is not PopupForm popupForm) return;
var mainForm = Application.MainWindow.Template as Form;
var X = mainForm.Location.X + (mainForm.Width - popupForm.Width) / 2;
var Y = mainForm.Location.Y + (mainForm.Height - popupForm.Height) / 2;
popupForm.SetDesktopLocation(X, Y);
}
protected override void OnDeactivated()
{
Window.TemplateChanged -= WindowsTemplateChanged;
base.OnDeactivated();
}
}
用户经常在显示器之间移动我的 XAF Winforms 应用程序。 但是 PopUpWindowShowAction 调用的对话框仍保留在旧监视器上
这个问题可以在 Dev Express 的主要演示中重复出现(尽管要在那里调试它我认为我需要进入 API 代码)。
- 运行 主演示并将应用程序 window 移动到第二台显示器。
- Select 用户,右键单击用户并 select 打印预览。
打印预览将出现在第一台显示器上。
在我的类似情况下,我的控制器是
public partial class JobHeadFilterController : ViewController, IClassicController
{
public JobHeadFilterController()
{
InitializeComponent();
TargetViewNesting = Nesting.Root;
}
protected override void OnActivated()
{
base.OnActivated();
popupWindowShowFilterAction.QuickAccess = true;
}
private void popupWindowShowFilterAction_CustomizePopupWindowParams(object sender,
CustomizePopupWindowParamsEventArgs e)
{
var holder = new JobHeadFilterHolder();
var npProvider = new NonPersistentObjectSpaceProvider(XafTypesInfo.Instance, null);
var os = (NonPersistentObjectSpace)npProvider.CreateObjectSpace();
var view = Application.CreateDetailView(os, holder);
e.View = view;
}
我已尝试浏览 CustomizePopupWindowParamsEventArgs 的属性,但看不到要设置的内容。
我可以使用
获取主窗体 var mainform = Application.MainWindow.Template as Form;
我想我需要在里面做类似下面的事情 popupWindowShowFilterAction_CustomizePopupWindowParams
var template = e.Application.MainWindow.Template;
var window = new Window(Application, ); // having trouble figuring out the parameters
e.DialogController.SetWindow(window);
正在学习the docs
[更新]
我试过了
var window = e.Application.MainWindow; e.DialogController.SetWindow(window);
但出现错误
The 'DevExpress.ExpressApp.SystemModule.DialogController' controller is active.
我尝试制作自己的继承自 Dev DevExpress.ExpressApp.SystemModule.DialogController 的对话框控制器,但遇到了同样的错误。
using System;
using System.Windows.Forms;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Templates;
using DevExpress.ExpressApp.Win.Templates;
namespace MyNameSpace;
public partial class CustomizeFormsWindowController : WindowController
{
public CustomizeFormsWindowController()
{
InitializeComponent();
TargetWindowType = WindowType.Child;
}
protected override void OnActivated()
{
base.OnActivated();
Window.TemplateChanged += WindowsTemplateChanged;
}
private void WindowsTemplateChanged(object sender, EventArgs e)
{
if (Window.Template is Form &&
Window.Template is ISupportStoreSettings)
((ISupportStoreSettings)Window.Template).SettingsReloaded +=
OnFormReadyForCustomizations;
}
private void OnFormReadyForCustomizations(object sender, EventArgs e)
{
if (sender is not PopupForm popupForm) return;
var mainForm = Application.MainWindow.Template as Form;
var X = mainForm.Location.X + (mainForm.Width - popupForm.Width) / 2;
var Y = mainForm.Location.Y + (mainForm.Height - popupForm.Height) / 2;
popupForm.SetDesktopLocation(X, Y);
}
protected override void OnDeactivated()
{
Window.TemplateChanged -= WindowsTemplateChanged;
base.OnDeactivated();
}
}