所有的C++程序員們,讓我們來(lái)體驗(yàn)Windows Vista 開(kāi)發(fā)平臺(tái)吧!
Win32??到 WinFX? 的進(jìn)步開(kāi)始于 Windows Vista 時(shí)代對(duì) .NET Framework 的改進(jìn)。這兩種編程模型使每個(gè)開(kāi)發(fā)人員都關(guān)注著 Windows Vista 的改進(jìn),包括改進(jìn)的顯示和通信子系統(tǒng)、改進(jìn)的連通性以及 Windows 在核心安全性、可管理性和可靠性方面的重要改進(jìn)。
前幾天在msdn中文網(wǎng)站下了幾部wencast講座,主要關(guān)注了下WinFX,個(gè)人覺(jué)得學(xué)到不少新思想,地址:
http://www.microsoft.com/china/msdn/events/webcasts/shared/Webcast/MSDNWebCast.aspxWinFX包括3個(gè)重要思想:
WPF(Windows Presentation Foundation):界面表現(xiàn)基礎(chǔ)。在我的
我心中最美的軟件框架 一篇中,曾經(jīng)提到軟件設(shè)計(jì)框架,當(dāng)時(shí)有人提到腳本技術(shù)做界面。以前VC的開(kāi)發(fā)思維中,做界面一味依靠界面庫(kù)(BCG或者XTREME等)或GDI(自己繪制窗口),而沒(méi)有考慮過(guò)多種開(kāi)發(fā)語(yǔ)言的結(jié)合,利用不同語(yǔ)言揚(yáng)長(zhǎng)避短。在去年年末的一個(gè)界面設(shè)計(jì)中,我終于苦惱了,開(kāi)始想結(jié)合HTML和WebBrowser控件實(shí)現(xiàn)漂亮界面,也獲得了一些成果,但是沒(méi)有運(yùn)用到開(kāi)發(fā)中去,
(運(yùn)用HTML例子) 。微軟的這項(xiàng)技術(shù)是利用DirectX技術(shù)來(lái)渲染界面,達(dá)到各種各樣的異形界面效果。
WCF(Windows Communication Foundation):不同平臺(tái)上運(yùn)行的應(yīng)用程序之間支持基本的互操作性且確保端對(duì)端安全和可靠通信的前提下完成這種互操作。本人對(duì)這個(gè)了解不多,這里有一篇講WCF的:
http://www.cnblogs.com/wayfarer/archive/2006/04/05/367474.html。
WFF(Windows FlowWork Foundation):底層實(shí)現(xiàn)工作流基礎(chǔ)。剛用C語(yǔ)言編程的時(shí)候,老師讓我們先畫流程圖。WFF技術(shù)正是基于這樣一種思想,把流程圖作為前端,代碼作為后端。在前端繪制流出(if-else, while, for等),通過(guò)點(diǎn)擊節(jié)點(diǎn)實(shí)現(xiàn)后端代碼,可以說(shuō)工作流繪制出來(lái),程序框架也就搭建好了,剩下來(lái)就是在框架里面添代碼。
本人對(duì)界面比較感興趣,所以主要想研究WPF。
下面開(kāi)始開(kāi)發(fā)環(huán)境的配置:
1、WinFX Runtime不支持WIN2K以及以下OS版本,XP或者2K3支持。為了確保不出問(wèn)題,我選擇2K3,在安裝時(shí)候不小心搞壞了以前的2K OS,害的我整整花了一天時(shí)間。
2、下載WinFX Runtime,這個(gè)大約43M,在微軟官方網(wǎng)站下載:
http://www.microsoft.com/downloads/details.aspx?FamilyId=F51C4D96-9AEA-474F-86D3-172BFA3B828B&displaylang=en注意不要下載上面那個(gè)網(wǎng)絡(luò)安裝,頁(yè)面拉下去下載這里:
for x86 or
for x64 which are both .EXE files(鏈接可能失效,因?yàn)楫吘故荁eta版本,時(shí)常更新)。
這個(gè)是安裝os后緊接著安裝的,會(huì)提示安裝.NET 2.0 FrameWork。我得Win2k3里面就有,沒(méi)有的可以裝VS2005里面的,但是千萬(wàn)不要安裝VS2005。
3、下載WinFX SDK,這個(gè)大約1.1G,在微軟官方網(wǎng)站下載:
http://www.microsoft.com/downloads/details.aspx?FamilyId=9BE1FC7F-0542-47F1-88DD-61E3EF88C402&displaylang=en下載完后,安裝。
4、安裝VS2005。
這樣基本把環(huán)境搭建好了。WinFX SDK安裝會(huì)在Program Files目錄下生成一個(gè)Microsoft SDKs目錄,進(jìn)去在\Windows\v1.0\samples下面找到AllWinFXsamples.zip,打開(kāi)如下圖:

進(jìn)入WindowsPresentationFoundation,如下圖:

里面例子真不少,隨便找一個(gè)例子,我解壓Gallery\SamplesGallery。用VS2005打開(kāi),編譯,應(yīng)該很快。然后在bin目錄下找到exe執(zhí)行,看看下面的界面吧!(VS2005目前不支持解決方案直接拖放功能,每次打開(kāi)一個(gè)關(guān)閉,非常麻煩)

今天編譯一個(gè)\WindowsPresentationFoundation\GraphicsMM_Brushes\UsingImageBrush,覺(jué)得不錯(cuò),把界面貼上來(lái):







WPF基于XAML語(yǔ)言,參看另一篇Blog:
WinFX編程模型下面是一個(gè)XAML文件,里面描述了界面。
<!--?This?example?shows?how?to?use?an?ImageBrush?to?fill?text.?-->
<Page?xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
??xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
??x:Class="Microsoft.Samples.Graphics.UsingImageBrush.TextFillsExample">

??<Grid?Margin="20">

????<Grid.ColumnDefinitions>
??????<ColumnDefinition?Width="Auto"/>
??????<ColumnDefinition?Width="Auto"/>
??????<ColumnDefinition?Width="Auto"?/>
????</Grid.ColumnDefinitions>
????
????<Grid.RowDefinitions>
??????<RowDefinition?Height="Auto"?/>
??????<RowDefinition?Height="Auto"?/>
??????<RowDefinition?Height="Auto"?/>
??????<RowDefinition?Height="Auto"?/>
??????<RowDefinition?Height="Auto"?/>
????</Grid.RowDefinitions>

????<TextBlock?Grid.Row="2"?Grid.Column="1"
??????FontSize="70pt"?FontWeight="Bold"??FontFamily="Verdana"
??????Margin="10">
??????<TextBlock.Foreground>
????????<ImageBrush
??????????ImageSource="sampleImages\purpleblock.jpg"></ImageBrush>
??????</TextBlock.Foreground>
??????Text
????</TextBlock>
????<TextBlock?Grid.Row="2"?Grid.Column="2"
??????FontSize="70pt"?FontWeight="Bold"??FontFamily="Verdana"
??????Margin="10">
??????<TextBlock.Foreground>
????????<ImageBrush
??????????Viewport="0,0,25,25"?ViewportUnits="Absolute"
??????????TileMode="Tile"
??????????ImageSource="sampleImages\purpleblock.jpg"></ImageBrush>
??????</TextBlock.Foreground>
??????Text
????</TextBlock>


????<TextBlock?Grid.Row="3"?Grid.Column="1"
??????FontSize="70pt"?FontWeight="Bold"??FontFamily="Verdana"
??????Margin="10">
??????<TextBlock.Foreground>
????????<ImageBrush
??????????ImageSource="sampleImages\square.jpg"></ImageBrush>
??????</TextBlock.Foreground>
??????Text
????</TextBlock>
????<TextBlock?Grid.Row="3"?Grid.Column="2"
??????FontSize="70pt"?FontWeight="Bold"??FontFamily="Verdana"
??????Margin="10">
??????<TextBlock.Foreground>
????????<ImageBrush
??????????Viewport="0,0,25,25"?ViewportUnits="Absolute"
??????????TileMode="Tile"
??????????ImageSource="sampleImages\square.jpg"></ImageBrush>
??????</TextBlock.Foreground>
??????Text
????</TextBlock>


????<TextBlock?Grid.Row="4"?Grid.Column="1"
??????FontSize="70pt"?FontWeight="Bold"??FontFamily="Verdana"
??????Margin="10">
??????<TextBlock.Foreground>
????????<ImageBrush
??????????ImageSource="sampleImages\pinkcherries.jpg"></ImageBrush>
??????</TextBlock.Foreground>
??????Text
????</TextBlock>

????<TextBlock?Grid.Row="4"?Grid.Column="2"
??????FontSize="70pt"?FontWeight="Bold"??FontFamily="Verdana"
??????Margin="10">
??????<TextBlock.Foreground>
????????<ImageBrush
??????????Viewport="0,0,25,25"
??????????ViewportUnits="Absolute"
??????????TileMode="Tile"
??????????ImageSource="sampleImages\pinkcherries.jpg"></ImageBrush>
??????</TextBlock.Foreground>
??????Text
????</TextBlock>

????<!--?Describes?the?sample.?-->
????<Rectangle?Grid.Row="0"?Grid.Column="0"?Grid.ColumnSpan="3"
??????Stroke="LimeGreen"?StrokeThickness="6">
??????<Rectangle.Fill>
????????<LinearGradientBrush?StartPoint="0,0.5"?EndPoint="1,0.5">
??????????<LinearGradientBrush.GradientStops>
????????????<GradientStop?Offset="0.0"?Color="LimeGreen"?/>
????????????<GradientStop?Offset="1.0"?Color="Yellow"?/>
??????????</LinearGradientBrush.GradientStops>
????????</LinearGradientBrush>
??????</Rectangle.Fill>
????</Rectangle>
????<TextBlock?Grid.Row="0"?Grid.Column="0"?Grid.ColumnSpan="3"??
??????Margin="10"?MaxWidth="400"??HorizontalAlignment="Left">
??????An?ImageBrush?may?be?used?to?paint?text.?The?following?examples?show
??????an?image?used?to?fill?text?with?and?without?tiling.
????</TextBlock>
????<TextBlock?Grid.Row="1"?Grid.Column="0"?FontWeight="Bold"?Margin="10">The?Image</TextBlock>
????<TextBlock?Grid.Row="1"?Grid.Column="1"?FontWeight="Bold"?Margin="10">Applied?to?Text?Without?Tiling</TextBlock>
????<TextBlock?Grid.Row="1"?Grid.Column="2"?FontWeight="Bold"?Margin="10">Applied?to?Text?With?Tiling</TextBlock>

????<!--?Shows?what?the?images?look?like?on?their?own.?-->
????<Image?Grid.Row="2"?Grid.Column="0"?Source="sampleImages\purpleblock.jpg"?Height="100"?Width="100"
??????HorizontalAlignment="Left"?Margin="10"/>
????<Image?Grid.Row="3"?Grid.Column="0"?Source="sampleImages\square.jpg"?Height="100"?Width="100"?
??????HorizontalAlignment="Left"?Margin="10"?/>
????<Image?Grid.Row="4"?Grid.Column="0"?Source="sampleImages\pinkcherries.jpg"?Height="100"?Width="100"
??????HorizontalAlignment="Left"?Margin="10"?/>
??</Grid>
</Page>
posted on 2006-04-11 23:39
萬(wàn)連文 閱讀(1886)
評(píng)論(2) 編輯 收藏 引用 所屬分類:
.NET