Home  All Courses Robotics C++ AP Java  AP Physics Electronics Astronomy Summer Session Sandia Cameras About
                                                       

Lottery Assistant

 

#pragma once

 

 

namespace LotteryAssistant

{

      using namespace System;

      using namespace System::ComponentModel;

      using namespace System::Collections;

      using namespace System::Windows::Forms;

      using namespace System::Data;

      using namespace System::Drawing;

 

      /// <summary>

      /// Summary for Form1

      ///

      /// WARNING: If you change the name of this class, you will need to change the

      ///          'Resource File Name' property for the managed resource compiler tool

      ///          associated with all .resx files this class depends on.  Otherwise,

      ///          the designers will not be able to interact properly with localized

      ///          resources associated with this form.

      /// </summary>

      public ref class Form1 : public System::Windows::Forms::Form

      {

      public:

            Form1(void)

            {

                  InitializeComponent();

                  //

                  //TODO: Add the constructor code here

                  //

            }

 

      protected:

            /// <summary>

            /// Clean up any resources being used.

            /// </summary>

            /// <param name="disposing">"description of the parameter"</param>

     

      private: System::Windows::Forms::MenuStrip^  mnuStrip;

      protected:

 

      private: System::Windows::Forms::Label^  lblFullSet;

      private: System::Windows::Forms::Label^  lblNumPics;

      private: System::Windows::Forms::Label^  lblNumRange;

      private: System::Windows::Forms::Label^  lblOutput;

      private: System::Windows::Forms::TextBox^  txtFullSet;

      private: System::Windows::Forms::TextBox^  txtNumPics;

      private: System::Windows::Forms::TextBox^  txtNumRange;

      private: System::Windows::Forms::TextBox^  txtOutput;

      private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  optionsToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  helpToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  getNumbersToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  clearNumberToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  backgroundToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  fontSizeToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  aboutToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  whiteToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  yellowToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  grayToolStripMenuItem;

      private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem2;

      private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem3;

      private: System::Windows::Forms::ToolStripMenuItem^  toolStripMenuItem4;

 

      protected:

 

      private:

            /// <summary>

            /// Required designer variable.

            /// </summary>

            System::ComponentModel::Container ^components;

 

#pragma 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>

            void InitializeComponent(void)

            {

                  this->mnuStrip = (gcnew System::Windows::Forms::MenuStrip());

                  this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->getNumbersToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->clearNumberToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->optionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->backgroundToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->whiteToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->yellowToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->grayToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->fontSizeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->toolStripMenuItem2 = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->toolStripMenuItem3 = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->toolStripMenuItem4 = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());

                  this->lblFullSet = (gcnew System::Windows::Forms::Label());

                  this->lblNumPics = (gcnew System::Windows::Forms::Label());

                  this->lblNumRange = (gcnew System::Windows::Forms::Label());

                  this->lblOutput = (gcnew System::Windows::Forms::Label());

                  this->txtFullSet = (gcnew System::Windows::Forms::TextBox());

                  this->txtNumPics = (gcnew System::Windows::Forms::TextBox());

                  this->txtNumRange = (gcnew System::Windows::Forms::TextBox());

                  this->txtOutput = (gcnew System::Windows::Forms::TextBox());

                  this->mnuStrip->SuspendLayout();

                  this->SuspendLayout();

                  //

                  // mnuStrip

                  //

                  this->mnuStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->fileToolStripMenuItem,

                        this->optionsToolStripMenuItem, this->helpToolStripMenuItem});

                  this->mnuStrip->Location = System::Drawing::Point(0, 0);

                  this->mnuStrip->Name = L"mnuStrip";

                  this->mnuStrip->Size = System::Drawing::Size(320, 24);

                  this->mnuStrip->TabIndex = 0;

                  this->mnuStrip->Text = L"menuStrip1";

                  //

                  // fileToolStripMenuItem

                  //

                  this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->getNumbersToolStripMenuItem,

                        this->clearNumberToolStripMenuItem, this->exitToolStripMenuItem});

                  this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";

                  this->fileToolStripMenuItem->Text = L"&File";

                  //

                  // getNumbersToolStripMenuItem

                  //

                  this->getNumbersToolStripMenuItem->Name = L"getNumbersToolStripMenuItem";

                  this->getNumbersToolStripMenuItem->ShortcutKeys = System::Windows::Forms::Keys::F1;

                  this->getNumbersToolStripMenuItem->Text = L"&Get Numbers";

                  this->getNumbersToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::getNumbersToolStripMenuItem_Click);

                  //

                  // clearNumberToolStripMenuItem

                  //

                  this->clearNumberToolStripMenuItem->Enabled = false;

                  this->clearNumberToolStripMenuItem->Name = L"clearNumberToolStripMenuItem";

                  this->clearNumberToolStripMenuItem->ShortcutKeys = System::Windows::Forms::Keys::F2;

                  this->clearNumberToolStripMenuItem->Text = L"&Clear Number";

                  this->clearNumberToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::clearNumberToolStripMenuItem_Click);

                  //

                  // exitToolStripMenuItem

                  //

                  this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";

                  this->exitToolStripMenuItem->Text = L"E&xit";

                  this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::exitToolStripMenuItem_Click);

                  //

                  // optionsToolStripMenuItem

                  //

                  this->optionsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->backgroundToolStripMenuItem,

                        this->fontSizeToolStripMenuItem});

                  this->optionsToolStripMenuItem->Name = L"optionsToolStripMenuItem";

                  this->optionsToolStripMenuItem->Text = L"&Options";

                  //

                  // backgroundToolStripMenuItem

                  //

                  this->backgroundToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->whiteToolStripMenuItem,

                        this->yellowToolStripMenuItem, this->grayToolStripMenuItem});

                  this->backgroundToolStripMenuItem->Name = L"backgroundToolStripMenuItem";

                  this->backgroundToolStripMenuItem->Text = L"&Background";

                  //

                  // whiteToolStripMenuItem

                  //

                  this->whiteToolStripMenuItem->Checked = true;

                  this->whiteToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked;

                  this->whiteToolStripMenuItem->Name = L"whiteToolStripMenuItem";

                  this->whiteToolStripMenuItem->Text = L"&White";

                  this->whiteToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::whiteToolStripMenuItem_Click);

                  //

                  // yellowToolStripMenuItem

                  //

                  this->yellowToolStripMenuItem->Name = L"yellowToolStripMenuItem";

                  this->yellowToolStripMenuItem->Text = L"&Yellow";

                  this->yellowToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::yellowToolStripMenuItem_Click);

                  //

                  // grayToolStripMenuItem

                  //

                  this->grayToolStripMenuItem->Name = L"grayToolStripMenuItem";

                  this->grayToolStripMenuItem->Text = L"&Gray";

                  this->grayToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::grayToolStripMenuItem_Click);

                  //

                  // fontSizeToolStripMenuItem

                  //

                  this->fontSizeToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->toolStripMenuItem2,

                        this->toolStripMenuItem3, this->toolStripMenuItem4});

                  this->fontSizeToolStripMenuItem->Name = L"fontSizeToolStripMenuItem";

                  this->fontSizeToolStripMenuItem->Text = L"&Font Size";

                  //

                  // toolStripMenuItem2

                  //

                  this->toolStripMenuItem2->Checked = true;

                  this->toolStripMenuItem2->CheckState = System::Windows::Forms::CheckState::Checked;

                  this->toolStripMenuItem2->Name = L"toolStripMenuItem2";

                  this->toolStripMenuItem2->Text = L"8";

                  this->toolStripMenuItem2->Click += gcnew System::EventHandler(this, &Form1::toolStripMenuItem2_Click);

                  //

                  // toolStripMenuItem3

                  //

                  this->toolStripMenuItem3->Name = L"toolStripMenuItem3";

                  this->toolStripMenuItem3->Text = L"10";

                  this->toolStripMenuItem3->Click += gcnew System::EventHandler(this, &Form1::toolStripMenuItem3_Click);

                  //

                  // toolStripMenuItem4

                  //

                  this->toolStripMenuItem4->Name = L"toolStripMenuItem4";

                  this->toolStripMenuItem4->Text = L"12";

                  this->toolStripMenuItem4->Click += gcnew System::EventHandler(this, &Form1::toolStripMenuItem4_Click);

                  //

                  // helpToolStripMenuItem

                  //

                  this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->aboutToolStripMenuItem});

                  this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem";

                  this->helpToolStripMenuItem->Text = L"&Help";

                  //

                  // aboutToolStripMenuItem

                  //

                  this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";

                  this->aboutToolStripMenuItem->Text = L"&About";

                  this->aboutToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::aboutToolStripMenuItem_Click);

                  //

                  // lblFullSet

                  //

                  this->lblFullSet->AutoSize = true;

                  this->lblFullSet->Location = System::Drawing::Point(12, 47);

                  this->lblFullSet->Name = L"lblFullSet";

                  this->lblFullSet->Size = System::Drawing::Size(188, 13);

                  this->lblFullSet->TabIndex = 1;

                  this->lblFullSet->Text = L"How many numbers make up a full set\?";

                  //

                  // lblNumPics

                  //

                  this->lblNumPics->AutoSize = true;

                  this->lblNumPics->Location = System::Drawing::Point(12, 73);

                  this->lblNumPics->Name = L"lblNumPics";

                  this->lblNumPics->Size = System::Drawing::Size(228, 13);

                  this->lblNumPics->TabIndex = 2;

                  this->lblNumPics->Text = L"How many sets of lottery numbers do you want\?";

                  //

                  // lblNumRange

                  //

                  this->lblNumRange->AutoSize = true;

                  this->lblNumRange->Location = System::Drawing::Point(12, 103);

                  this->lblNumRange->Name = L"lblNumRange";

                  this->lblNumRange->Size = System::Drawing::Size(230, 13);

                  this->lblNumRange->TabIndex = 3;

                  this->lblNumRange->Text = L"What is the highest number that can be picked\?";

                  //

                  // lblOutput

                  //

                  this->lblOutput->AutoSize = true;

                  this->lblOutput->Location = System::Drawing::Point(111, 139);

                  this->lblOutput->Name = L"lblOutput";

                  this->lblOutput->Size = System::Drawing::Size(99, 13);

                  this->lblOutput->TabIndex = 4;

                  this->lblOutput->Text = L"Your lottery numbers";

                  //

                  // txtFullSet

                  //

                  this->txtFullSet->Location = System::Drawing::Point(247, 47);

                  this->txtFullSet->Name = L"txtFullSet";

                  this->txtFullSet->Size = System::Drawing::Size(61, 20);

                  this->txtFullSet->TabIndex = 5;

                  //

                  // txtNumPics

                  //

                  this->txtNumPics->Location = System::Drawing::Point(247, 73);

                  this->txtNumPics->Name = L"txtNumPics";

                  this->txtNumPics->Size = System::Drawing::Size(61, 20);

                  this->txtNumPics->TabIndex = 6;

                  //

                  // txtNumRange

                  //

                  this->txtNumRange->Location = System::Drawing::Point(247, 100);

                  this->txtNumRange->Name = L"txtNumRange";

                  this->txtNumRange->Size = System::Drawing::Size(61, 20);

                  this->txtNumRange->TabIndex = 7;

                  //

                  // txtOutput

                  //

                  this->txtOutput->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

                        static_cast<System::Byte>(0)));

                  this->txtOutput->Location = System::Drawing::Point(12, 156);

                  this->txtOutput->Multiline = true;

                  this->txtOutput->Name = L"txtOutput";

                  this->txtOutput->ReadOnly = true;

                  this->txtOutput->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;

                  this->txtOutput->Size = System::Drawing::Size(296, 106);

                  this->txtOutput->TabIndex = 8;

                  this->txtOutput->TabStop = false;

                  this->txtOutput->WordWrap = false;

                  //

                  // Form1

                  //

                  this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

                  this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

                  this->BackColor = System::Drawing::SystemColors::ActiveCaptionText;

                  this->ClientSize = System::Drawing::Size(320, 274);

                  this->Controls->Add(this->txtOutput);

                  this->Controls->Add(this->txtNumRange);

                  this->Controls->Add(this->txtNumPics);

                  this->Controls->Add(this->txtFullSet);

                  this->Controls->Add(this->lblOutput);

                  this->Controls->Add(this->lblNumRange);

                  this->Controls->Add(this->lblNumPics);

                  this->Controls->Add(this->lblFullSet);

                  this->Controls->Add(this->mnuStrip);

                  this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;

                  this->MainMenuStrip = this->mnuStrip;

                  this->Name = L"Form1";

                  this->SizeGripStyle = System::Windows::Forms::SizeGripStyle::Show;

                  this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;

                  this->Text = L"Lottery Assistant";

                  this->mnuStrip->ResumeLayout(false);

                  this->ResumeLayout(false);

                  this->PerformLayout();

 

            }

#pragma endregion

      private: System::Void getNumbersToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                         Double dblInputTest = 0;  //Used to test input

                         const Int16 cMinInSet = 3,     //Set range

                                            cMaxInSet = 10,

                                            cMinNumPics = 1,  //Number of sets

                                            cMaxNumPics = 10,

                                            cMinNumRange = 1, //Range of picks

                                            cMaxNumRange = 50;

                         //Confirm full set is a proper entry

                         if( !Double::TryParse( txtFullSet->Text, dblInputTest ) ||

                               !(dblInputTest >= cMinInSet && dblInputTest <= cMaxInSet) )

                         {

                               MessageBox::Show( String::Concat( "You must enter"

                               " a number between ", cMinInSet.ToString(),

                               " and ", cMaxInSet.ToString(), " for the full set." ) );

                               return;

                         }

                         //Confirm number of picks is a proper entry

                         if( !Double::TryParse( txtNumPics->Text, dblInputTest ) ||

                               !(dblInputTest >= cMinNumPics && dblInputTest <= cMaxNumPics) )

                         {

                               MessageBox::Show( String::Concat( "You must enter"

                               " a number between ", cMinNumPics.ToString(),

                               " and ", cMaxNumPics.ToString(), " for the "

                               "number of sets you want." ) );

                               return;

                         }

                         //Confirm range is a proper entry

                         if( !Double::TryParse( txtNumRange->Text, dblInputTest ) ||

                               !(dblInputTest > cMinNumRange && dblInputTest <= cMaxNumRange) )

                         {

                               MessageBox::Show( String::Concat( "You must enter"

                               " a number greater than ", cMinNumRange.ToString(),

                               " and less than ", cMaxNumRange.ToString(), " for"

                               " the range of numbers." ) );

                               return;

                         }

                         //Confirm range is greater than number within a set

                         if( Int16::Parse( txtNumRange->Text ) < \

                               Int16::Parse( txtFullSet->Text ) )

                         {

                               MessageBox::Show( "You must enter a range "

                               "of numbers that is greater than the number "

                               "of picks in order to be able to generate "

                               "one unique number for each pick."  );

                               return;

                         }

                         //Create random numbers based on current time

                         DateTime moment = DateTime::Now;

                         Random^ randNumGen = gcnew Random( moment.Millisecond );

                         //Create a list that will hold the picks

                         //  and allow checks for duplicates

                         Int16 iLotteryArray[cMaxInSet];

                         //Generate all random numbers

                         for( Int16 iNumSetCntr = 0;

                                iNumSetCntr < Int16::Parse( txtNumPics->Text);

                                iNumSetCntr++ )

                         {

                               //Clear the list of picks

                               Int16 iCurPickCntr;

                               for( iCurPickCntr = 0; iCurPickCntr < cMaxInSet;

                                      iCurPickCntr++ )

                                      iLotteryArray[iCurPickCntr] = 0;

                               //Generate the list

                               iCurPickCntr = 0;

                               Boolean bPickDuplicate;

                               do

                               {

                                     bPickDuplicate = false;

                                     //Get a possible lottery value

                                     iLotteryArray[iCurPickCntr] = cMinNumRange + \

                                     randNumGen->Next() \

                                     % (Int16::Parse( txtNumRange->Text) - \

                                     cMinNumRange );

                                     //Check to see if the pick is duplicate

                                     for( Int16 iDupCntr = 0; iDupCntr < iCurPickCntr;\

                                            iDupCntr++ )

                                     {

                                           if( iLotteryArray[iDupCntr] == \

                                                 iLotteryArray[iCurPickCntr] )

                                           {

                                                 bPickDuplicate = true;

                                                 break;

                                           }

                                     }

                                     //If number is duplicate, try again

                                     if( bPickDuplicate == true )

                                           continue;

                                     //Number is not duplicate, output

                                     //  and move to next

                                     txtOutput->Text = String::Concat(

                                     txtOutput->Text, Convert::ToString( \

                                     iLotteryArray[iCurPickCntr] ), "\t" );

                                     iCurPickCntr++;

                               } while( iCurPickCntr < \

                                          Int16::Parse( txtFullSet->Text) );

                               txtOutput->Text = String::Concat( \

                               txtOutput->Text, "\r\r\n\r\r\n" );

                         }

                         getNumbersToolStripMenuItem->Enabled = false;

                         clearNumberToolStripMenuItem->Enabled = true;

                   }

private: System::Void clearNumberToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                   txtFullSet->Text = "";

                   txtNumPics->Text = "";

                   txtNumRange->Text = "";

                   txtOutput->Text = "";

                   txtFullSet->Focus();

                   getNumbersToolStripMenuItem->Enabled = true;

             }

private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->Close();

             }

private: System::Void whiteToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->BackColor = Color::White;

                   whiteToolStripMenuItem->Checked = true;

                   yellowToolStripMenuItem->Checked = false;

                   grayToolStripMenuItem->Checked = false;

             }

private: System::Void yellowToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->BackColor = Color::Yellow;

                   whiteToolStripMenuItem->Checked = false;

                   yellowToolStripMenuItem->Checked = true;

                   grayToolStripMenuItem->Checked = false;

             }

private: System::Void grayToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->BackColor = Color::Gray;

                   whiteToolStripMenuItem->Checked = false;

                   yellowToolStripMenuItem->Checked = false;

                   grayToolStripMenuItem->Checked = true;

             }

private: System::Void toolStripMenuItem2_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->txtOutput->Font = gcnew Drawing::Font(L"Arial", 8.25F );

                   toolStripMenuItem2->Checked = true;

                   toolStripMenuItem3->Checked = false;

                   toolStripMenuItem4->Checked = false;

             }

private: System::Void toolStripMenuItem3_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->txtOutput->Font = gcnew Drawing::Font(L"Arial", 10.0F );

                   toolStripMenuItem2->Checked = false;

                   toolStripMenuItem3->Checked = true;

                   toolStripMenuItem4->Checked = false;

             }

private: System::Void toolStripMenuItem4_Click(System::Object^  sender, System::EventArgs^  e) {

                   this->txtOutput->Font = gcnew Drawing::Font(L"Arial", 12.0F );

                   toolStripMenuItem2->Checked = false;

                   toolStripMenuItem3->Checked = false;

                   toolStripMenuItem4->Checked = true;

             }

private: System::Void aboutToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {

                   MessageBox::Show( "This Visual C++ application was"

                   "created by Aaron Miller" );

             }

};

}