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.
随机推荐
- js如何获得系统时间年月日时分秒
javascript 自带有个对象(构造函数),Date().下面是代码: 回答一: var now = new Date(); var nowTime = now.toLocaleString() ...
- laravel-多条件查询并指定key输出
$room = DB::table('room') ->where(function($query) use($contList){ foreach ($contList as $k=>$ ...
- 如果文件里是汉字的话,这地方seek括号里面只能是偶数
>>> f=open("E:/pythonLearn/140.txt") >>> f.seek(8) #如果文件里是汉字的话,这地方seek括号 ...
- linux基础命令3(man)
Type:显示指定的命令是那种类型. Linux下有两种模式的时间 date:用于系统时间管理.(软件操作的系统时 ...
- C语言字符篇(三)字符串比较函数
#include <string.h> int strcmp(const char *s1, const char *s2); 比较字符串s1和s2 int strncmp(const ...
- 笔记-python-多线程-深入-1
笔记-python-多线程-深入-1 1. 线程池 1.1. 线程池:控制同时存在的线程数量 threading没有线程池,只能自己控制线程数量. 基本有两种方式: 每间隔一段时间创建 ...
- Oozie是什么
Apache Oozie Workflow Scheduler for Hadoop Oozie is a workflow scheduler system to manage Apache Had ...
- 剑指Offer - 九度1384 - 二维数组中的查找
剑指Offer - 九度1384 - 二维数组中的查找2013-11-23 23:23 题目描述: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个 ...
- maven的一些使用配置!
1.国外库太慢,更换为国内镜像库在你的maven安装目录下找到conf目录下的setting.xml修改:<mirrors> <id>CN</id> <nam ...
- 《Android权威编程指南(The Big Nerd Ranch Guide)(第二版)》12.4挑战练习
本书第12章是讲解Dialog.12.4挑战练习是在CriminalIntent项目中,再增加一个TimePickerFragment的对话框fragment.通过在CrimeFragment用户界面 ...