惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
小众软件
小众软件
I
InfoQ
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
月光博客
月光博客
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
V
Visual Studio Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - wgscd

Git 无法访问 GitHub(unable to access ‘https://github.com/.../.git‘)问题解决教程 RapidOcrNet文字识别OCR C#+Audio绘制麦克风波形 一共免费大模型API AI聊天对话界面的HTML代码。 纯JavaScript代码实现保存Canvas图片到电脑 WPF鼠标拖动改变图片透明度 Fiddler自定义规则保存图片和提示The system proxy was changed自动重连 缩放 div 浏览器语音识别-webkitSpeechRecognition HTML获取摄像头画面,拍照截图保存 JS摄像头手势识别-Handsfree.js HTML,JS 模拟聊天界面UI JS获取元素相对窗口的位置和大小 C# 判断是否安装了ffmpeg shadow-root中的元素定位方法 JS MutationObserver监听DOM元素改变 Webview2动态设置页面video的Blob进行播放 C# 文件分割和文件合并 JS利用浏览器进行语言识别 WPF设置默认语言地区CultureInfo VS2022推送代码 到github错误: CertGetCertificateChain trust error CERT_TRUST_IS_PARTIAL_CHAIN的解决办法 C#正则表达式匹配候选词 使用ffmpeg去除音频静音
WPF刮刮乐
wgscd · 2025-01-09 · via 博客园 - wgscd

WPF刮刮乐

<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>
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;
            }
        }
    }