//Lab3 functions:
 private void btnApplyMask_Click(object sender, EventArgs e)
 {
     if (cbOwnMask.Checked)
     {
         try
         {
             int k = 0;
             int[,] ownMask = new int[maskSizeX, maskSizeY];
             for (int i = 0; i < maskSizeX; i++)
             {
                 for (int j = 0; j < maskSizeY; j++)
                 {
                     ownMask[i, j] = Convert.ToInt32(txtMaskMatrixList[k].Text);
                     k++;
                 }
             }
             mainImage.MaskOnImage(ownMask);
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.Message, "Exception");
         }
     }
     else if (mask <= masksAplied.onSixteen)
     {
         mainImage.MaskOnImage(intMaskList[(int)mask], kDiv);
     }
     else if (mask <= masksAplied.edgeThree)
     {
         mainImage.MaskOnImage(intMaskList[(int)mask]);
     }
     else
     {
         int  tempPixel         = 0;
         bool tryParseUserPixel = Int32.TryParse(txtUserPixel.Text, out tempPixel);
         if (!tryParseUserPixel)
         {
             MessageBox.Show("Enter valid number in userPixel text box!");
             return;
         }
         if (tempPixel < 0 || tempPixel > 255)
         {
             MessageBox.Show("User pixel must be >= 0 and <= 255!");
             return;
         }
         userPixel = tempPixel;
         mainImage.MaskOnImage(intMaskList[(int)mask], (edgeMethods)cbEdgeMethods.SelectedIndex, (scaleMethods)cbScaleMethods.SelectedIndex, userPixel);
     }
     InvalidateImage();
 }