Ejemplo n.º 1
0
        private void customAlignElementButton_Click(object sender, EventArgs e)
        {
            if (!CheckAllSelectedElementsEnabled(true))
            {
                return;
            }

            var listSelectedElements = ElementManager.Instance.SelectedElements;

            if (listSelectedElements == null || listSelectedElements.Count == 0)
            {
                return;
            }

            const string VERTICAL_SPACING      = "vertical_spacing";
            const string APPLY_ELEMENT_WIDTHS  = "apply_element_widths";
            const string HORIZONTAL_SPACING    = "horizontal_spacing";
            const string APPLY_ELEMENT_HEIGHTS = "apply_element_heights";

            var zQuery = new QueryPanelDialog("Custom Align Elements", 450, 150, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);

            zQuery.AddNumericBox("Vertical Pixel Spacing", 0, int.MinValue, int.MaxValue, VERTICAL_SPACING);
            zQuery.AddCheckBox("Include Element Heights", false, APPLY_ELEMENT_HEIGHTS);
            zQuery.AddNumericBox("Horizontal Pixel Spacing", 0, int.MinValue, int.MaxValue, HORIZONTAL_SPACING);
            zQuery.AddCheckBox("Include Element Widths", false, APPLY_ELEMENT_WIDTHS);

            if (DialogResult.OK != zQuery.ShowDialog(CardMakerInstance.ApplicationForm))
            {
                return;
            }

            var nVerticalSpace       = (int)zQuery.GetDecimal(VERTICAL_SPACING);
            var nHorizontalSpace     = (int)zQuery.GetDecimal(HORIZONTAL_SPACING);
            var bApplyElementWidths  = zQuery.GetBool(APPLY_ELEMENT_WIDTHS);
            var bApplyElementHeights = zQuery.GetBool(APPLY_ELEMENT_HEIGHTS);

            var dictionaryOriginalPositions = ElementManager.Instance.GetUndoRedoPoints();

            // apply the translation
            var nX = listSelectedElements[0].x;
            var nY = listSelectedElements[0].y;

            foreach (var zElement in listSelectedElements)
            {
                zElement.x = nX;
                zElement.y = nY;
                nX        += bApplyElementWidths ? zElement.width : 0;
                nY        += bApplyElementHeights ? zElement.height : 0;
                nX        += nHorizontalSpace;
                nY        += nVerticalSpace;
            }
            ElementManager.ConfigureUserAction(dictionaryOriginalPositions,
                                               ElementManager.Instance.GetUndoRedoPoints());

            ElementManager.Instance.FireElementBoundsUpdateEvent();
        }
Ejemplo n.º 2
0
        public static void ShowProjectSettings(Form parentForm)
        {
            const string TRANSLATOR = "translator";
            const string DEFAULT_DEFINE_REFERENCE_TYPE = "default_define_reference_type";
            const string OVERRIDE_DEFINE_REFRENCE_NAME = "override_define_reference_name";
            const string JS_ESCAPE_SINGLE_QUOTES       = "js_escape_single_quotes";
            const string JS_TILDE_CODE     = "js_tilde_code";
            const string JS_KEEP_FUNCTIONS = "js_keep_functions";

            var zQuery = new QueryPanelDialog("Project Settings", 550, 300, true);

            zQuery.SetIcon(Resources.CardMakerIcon);

            TranslatorType eTranslator = ProjectManager.Instance.LoadedProjectTranslatorType;
            ReferenceType  eDefaultDefineReferenceType = ProjectManager.Instance.LoadedProjectDefaultDefineReferenceType;

            zQuery.ChangeToTab("Base");

            zQuery.AddPullDownBox("Translator",
                                  Enum.GetNames(typeof(TranslatorType)), (int)eTranslator, TRANSLATOR);

            zQuery.AddPullDownBox("Default Define Reference Type", Enum.GetNames(typeof(ReferenceType)), (int)eDefaultDefineReferenceType, DEFAULT_DEFINE_REFERENCE_TYPE);
            zQuery.AddSelectorBox(
                "Google Project define spreadsheet override",
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName,
                () =>
            {
                if (GoogleAuthManager.CheckGoogleCredentials(parentForm))
                {
                    return(new GoogleSpreadsheetBrowser(new GoogleSpreadsheet(CardMakerInstance.GoogleInitializerFactory), false));
                }
                return(null);
            },
                (zGoogleSpreadsheetBrowser, txtOverride) =>
            {
                txtOverride.Text = new GoogleSpreadsheetReference(zGoogleSpreadsheetBrowser.SelectedSpreadsheet)
                                   .generateSpreadsheetReference();
            },
                OVERRIDE_DEFINE_REFRENCE_NAME);

            zQuery.ChangeToTab("Javascript");
            zQuery.AddCheckBox("Escape Single Quotes", ProjectManager.Instance.LoadedProject.jsEscapeSingleQuotes, JS_ESCAPE_SINGLE_QUOTES);
            zQuery.AddCheckBox("~ Means Code", ProjectManager.Instance.LoadedProject.jsTildeMeansCode, JS_TILDE_CODE);
            zQuery.AddCheckBox("Keep Functions", ProjectManager.Instance.LoadedProject.jsKeepFunctions, JS_KEEP_FUNCTIONS);

            if (DialogResult.OK == zQuery.ShowDialog(parentForm))
            {
                ProjectManager.Instance.LoadedProject.translatorName              = ((TranslatorType)zQuery.GetIndex(TRANSLATOR)).ToString();
                ProjectManager.Instance.LoadedProject.defaultDefineReferenceType  = ((ReferenceType)zQuery.GetIndex(DEFAULT_DEFINE_REFERENCE_TYPE)).ToString();
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName =
                    zQuery.GetString(OVERRIDE_DEFINE_REFRENCE_NAME).Trim();
                ProjectManager.Instance.LoadedProject.jsEscapeSingleQuotes = zQuery.GetBool(JS_ESCAPE_SINGLE_QUOTES);
                ProjectManager.Instance.LoadedProject.jsTildeMeansCode     = zQuery.GetBool(JS_TILDE_CODE);
                ProjectManager.Instance.LoadedProject.jsKeepFunctions      = zQuery.GetBool(JS_KEEP_FUNCTIONS);
                ProjectManager.Instance.FireProjectUpdated(true);
                LayoutManager.Instance.InitializeActiveLayout();
            }
        }
Ejemplo n.º 3
0
        private void AdjustLayoutSettings(bool bCreateNew, ProjectLayout zLayout)
        {
            var zQuery = new QueryPanelDialog("Resize Layout", 450, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            const string LAYOUT_NAME     = "layoutName";
            const string CENTER_ELEMENTS = "centerElements";
            const string WIDTH           = "width";
            const string HEIGHT          = "height";

            if (bCreateNew)
            {
                zQuery.AddTextBox("Layout Name", zLayout.Name + " copy", false, LAYOUT_NAME);
            }
            zQuery.AddNumericBox("Width", zLayout.width, 1, int.MaxValue, WIDTH);
            zQuery.AddNumericBox("Height", zLayout.height, 1, int.MaxValue, HEIGHT);
            zQuery.AddCheckBox("Center Elements", false, CENTER_ELEMENTS);

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var zLayoutAdjusted = bCreateNew ? new ProjectLayout(zQuery.GetString(LAYOUT_NAME)) : zLayout;

                var nOriginalWidth  = zLayout.width;
                var nOriginalHeight = zLayout.height;

                if (bCreateNew)
                {
                    zLayoutAdjusted.DeepCopy(zLayout);
                }

                zLayoutAdjusted.width  = (int)zQuery.GetDecimal(WIDTH);
                zLayoutAdjusted.height = (int)zQuery.GetDecimal(HEIGHT);

                if (zQuery.GetBool(CENTER_ELEMENTS) && null != zLayoutAdjusted.Element)
                {
                    var pointOldCenter = new Point(nOriginalWidth / 2, nOriginalHeight / 2);
                    var pointNewCenter = new Point(zLayoutAdjusted.width / 2, zLayoutAdjusted.height / 2);
                    var nXAdjust       = pointNewCenter.X - pointOldCenter.X;
                    var nYAdjust       = pointNewCenter.Y - pointOldCenter.Y;
                    foreach (var zElement in zLayoutAdjusted.Element)
                    {
                        zElement.x += nXAdjust;
                        zElement.y += nYAdjust;
                    }
                }

                UserAction.ClearUndoRedoStacks();

                if (bCreateNew)
                {
                    ProjectManager.Instance.AddLayout(zLayoutAdjusted);
                }
                else
                {
                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                }
            }
        }
Ejemplo n.º 4
0
        private static FileCardExporter BuildProjectExporter()
        {
            var zQuery = new QueryPanelDialog("Export to Images", 750, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);

            var sDefinition         = ProjectManager.Instance.LoadedProject.exportNameFormat; // default to the project level definition
            var nDefaultFormatIndex = GetLastFormatIndex();

            zQuery.AddPullDownBox("Format", s_arrayAllowedFormatNames, nDefaultFormatIndex, ExportOptionKey.Format);
            zQuery.AddCheckBox("Override Layout File Name Formats", false, ExportOptionKey.NameFormatOverride);
            zQuery.AddNumericBox("Stitch Skip Index", CardMakerSettings.ExportStitchSkipIndex, 0, 65535, 1, 0, ExportOptionKey.StitchSkipIndex);
            zQuery.AddTextBox("File Name Format (optional)", sDefinition ?? string.Empty, false, ExportOptionKey.NameFormat);
            // associated check box and the file format override text box
            zQuery.AddEnableControl(ExportOptionKey.NameFormatOverride, ExportOptionKey.NameFormat);
            zQuery.AddFolderBrowseBox("Output Folder",
                                      Directory.Exists(ProjectManager.Instance.LoadedProject.lastExportPath) ? ProjectManager.Instance.LoadedProject.lastExportPath : string.Empty,
                                      ExportOptionKey.Folder);
            zQuery.UpdateEnableStates();

            if (DialogResult.OK != zQuery.ShowDialog(CardMakerInstance.ApplicationForm))
            {
                return(null);
            }
            var sFolder = zQuery.GetString(ExportOptionKey.Folder);

            SetupExportFolder(sFolder);

            if (!Directory.Exists(sFolder))
            {
                FormUtils.ShowErrorMessage("The folder specified does not exist!");
                return(null);
            }

            ProjectManager.Instance.LoadedProject.lastExportPath = sFolder;
            var nStartLayoutIdx = 0;
            var nEndLayoutIdx   = ProjectManager.Instance.LoadedProject.Layout.Length;
            var bOverrideLayout = false;

            bOverrideLayout = zQuery.GetBool(ExportOptionKey.NameFormatOverride);

            CardMakerSettings.IniManager.SetValue(IniSettings.LastImageExportFormat, s_arrayAllowedFormatNames[zQuery.GetIndex(ExportOptionKey.Format)]);
            CardMakerSettings.ExportStitchSkipIndex = (int)zQuery.GetDecimal(ExportOptionKey.StitchSkipIndex);

            return(new FileCardExporter(nStartLayoutIdx, nEndLayoutIdx, sFolder, bOverrideLayout ? zQuery.GetString(ExportOptionKey.NameFormat) : null,
                                        CardMakerSettings.ExportStitchSkipIndex, s_arrayAllowedFormats[zQuery.GetIndex(ExportOptionKey.Format)]));
        }
Ejemplo n.º 5
0
        private void setNameFormatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string NAME               = "NAME";
            const string ROTATION           = "ROTATION";
            const string EXPORT_WIDTH       = "EXPORT_WIDTH";
            const string EXPORT_HEIGHT      = "EXPORT_HEIGHT";
            const string EXPORT_TRANSPARENT = "EXPORT_TRANSPARENT";

            Type   typeObj         = treeView.SelectedNode.Tag.GetType();
            string sExistingFormat = String.Empty;
            var    zQuery          = new QueryPanelDialog("Configure Layout Export", 550, 300, false);

            zQuery.SetIcon(Resources.CardMakerIcon);

            if (typeof(Project) == typeObj)
            {
                sExistingFormat = ((Project)treeView.SelectedNode.Tag).exportNameFormat;
            }
            else if (typeof(ProjectLayout) == typeObj)
            {
                var zProjectLayout = ((ProjectLayout)treeView.SelectedNode.Tag);

                sExistingFormat = zProjectLayout.exportNameFormat;
                var nDefaultRotationIndex =
                    Math.Max(0, ProjectLayout.AllowedExportRotations.ToList()
                             .IndexOf(zProjectLayout.exportRotation.ToString()));
                zQuery.AddPullDownBox("Export Rotation (Print/PDF/Export)", ProjectLayout.AllowedExportRotations,
                                      nDefaultRotationIndex, ROTATION);

                var nColumns = 0;
                var nRows    = 0;

                if (zProjectLayout.exportWidth > 0)
                {
                    var nWidth = zProjectLayout.width + zProjectLayout.buffer;
                    nColumns = zProjectLayout.exportWidth / nWidth;
                }

                if (zProjectLayout.exportHeight > 0)
                {
                    var nHeight = zProjectLayout.width + zProjectLayout.buffer;
                    nRows = zProjectLayout.exportHeight / nHeight;
                }

                var numericColumns = zQuery.AddNumericBox("Stitched Columns (changes export width)", nColumns, 0, 100, "COLUMNS");

                var numericRows = zQuery.AddNumericBox("Stitched Rows (changes export height)", nRows, 0, 100, "ROWS");

                var numericExportWidth = zQuery.AddNumericBox("Export Width", zProjectLayout.exportWidth,
                                                              0, 65536, EXPORT_WIDTH);
                var numericExportHeight = zQuery.AddNumericBox("Export Height", zProjectLayout.exportHeight,
                                                               0, 65536, EXPORT_HEIGHT);
                zQuery.AddCheckBox("Export Transparent Background", zProjectLayout.exportTransparentBackground,
                                   EXPORT_TRANSPARENT);

                numericColumns.ValueChanged += (o, args) =>
                {
                    numericExportWidth.Value = (zProjectLayout.width * numericColumns.Value) +
                                               Math.Max(0, (numericColumns.Value - 1) * zProjectLayout.buffer);
                };

                numericRows.ValueChanged += (o, args) =>
                {
                    numericExportHeight.Value = (zProjectLayout.height * numericRows.Value) +
                                                Math.Max(0, (numericRows.Value - 1) * zProjectLayout.buffer);
                };
            }

            zQuery.AddTextBox("Name Format", sExistingFormat ?? String.Empty, false, NAME);

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                if (typeof(Project) == typeObj)
                {
                    ((Project)treeView.SelectedNode.Tag).exportNameFormat = zQuery.GetString(NAME);
                }
                else if (typeof(ProjectLayout) == typeObj)
                {
                    var zProjectLayout = ((ProjectLayout)treeView.SelectedNode.Tag);
                    zProjectLayout.exportNameFormat            = zQuery.GetString(NAME);
                    zProjectLayout.exportRotation              = Int32.Parse(zQuery.GetString(ROTATION));
                    zProjectLayout.exportWidth                 = Int32.Parse(zQuery.GetString(EXPORT_WIDTH));
                    zProjectLayout.exportHeight                = Int32.Parse(zQuery.GetString(EXPORT_HEIGHT));
                    zProjectLayout.exportTransparentBackground = zQuery.GetBool(EXPORT_TRANSPARENT);
                }
                ProjectManager.Instance.FireProjectUpdated(true);
            }
        }
Ejemplo n.º 6
0
        private void ExportViaPDFSharp(bool bExportAllLayouts)
        {
            var zQuery = new QueryPanelDialog("Export to PDF (via PDFSharp)", 750, false);

            zQuery.SetIcon(Icon);
            const string ORIENTATION    = "orientation";
            const string OUTPUT_FILE    = "output_file";
            const string OPEN_ON_EXPORT = "open_on_export";

            zQuery.AddPullDownBox("Page Orientation",
                                  new string[]
            {
                PageOrientation.Portrait.ToString(),
                PageOrientation.Landscape.ToString()
            },
                                  m_nPdfExportLastOrientationIndex,
                                  ORIENTATION);

            zQuery.AddFileBrowseBox("Output File", m_sPdfExportLastFile, "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*", OUTPUT_FILE);
            zQuery.AddCheckBox("Open PDF on Export", m_bPdfExportLastOpen, OPEN_ON_EXPORT);

            if (DialogResult.OK != zQuery.ShowDialog(this))
            {
                return;
            }

            var nStartLayoutIdx = 0;
            var nEndLayoutIdx   = ProjectManager.Instance.LoadedProject.Layout.Length;

            if (!bExportAllLayouts)
            {
                int nIdx = ProjectManager.Instance.GetLayoutIndex(LayoutManager.Instance.ActiveLayout);
                if (-1 == nIdx)
                {
                    FormUtils.ShowErrorMessage("Unable to determine the current layout. Please select a layout in the tree view and try again.");
                    return;
                }
                nStartLayoutIdx = nIdx;
                nEndLayoutIdx   = nIdx + 1;
            }

            m_sPdfExportLastFile             = zQuery.GetString(OUTPUT_FILE);
            m_bPdfExportLastOpen             = zQuery.GetBool(OPEN_ON_EXPORT);
            m_nPdfExportLastOrientationIndex = zQuery.GetIndex(ORIENTATION);

            if (!m_sPdfExportLastFile.EndsWith(".pdf", StringComparison.CurrentCultureIgnoreCase))
            {
                m_sPdfExportLastFile += ".pdf";
            }

            var zFileCardExporter = new PdfSharpExporter(nStartLayoutIdx, nEndLayoutIdx, m_sPdfExportLastFile, zQuery.GetString(ORIENTATION));

            var zWait = new WaitDialog(
                2,
                zFileCardExporter.ExportThread,
                "Export",
                new string[] { "Layout", "Card" },
                450);

#if true
            zWait.ShowDialog(this);
#else
            zFileCardExporter.ExportThread();
#endif

            if (zWait.ThreadSuccess &&
                m_bPdfExportLastOpen &&
                File.Exists(m_sPdfExportLastFile))
            {
                Process.Start(m_sPdfExportLastFile);
            }
        }
Ejemplo n.º 7
0
        private void customHoritonalAlignButton_Click(object sender, EventArgs e)
        {
            if (!CheckAllSelectedElementsEnabled(true))
            {
                return;
            }

            var listSelectedElements = ElementManager.Instance.SelectedElements;

            if (listSelectedElements == null || listSelectedElements.Count == 0)
            {
                return;
            }

            const string HORIZONTAL_SPACING   = "horizontal_spacing";
            const string APPLY_ELEMENT_WIDTHS = "apply_element_widths";
            const string ELEMENT_CENTERING    = "element_centering";

            var zQuery = new QueryPanelDialog("Custom Horizontal Align Elements", 450, 150, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);

            zQuery.AddNumericBox("Horizontal Pixel Spacing", 0, int.MinValue, int.MaxValue, HORIZONTAL_SPACING);
            zQuery.AddCheckBox("Include Element Widths", false, APPLY_ELEMENT_WIDTHS);
            zQuery.AddPullDownBox("Vertical Centering", Enum.GetNames(typeof(ElementCenterAlign)), 0,
                                  ELEMENT_CENTERING);


            if (DialogResult.OK != zQuery.ShowDialog(CardMakerInstance.ApplicationForm))
            {
                return;
            }

            var nHorizontalSpace    = (int)zQuery.GetDecimal(HORIZONTAL_SPACING);
            var bApplyElementWidths = zQuery.GetBool(APPLY_ELEMENT_WIDTHS);
            var eCenterAlignment    = (ElementCenterAlign)zQuery.GetIndex(ELEMENT_CENTERING);

            // determine the centering
            var nCenterY = 0;

            switch (eCenterAlignment)
            {
            case ElementCenterAlign.FirstElement:
                nCenterY = listSelectedElements[0].y + (listSelectedElements[0].height / 2);
                break;

            case ElementCenterAlign.Layout:
                nCenterY = LayoutManager.Instance.ActiveLayout.height / 2;
                break;
            }

            var dictionaryOriginalPositions = ElementManager.Instance.GetUndoRedoPoints();

            // apply the translation
            var nX = listSelectedElements[0].x;

            for (var nIdx = 0; nIdx < listSelectedElements.Count; nIdx++)
            {
                var zElement = listSelectedElements[nIdx];
                zElement.x = nX;
                nX        += bApplyElementWidths ? zElement.width : 0;
                nX        += nHorizontalSpace;
                switch (eCenterAlignment)
                {
                case ElementCenterAlign.FirstElement:
                    if (0 < nIdx)
                    {
                        zElement.y = nCenterY - (zElement.width / 2);
                    }
                    break;

                case ElementCenterAlign.Layout:
                    zElement.y = nCenterY - (zElement.width / 2);
                    break;
                }
            }
            ElementManager.ConfigureUserAction(dictionaryOriginalPositions,
                                               ElementManager.Instance.GetUndoRedoPoints());

            ElementManager.Instance.FireElementBoundsUpdateEvent();
        }
Ejemplo n.º 8
0
        private void ExportImages(bool bExportAllLayouts)
        {
            var zQuery = new QueryPanelDialog("Export to Images", 750, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);
            const string FORMAT      = "FORMAT";
            const string NAME_FORMAT = "NAME_FORMAT";
            const string NAME_FORMAT_LAYOUT_OVERRIDE = "NAME_FORMAT_LAYOUT_OVERRIDE";
            const string FOLDER            = "FOLDER";
            const string STITCH_SKIP_INDEX = "DUMMY_IDX";
            var          arrayImageFormats = new ImageFormat[] {
                ImageFormat.Bmp,
                ImageFormat.Emf,
                ImageFormat.Exif,
                ImageFormat.Gif,
                ImageFormat.Icon,
                ImageFormat.Jpeg,
                ImageFormat.Png,
                ImageFormat.Tiff,
                ImageFormat.Wmf
            };
            var arrayImageFormatStrings = new string[arrayImageFormats.Length];

            for (int nIdx = 0; nIdx < arrayImageFormats.Length; nIdx++)
            {
                arrayImageFormatStrings[nIdx] = arrayImageFormats[nIdx].ToString();
            }


            var nDefaultFormatIndex = 0;
            var lastImageFormat     = CardMakerSettings.IniManager.GetValue(IniSettings.LastImageExportFormat, string.Empty);

            // TODO: .NET 4.x offers enum.parse... when the project gets to that version
            if (lastImageFormat != string.Empty)
            {
                for (int nIdx = 0; nIdx < arrayImageFormats.Length; nIdx++)
                {
                    if (arrayImageFormats[nIdx].ToString().Equals(lastImageFormat))
                    {
                        nDefaultFormatIndex = nIdx;
                        break;
                    }
                }
            }

            zQuery.AddPullDownBox("Format", arrayImageFormatStrings, nDefaultFormatIndex, FORMAT);

            var sDefinition = ProjectManager.Instance.LoadedProject.exportNameFormat; // default to the project level definition

            if (!bExportAllLayouts)
            {
                sDefinition = LayoutManager.Instance.ActiveLayout.exportNameFormat;
            }
            else
            {
                zQuery.AddCheckBox("Override Layout File Name Formats", false, NAME_FORMAT_LAYOUT_OVERRIDE);
            }

            zQuery.AddNumericBox("Stitch Skip Index", CardMakerSettings.ExportStitchSkipIndex, 0, 65535, 1, 0, STITCH_SKIP_INDEX);

            zQuery.AddTextBox("File Name Format (optional)", sDefinition ?? string.Empty, false, NAME_FORMAT);

            if (bExportAllLayouts)
            {
                // associated check box and the file format text box
                zQuery.AddEnableControl(NAME_FORMAT_LAYOUT_OVERRIDE, NAME_FORMAT);
            }
            zQuery.AddFolderBrowseBox("Output Folder", Directory.Exists(ProjectManager.Instance.LoadedProject.lastExportPath) ? ProjectManager.Instance.LoadedProject.lastExportPath : string.Empty, FOLDER);

            zQuery.UpdateEnableStates();

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                string sFolder = zQuery.GetString(FOLDER);
                if (!Directory.Exists(sFolder))
                {
                    try
                    {
                        Directory.CreateDirectory(sFolder);
                    }
                    catch (Exception e)
                    {
                        Logger.AddLogLine("Error creating folder {0}: {1}".FormatString(sFolder, e.Message));
                    }
                }
                if (Directory.Exists(sFolder))
                {
                    ProjectManager.Instance.LoadedProject.lastExportPath = sFolder;
                    var nStartLayoutIdx = 0;
                    var nEndLayoutIdx   = ProjectManager.Instance.LoadedProject.Layout.Length;
                    var bOverrideLayout = false;
                    if (!bExportAllLayouts)
                    {
                        int nIdx = ProjectManager.Instance.GetLayoutIndex(LayoutManager.Instance.ActiveLayout);
                        if (-1 == nIdx)
                        {
                            FormUtils.ShowErrorMessage("Unable to determine the current layout. Please select a layout in the tree view and try again.");
                            return;
                        }
                        nStartLayoutIdx = nIdx;
                        nEndLayoutIdx   = nIdx + 1;
                    }
                    else
                    {
                        bOverrideLayout = zQuery.GetBool(NAME_FORMAT_LAYOUT_OVERRIDE);
                    }

                    CardMakerSettings.IniManager.SetValue(IniSettings.LastImageExportFormat, arrayImageFormats[zQuery.GetIndex(FORMAT)].ToString());
                    CardMakerSettings.ExportStitchSkipIndex = (int)zQuery.GetDecimal(STITCH_SKIP_INDEX);

                    ICardExporter zFileCardExporter = new FileCardExporter(nStartLayoutIdx, nEndLayoutIdx, sFolder, bOverrideLayout, zQuery.GetString(NAME_FORMAT),
                                                                           (int)zQuery.GetDecimal(STITCH_SKIP_INDEX), arrayImageFormats[zQuery.GetIndex(FORMAT)]);
#if true
                    var zWait = new WaitDialog(
                        2,
                        zFileCardExporter.ExportThread,
                        "Export",
                        new string[] { "Layout", "Card" },
                        450);
                    zWait.ShowDialog(this);
#else // non threaded
                    zFileCardExporter.ExportThread();
#endif
                }
                else
                {
                    FormUtils.ShowErrorMessage("The folder specified does not exist!");
                }
            }
        }