示例#1
0
        private void PrintExecute()
        {
            try
            {
                //we check if user enter valid value for number of coppies
                if (!ValidationClass.NumberOfCoppiesIsValid(numberOfCopies))
                {
                    MessageBox.Show("Morate uneti pozitivan ceo broj manji od 100.");
                    return;
                }
                //we check if user enter valid value for number of coppies
                if (Int32.Parse(numberOfCopies) <= 0 || Int32.Parse(numberOfCopies) >= 100)
                {
                    MessageBox.Show("Morate uneti pozitivan ceo broj manji od 100.");
                    return;
                }
                //if the Background is running we cant call Print commad
                //program will print a message to user and command will end here
                if (worker.IsBusy)
                {
                    MessageBox.Show("Stampanje je vec u toku.");
                    return;
                }

                firstPrinting = false;

                if (!worker.IsBusy)
                {
                    //this method call DoWork method of Background Worker
                    DoStuff();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }