Exemplo n.º 1
0
        private BitmapFileSettings GetBitmapFileSettings()
        {
            BitmapFileSettings bitmapSettings = null;

            var saveFileDialog = new SaveFileDialog
            {
                Title            = "Save Spirograph Image File",
                FileName         = DefaultImageFileName,
                Filter           = BitmapFileSettings.FileFilters,
                FilterIndex      = PNGDefaultFileFiler,
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                AddExtension     = true,
                OverwritePrompt  = true,
                ValidateNames    = true,
            };

            bool?dialogResult = saveFileDialog.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value == true)
            {
                var encoding      = (BitmapEncoding)(saveFileDialog.FilterIndex - 1);
                var imageFileName = saveFileDialog.FileName;

                bitmapSettings = new BitmapFileSettings(encoding, imageFileName);
            }

            return(bitmapSettings);
        }
Exemplo n.º 2
0
        private void SaveSpirographImage()
        {
            BitmapFileSettings bitmapSettings = GetBitmapFileSettings();

            if (theSpirograph != null)
            {
                if (bitmapSettings != null)
                {
                    theSpirograph.Save(SpiroCanvas,
                                       bitmapSettings.Encoder,
                                       bitmapSettings.BitmapFileName);
                }
            }
        }