コード例 #1
0
        private void CrossStitchButton_Click(object sender, EventArgs e)
        {
            crossStitchButton.Enabled = false;
            Cursor.Current            = Cursors.WaitCursor;
            var filename     = openFileDialog1.FileName;
            var colorPattern = ColorCheckBox.Checked;
            var ditherImage  = ditherCB.Checked;
            var projectName  = FolderNameBox.Text;

            try
            {
                var b             = new Bitmap(filename);
                var crossStitcher = new CrossStitcher
                                        (b, colorPattern, ditherImage, projectName);
                crossStitcher.GenerateCrossStitch();
            }
            catch (Exception ex)
            {
                DisplayException("Error occurred during generation", ex);
            }
            finally
            {
                crossStitchButton.Enabled = true;
                Cursor.Current            = Cursors.Default;
            }
        }
コード例 #2
0
        private void PreviewButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(openFileDialog1.FileName))
            {
                return;
            }
            previewButton.Enabled = false;
            Cursor.Current        = Cursors.WaitCursor;
            var filename     = openFileDialog1.FileName;
            var colorPattern = ColorCheckBox.Checked;
            var ditherImage  = ditherCB.Checked;
            var projectName  = FolderNameBox.Text;

            try
            {
                var b             = new Bitmap(filename);
                var crossStitcher = new CrossStitcher
                                        (b, colorPattern, ditherImage, projectName);
                var preview = crossStitcher.GenerateStitchBitmap();
                using (var previewForm = new Form())
                {
                    previewForm.StartPosition = FormStartPosition.CenterScreen;
                    previewForm.Width         = preview.Width + 50;
                    previewForm.Height        = preview.Height + 50;
                    var pb = new PictureBox
                    {
                        Dock  = DockStyle.Fill,
                        Image = preview
                    };
                    previewForm.Controls.Add(pb);
                    previewForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                DisplayException("Error generating preview", ex);
            }
            finally
            {
                previewButton.Enabled = true;
                Cursor.Current        = Cursors.Default;
            }
        }