基本信息
源码名称:C# 抽奖系统源码
源码大小:0.35M
文件格式:.rar
开发语言:C#
更新时间:2020-12-24
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 18 元×
微信扫码支付:18 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsForms { public partial class Chance : Form { public int 奖品1概率 = 25; public int 奖品2概率 = 100; public int 奖品3概率 = 100; public int 奖品4概率 = 100; public int 奖品5概率 = 100; public int 奖品6概率 = 100; public int 奖品7概率 = 100; public int 未中奖概率 = 100; public int G; public double G1; public double G2; public double G3; public double G4; public double G5; public double G6; public double G7; public double G8; Thread 更新线程 = null; SynchronizationContext 更新线程使者 = null; int 暂停 = 0; int 异常 = 0; public Chance() { InitializeComponent(); 更新线程使者 = SynchronizationContext.Current; textBox1.Text = 奖品1概率.ToString(); textBox2.Text = 奖品2概率.ToString(); textBox3.Text = 奖品3概率.ToString(); textBox4.Text = 奖品4概率.ToString(); textBox5.Text = 奖品5概率.ToString(); textBox6.Text = 奖品6概率.ToString(); textBox7.Text = 奖品7概率.ToString(); textBox8.Text = 未中奖概率.ToString(); } private void Chance_Load(object sender, EventArgs e) { 概率计算(); 概率写入(); 更新Start(); } public void 更新Start() //执行更新线程---线程2 { 更新线程 = new Thread(更新线程Do); 更新线程.Start(); } public void 更新线程Do() { while (true) { bool T1 = double.TryParse(textBox1.Text, out double X1); bool T2 = double.TryParse(textBox2.Text, out double X2); bool T3 = double.TryParse(textBox3.Text, out double X3); bool T4 = double.TryParse(textBox4.Text, out double X4); bool T5 = double.TryParse(textBox5.Text, out double X5); bool T6 = double.TryParse(textBox6.Text, out double X6); bool T7 = double.TryParse(textBox7.Text, out double X7); bool T8 = double.TryParse(textBox8.Text, out double X8); if (T1 == true && T2 == true && T3 == true && T4 == true && T5 == true && T6 == true && T7 == true && T8 == true) { 暂停 = 0; 异常 = 0; } if (暂停 == 1) { continue; } Thread.Sleep(100); int 更新 = 0; 更新线程使者.Post(更新线程使者Do, 更新); } } public void 更新线程使者Do(object 更新) { G = 奖品1概率 奖品2概率 奖品3概率 奖品4概率 奖品5概率 奖品6概率 奖品7概率 未中奖概率; 强制转换(); 概率计算(); 概率写入(); } void 概率计算() { G1 = double.Parse(textBox1.Text) * 1.0 / G; G2 = double.Parse(textBox2.Text) * 1.0 / G; G3 = double.Parse(textBox3.Text) * 1.0 / G; G4 = double.Parse(textBox4.Text) * 1.0 / G; G5 = double.Parse(textBox5.Text) * 1.0 / G; G6 = double.Parse(textBox6.Text) * 1.0 / G; G7 = double.Parse(textBox7.Text) * 1.0 / G; G8 = double.Parse(textBox8.Text) * 1.0 / G; } public void 概率写入() { textBoxG1.Text = G1.ToString() "%"; textBoxG2.Text = G2.ToString() "%"; textBoxG3.Text = G3.ToString() "%"; textBoxG4.Text = G4.ToString() "%"; textBoxG5.Text = G5.ToString() "%"; textBoxG6.Text = G6.ToString() "%"; textBoxG7.Text = G7.ToString() "%"; textBoxG8.Text = G8.ToString() "%"; } void 强制转换() { bool T1 = double.TryParse(textBox1.Text, out double X1); bool T2 = double.TryParse(textBox2.Text, out double X2); bool T3 = double.TryParse(textBox3.Text, out double X3); bool T4 = double.TryParse(textBox4.Text, out double X4); bool T5 = double.TryParse(textBox5.Text, out double X5); bool T6 = double.TryParse(textBox6.Text, out double X6); bool T7 = double.TryParse(textBox7.Text, out double X7); bool T8 = double.TryParse(textBox8.Text, out double X8); if (T1 == true) { textBox1.BackColor = Color.GreenYellow; 暂停 = 0; 奖品1概率 = int.Parse(textBox1.Text); } if (T2 == true) { textBox2.BackColor = Color.GreenYellow; 暂停 = 0; 奖品2概率 = int.Parse(textBox2.Text); } if (T3 == true) { textBox3.BackColor = Color.GreenYellow; 暂停 = 0; 奖品3概率 = int.Parse(textBox3.Text); } if (T4 == true) { textBox4.BackColor = Color.GreenYellow; 暂停 = 0; 奖品4概率 = int.Parse(textBox4.Text); } if (T5 == true) { textBox5.BackColor = Color.GreenYellow; 暂停 = 0; 奖品5概率 = int.Parse(textBox5.Text); } if (T6 == true) { textBox6.BackColor = Color.GreenYellow; 暂停 = 0; 奖品6概率 = int.Parse(textBox6.Text); } if (T7 == true) { textBox7.BackColor = Color.GreenYellow; 暂停 = 0; 奖品7概率 = int.Parse(textBox7.Text); } if (T8 == true) { textBox8.BackColor = Color.GreenYellow; 暂停 = 0; 奖品1概率 = int.Parse(textBox8.Text); } if (T1 == false || textBox1.Text == "") { textBox1.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } if (T2 == false || textBox2.Text == "") { textBox2.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } if (T3 == false || textBox3.Text == "") { textBox3.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } if (T4 == false || textBox4.Text == "") { textBox4.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } if (T5 == false || textBox5.Text == "") { textBox5.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } if (T6 == false || textBox6.Text == "") { textBox6.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } if (T7 == false||textBox7.Text == "") { textBox7.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } //this.数据一.判断数字(); if (T8 == false || textBox8.Text == "") { textBox8.BackColor = Color.Red; 异常 ; if (异常 == 1) { MessageBox.Show("此值输入无效!"); } 暂停 = 1; } } public void button_退出_Click(object sender, EventArgs e) { this.Hide(); } private void textBox1_TextChanged(object sender, EventArgs e) { } public void T9(string a) { textBox9.Text = a; } private void textBoxG7_TextChanged(object sender, EventArgs e) { } } }