-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form_BuyRepairs.cs
183 lines (164 loc) · 5.94 KB
/
Form_BuyRepairs.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*******************************************************************************
*
* Space Trader for Windows 1.00
*
* Copyright (C) 2016 Keith Banner, All Rights Reserved
*
* Port to Windows by David Pierron & Jay French
* Original coding by Pieter Spronck, Sam Anderson, Samuel Goldstein, Matt Lee
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* If you'd like a copy of the GNU General Public License, go to
* http://www.gnu.org/copyleft/gpl.html.
*
* You can contact the author at [email protected]
*
******************************************************************************/
using System;
namespace SpaceTrader
{
public class FormBuyRepairs : System.Windows.Forms.Form
{
#region Control Declarations
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Label lblQuestion;
private System.Windows.Forms.Button btnMax;
private System.Windows.Forms.Button btnNothing;
private System.Windows.Forms.NumericUpDown numAmount;
private System.ComponentModel.Container components = null;
#endregion
#region Member Declarations
private Game game = Game.CurrentGame;
#endregion
#region Methods
public FormBuyRepairs()
{
InitializeComponent();
Commander cmdr = game.Commander;
numAmount.Maximum = Math.Min(cmdr.Cash, (cmdr.Ship.HullStrength - cmdr.Ship.Hull) * cmdr.Ship.RepairCost);
numAmount.Value = numAmount.Maximum;
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
components.Dispose();
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblQuestion = new System.Windows.Forms.Label();
this.numAmount = new System.Windows.Forms.NumericUpDown();
this.btnOk = new System.Windows.Forms.Button();
this.btnMax = new System.Windows.Forms.Button();
this.btnNothing = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numAmount)).BeginInit();
this.SuspendLayout();
//
// lblQuestion
//
this.lblQuestion.AutoSize = true;
this.lblQuestion.Location = new System.Drawing.Point(8, 8);
this.lblQuestion.Name = "lblQuestion";
this.lblQuestion.Size = new System.Drawing.Size(227, 13);
this.lblQuestion.TabIndex = 3;
this.lblQuestion.Text = "How much do you want to spend on repairs?";
//
// numAmount
//
this.numAmount.Location = new System.Drawing.Point(232, 6);
this.numAmount.Maximum = new System.Decimal(new int[] {
999,
0,
0,
0});
this.numAmount.Minimum = new System.Decimal(new int[] {
1,
0,
0,
0});
this.numAmount.Name = "numAmount";
this.numAmount.Size = new System.Drawing.Size(44, 20);
this.numAmount.TabIndex = 1;
this.numAmount.Value = new System.Decimal(new int[] {
888,
0,
0,
0});
//
// btnOk
//
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOk.Location = new System.Drawing.Point(69, 32);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(41, 22);
this.btnOk.TabIndex = 2;
this.btnOk.Text = "Ok";
//
// btnMax
//
this.btnMax.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnMax.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMax.Location = new System.Drawing.Point(117, 32);
this.btnMax.Name = "btnMax";
this.btnMax.Size = new System.Drawing.Size(41, 22);
this.btnMax.TabIndex = 3;
this.btnMax.Text = "Max";
//
// btnNothing
//
this.btnNothing.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnNothing.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNothing.Location = new System.Drawing.Point(165, 32);
this.btnNothing.Name = "btnNothing";
this.btnNothing.Size = new System.Drawing.Size(53, 22);
this.btnNothing.TabIndex = 4;
this.btnNothing.Text = "Nothing";
//
// FormBuyRepairs
//
this.AcceptButton = this.btnOk;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.btnNothing;
this.ClientSize = new System.Drawing.Size(286, 63);
this.ControlBox = false;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnNothing,
this.btnMax,
this.btnOk,
this.numAmount,
this.lblQuestion});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "FormBuyRepairs";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Hull Repair";
((System.ComponentModel.ISupportInitialize)(this.numAmount)).EndInit();
this.ResumeLayout(false);
}
#endregion
#endregion
#region Event Handlers
private void btnMax_Click(object sender, System.EventArgs e)
{
numAmount.Value = numAmount.Maximum;
}
#endregion
#region Properties
public int Amount => (int)numAmount.Value;
#endregion
}
}