zoukankan      html  css  js  c++  java
  • Windows Phone Canvas

    效果

    image

    XAML

    01:  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    02:              <Canvas Name="canvas1" HorizontalAlignment="Center" 
    03:                  VerticalAlignment="Top" Width="400" Height="400">
    04:                  <Ellipse Name="greenBall" Fill="#00FF00" Canvas.Left="150" Canvas.Top="145" 
    05:                          Height="100" Stroke="Black" StrokeThickness="1" Width="100" />
    06:                  <Ellipse Name="redBall"  Fill="Red" Canvas.Left="26" Canvas.Top="177" 
    07:                          Height="150" Stroke="Black" StrokeThickness="1" Width="150" />
    08:              </Canvas>
    09:  
    10:              <Button Content="^" Height="72" HorizontalAlignment="Left" Margin="191,442,0,0" Name="btnUp" VerticalAlignment="Top" Width="80" Click="btnUp_Click" />
    11:              <Button Content="&lt;" Height="72" HorizontalAlignment="Left" Margin="120,504,0,0" Name="btnLeft" VerticalAlignment="Top" Width="80" Click="btnLeft_Click" />
    12:              <Button Content="&gt;" Height="72" HorizontalAlignment="Left" Margin="266,504,0,0" Name="btnRight" VerticalAlignment="Top" Width="80" Click="btnRight_Click" />
    13:              <Button Content="+" Height="72" HorizontalAlignment="Left" Margin="191,504,0,0" Name="btnDown" VerticalAlignment="Top" Width="80" Click="btnDown_Click" />
    14:              <Button Content="Z+" Height="72" HorizontalAlignment="Left" Margin="371,442,0,0" Name="btnUpZ" VerticalAlignment="Top" Width="80" IsEnabled="True" Click="btnUpZ_Click" />
    15:              <Button Content="Z-" Height="72" HorizontalAlignment="Left" IsEnabled="True" Margin="371,504,0,0" Name="btnDownZ" VerticalAlignment="Top" Width="80" Click="btnDownZ_Click" />
    16:          </Grid>
    17:  

    CS

    01:  //移动greenBall的位置
    02:          private void btnLeft_Click(object sender, RoutedEventArgs e)
    03:          {
    04:              Canvas.SetLeft(greenBall, Canvas.GetLeft(greenBall) - 10);
    05:          }
    06:          private void btnRight_Click(object sender, RoutedEventArgs e)
    07:          {
    08:              Canvas.SetLeft(greenBall, Canvas.GetLeft(greenBall) + 10);
    09:  
    10:          }
    11:          private void btnUp_Click(object sender, RoutedEventArgs e)
    12:          {
    13:              Canvas.SetTop(greenBall, Canvas.GetTop(greenBall) - 10);
    14:          }
    15:          private void btnDown_Click(object sender, RoutedEventArgs e)
    16:          {
    17:              Canvas.SetTop(greenBall, Canvas.GetTop(greenBall) + 10);
    18:          }
    19:  
    20:          //改变greenBall的层次
    21:          private void btnUpZ_Click(object sender, RoutedEventArgs e)
    22:          {
    23:              Canvas.SetZIndex(greenBall, 1);
    24:          }
    25:          private void btnDownZ_Click(object sender, RoutedEventArgs e)
    26:          {
    27:              Canvas.SetZIndex(greenBall, 0);
    28:          }
  • 相关阅读:
    React Native for Android应用名及图标修改
    如何不使用Navigator空间实现跳转页面?
    ReactNative WebView组件详解
    react-native react-navigation使用
    微信小程序——选择某个区间的数字
    Git分支操作——查看、新建、删除、提交、合并
    Github + Hexo 搭建个人博客
    微信小程序——动态设置swiper的高度
    微信小程序——购物车结算
    解决stackoverflow打开慢的问题
  • 原文地址:https://www.cnblogs.com/finehappy/p/2060758.html
Copyright © 2011-2022 走看看