다음을 통해 공유


Floating Teapot

以前書いた、透明ウィンドウとViewport3Dを組み合わせると、面白いデスクトップ効果が得られると思い付き、デスクトップに浮かぶティーポット作ってみました。.NET Framework 3.0 のWindows Applicationテンプレートでプロジェクトを作って、Windows1.xaml と  Windows1.xaml.csを編集します。

XAML部分は透明なウィンドウになるように先のteapot.xamlの最初の部分を次のように修正しました(もちろん最後のタグも)。

<Window x:Class="Teapot.Window1"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    Title="Teapot" Height="500" Width="500" AllowsTransparency="True" WindowStyle="None" Background="Transparent"
    >

これだけだと、閉じることができないし、移動もできないので、C#部分は次のように、終了と移動のコールバックをオーバーライドしました。

protected override void OnKeyDown(KeyEventArgs e)
{
     base.OnKeyDown(e);
     if (e.Key == Key.Escape) this.Close();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
     base.OnMouseLeftButtonDown(e);
     this.DragMove();
}

DragMoveなんていうメソッドがあるのにちょっと驚きです。これでEscキーで終了し、マウスの左ドラッグでティーポットが移動します。

10年ほど前に、Chrome Effectというデスクトップに3Dユーザーインターフェイスを導入しようというプロジェクトがDirectXにあったのですが、彼らはこういうユーザーインターフェイスを作りたかったのかなと思い出しました。彼らは時代を早く生きすぎたのかな...

Comments

  • Anonymous
    September 29, 2006
    Blog 2006-09-30  &amp;dagger;     2006-09-30   GoogleReader??????????????   MDX2??X-DAY      &amp;uarr;GoogleReader??????????????  &amp;dagger; ????????????????Blog????????????????????????????????????????????????Blog????????????????????????????????????????????????..

  • Anonymous
    November 29, 2007
    Visual Studio 2008 のリリースと同時に .NET Framework 3.5 もリリースされました。これに伴い Windows Presentation Foundation にもいくつかの新機能が追加されました。その新機能を紹介していきます。

  • Anonymous
    November 29, 2007
    Visual Studio 2008 のリリースと同時に .NET Framework 3.5 もリリースされました。これに伴い Windows Presentation Foundation にもいくつかの新機能が追加されました