Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string templateFileName = string.Concat(ImageProcessingManager.TemplatePath, txtTemplateName.Text, ".bin");

            if (Directory.Exists(ImageProcessingManager.TemplatePath) == false)
            {
                Directory.CreateDirectory(ImageProcessingManager.TemplatePath);
            }

            try
            {
                if (File.Exists(templateFileName))
                {
                    var result = MessageBox.Show("Template Name already present. Do you want to overwrite it?", "Save Template", MessageBoxButtons.YesNoCancel);
                    if (result != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }
                }
                var masterTemplate = ImageProcessingManager.FillMasterTemplate(ChessBoard, Padding, IsWhiteFirst);
                ImageProcessingManager.SaveTemplate(ChessBoard, templateFileName, masterTemplate, Intensity);
                AddEntryToTemplateCatalog(txtTemplateName.Text, lbl.Text, templateFileName);

                MessageBox.Show("Template saved successfully!", "Save Template", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            this.Close();
        }
Example #2
0
        private void btnReadMasterTemplate_Click(object sender, EventArgs e)
        {
            //this.SetDesktopLocation(Left+20, this.Top);

            Cursor = Cursors.WaitCursor;
            //Console.WriteLine("Reading master template...");
            int paddingPixel = int.Parse(txtPadding.Text);

            if (rbtnWhite.Checked)
            {
                //ImageProcessingManager.FillMasterTemplate(Image.FromFile("white.png"), paddingPixel, rbtnWhite.Checked);
                ImageProcessingManager.FillMasterTemplate(Image.FromFile("croppedTemplate.png"), paddingPixel, rbtnWhite.Checked);
                //ImageProcessingManager.FillMasterTemplate(Image.FromFile("test.jpg"), paddingPixel, rbtnWhite.Checked);
                //ImageProcessingManager.PrintChessBoard();
            }
            else
            {
                ImageProcessingManager.FillMasterTemplate(Image.FromFile("black.png"), 5, rbtnWhite.Checked);
            }
            Cursor = Cursors.Default;
            //Console.WriteLine("Done!");
        }