資源簡介
演示分割旋轉、組件旋轉方式。
1、分割旋轉如需對組件窗體進行分割,可以將其轉換為圖像進行旋轉,完畢后再顯示組件窗體;
轉為圖像可修改如下代碼:可以自行更改換為BitmapSource
private void SaveControlImage(FrameworkElement control, string filename)
{
Rect rect = VisualTreeHelper.GetDescendantBounds(control);
DrawingVisual dv = new DrawingVisual();
using (DrawingContext ctx = dv.RenderOpen())
{
VisualBrush brush = new VisualBrush(control);
ctx.DrawRectangle(brush, null, new Rect(rect.Size));
}
int width = (int)control.ActualWidth;
int height = (int)control.ActualHeight;
RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
rtb.Render(dv);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
using (FileStream fs = new FileStream(filename,FileMode.Create, FileAccess.Write, FileShare.None))
{
encoder.Save(fs);
}
}
這里只演示圖像。
2、組件旋轉為整體旋轉,可當做窗體,加入其它組件。旋轉如果加入陰影(DropShadowEffect)動畫將不流暢出現抖動,這里通過圖像方式制作陰影(CustomShadow.cs),
未使用DropShadowEffect方式,動畫較為流暢。
3、設置幀率:見App.xaml、App.cs文件
private void Application_Startup(object sender, StartupEventArgs e)
{
Timeline.DesiredFrameRateProperty.OverrideMetadata(
typeof(Timeline),
new FrameworkPropertyMetadata { DefaultValue = null }
);
}
可將null設置為60、90、100等。
畫面流暢時看不出來,將null設置為5、10等較小值可見其作用。
1、分割旋轉如需對組件窗體進行分割,可以將其轉換為圖像進行旋轉,完畢后再顯示組件窗體;
轉為圖像可修改如下代碼:可以自行更改換為BitmapSource
private void SaveControlImage(FrameworkElement control, string filename)
{
Rect rect = VisualTreeHelper.GetDescendantBounds(control);
DrawingVisual dv = new DrawingVisual();
using (DrawingContext ctx = dv.RenderOpen())
{
VisualBrush brush = new VisualBrush(control);
ctx.DrawRectangle(brush, null, new Rect(rect.Size));
}
int width = (int)control.ActualWidth;
int height = (int)control.ActualHeight;
RenderTargetBitmap rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
rtb.Render(dv);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
using (FileStream fs = new FileStream(filename,FileMode.Create, FileAccess.Write, FileShare.None))
{
encoder.Save(fs);
}
}
這里只演示圖像。
2、組件旋轉為整體旋轉,可當做窗體,加入其它組件。旋轉如果加入陰影(DropShadowEffect)動畫將不流暢出現抖動,這里通過圖像方式制作陰影(CustomShadow.cs),
未使用DropShadowEffect方式,動畫較為流暢。
3、設置幀率:見App.xaml、App.cs文件
private void Application_Startup(object sender, StartupEventArgs e)
{
Timeline.DesiredFrameRateProperty.OverrideMetadata(
typeof(Timeline),
new FrameworkPropertyMetadata { DefaultValue = null }
);
}
可將null設置為60、90、100等。
畫面流暢時看不出來,將null設置為5、10等較小值可見其作用。
4、動畫按照對象原始大小顯示方法,代碼里查看
viewport3D = new Viewport3D();
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Configuration;
using?System.Data;
using?System.Linq;
using?System.Threading.Tasks;
using?System.Windows;
using?System.Windows.Media.Animation;
namespace?demo_E
{
????///?
????///?App.xaml?的交互邏輯
????///?
????public?partial?class?App?:?Application
????{
????????private?void?Application_Startup(object?sender?StartupEventArgs?e)
????????{
????????????Timeline.DesiredframeRateProperty.Overridemetadata(
????????????????typeof(Timeline)
????????????????new?frameworkPropertymetadata?{?DefaultValue?=?null?}
????????????????);
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????66048??2019-09-27?21:34??demo_G\.vs\demo_G\v16\.suo
?????文件??????????0??2019-09-27?19:50??demo_G\.vs\demo_G\v16\Server\sqlite3\db.lock
?????文件?????720896??2019-09-27?21:34??demo_G\.vs\demo_G\v16\Server\sqlite3\storage.ide
?????文件????????189??2019-09-27?19:50??demo_G\demo_G\App.config
?????文件????????425??2019-09-27?19:51??demo_G\demo_G\App.xaml
?????文件????????662??2019-09-27?19:51??demo_G\demo_G\App.xaml.cs
?????文件????1077248??2019-09-27?21:34??demo_G\demo_G\bin\Debug\demo_G.exe
?????文件????????189??2019-09-27?19:50??demo_G\demo_G\bin\Debug\demo_G.exe.config
?????文件??????71168??2019-09-27?21:34??demo_G\demo_G\bin\Debug\demo_G.pdb
?????文件???????5231??2019-09-27?19:54??demo_G\demo_G\demo_G.csproj
?????文件???????3421??2019-09-26?19:51??demo_G\demo_G\Effect\CustomShadow.cs
?????文件???????1368??2019-09-26?20:30??demo_G\demo_G\Effect\effectHelper.cs
?????文件?????????75??2019-09-27?21:34??demo_G\demo_G\Effect\Rotary\Container.cs
?????文件????????579??2019-09-22?09:37??demo_G\demo_G\Effect\Rotary\ContainerUtils.cs
?????文件????????377??2019-09-26?11:03??demo_G\demo_G\Effect\Rotary\PlaneRotary.xaml
?????文件???????7375??2019-09-26?20:53??demo_G\demo_G\Effect\Rotary\PlaneRotary.xaml.cs
?????文件???????1056??2019-09-24?20:29??demo_G\demo_G\Effect\Rotary\RotaryElement.cs
?????文件????????451??2019-09-24?20:25??demo_G\demo_G\Effect\Rotary\Rotate3DContainer.xaml
?????文件??????11554??2019-09-24?20:28??demo_G\demo_G\Effect\Rotary\Rotate3DContainer.xaml.cs
?????文件??????17145??2019-09-24?08:30??demo_G\demo_G\Images\shadow.png
?????文件?????406047??2019-09-27?18:40??demo_G\demo_G\Images\za.png
?????文件?????626012??2019-09-27?18:41??demo_G\demo_G\Images\zb.png
?????文件????????695??2019-09-27?19:56??demo_G\demo_G\MainWindow.xaml
?????文件???????3055??2019-09-27?20:21??demo_G\demo_G\MainWindow.xaml.cs
?????文件???????2559??2019-09-27?21:34??demo_G\demo_G\obj\Debug\App.g.cs
?????文件???????2559??2019-09-27?21:34??demo_G\demo_G\obj\Debug\App.g.i.cs
?????文件?????????42??2019-09-27?21:34??demo_G\demo_G\obj\Debug\demo_G.csproj.CoreCompileInputs.cache
?????文件???????1018??2019-09-27?21:34??demo_G\demo_G\obj\Debug\demo_G.csproj.FileListAbsolute.txt
?????文件????????954??2019-09-27?21:34??demo_G\demo_G\obj\Debug\demo_G.csproj.GenerateResource.cache
?????文件????1077248??2019-09-27?21:34??demo_G\demo_G\obj\Debug\demo_G.exe
............此處省略351個文件信息
評論
共有 條評論
相關資源
- 第二代Kinect WPF開發(fā)從入門到精通資料
- WPF21個優(yōu)秀項目及源碼
- SciChart控件破解方法見包內
- WPF開發(fā)框架
- C# EF6連接、操作Mysql教程和增刪改查
- wpf特效輪播圖
- WPF做的監(jiān)控程序
- wpf 圖片滑動效果
- Telerik_UI_for_WPF破解版
- Telerik_UI_for_WPF_2019_1_116_Dev.msi
- WPF編程寶典2012源碼和書(全)
- 深入淺出WPF劉鐵猛 重新整理書簽 帶源
- WPF程序設計指南完整PDF高清版
- Telerik UI for WPF 2018_1_116
- Opencvsharp
- 深入淺出WPF 重新整理目錄,帶源碼
- Pro WPF 4.5 in C# Pro WPF系列第四版 英文書
- WPF學習書籍pdf《葵花寶典_WPF自學手冊
- Telerik_UI_for_WPF_Documentation
- WPF編程寶典C#2012 第4版(包含源碼)
- WPF編程寶典 第四版
- c# WPF 動態(tài)曲線顯示
- WPF高級編程PDF
- C#VS2013與DirectX顯示旋轉的四棱錐
- WPF崩潰重啟
- C#/WPF下的通用自動更新模塊修正
- 基于WPF的USB設備瀏覽器
- WPF實現類似安卓,ISO的日期選擇器
- WPF MVVM模式下 TreeView 右鍵菜單
- wpf入門第五篇 WPF with ECharts 項目源碼