Floating Teapot

Published 22 September 06 02:35 PM | hiroyuk 

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

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

<Window x:Class="Teapot.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://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

# PukiWiki/TrackBack 0.2 said on September 29, 2006 8:38 PM:
Blog 2006-09-30  &amp;dagger;     2006-09-30   GoogleReader??????????????   MDX2??X-DAY      &amp;uarr;GoogleReader??????????????  &amp;dagger; ????????????????Blog????????????????????????????????????????????????Blog????????????????????????????????????????????????..
# 川西 裕幸のブログ said on November 29, 2007 7:03 PM:

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

# Noticias externas said on November 29, 2007 7:48 PM:

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

Anonymous comments are disabled

About hiroyuk

マイクロソフト㈱エバンジェリスト。北海道大学理学部物理学科卒。リアルタイム3Dグラフィックスを専門とし、グラフィックスやシェーダに関する技術文章を執筆・講演。 DirectX SDK日本語ドキュメントの開発に携わるとともに、Windows Presentation Foundation プログラミング(オーム社)、Game Programming Gemsシリーズ、リアルタイム レンダリング第2版(ボーンデジタル)、Texturing & Modeling, A Procedural Approach などを翻訳・監修、XAMLプログラミング(ソフトバンク クリエイティブ)を執筆。趣味は薪割り。

Search

This Blog

DirectX 情報

Silverlight 情報

Windows 情報

WPF 情報

並列コンピューティング情報

著書

Syndication

Page view tracker