65.9K
CodeProject 正在变化。 阅读更多。
Home

多显示器“曲速”屏保

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.60/5 (12投票s)

2008年12月21日

BSD

1分钟阅读

viewsIcon

55087

downloadIcon

1638

一款高速屏保,模拟曲速效果;可以跨越多个显示器。

引言

我和儿子在电视上观看科幻节目时,看到了一种模拟宇宙飞船接近光速的酷炫效果。后来他问我是否可以在电脑上制作类似的效果作为屏保——这就是我们的尝试。

背景

我找到了一些 C# 的入门程序可以制作屏保,但没有一个能跨越多个屏幕——这个屏保可以。它足够简单,可以作为任何其他屏保想法的一个很好的起点——如果没有,你也可以简单地享受拥有这个屏保选项。

Using the Code

要在你的电脑上部署屏保,你只需要将二进制文件“Warp Speed.scr”复制到你的 Windows system32 文件夹(通常是 C:\Windows\system32\)。一旦复制到那里,屏保应该像任何其他屏保一样出现在你的系统中。它有一套详细的选项可以调整效果,并且预览窗口也能正常工作。请注意,如果你修改了程序并重新编译,你需要将“Warp Speed.exe”重命名为“Warp Speed.scr”,然后重新部署到你的 system 文件夹。以下是一些可用的选项

WarpSpeedOptions.JPG

关注点

对于那些想要编写跨越多个显示器的屏保的人来说,特别感兴趣的是 ScreenArea 类,以下是摘录

/// <summary>
/// Gets the least "x" coordinate of all screens on the system
/// </summary>
/// <returns>The smallest visible "x" screen coordinate</returns>
public static int LeftMostBound
{
    get
    {
        int leftBound = int.MaxValue;

        // Return the left-most "x" screen coordinate
        foreach (Screen display in Screen.AllScreens)
        {
            if (leftBound > display.Bounds.X)
                leftBound = display.Bounds.X;
        }

        return leftBound;
    }
}

这个类允许屏保计算所有连接屏幕的边界,如下所示

// Screen saver is in full screen mode 
// (i.e., not the preview window) - make form span all available system screens
Left = ScreenArea.LeftMostBound;
Top = ScreenArea.TopMostBound;
Width = ScreenArea.TotalWidth;
Height = ScreenArea.TotalHeight;

历史

  • 2008年12月21日:初始发布
© . All rights reserved.