我可以使用WPF摇动用户桌面吗?

Sco*_*Muc 5 wpf shake

我正在编写一个供个人使用的应用程序,它将跟踪我到达鼠标的频率,并将反击我已经没用鼠标的时间.当我使用鼠标时,我希望它可以将我的桌面工作区摇动一秒作为负强化动作.

该应用程序将被称为WristSlap,一旦我准备好0.1版本,它将在github上.

Jos*_*osh 4

丹尼正在研究透明窗户的想法。但它不一定是透明的。不过,您必须接受一些某些限制。

您可能想要抓取桌面的屏幕截图并将其应用到全屏 WPF 窗口。(查看我的博客,了解 WPF 窗口的方便 FullScreenBehavior)。然后,您只需将一些引发癫痫的动画应用到根元素上的平移布局转换即可。这会产生震动的效果。最后,窗户可能会关闭。

由于在动画过程中,所有内容的坐标都会遍布各处,因此您可能不想尝试将移动桌面上的鼠标点击转换为底层控件。如果动画足够短,那也没关系,因为你没有时间在它摇晃时尝试单击任何东西。

为了获得更真实的效果,您可以考虑使用 DWM(桌面窗口管理器)来投影桌面的“实时”视图,但这可能不值得,特别是如果您的动画很短。

我几乎想自己尝试一下以获取乐趣。

我现在使用静态图像想出了这个。没关系,但还可以改进。

<Image Source="Slide1.png" Stretch="UniformToFill">

<Image.Effect>
  <BlurEffect Radius="5" />
</Image.Effect>

<Image.RenderTransform>
  <TranslateTransform Y="0" X="0"/>
</Image.RenderTransform>

<Image.Triggers>
  <EventTrigger RoutedEvent="FrameworkElement.Loaded">
    <BeginStoryboard>
      <Storyboard RepeatBehavior="00:00:01" SpeedRatio="15">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="-10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="-10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="-10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="10"/>
          <SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </BeginStoryboard>
  </EventTrigger>
</Image.Triggers>

</Image>
Run Code Online (Sandbox Code Playgroud)