private void CreatePuzzleButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(_filename))
            {
                MessageBox.Show("Image does not selected!");
                return;
            }

            var filePath = _filename;
            var x = XBlocksCount;
            var y = YBlocksCount;
            var generator = new PuzzleCreator(filePath);
            var images = generator.GetMixedPartsOfImage(x, y);
            Bitmap bitmap = generator.GenerateBitmap(images, x, y);

            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.FileName = "puzzle";
            saveFileDialog.DefaultExt = ".jpg";
            saveFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png) | *.jpg; *.jpeg; *.png";

            Nullable<bool> result = saveFileDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                bitmap.Save(saveFileDialog.FileName);
            }
            else
            {
                MessageBox.Show("Puzzle does not saved!");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                var filePath = args[0];
                var x = int.Parse(args[1]);
                var y = int.Parse(args[2]);

                var generator = new PuzzleCreator(filePath);
                var images = generator.GetMixedPartsOfImage(x, y);
                Bitmap bitmap = generator.GenerateBitmap(images, x, y);
                bitmap.Save(string.Format(@"puzzle_{0}", filePath));
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }