-
Notifications
You must be signed in to change notification settings - Fork 0
/
OddsConfigForTicketTypeUserControl.cs
109 lines (95 loc) · 4.51 KB
/
OddsConfigForTicketTypeUserControl.cs
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HorseRacingAutoPurchaser.Utils;
using HorseRacingAutoPurchaser.Infrastructures;
using HorseRacingAutoPurchaser.Models;
namespace HorseRacingAutoPurchaser
{
public partial class OddsConfigForTicketTypeUserControl : UserControl
{
[Browsable(true)]
[Description("設定名の表示名")]
public string DisplayName
{
get { return groupBox1.Text; }
set { groupBox1.Text = value; }
}
//[Browsable(false)]
//private BetConfigForTicketType BetConfigForTicketType { get; set; }
public OddsConfigForTicketTypeUserControl()
{
InitializeComponent();
}
private void RadioButton_UseCocomo_CheckedChanged(object sender, EventArgs e)
{
ChangeBetTacticsStatus();
}
public bool NeedAlert()
{
if(!checkBox_PurchaseCentral.Checked && !checkBox_PurchaseRegional.Checked)
{
return false;
}
return numericUpDown_MinimumPayBack.Value >= 10000 ||
(radioButton_UseCocomo.Checked &&
(numericUpDown_CocomoThreshold.Value < 50 || numericUpDown_CocomoMaxMagnification.Value > 10)) ||
(numericUpDown_MaxPurchaseCountOrderByRatio.Value + numericUpDown_MaxPurchaseCountOrderByRatio.Value) * numericUpDown_MinimumPayBack.Value >= 30000 ||
numericUpDown_MinimumPayBack.Value >= 30000 ||
numericUpDown_MinimumPayBack.Value >= 10000 * numericUpDown_MinimumOdds.Value;
}
public void SetBetConfigForTicketType(BetConfigForTicketType betConfigForTicketType)
{
numericUpDown_OddsRatio.Value = (decimal)betConfigForTicketType.OddsRatio;
numericUpDown_MinimumOdds.Value = (decimal)betConfigForTicketType.MinimumOdds;
numericUpDown_MaximumOdds.Value = (decimal)betConfigForTicketType.MaximumOdds;
numericUpDown_MinimumPayBack.Value = (decimal)betConfigForTicketType.MinimumPayBack;
numericUpDown_MaxPurchaseCountOrderByRatio.Value = betConfigForTicketType.MaxPurchaseCountOrderByRatio;
numericUpDown_MaxPurchaseCountOrderByProbability.Value = betConfigForTicketType.MaxPurchaseCountOrderByProbability;
radioButton_UseCocomo.Checked = betConfigForTicketType.UseCocomo;
radioButton_NoBetTactics.Checked = !radioButton_UseCocomo.Checked;
numericUpDown_CocomoThreshold.Value = betConfigForTicketType.CocomoThreshold;
numericUpDown_CocomoMaxMagnification.Value = betConfigForTicketType.CocomoMaxMagnification;
checkBox_PurchaseCentral.Checked = betConfigForTicketType.PurchaseCentral;
checkBox_PurchaseRegional.Checked = betConfigForTicketType.PurchaseRegional;
ChangeBetTacticsStatus();
}
public BetConfigForTicketType GetCurrentConfig()
{
var betConfig = new BetConfigForTicketType
{
OddsRatio = (double)numericUpDown_OddsRatio.Value,
MinimumOdds = (double)numericUpDown_MinimumOdds.Value,
MaximumOdds = (double)numericUpDown_MaximumOdds.Value,
MinimumPayBack = (double)numericUpDown_MinimumPayBack.Value,
MaxPurchaseCountOrderByRatio = (int)numericUpDown_MaxPurchaseCountOrderByRatio.Value,
MaxPurchaseCountOrderByProbability = (int)numericUpDown_MaxPurchaseCountOrderByProbability.Value,
UseCocomo = radioButton_UseCocomo.Checked,
CocomoThreshold = (int)numericUpDown_CocomoThreshold.Value,
CocomoMaxMagnification = (int)numericUpDown_CocomoMaxMagnification.Value,
PurchaseCentral = checkBox_PurchaseCentral.Checked,
PurchaseRegional = checkBox_PurchaseRegional.Checked
};
return betConfig;
}
private void ChangeBetTacticsStatus()
{
if (radioButton_UseCocomo.Checked)
{
numericUpDown_CocomoThreshold.Enabled = true;
numericUpDown_CocomoMaxMagnification.Enabled = true;
}
else
{
numericUpDown_CocomoThreshold.Enabled = false;
numericUpDown_CocomoMaxMagnification.Enabled = false;
}
}
}
}