C# WPF屏幕保护程序不工作

C# WPF屏幕保护程序不工作,c#,wpf,C#,Wpf,我已经用WPF和一些不错的教程构建了一个屏幕保护程序。当我将exe重命名为scr并测试它时,它会按预期运行,移动鼠标或按键会按预期退出 当我右键单击并安装屏幕保护程序时,它会显示带有预览的屏幕保护程序窗口(看起来像是我当前桌面的屏幕截图,很烦人,如果有人知道如何更改,那将很有用) 如果我按Preview,它应该会显示我的屏幕保护程序,而不是什么都没有发生(除了预览图像外,它看起来好像被一个新的图像替换了) 如果我让屏幕保护程序超时,我得到的只是一个闪光灯,但实际上什么也没有显示 这是我的密码:

我已经用WPF和一些不错的教程构建了一个屏幕保护程序。当我将exe重命名为scr并测试它时,它会按预期运行,移动鼠标或按键会按预期退出

当我右键单击并安装屏幕保护程序时,它会显示带有预览的屏幕保护程序窗口(看起来像是我当前桌面的屏幕截图,很烦人,如果有人知道如何更改,那将很有用)

如果我按Preview,它应该会显示我的屏幕保护程序,而不是什么都没有发生(除了预览图像外,它看起来好像被一个新的图像替换了)

如果我让屏幕保护程序超时,我得到的只是一个闪光灯,但实际上什么也没有显示

这是我的密码:

/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
    private void OnStartup(object sender, StartupEventArgs e)
    {
        string[] args = e.Args;

        if (args.Length > 0)
        {
            // Get the 2 character command line argument
            string arg = args[0].ToLower(CultureInfo.InvariantCulture).Trim().Substring(0, 2);
            switch (arg)
            {
                case "/c":
                    // Show the options dialog
                    MessageBox.Show("This screensaver has no options.");
                    break;
                case "/p":
                    // Don't do anything for preview
                    ShowScreensaver();
                    break;
                case "/s":
                    // Show screensaver form
                    ShowScreensaver();
                    break;
                default:
                    MessageBox.Show("Default!.");
                    Application.Current.Shutdown();
                    break;
            }
        }
        else
        {
            // If no arguments were passed in, show the screensaver
            ShowScreensaver();
        }
    }

    /// <summary>
    /// Shows screen saver by creating one instance of Window1 for each monitor.
    /// 
    /// Note: uses WinForms's Screen class to get monitor info.
    /// </summary>
    void ShowScreensaver()
    {
        //creates window on primary screen
        var primaryWindow = new MainWindow();

        //creates window on other screens
        foreach (var screen in System.Windows.Forms.Screen.AllScreens)
        {
            if (screen == System.Windows.Forms.Screen.PrimaryScreen)
                continue;

            var window = new MainWindow();
        }

        //show non-primary screen windows
        foreach (Window window in System.Windows.Application.Current.Windows)
        {
            if (window != primaryWindow)
                window.Show();
        }

        ///shows primary screen window last
        primaryWindow.Show();
    }
}
XAML很简单:

<Application x:Class="PlayOnScreen.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="OnStartup">
    <Application.Resources>

    </Application.Resources>
</Application>

屏幕保护程序呢

<Window xmlns:my="http://schemas.awesomium.com/winfx" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="PlayOnScreen.MainWindow"
        Title="mediaPlayer" Height="350" Width="525" 
        Loaded="OnLoaded" Cursor="None">
    <Grid x:Name="root">
        <Grid Panel.ZIndex="1000">
            <Image x:Name="overlay" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
        </Grid>
    </Grid>
</Window>


请帮助我解决此问题:(

预览处理程序在哪里?预览处理程序应该修改HWND处理程序,然后您必须在该窗口上呈现屏幕保护程序。它应该是“/p 9999”,handle=99999嗯,事实上,我不知道预览处理程序是什么,这意味着这可能就是答案:D你能解释一下吗?我知道你现在在说什么,但我不想在一个小窗口中显示预览,我希望它显示真实的东西。另外,主要的问题是如何让它工作。。。。
<Window xmlns:my="http://schemas.awesomium.com/winfx" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="PlayOnScreen.MainWindow"
        Title="mediaPlayer" Height="350" Width="525" 
        Loaded="OnLoaded" Cursor="None">
    <Grid x:Name="root">
        <Grid Panel.ZIndex="1000">
            <Image x:Name="overlay" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
        </Grid>
    </Grid>
</Window>