Lesson9 some interesting things in C#
1、关键帧动画
1)xml 界面
<Page
x:Class="Test.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Test"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Page.Resources>
<Storyboard x:Name="Bounce">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ball" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value=""/>
<SplineDoubleKeyFrame KeyTime="00:00:04" Value=""/>
<SplineDoubleKeyFrame KeyTime="00:00:06" Value=""/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ball" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value=""/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="-206">
<SplineDoubleKeyFrame.KeySpline>
<KeySpline ControlPoint1="0,1" ControlPoint2="1,1"/>
</SplineDoubleKeyFrame.KeySpline>
</SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:04" Value="">
<SplineDoubleKeyFrame.KeySpline>
<KeySpline ControlPoint1="1,0" ControlPoint2="1,1"/>
</SplineDoubleKeyFrame.KeySpline>
</SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:05" Value="-20">
<SplineDoubleKeyFrame.KeySpline>
<KeySpline ControlPoint1="0,1" ControlPoint2="1,1"/>
</SplineDoubleKeyFrame.KeySpline>
</SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:06" Value="">
<SplineDoubleKeyFrame.KeySpline>
<KeySpline ControlPoint1="1,0" ControlPoint2="1,1"/>
</SplineDoubleKeyFrame.KeySpline>
</SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Grid Background="#FFF0F1FF">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions> <StackPanel x:Name="TitlePanel" Grid.Row="" Margin="12,35,0,28">
<TextBlock Foreground="CornflowerBlue" Text="Naughty Egg" FontSize="" HorizontalAlignment="Center"/>
</StackPanel>
<!--
<Grid Background="AliceBlue" x:Name="ContentPanel" Grid.Row="" Margin="12,0,12,0">
<Path Margin ="50,-200,0,0" Height="" Width="" Stretch="Uniform"
HorizontalAlignment="Left" >
<Path.Fill >
<ImageBrush Stretch="UniformToFill" ImageSource="Assets/Pic1.png" />
</Path.Fill>
<Path.Data >
<GeometryGroup FillRule="EvenOdd" >
<EllipseGeometry Center="50,50" RadiusX="" RadiusY=""
x:Name="ball">
</EllipseGeometry>
</GeometryGroup>
</Path.Data>
</Path>
</Grid>
-->
<Grid x:Name="ContentPanel" Grid.Row="" Margin="12,0,12,0">
<Path Margin ="60,-250,0,0" Height="" Width="" Stretch="Uniform"
HorizontalAlignment="Left">
<Path.Fill >
<ImageBrush Stretch="UniformToFill" ImageSource="Assets/Pic1.png" />
</Path.Fill>
<Path.Data>
<GeometryGroup FillRule="EvenOdd" >
<EllipseGeometry RadiusX="" RadiusY=""
Center="100,100">
</EllipseGeometry>
</GeometryGroup>
</Path.Data>
</Path>
<Ellipse Height="" HorizontalAlignment="Left" Margin="5,0,0,151" VerticalAlignment="Bottom" Width="" Fill="#FFF40B0B" Stroke="#FF000000" x:Name="ball" RenderTransformOrigin="0.5,0.5" Opacity="0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<TranslateTransform/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<StackPanel Margin="0,300,0,100" >
<ProgressRing Background="#FFF0F1FF" x:Name="prgRing" Width="" Height="" Foreground="LightSeaGreen"
IsActive ="True" /> </StackPanel> </Grid> </Grid> </Page>
2) .cs 中控制播放:
public MainPage()
{
this.InitializeComponent();
//开始运行Storyboard
Bounce.Begin();
Bounce.Completed += ToNewPage; timer.Tick += dispatcherTimer_Tick;
timer.Interval = TimeSpan.FromSeconds(1.1); //设置刷新的间隔时间
timer.Start();
}
void dispatcherTimer_Tick(object sender, object e)
{
//function to execute
count++;
if (count == )
{
this.prgRing.IsActive = false;
} }
private void ToNewPage(object sender, object e)
{
Frame rootFrame = this.Parent as Frame;
if (rootFrame == null)
{
return;
} rootFrame.Navigate(typeof(Choice));
}
3)效果:

2、C#中的触控
xml:
<Grid x:Name="gamegrid" RenderTransformOrigin="0.335,0.445" Margin="0,0,0,49"
Background="White" Opacity="0.9">
<Canvas Name="canvas" Margin="5,4,5,3" >
<Ellipse Name="circle"
Width=""
Height=""
Canvas.Left=""
ManipulationDelta="OnManipulationDelta" ManipulationStarting="OnManipulationStarting"
ManipulationCompleted="OnManipulationCompleted" PointerPressed="finger_PointerPressed"
PointerMoved="finger_PointerMoved" PointerReleased="finger_PointerReleased"
Canvas.Top="" RenderTransformOrigin="3.56,3.875">
<Ellipse.DataContext>
<Button Content=" " ></Button>
<!--<Image Name="img1" Source="Assets/Pic2.png" Margin="" Width="" Height="" />-->
</Ellipse.DataContext>
</Ellipse>
<TextBlock Foreground="CornflowerBlue" Canvas.Left="" TextWrapping="Wrap" Text="Grades" Canvas.Top="" FontSize="" Height="" Width=""
/>
<TextBlock Height="" Canvas.Left="" TextWrapping="Wrap"
Name="test" Foreground="CornflowerBlue"
Text="{Binding Path=HP}" Canvas.Top="" Width="" FontSize="" FontFamily="Buxton Sketch"
/>
<TextBlock HorizontalAlignment="Center" Name="lev" Foreground="CornflowerBlue" FontSize="" Canvas.Left="" TextWrapping="Wrap" Text="level1" Canvas.Top="" Height="" Width=""/>
</Canvas>
</Grid>
</Grid>
</Page>
.cs控制:
//控制触摸移动的开始
private void OnManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
{
mapMode = e.Mode;
}
//移动中触发
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
if (ManipulationModes.TranslateX == (mapMode & ManipulationModes.TranslateX))
{
cpTransform.TranslateX += e.Delta.Translation.X;
x = cpTransform.TranslateX;
}
if (ManipulationModes.TranslateY == (mapMode & ManipulationModes.TranslateY))
{
cpTransform.TranslateY += e.Delta.Translation.Y;
y = (double)cpTransform.TranslateY;
} }
// 移动停止时触发
private void OnManipulationCompleted(object sender,ManipulationCompletedRoutedEventArgs e)
{ } // 按下时触发
Boolean pushDown = false;
private void finger_PointerPressed(object sender, PointerRoutedEventArgs e)
{
pushDown = true;
// rect1.Fill = new SolidColorBrush(Colors.Black); }
// 指针或手松开时触发
private void finger_PointerReleased(object sender, PointerRoutedEventArgs e)
{
pushDown = false;
//rect1.Fill = new SolidColorBrush(Colors.Orange);
if (p.HP <= && p.HP >= )
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
XmlNodeList elements = toastXml.GetElementsByTagName("text");
elements[].AppendChild(toastXml.CreateTextNode("恭喜你成为人生赢家!"));
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
}
// 按下手或指针移动过程中触发
private void finger_PointerMoved(object sender, PointerRoutedEventArgs e)
{
Point p = e.GetCurrentPoint(circle).Position;
Point p2 = e.GetCurrentPoint(rect1).Position;
mousepoint = e.GetCurrentPoint(circle).Position;
if (pushDown) {
if (tag == )
{
rect1.Fill = new SolidColorBrush(Colors.Red); //矩形的填充颜色为红色!
changecolor(p2);
}
else
{
changecolor2(p2);
rect1.Fill = new SolidColorBrush(Colors.Green); //矩形的填充颜色为绿色!
}
}
}
效果:

3、画刷
前端xml界面:
<Grid x:Name="ContentPanel" Grid.Row="" Margin="12,0,12,0">
<Path Margin ="60,-250,0,0" Height="" Width="" Stretch="Uniform"
HorizontalAlignment="Left">
<Path.Fill >
<ImageBrush Stretch="UniformToFill" ImageSource="Assets/Pic1.png" />
</Path.Fill>
<Path.Data>
<GeometryGroup FillRule="EvenOdd" >
<EllipseGeometry RadiusX="" RadiusY=""
Center="100,100">
</EllipseGeometry>
</GeometryGroup>
</Path.Data>
</Path>
<Ellipse Height="" HorizontalAlignment="Left" Margin="5,0,0,151" VerticalAlignment="Bottom" Width="" Fill="#FFF40B0B" Stroke="#FF000000" x:Name="ball" RenderTransformOrigin="0.5,0.5" Opacity="0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<TranslateTransform/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<StackPanel Margin="0,300,0,100" >
<ProgressRing Background="#FFF0F1FF" x:Name="prgRing" Width="" Height="" Foreground="LightSeaGreen"
IsActive ="True" /> </StackPanel> </Grid>
效果:
见上图中透出的椭圆形图片效果
Lesson9 some interesting things in C#的更多相关文章
- An interesting experiment on China’s censorship
This paper presented a very interesting topic. Censorship in China has always drawn people's attenti ...
- 2015年辽宁省赛Interesting Tree
题目描述 Recently, Miss Huang want to receive a Tree as her birthday gift! (What a interesting person!) ...
- HDU5785 Interesting(Manacher + 延迟标记)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5785 Description Alice get a string S. She think ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- 多校赛3- Solve this interesting problem 分类: 比赛 2015-07-29 21:01 8人阅读 评论(0) 收藏
H - Solve this interesting problem Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I ...
- hdu Interesting Fibonacci
Interesting Fibonacci Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组
题目链接:CF #365 (Div. 2) D - Mishka and Interesting sum 题意:给出n个数和m个询问,(1 ≤ n, m ≤ 1 000 000) ,问在每个区间里所有 ...
- CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组(转)
转载自:http://www.cnblogs.com/icode-girl/p/5744409.html 题目链接:CF #365 (Div. 2) D - Mishka and Interestin ...
- Calculations are rather interesting
Calculations are rather interesting, especially when some thoughts are involved therein.
随机推荐
- dede后台添加优酷等视频iframe链接时被替换成了图片
添加文章时 添加优酷视频 :<iframe height=498 width=510 src='http://player.youku.com/embed/XNDAzNTAzODE4OA==' ...
- 【PHP】Maximum execution time of 30 seconds exceeded解决办法
Maximum execution time of 30 seconds exceeded,今天把这个错误的解决方案总结一下: 简单总结一下解决办法: 报错一:内存超限,具体报错语句忘了,简单说一下解 ...
- 记 页面使用overflow-scroll在iOS上滑动卡顿的问题
页面使用overflow-scroll在iOS上滑动卡顿的问题 因在做一个滑动的list列表,为某个div使用了overflow: scroll属性. 结果在手机上测试时,ios手机有明显的滑动卡顿问 ...
- IAR 编译时找不到头文件的解决方法
Fatal Error[Pe1696]: cannot open source file "x.h" 那是因为头文件路径没有找对 到报错的.c源文件 选中右键 选择options ...
- Git-历史穿梭
图形工具:gitk gitk是最早实现的一个图形化的Git版本库浏览器软件,基于tcl/tk实现,因此gitk非常简洁,本身就是一个1万多行的tcl脚本写成的.gitk的代码已经和Git的代码放在同一 ...
- nodejs 操作mongodb, 增删改查
很久没有学node了,之前书看了一半,今天继续学发现版本问题很坑爹,按书例子执行一堆错误.想学nodejs操作db,百度半天,一堆sb写神马鸟玩儿?简简单单写一大堆还运行不了的.需要代码也是看别人写的 ...
- 《Cracking the Coding Interview》——第7章:数学和概率论——题目3
2014-03-20 02:05 题目:给定笛卡尔二维平面上两条直线,判断它们是否相交. 解法:相交.重合.平行. 代码: // 7.3 Given two lines on the Cartesia ...
- Python 绘制棋盘
import turtle pen = turtle.Pen() pen.speed(10) width = 30 # 格子宽度 count = 18 # 横向纵向格子数 o = width * co ...
- 社区版pycharm安装Django框架
1.cmd下执行:pip3 install django 2.cmd下执行:django-admin startproject Demo (Demo为项目名称,可以更改你取的项目名称) 3.cmd下执 ...
- flask_入门教程之一
一.教程涉及开发语言.脚本.框架.数据库等内容 Python + Flask + requests 通过命令安装:pip install flask 二.创建第一个flask脚本 一个最小的 Flas ...