📄 form1.h
字号:
this->euroStar2->BackColor = System::Drawing::Color::Gold;
this->euroStar2->ContextMenuStrip = this->buttonContextMenu;
this->euroStar2->Location = System::Drawing::Point(418, 47);
this->euroStar2->Name = L"euroStar2";
this->euroStar2->Size = System::Drawing::Size(75, 23);
this->euroStar2->TabIndex = 1;
this->euroStar2->Text = L"2";
this->euroStar2->UseVisualStyleBackColor = false;
this->euroStar2->Click += gcnew System::EventHandler(this, &Form1::euroStarClick);
//
// euroStar1
//
this->euroStar1->BackColor = System::Drawing::Color::Gold;
this->euroStar1->ContextMenuStrip = this->buttonContextMenu;
this->euroStar1->Location = System::Drawing::Point(85, 47);
this->euroStar1->Name = L"euroStar1";
this->euroStar1->Size = System::Drawing::Size(75, 23);
this->euroStar1->TabIndex = 0;
this->euroStar1->Text = L"1";
this->euroStar1->UseVisualStyleBackColor = false;
this->euroStar1->Click += gcnew System::EventHandler(this, &Form1::euroStarClick);
//
// webTab
//
this->webTab->Controls->Add(this->webBrowser);
this->webTab->Location = System::Drawing::Point(4, 22);
this->webTab->Name = L"webTab";
this->webTab->Padding = System::Windows::Forms::Padding(3);
this->webTab->Size = System::Drawing::Size(584, 312);
this->webTab->TabIndex = 2;
this->webTab->Text = L"Web Page";
this->webTab->UseVisualStyleBackColor = true;
//
// webBrowser
//
this->webBrowser->Dock = System::Windows::Forms::DockStyle::Fill;
this->webBrowser->Location = System::Drawing::Point(3, 3);
this->webBrowser->MinimumSize = System::Drawing::Size(20, 20);
this->webBrowser->Name = L"webBrowser";
this->webBrowser->Size = System::Drawing::Size(578, 306);
this->webBrowser->TabIndex = 0;
this->webBrowser->Url = (gcnew System::Uri(L"http://www.national-lottery.co.uk", System::UriKind::Absolute));
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(592, 362);
this->Controls->Add(this->tabControl1);
this->Controls->Add(this->menuStrip1);
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->Text = L"A Winning Application";
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->tabControl1->ResumeLayout(false);
this->buttonContextMenu->ResumeLayout(false);
this->lottoTab->ResumeLayout(false);
this->lottoValues->ResumeLayout(false);
this->euroTab->ResumeLayout(false);
this->euroEntry->Panel1->ResumeLayout(false);
this->euroEntry->Panel2->ResumeLayout(false);
this->euroEntry->ResumeLayout(false);
this->euroValues->ResumeLayout(false);
this->euroStars->ResumeLayout(false);
this->webTab->ResumeLayout(false);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private:
System::Void playMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
array<int>^ values; // Variable to store a handle to array of integers
if(lottoTab->Visible)
{
// Generate and set values for Lotto entry
values = gcnew array<int>(lottoValuesCount); // Create the array
GetValues(values, lottoUserMinimum, lottoUserMaximum); // Generate values
SetValues(values, lottoValues);
}
else if(euroTab->Visible)
{
// Generate and set values for Euromillions entry
values = gcnew array<int>(euroValuesCount);
GetValues(values, euroUserMinimum, euroUserMaximum);
SetValues(values, euroValues);
values = gcnew array<int>(euroStarsCount);
GetValues(values, euroStarsUserMinimum, euroStarsUserMaximum);
SetValues(values, euroStars);
}
}
private:
System::Void upperMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
::DialogResult result;
if(lottoTab->Visible)
{
lottoLimitsDialog->SetUpperEnabled();
result = lottoLimitsDialog->ShowDialog(this);
if(result == ::DialogResult::OK)
{
lottoUserMaximum = lottoLimitsDialog->UpperLimit;
lottoUserMinimum = lottoLimitsDialog->LowerLimit;
}
}
else if(euroTab->Visible)
{
euroLimitsDialog->SetUpperEnabled();
result = euroLimitsDialog->ShowDialog(this);
if(result == ::DialogResult::OK)
{
euroUserMaximum = euroLimitsDialog->UpperValuesLimit;
euroUserMinimum = euroLimitsDialog->LowerValuesLimit;
euroStarsUserMaximum = euroLimitsDialog->UpperStarsLimit;
euroStarsUserMinimum = euroLimitsDialog->LowerStarsLimit;
}
}
}
private:
System::Void lowerMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
::DialogResult result;
if(lottoTab->Visible)
{
lottoLimitsDialog->SetLowerEnabled();
::DialogResult result = lottoLimitsDialog->ShowDialog(this);
if(result == ::DialogResult::OK)
{
// Update user limits from dialog properties
lottoUserMaximum = lottoLimitsDialog->UpperLimit;
lottoUserMinimum = lottoLimitsDialog->LowerLimit;
}
}
else if(euroTab->Visible)
{
euroLimitsDialog->SetLowerEnabled();
result = euroLimitsDialog->ShowDialog(this);
if(result == ::DialogResult::OK)
{
euroUserMaximum = euroLimitsDialog->UpperValuesLimit;
euroUserMinimum = euroLimitsDialog->LowerValuesLimit;
euroStarsUserMaximum = euroLimitsDialog->UpperStarsLimit;
euroStarsUserMinimum = euroLimitsDialog->LowerStarsLimit;
}
}
}
private:
System::Void aboutMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
helpAboutDialog->ShowDialog(this);
}
private:
System::Void chooseValue_Click(System::Object^ sender, System::EventArgs^ e)
{
array<int>^ values; // Array to store current button values
array<Button^>^ theButtons; // Handle to aray of buttons
// Check if the button is in the lottoValues group box
if(lottoValues->Controls->Contains(contextButton))
{
// the button is from the lotto group...
array<Button^>^ buttons = {lottoValue1, lottoValue2, lottoValue3,
lottoValue4, lottoValue5, lottoValue6};
theButtons = buttons; // Store array handle at outer scope
values = GetButtonValues(buttons); // Get array of button values
// Set up the dialog ready to be shown
userValueDialog->Values = values = GetButtonValues(buttons);
userValueDialog->LowerLimit = lottoUserMinimum;
userValueDialog->UpperLimit = lottoUserMaximum;
userValueDialog->SetLabelText(lottoUserMinimum, lottoUserMaximum);
}
// Check if the button is in the euroValues group box
else if(euroValues->Controls->Contains(contextButton))
{
// The button is in the Values group...
array<Button^>^ buttons = {euroValue1, euroValue2, euroValue3,
euroValue4, euroValue5};
theButtons = buttons; // Store array handle at outer scope
values = GetButtonValues(buttons); // Get array of button values
// Set up the dialog ready to be shown
userValueDialog->Values = values;
userValueDialog->LowerLimit = euroUserMinimum;
userValueDialog->UpperLimit = euroUserMaximum;
userValueDialog->SetLabelText(euroUserMinimum, euroUserMaximum);
}
// Check if the button is in the euroStars group box
else if(euroStars->Controls->Contains(contextButton))
{
// The button is in the Stars group...
array<Button^>^ buttons = { euroStar1, euroStar2 };
theButtons = buttons; // Store array handle at outer scope
values = GetButtonValues(buttons); // Get array of button values
// Set up the dialog ready to be shown
userValueDialog->Values = values;
userValueDialog->LowerLimit = euroStarsUserMinimum;
userValueDialog->UpperLimit = euroStarsUserMaximum;
userValueDialog->SetLabelText(euroStarsUserMinimum, euroStarsUserMaximum);
}
// Display the dialog
if(userValueDialog->ShowDialog(this) == ::DialogResult::OK)
{
// Determine which button value should be replaced
for(int i = 0 ; i<theButtons->Length ; i++)
if(contextButton == theButtons[i])
{
values[i] = userValueDialog->Value;
break;
}
Array::Sort(values); // Sort the values
// Set all the button values
for(int i = 0 ; i<theButtons->Length ; i++)
theButtons[i]->Text = values[i].ToString();
}
}
// Creates an array of button values from an array of buttons
array<int>^ GetButtonValues(array<Button^>^ buttons)
{
array<int>^ values = gcnew array<int>(buttons->Length);
for(int i = 0 ; i<values->Length ; i++)
values[i] = Int32::Parse(buttons[i]->Text);
return values;
}
private:
System::Void resetMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
if(lottoTab->Visible)
{
// Reset user limits for Lotto
lottoUserMaximum = lottoUpperLimit;
lottoUserMinimum = lottoLowerLimit;
lottoLimitsDialog->UpperLimit = lottoUpperLimit;
lottoLimitsDialog->LowerLimit = lottoLowerLimit;
}
else if(euroTab->Visible)
{
// Reset user limits for Euromillions
euroUserMaximum = euroUpperLimit;
euroUserMinimum = euroLowerLimit;
euroStarsUserMaximum = euroStarsUpperLimit;
euroStarsUserMinimum = euroStarsLowerLimit;
// Code to update Euromillions limits dialog...
}
}
private:
System::Void lottoValue_Click(System::Object^ sender, System::EventArgs^ e)
{
Button^ button = safe_cast<Button^>(sender);
// Create the array of button handles
array<Button^>^ buttons = {lottoValue1, lottoValue2, lottoValue3,
lottoValue4, lottoValue5, lottoValue6};
// Replace the value on button
SetNewValue(button, buttons, lottoUserMinimum, lottoUserMaximum);
}
private:
System::Void euroValue_Click(System::Object^ sender, System::EventArgs^ e)
{
Button^ button = safe_cast<Button^>(sender);
array<Button^>^ buttons = {euroValue1, euroValue2, euroValue3,
euroValue4, euroValue5 };
SetNewValue(button, buttons, euroUserMinimum, euroUserMaximum);
}
private:
System::Void euroStarClick(System::Object^ sender, System::EventArgs^ e)
{
Button^ button = safe_cast<Button^>(sender);
array<Button^>^ buttons = { euroStar1, euroStar2 };
SetNewValue(button, buttons, euroStarsUserMinimum, euroStarsUserMaximum);
}
private:
System::Void buttonContextMenu_Opening(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e)
{
contextButton = safe_cast<Button^>(buttonContextMenu->SourceControl);
}
private:
HelpAboutDialog^ helpAboutDialog;
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -