WPF刮刮乐
WPF刮刮乐
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <Window x:Class= "WpfApp2.MainWindow" xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d= "http://schemas.microsoft.com/expression/blend/2008" xmlns:local= "clr-namespace:WpfApp2" xmlns:mc= "http://schemas.openxmlformats.org/markup-compatibility/2006" Title= "MainWindow" Width= "329" Height= "450" MouseDown= "UserControl_MouseDown" MouseMove= "UserControl_MouseMove" MouseUp= "UserControl_MouseUp" mc:Ignorable= "d" > <Grid> <Grid.Background> <ImageBrush ImageSource= "/220810025-677037712005f5749b8c6481aa1b6c9a507047e97479d68af717064904b1db2d (1).png" Stretch= "Uniform" /> </Grid.Background> <Grid x:Name= "gridShadow" > <Grid.Background> <ImageBrush ImageSource= "/325e99d639690e7e8a30d908d6c8b1cd399f0ac611a49e30a848ccf2eaae4ccf.png" /> </Grid.Background> <TextBlock HorizontalAlignment= "Center" VerticalAlignment= "Center" FontSize= "30" Foreground= "White" > 刮奖区 </TextBlock> </Grid> </Grid> </Window> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | using System; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApp2 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { PathGeometry gridGeometry = new PathGeometry(); private bool isDown = false ; double originArea; bool hasShowResult = false ; public MainWindow() { InitializeComponent(); RectangleGeometry rg = new RectangleGeometry(); rg.Rect = new Rect(0, 0, this .Width, this .Height); gridGeometry = Geometry.Combine(gridGeometry, rg, GeometryCombineMode.Union, null ); gridShadow.Clip = gridGeometry; originArea = gridGeometry.GetArea(); } private void UserControl_MouseMove( object sender, MouseEventArgs e) { if (isDown) { EllipseGeometry rg = new EllipseGeometry(); rg.Center = e.GetPosition(gridShadow); rg.RadiusX = 20; rg.RadiusY = 20; //排除几何图形 gridGeometry = Geometry.Combine(gridGeometry, rg, GeometryCombineMode.Exclude, null ); gridShadow.Clip = gridGeometry; var currentArea = gridGeometry.GetArea(); if ((currentArea * 100 / originArea) < 50 && !hasShowResult) { hasShowResult = true ; MessageBox.Show( "恭喜中奖1个亿!" ); } } } private void UserControl_MouseDown( object sender, MouseButtonEventArgs e) { isDown = true ; } private void UserControl_MouseUp( object sender, MouseButtonEventArgs e) { isDown = false ; } } } |
fffffffffffffffff
test red font.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
2020-01-09 WPF 资源定义空字符串或者空格问题
2020-01-09 WPF test animation robot(simulate blink,mouse talk)