DockableFloatingWindow 上的最大化和 Aero 捕捉

发布于 2024-11-09 20:12:51 字数 1162 浏览 9 评论 0原文

我有以下代码可以使未停靠的浮动 AvalonDock 窗口最大化:

class MaximizableDockableContent : AvalonDock.DockableContent
{
    public MaximizableDockableContent()
        : base()
    {
         base.StateChanged += MaximizableDockableContent_StateChanged;
    }

    private void MaximizableDockableContent_StateChanged(
        object sender, RoutedEventArgs e)
    {
        MaximizableDockableContent mdc = (MaximizableDockableContent)sender;
        if (mdc.State == DockableContentState.DockableWindow)
        {
            base.FloatingWindowSizeToContent = SizeToContent.WidthAndHeight;
            FloatingDockablePane fdp = (FloatingDockablePane)base.Parent;
            DockableFloatingWindow dfw = (DockableFloatingWindow)fdp.Parent;

            //dfw.WindowState = WindowState.Maximized;
            dfw.WindowStyle = WindowStyle.ThreeDBorderWindow;
            dfw.ResizeMode = ResizeMode.CanResize;

            //disable minimize button
            ControlBox.SetHasMinimizeButton(dfw, false);
        }
    }
}

我如何添加 Aero Snap 功能吗?

I have the following code to give a undocked floating AvalonDock window the ability to maximize:

class MaximizableDockableContent : AvalonDock.DockableContent
{
    public MaximizableDockableContent()
        : base()
    {
         base.StateChanged += MaximizableDockableContent_StateChanged;
    }

    private void MaximizableDockableContent_StateChanged(
        object sender, RoutedEventArgs e)
    {
        MaximizableDockableContent mdc = (MaximizableDockableContent)sender;
        if (mdc.State == DockableContentState.DockableWindow)
        {
            base.FloatingWindowSizeToContent = SizeToContent.WidthAndHeight;
            FloatingDockablePane fdp = (FloatingDockablePane)base.Parent;
            DockableFloatingWindow dfw = (DockableFloatingWindow)fdp.Parent;

            //dfw.WindowState = WindowState.Maximized;
            dfw.WindowStyle = WindowStyle.ThreeDBorderWindow;
            dfw.ResizeMode = ResizeMode.CanResize;

            //disable minimize button
            ControlBox.SetHasMinimizeButton(dfw, false);
        }
    }
}

How do I go about adding Aero Snap functionality to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝眸 2024-11-16 20:12:51

对于感兴趣的人,最新版本的 AvalonDock(版本 2)本身支持浮动窗口 aero snap 功能。
AvalonDock 2.0 仍处于测试阶段,更多信息:
http://avalondock.codeplex.com/
新功能:
http://avalondock.codeplex.com/wikipage?title=Version2Concept

For who is interested latest version of AvalonDock (version 2) natively supports floating window aero snap feature.
AvalonDock 2.0 is still in beta, more info:
http://avalondock.codeplex.com/
New features:
http://avalondock.codeplex.com/wikipage?title=Version2Concept

碍人泪离人颜 2024-11-16 20:12:51

您可以使用运行时运行外部进程:

从以下位置下载nircmd.exe: http://www.nirsoft .net/utils/nircmd.html
并确保它与 .class 文件位于同一目录中或在 Windows PATH 环境变量中

,然后使用 Runtime.exec() 运行它多次:

Runtime r=Runtime.getRuntime();
r.exec("nircmd.exe sendkey lwin down");
r.exec("nircmd.exe sendkey "+direction+" press");
//change direction to "right" (for right side), "left" (for left side), or "up" (for full window).
r.exec("nircmd.exe sendkey lwin up");

请注意,这可能会引发 IOException,因此可能会出现 try/catch 块必要的。

注意:这假设该窗口是活动窗口。

you could run an external process, using runtime:

download nircmd.exe from: http://www.nirsoft.net/utils/nircmd.html
and make sure it is in the same directory as the .class file or in the windows PATH environment variable

then use Runtime.exec() to run it several times:

Runtime r=Runtime.getRuntime();
r.exec("nircmd.exe sendkey lwin down");
r.exec("nircmd.exe sendkey "+direction+" press");
//change direction to "right" (for right side), "left" (for left side), or "up" (for full window).
r.exec("nircmd.exe sendkey lwin up");

note that this can throw an IOException, so a try/catch block might be necessary.

note:this assumes that the window is the active one.

岁月无声 2024-11-16 20:12:51

匿名说:“不幸的是,Windows + 向上或向下箭头也被禁用。活动窗口。”

vIBIUS 说:“这也会禁用 Windows 键 + Shift 和左/右选项!”

Kermonk 说“不幸的是,这也禁用了“摇动窗口以关闭所有其他窗口”功能……”

尝试一下:

[HKEY_CURRENT_USER\Control Panel\Desktop]
"DockMoving"="0"

它禁用鼠标操作以最大化窗口并将窗口对齐到侧面,但不能禁用键盘快捷键。它不会影响 AeroPeak 或 AeroShake。它也不会影响“仅在垂直方向上最大化窗口”。

anon said “Unfortunately is also disables, Windows + Up or Down arrow for Max./Min. the active Window.”

vIBIUS said “This also disables the Windows Key + Shift and Left/Right option!”

Kermonk said “unfortunately that also disables the “shake window to close all other windows” feature…”

Try this:

[HKEY_CURRENT_USER\Control Panel\Desktop]
"DockMoving"="0"

It disables the mouse action to maximise windows and snap windows to the side but not the keyboard shortcuts. It does not affect AeroPeak or AeroShake. It also does not affect ‘maximising a window in a verticle direction only’.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文