コード例 #1
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void btnConfigureSize_Click(object sender, EventArgs e)
        {
            const string CARD_WIDTH  = "cardWidth";
            const string CARD_HEIGHT = "cardHeight";
            var          zQuery      = new QueryPanelDialog("CardMaker Settings", 450, 250, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            zQuery.SetMaxHeight(600);
            zQuery.AddPullDownBox("Unit of Measure", Enum.GetNames(typeof(MeasurementUnit)), (int)CardMakerSettings.PrintPageMeasurementUnit, IniSettings.PrintPageMeasurementUnit);
            zQuery.AddNumericBox("Width", 10, 0, int.MaxValue, 1, 2, CARD_WIDTH);
            zQuery.AddNumericBox("Height", 10, 0, int.MaxValue, 1, 2, CARD_HEIGHT);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                switch ((MeasurementUnit)zQuery.GetIndex(IniSettings.PrintPageMeasurementUnit))
                {
                case MeasurementUnit.Inch:
                    numericCardSetWidth.Value  = zQuery.GetDecimal(CARD_WIDTH) * numericCardSetDPI.Value;
                    numericCardSetHeight.Value = zQuery.GetDecimal(CARD_HEIGHT) * numericCardSetDPI.Value;
                    break;

                case MeasurementUnit.Millimeter:
                    numericCardSetWidth.Value  = (decimal)(MeasurementUtil.GetInchesFromMillimeter((double)zQuery.GetDecimal(CARD_WIDTH)) * (double)numericCardSetDPI.Value);
                    numericCardSetHeight.Value = (decimal)(MeasurementUtil.GetInchesFromMillimeter((double)zQuery.GetDecimal(CARD_HEIGHT)) * (double)numericCardSetDPI.Value);
                    break;

                case MeasurementUnit.Centimeter:
                    numericCardSetWidth.Value  = (decimal)(MeasurementUtil.GetInchesFromCentimeter((double)zQuery.GetDecimal(CARD_WIDTH)) * (double)numericCardSetDPI.Value);
                    numericCardSetHeight.Value = (decimal)(MeasurementUtil.GetInchesFromCentimeter((double)zQuery.GetDecimal(CARD_HEIGHT)) * (double)numericCardSetDPI.Value);
                    break;
                }
            }
        }
コード例 #2
0
        private void addLayoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string NAME   = "name";
            const string WIDTH  = "width";
            const string HEIGHT = "height";
            const string DPI    = "dpi";

            var zQuery = new QueryPanelDialog("New Layout", 450, false);

            zQuery.SetIcon(Resources.CardMakerIcon);
            zQuery.AddTextBox("Name", "New Layout", false, NAME);
            zQuery.AddNumericBox("Width", 300, 1, Int32.MaxValue, WIDTH);
            zQuery.AddNumericBox("Height", 300, 1, Int32.MaxValue, HEIGHT);
            zQuery.AddNumericBox("DPI", 300, 100, 9600, DPI);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var zLayout = new ProjectLayout(zQuery.GetString(NAME))
                {
                    width  = (int)zQuery.GetDecimal(WIDTH),
                    height = (int)zQuery.GetDecimal(HEIGHT),
                    dpi    = (int)zQuery.GetDecimal(DPI)
                };
                ProjectManager.Instance.AddLayout(zLayout);
                ProjectManager.Instance.FireProjectUpdated(true);
            }
        }
コード例 #3
0
        private void projectSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string TRANSLATOR = "translator";
            const string DEFAULT_DEFINE_REFERENCE_TYPE = "default_define_reference_type";
            const string OVERRIDE_DEFINE_REFRENCE_NAME = "override_define_reference_name";

            var zQuery = new QueryPanelDialog("Project Settings", 450, 200, false);

            zQuery.SetIcon(Resources.CardMakerIcon);

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

            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.AddTextBox(
                "Google Project Define Spreadsheet override",
                ProjectManager.Instance.LoadedProject.overrideDefineReferenceName,
                false,
                OVERRIDE_DEFINE_REFRENCE_NAME);

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                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.FireProjectUpdated(true);
                LayoutManager.Instance.InitializeActiveLayout();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
ファイル: MDIProject.cs プロジェクト: ral182/cardmaker
        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);
                }
            }
        }
コード例 #6
0
ファイル: MDICanvas.cs プロジェクト: imshady2020/cardmaker
        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();
        }
コード例 #7
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void btnDuplicate_Click(object sender, EventArgs e)
        {
            if (0 == listViewElements.SelectedItems.Count)
            {
                return;
            }

            const string ELEMNAME = "ELEMNAME";
            var          zQuery   = new QueryPanelDialog("Duplicate Element", 400, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);
            zQuery.AddLabel("Duplicate Element Names are broken up by a line.", 24);
            zQuery.AddMultiLineTextBox("Element Name(s)", string.Empty, 200, ELEMNAME);
            if (1 < listViewElements.SelectedItems.Count)
            {
                zQuery.Form.Closing += (o, args) =>
                {
                    if (zQuery.Form.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    var arrayNames = zQuery.GetString(ELEMNAME)
                                     .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    if (arrayNames.Length != listViewElements.SelectedItems.Count)
                    {
                        MessageBox.Show(zQuery.Form,
                                        $"Please specify {listViewElements.SelectedItems.Count} element names.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        args.Cancel = true;
                    }
                };
            }

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                string[] arrayNames = zQuery.GetString(ELEMNAME)
                                      .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                if (1 == listViewElements.SelectedItems.Count)
                {
                    AddElements(arrayNames, (ProjectLayoutElement)listViewElements.SelectedItems[0].Tag);
                }
                else if (arrayNames.Length == listViewElements.SelectedIndices.Count)
                {
                    var listIndicies = new List <int>();
                    foreach (int nIdx in listViewElements.SelectedIndices)
                    {
                        listIndicies.Add(nIdx);
                    }
                    listIndicies.Sort();
                    for (var nIdx = 0; nIdx < arrayNames.Length; nIdx++)
                    {
                        AddElements(new string[] { arrayNames[nIdx] }, (ProjectLayoutElement)listViewElements.Items[listIndicies[nIdx]].Tag);
                    }
                }
            }
        }
コード例 #8
0
        private void addCardLayoutFromTemplateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string TEMPLATE          = "template";
            const string NAME              = "name";
            const string COUNT             = "count";
            var          listTemplateNames = new List <string>();

            LayoutTemplateManager.Instance.LayoutTemplates.ForEach(x => listTemplateNames.Add(x.ToString()));

            var zQuery = new QueryPanelDialog("Select Layout Template", 600, false);

            zQuery.SetIcon(Resources.CardMakerIcon);
            zQuery.AddTextBox("New Layout Name", "New Layout", false, NAME);
            zQuery.AddNumericBox("Number to create", 1, 1, 256, COUNT);
            var zTxtFilter        = zQuery.AddTextBox("Template Filter", string.Empty, false, TEMPLATE + NAME);
            var zListBoxTemplates = zQuery.AddListBox("Template", listTemplateNames.ToArray(), null, false, 240, TEMPLATE);

            zListBoxTemplates.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left;
            zTxtFilter.TextChanged  += (o, args) =>
            {
                var txtBox = (TextBox)o;
                zListBoxTemplates.Items.Clear();
                if (string.IsNullOrWhiteSpace(txtBox.Text))
                {
                    listTemplateNames.ForEach(zTemplate => zListBoxTemplates.Items.Add(zTemplate));
                }
                else
                {
                    listTemplateNames.Where(sTemplateName => sTemplateName.ToLower().Contains(txtBox.Text.ToLower())).ToList().ForEach(zTemplate => zListBoxTemplates.Items.Add(zTemplate));
                }
            };

            zQuery.AllowResize();
            while (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var nSelectedIndex = listTemplateNames.IndexOf(zQuery.GetString(TEMPLATE));
                if (-1 == nSelectedIndex)
                {
                    MessageBox.Show("Please select a layout template");
                    continue;
                }

                ProjectLayout zSelectedLayout = LayoutTemplateManager.Instance.LayoutTemplates[nSelectedIndex].Layout;

                for (int nCount = 0; nCount < zQuery.GetDecimal(COUNT); nCount++)
                {
                    var zLayout = new ProjectLayout(zQuery.GetString(NAME));
                    zLayout.DeepCopy(zSelectedLayout);
                    ProjectManager.Instance.AddLayout(zLayout);
                }
                break;
            }
        }
コード例 #9
0
ファイル: MDILayoutControl.cs プロジェクト: xetra11/cardmaker
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (0 < m_listClipboardElements.Count)
            {
                Dictionary <string, ProjectLayoutElement> dictionaryExistingElements = null;
                if (null != LayoutManager.Instance.ActiveLayout.Element)
                {
                    dictionaryExistingElements = LayoutManager.Instance.ActiveLayout.Element.ToDictionary(x => x.name);
                }

                if (dictionaryExistingElements != null)
                {
                    if (m_listClipboardElements.Exists(
                            zElement => dictionaryExistingElements.ContainsKey(zElement.name)))
                    {
                        const string ELEMENT_NAMES = "ELEMENT_NAMES";
                        var          zQuery        = new QueryPanelDialog("Duplicate Elements Rename", 400, false);
                        zQuery.SetIcon(Properties.Resources.CardMakerIcon);
                        zQuery.AddLabel("Each line has the name of an element to be pasted.", 24);
                        zQuery.AddLabel("Duplicated element names are marked with *", 24);
                        zQuery.AddMultiLineTextBox("Element Name(s)",
                                                   string.Join(Environment.NewLine, m_listClipboardElements.Select(zElement =>
                        {
                            return(zElement.name + (dictionaryExistingElements.ContainsKey(zElement.name) ? "*" : ""));
                        }).ToList()),
                                                   200,
                                                   ELEMENT_NAMES);

                        if (DialogResult.OK == zQuery.ShowDialog(this))
                        {
                            var arrayNames = zQuery.GetString(ELEMENT_NAMES)
                                             .Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            if (arrayNames.Length != m_listClipboardElements.Count)
                            {
                                MessageBox.Show(zQuery.Form,
                                                "The number of elements names does not match the clipboard. Cancelling paste.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }

                            for (var nIdx = 0; nIdx < m_listClipboardElements.Count; nIdx++)
                            {
                                AddElements(new string[] { arrayNames [nIdx] }, m_listClipboardElements[nIdx]);
                            }
                        }
                        return;
                    }
                }
                m_listClipboardElements.ForEach(x => AddElements(new string[] { x.name }, x));
            }
        }
コード例 #10
0
        private static FileCardExporter BuildLayoutExporter()
        {
            var zQuery = new QueryPanelDialog("Export to Images", 750, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);

            var sDefinition         = LayoutManager.Instance.ActiveLayout.exportNameFormat;
            var nDefaultFormatIndex = GetLastFormatIndex();


            zQuery.AddPullDownBox("Format", s_arrayAllowedFormatNames, nDefaultFormatIndex, ExportOptionKey.Format);
            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);
            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 nLayoutIndex = ProjectManager.Instance.GetLayoutIndex(LayoutManager.Instance.ActiveLayout);

            if (-1 == nLayoutIndex)
            {
                FormUtils.ShowErrorMessage("Unable to determine the current layout. Please select a layout in the tree view and try again.");
                return(null);
            }

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

            return(new FileCardExporter(nLayoutIndex, nLayoutIndex + 1, sFolder, zQuery.GetString(ExportOptionKey.NameFormat),
                                        CardMakerSettings.ExportStitchSkipIndex, s_arrayAllowedFormats[zQuery.GetIndex(ExportOptionKey.Format)]));
        }
コード例 #11
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void btnScale_Click(object sender, EventArgs e)
        {
            var          zQuery        = new QueryPanelDialog("Resize Elements", 500, false);
            const string WIDTH_ADJUST  = "widthadjust";
            const string HEIGHT_ADJUST = "heightadjust";

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            zQuery.AddNumericBox("Width Scale", 1, 0.001m, 1000, 0.001m, 3, WIDTH_ADJUST);
            zQuery.AddNumericBox("Height Scale", 1, 0.001m, 1000, 0.001m, 3, HEIGHT_ADJUST);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var dWidthAdjust  = zQuery.GetDecimal(WIDTH_ADJUST);
                var dHeightAdjust = zQuery.GetDecimal(HEIGHT_ADJUST);
                ElementManager.Instance.ProcessSelectedElementsChange(0, 0, 0, 0, dWidthAdjust, dHeightAdjust);
            }
        }
コード例 #12
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)]));
        }
コード例 #13
0
        private void btnElementRename_Click(object sender, EventArgs e)
        {
            if (1 != listViewElements.SelectedItems.Count)
            {
                return;
            }
            const string NAME     = "NAME";
            var          zElement = (ProjectLayoutElement)listViewElements.SelectedItems[0].Tag;

            if (!string.IsNullOrEmpty(zElement.layoutreference))
            {
                MessageBox.Show(this, "You cannot rename a Reference Element.", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            var zQuery = new QueryPanelDialog("Rename", 350, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);
            zQuery.AddTextBox("Name: ", zElement.name, false, NAME);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                string sName = zQuery.GetString(NAME).Trim();
                if (!m_dictionaryItems.ContainsKey(sName))
                {
                    // UserAction
                    var lvItem    = listViewElements.SelectedItems[0];
                    var sRedoName = sName;
                    var sUndoName = zElement.name;
                    UserAction.PushAction(bRedo =>
                    {
                        string sOldName = bRedo ? sUndoName : sRedoName;
                        string sNewName = bRedo ? sRedoName : sUndoName;

                        RenameElement(zElement, lvItem, sOldName, sNewName);
                    });

                    RenameElement(zElement, lvItem, zElement.name, sName);

                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                }
                else
                {
                    MessageBox.Show(this, "The new name already exists!", "Duplicate Name", MessageBoxButtons.OK);
                }
            }
        }
コード例 #14
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void btnAddElement_Click(object sender, EventArgs e)
        {
            const string ELEMNAME = "ELEMNAME";
            var          zQuery   = new QueryPanelDialog("Add Element", 400, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);
            zQuery.AddLabel("Element Names are broken up by a line.", 24);
            zQuery.AddMultiLineTextBox("Element Name(s)", string.Empty, 200, ELEMNAME);

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var arrayNames = zQuery.GetString(ELEMNAME).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                if (0 < arrayNames.Length)
                {
                    AddElements(arrayNames, null);
                    ChangeSelectedElement(arrayNames[0]);
                }
            }
        }
コード例 #15
0
ファイル: KeyCaptureConfig.cs プロジェクト: nhmkdev/KeyCap
        private void btnAddOutputString_Click(object sender, EventArgs e)
        {
            const string MACRO_STRING_KEY = "macro_string_key";
            var          zQuery           = new QueryPanelDialog("Enter String Macro", 400, false);

            zQuery.SetIcon(this.Icon);
            zQuery.AddTextBox("String", string.Empty, false, MACRO_STRING_KEY);
            if (DialogResult.OK != zQuery.ShowDialog(this))
            {
                return;
            }
            var sMacro = zQuery.GetString(MACRO_STRING_KEY);

            if (string.IsNullOrWhiteSpace(sMacro))
            {
                MessageBox.Show(this, "Please specify a string of output characters.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var zCurrentInputConfig = (InputConfig)txtKeyIn.Tag;

            if (null == zCurrentInputConfig)
            {
                ShowKeysNotDefinedError();
                return;
            }

            try
            {
                var zRemapEntry = new RemapEntry(zCurrentInputConfig, CreateOutputConfigFromCharacter(sMacro[0]));
                for (var nIdx = 1; nIdx < sMacro.Length; nIdx++)
                {
                    zRemapEntry.AppendOutputConfig(CreateOutputConfigFromCharacter(sMacro[nIdx]));
                }
                if (!IsInputAlreadyDefined(zRemapEntry))
                {
                    AddRemapEntryToListView(zRemapEntry, true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Unfortunately you have specified an unsupported character (at this time)." + ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #16
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";

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

            zQuery.SetIcon(Resources.CardMakerIcon);

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

            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(GoogleReferenceReader.APP_NAME, GoogleReferenceReader.CLIENT_ID,
                                                        CardMakerInstance.GoogleAccessToken, false));
                }
                return(null);
            },
                (zGoogleSpreadsheetBrowser, txtOverride) => { txtOverride.Text = zGoogleSpreadsheetBrowser.SelectedSpreadsheet.Title.Text; },
                OVERRIDE_DEFINE_REFRENCE_NAME);

            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.FireProjectUpdated(true);
                LayoutManager.Instance.InitializeActiveLayout();
            }
        }
コード例 #17
0
        private void projectSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string TRANSLATOR = "translator";

            var zQuery = new QueryPanelDialog("Project Settings", 450, 200, false);

            zQuery.SetIcon(Resources.CardMakerIcon);

            TranslatorType eTranslator = ProjectManager.Instance.LoadedProjectTranslatorType;

            zQuery.AddPullDownBox("Translator",
                                  new string[] { TranslatorType.Incept.ToString(), TranslatorType.JavaScript.ToString() }, (int)eTranslator, TRANSLATOR);

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                ProjectManager.Instance.LoadedProject.translatorName = ((TranslatorType)zQuery.GetIndex(TRANSLATOR)).ToString();
                ProjectManager.Instance.FireProjectUpdated(true);
                LayoutManager.Instance.InitializeActiveLayout();
            }
        }
コード例 #18
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void btnGenCards_Click(object sender, EventArgs e)
        {
            if (LayoutManager.Instance.ActiveDeck.CardLayout.Reference != null &&
                LayoutManager.Instance.ActiveDeck.CardLayout.Reference.Length > 0)
            {
                FormUtils.ShowErrorMessage("You cannot assign a default card count to a layout with an associated reference.");
                return;
            }
            const string CARD_COUNT = "CARD_COUNT";
            var          zQuery     = new QueryPanelDialog("Default Card Count", 240, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            zQuery.AddNumericBox("Card Count", LayoutManager.Instance.ActiveDeck.CardLayout.defaultCount, 1, int.MaxValue, CARD_COUNT);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                LayoutManager.Instance.ActiveLayout.defaultCount = (int)zQuery.GetDecimal(CARD_COUNT);
                LayoutManager.Instance.InitializeActiveLayout();
                LayoutManager.Instance.FireLayoutUpdatedEvent(true);
            }
        }
コード例 #19
0
        private void defineAsTemplateLayoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string NAME = "name";
            //const string COPY_REFS = "copy_refs";
            var zQuery = new QueryPanelDialog("Template Name", 450, 80, false);

            zQuery.SetIcon(Resources.CardMakerIcon);
            zQuery.AddTextBox("Name", "New Template", false, NAME);
            // TODO: is there really a case where the refs should be copied?
            //zQuery.AddCheckBox("Copy References", false, COPY_REFS);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var zLayout = new ProjectLayout();
                zLayout.DeepCopy((ProjectLayout)treeView.SelectedNode.Tag, /*zQuery.GetBool(COPY_REFS)*/ false);
                var zTemplate = new LayoutTemplate(zQuery.GetString(NAME), zLayout);
                if (LayoutTemplateManager.Instance.SaveLayoutTemplate(CardMakerInstance.StartupPath, zTemplate))
                {
                    LayoutTemplateManager.Instance.LayoutTemplates.Add(zTemplate);
                }
            }
        }
コード例 #20
0
ファイル: CardMakerMDI.cs プロジェクト: codeisgood1/cardmaker
        private void removeLayoutTemplatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string TEMPLATE  = "template";
            var          listItems = new List <string>();

            LayoutTemplateManager.Instance.LayoutTemplates.ForEach(x => listItems.Add(x.ToString()));

            var zQuery = new QueryPanelDialog("Remove Layout Templates", 450, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);
            zQuery.AddLabel("Select the templates to remove.", 20);
            zQuery.AddListBox("Templates", listItems.ToArray(), null, true, 240, TEMPLATE)
            .Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            zQuery.AllowResize();
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var arrayRemove = zQuery.GetIndices(TEMPLATE);
                if (0 == arrayRemove.Length)
                {
                    return;
                }
                var trimmedList = new List <LayoutTemplate>();
                int removalIdx  = 0;
                List <LayoutTemplate> listOldTemplates = LayoutTemplateManager.Instance.LayoutTemplates;
                for (int nIdx = 0; nIdx < listOldTemplates.Count; nIdx++)
                {
                    if (removalIdx < arrayRemove.Length && nIdx == arrayRemove[removalIdx])
                    {
                        removalIdx++;
                        // delete failures are logged
                        LayoutTemplateManager.Instance.DeleteLayoutTemplate(CardMakerInstance.StartupPath, listOldTemplates[nIdx]);
                    }
                    else
                    {
                        trimmedList.Add(listOldTemplates[nIdx]);
                    }
                }
                LayoutTemplateManager.Instance.LayoutTemplates = trimmedList;
            }
        }
コード例 #21
0
        private void addCardLayoutFromTemplateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string TEMPLATE  = "template";
            const string NAME      = "name";
            const string COUNT     = "count";
            var          listItems = new List <string>();

            LayoutTemplateManager.Instance.LayoutTemplates.ForEach(x => listItems.Add(x.ToString()));

            var zQuery = new QueryPanelDialog("Select Layout Template", 450, false);

            zQuery.SetIcon(Resources.CardMakerIcon);
            zQuery.AddTextBox("New Layout Name", "New Layout", false, NAME);
            zQuery.AddNumericBox("Number to create", 1, 1, 256, COUNT);
            zQuery.AddListBox("Template", listItems.ToArray(), null, false, 120, TEMPLATE);
            zQuery.AllowResize();
            while (DialogResult.OK == zQuery.ShowDialog(this))
            {
                int nSelectedIndex = zQuery.GetIndex(TEMPLATE);
                if (-1 == nSelectedIndex)
                {
                    MessageBox.Show("Please select a layout template");
                    continue;
                }

                ProjectLayout zSelectedLayout = LayoutTemplateManager.Instance.LayoutTemplates[nSelectedIndex].Layout;

                for (int nCount = 0; nCount < zQuery.GetDecimal(COUNT); nCount++)
                {
                    var zLayout = new ProjectLayout(zQuery.GetString(NAME));
                    zLayout.DeepCopy(zSelectedLayout);
                    ProjectManager.Instance.AddLayout(zLayout);
                }
                break;
            }
        }
コード例 #22
0
        private void illegalFilenameCharacterReplacementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var zQuery = new QueryPanelDialog("Illegal File Name Character Replacement", 350, false);

            zQuery.SetIcon(Properties.Resources.CardMakerIcon);
            var arrayBadChars         = FilenameTranslator.DISALLOWED_FILE_CHARS_ARRAY;
            var arrayReplacementChars = CardMakerSettings.IniManager.GetValue(IniSettings.ReplacementChars, string.Empty).Split(new char[] { CardMakerConstants.CHAR_FILE_SPLIT });

            if (arrayReplacementChars.Length == FilenameTranslator.DISALLOWED_FILE_CHARS_ARRAY.Length)
            {
                // from ini
                for (int nIdx = 0; nIdx < arrayBadChars.Length; nIdx++)
                {
                    zQuery.AddTextBox(arrayBadChars[nIdx].ToString(CultureInfo.InvariantCulture), arrayReplacementChars[nIdx], false, nIdx.ToString(CultureInfo.InvariantCulture));
                }
            }
            else
            {
                // default
                for (int nIdx = 0; nIdx < arrayBadChars.Length; nIdx++)
                {
                    zQuery.AddTextBox(arrayBadChars[nIdx].ToString(CultureInfo.InvariantCulture), string.Empty, false, nIdx.ToString(CultureInfo.InvariantCulture));
                }
            }
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var zBuilder = new StringBuilder();
                for (int nIdx = 0; nIdx < arrayBadChars.Length; nIdx++)
                {
                    zBuilder.Append(zQuery.GetString(nIdx.ToString(CultureInfo.InvariantCulture)) + CardMakerConstants.CHAR_FILE_SPLIT);
                }
                zBuilder.Remove(zBuilder.Length - 1, 1); // remove last char
                CardMakerSettings.IniManager.SetValue(IniSettings.ReplacementChars, zBuilder.ToString());
                RestoreReplacementChars();
            }
        }
コード例 #23
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);
            }
        }
コード例 #24
0
        private void btnAssist_Click(object sender, EventArgs e)
        {
            contextMenuStripAssist.Items.Clear();
            // NOTE: if there is ever a third scripting language (hopefully not) break this kind of logic out into the Translator classes
#warning this is a bit of a hack, this kind of logic should be handled by the translator
            if (TranslatorType.Incept == ProjectManager.Instance.LoadedProjectTranslatorType)
            {
                contextMenuStripAssist.Items.Add("Add Empty", null, (os, ea) => InsertVariableText("#empty"));
                contextMenuStripAssist.Items.Add("No Draw", null, (os, ea) => InsertVariableText("#nodraw"));
                contextMenuStripAssist.Items.Add("Add If Statement", null,
                                                 (os, ea) => InsertVariableText("#(if x == y then a)#"));
                contextMenuStripAssist.Items.Add("Add If Else Statement", null,
                                                 (os, ea) => InsertVariableText("#(if x == y then a else b)#"));
                contextMenuStripAssist.Items.Add("Add Switch Statement", null,
                                                 (os, ea) =>
                                                 InsertVariableText("#(switch;key;keytocheck1;value1;keytocheck2;value2;#default;#empty)#"));
                switch ((ElementType)comboElementType.SelectedIndex)
                {
                case ElementType.FormattedText:
                    contextMenuStripAssist.Items.Add("Add New Line", null, (os, ea) => InsertVariableText("<br>"));
                    contextMenuStripAssist.Items.Add("Add Quote (\")", null, (os, ea) => InsertVariableText("<q>"));
                    contextMenuStripAssist.Items.Add("Add Comma", null, (os, ea) => InsertVariableText("<c>"));
                    break;

                case ElementType.Text:
                    contextMenuStripAssist.Items.Add("Add Counter...", null, (os, ea) =>
                    {
                        var zQuery = new QueryPanelDialog("Add Counter", 450, false);
                        zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
                        const string INIT_VALUE = "initialValue";
                        const string MULT_VALUE = "multValue";
                        const string PAD_VALUE  = "padValue";
                        zQuery.AddNumericBox("Initial Value", 1, int.MinValue, int.MaxValue, INIT_VALUE);
                        zQuery.AddNumericBox("Multiplier Value", 1, int.MinValue, int.MaxValue, MULT_VALUE);
                        zQuery.AddNumericBox("Left 0 Padding", 0, int.MinValue, int.MaxValue, PAD_VALUE);
                        if (DialogResult.OK == zQuery.ShowDialog(this))
                        {
                            InsertVariableText("##" +
                                               zQuery.GetDecimal(INIT_VALUE) + ";" +
                                               zQuery.GetDecimal(MULT_VALUE) + ";" +
                                               zQuery.GetDecimal(PAD_VALUE) + "#");
                        }
                    });
                    contextMenuStripAssist.Items.Add("Add New Line", null, (os, ea) => InsertVariableText("\\n"));
                    contextMenuStripAssist.Items.Add("Add Quote (\")", null, (os, ea) => InsertVariableText("\\q"));
                    contextMenuStripAssist.Items.Add("Add Comma", null, (os, ea) => InsertVariableText("\\c"));
                    break;

                case ElementType.Graphic:
                    contextMenuStripAssist.Items.Add("Add Draw No Image", null,
                                                     (os, ea) => InsertVariableText("none"));
                    break;

                case ElementType.Shape:
                    break;
                }
            }
            else if (TranslatorType.JavaScript == ProjectManager.Instance.LoadedProjectTranslatorType)
            {
                contextMenuStripAssist.Items.Add("Add Empty", null, (os, ea) => InsertVariableText("'#empty'"));
                contextMenuStripAssist.Items.Add("No Draw", null, (os, ea) => InsertVariableText("'#nodraw'"));
                contextMenuStripAssist.Items.Add("Add If Statement", null,
                                                 (os, ea) => InsertVariableText(string.Format("if(x == y){0}{{{0}{0}}}", Environment.NewLine)));
                contextMenuStripAssist.Items.Add("Add If Else Statement", null,
                                                 (os, ea) => InsertVariableText(string.Format("if(x == y){0}{{{0}{0}}}{0}else{0}{{{0}{0}}}", Environment.NewLine)));
                contextMenuStripAssist.Items.Add("Add Switch Statement", null,
                                                 (os, ea) =>
                                                 InsertVariableText(string.Format("switch(key){0}{{{0}case keytocheck1:{0}\tvalue1;{0}}}", Environment.NewLine)));
                switch ((ElementType)comboElementType.SelectedIndex)
                {
                case ElementType.FormattedText:
                    contextMenuStripAssist.Items.Add("Add New Line", null, (os, ea) => InsertVariableText("<br>"));
                    contextMenuStripAssist.Items.Add("Add Quote (\")", null, (os, ea) => InsertVariableText("<q>"));
                    contextMenuStripAssist.Items.Add("Add Comma", null, (os, ea) => InsertVariableText("<c>"));
                    break;

                case ElementType.Text:
                    contextMenuStripAssist.Items.Add("Add New Line", null, (os, ea) => InsertVariableText("\\\\n"));
                    contextMenuStripAssist.Items.Add("Add Quote (\")", null, (os, ea) => InsertVariableText("\\\\q"));
                    contextMenuStripAssist.Items.Add("Add Comma", null, (os, ea) => InsertVariableText("\\\\c"));
                    break;

                case ElementType.Graphic:
                    contextMenuStripAssist.Items.Add("Add Draw No Image", null,
                                                     (os, ea) => InsertVariableText("none"));
                    break;

                case ElementType.Shape:
                    break;
                }
            }
            contextMenuStripAssist.Show(btnAssist, new Point(btnAssist.Width, 0), ToolStripDropDownDirection.AboveLeft);
        }
コード例 #25
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);
            }
        }
コード例 #26
0
ファイル: MDICanvas.cs プロジェクト: imshady2020/cardmaker
        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();
        }
コード例 #27
0
        /// <summary>
        /// Displays the adjust layout dialog (for scaling primarily)
        /// </summary>
        /// <param name="bCreateNew">Flag indicating that a copy of the specified layout should be created.</param>
        /// <param name="zLayout">The base layout to adjust or duplicate</param>
        public static void ShowAdjustLayoutSettingsDialog(bool bCreateNew, ProjectLayout zLayout, Form zParentForm)
        {
            var zQuery = new QueryPanelDialog(bCreateNew ? "Duplicate Layout (Custom)" : "Resize Layout", 450, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            const string LAYOUT_NAME = "layoutName";

            const string RESIZE_ADJUST_DIMENSIONS = "Dimensions";
            const string RESIZE_ADJUST_SCALE      = "Scale";
            const string RESIZE_ADJUST_DPI        = "DPI";
            const string RESIZE_ADJUST            = "resizeAdjust";

            const string ELEMENTS_ADJUST_NOTHING = "Nothing";
            const string ELEMENTS_ADJUST_SCALE   = "Scale";
            const string ELEMENTS_ADJUST_CENTER  = "Center";
            const string ELEMENTS_ADJUST         = "elementAdjust";
            const string DPI    = "dpi";
            const string SCALE  = "scale";
            const string WIDTH  = "width";
            const string HEIGHT = "height";

            var listMeasureUnits = new List <string>();

            listMeasureUnits.AddRange(Enum.GetNames(typeof(MeasurementUnit)));
            listMeasureUnits.Add(MeasurementUtil.PIXEL);

            if (bCreateNew)
            {
                zQuery.AddTextBox("Layout Name", zLayout.Name + " copy", false, LAYOUT_NAME);
            }
            // intentionall start the index as non-zero
            var comboResizeType = zQuery.AddPullDownBox("Resize Type", new string[] { RESIZE_ADJUST_DIMENSIONS, RESIZE_ADJUST_SCALE, RESIZE_ADJUST_DPI }, 0, RESIZE_ADJUST);

            zQuery.AddLabel("Note: The DPI is only adjusted if DPI Resize Type is used.", 18);
            zQuery.AddVerticalSpace(10);
            var comboUnitMeasure = zQuery.AddPullDownBox("Unit of Measure",
                                                         listMeasureUnits.ToArray(),
                                                         (int)CardMakerSettings.PrintPageMeasurementUnit,
                                                         IniSettings.PrintPageMeasurementUnit);

            // beware of the minimums as things like measurements definitely can be very small (<1)
            var numericWidth  = zQuery.AddNumericBox("Width", 1, 0.001m, int.MaxValue, 1, 3, WIDTH);
            var numericHeight = zQuery.AddNumericBox("Height", 1, 0.001m, int.MaxValue, 1, 3, HEIGHT);
            var numericDPI    = zQuery.AddNumericBox("Export DPI (Scales)", zLayout.dpi, 100, int.MaxValue, DPI);
            var numericScale  = zQuery.AddNumericBox("Scale", 1, 0.01m, int.MaxValue, 0.01m, 3, SCALE);

            EventHandler zComboUnitMeasureAction = (sender, args) =>
            {
                decimal dWidth, dHeight;
                MeasurementUtil.GetMeasurement(zLayout.width, zLayout.height, zLayout.dpi, comboUnitMeasure.Text, out dWidth, out dHeight);
                numericWidth.Value  = dWidth;
                numericHeight.Value = dHeight;
            };

            comboUnitMeasure.SelectedIndexChanged += zComboUnitMeasureAction;
            zComboUnitMeasureAction.Invoke(null, null);

            EventHandler zComboResizeTypeAction = (sender, args) =>
            {
                switch (comboResizeType.Text)
                {
                case RESIZE_ADJUST_DIMENSIONS:
                    comboUnitMeasure.Enabled = numericWidth.Enabled = numericHeight.Enabled = true;
                    numericDPI.Enabled       = numericScale.Enabled = false;
                    break;

                case RESIZE_ADJUST_SCALE:
                    comboUnitMeasure.SelectedIndex = listMeasureUnits.Count - 1;     // pixel index
                    numericScale.Enabled           = true;
                    comboUnitMeasure.Enabled       = numericDPI.Enabled = numericWidth.Enabled = numericHeight.Enabled = false;
                    break;

                case RESIZE_ADJUST_DPI:
                    comboUnitMeasure.SelectedIndex = listMeasureUnits.Count - 1;     // pixel index
                    numericDPI.Enabled             = true;
                    comboUnitMeasure.Enabled       = numericScale.Enabled = numericWidth.Enabled = numericHeight.Enabled = false;
                    break;
                }
            };

            comboResizeType.SelectedIndexChanged += zComboResizeTypeAction;
            zComboResizeTypeAction.Invoke(null, null);

            numericScale.ValueChanged += (sender, e) =>
            {
                var dScale = numericScale.Value / 1m;
                numericWidth.Value  = (int)Math.Max(numericWidth.Minimum, ((decimal)zLayout.width * dScale));
                numericHeight.Value = (int)Math.Max(numericHeight.Minimum, ((decimal)zLayout.height * dScale));
                // do not adjust the DPI in any mode but the DPI mode
                //numericDPI.Value = (int) Math.Max(numericDPI.Minimum, ((decimal) zLayout.dpi * dScale));
            };

            numericDPI.ValueChanged += (sender, e) =>
            {
                var dScale = (decimal)numericDPI.Value / (decimal)zLayout.dpi;
                numericWidth.Value  = (int)Math.Max(numericWidth.Minimum, ((decimal)zLayout.width * dScale));
                numericHeight.Value = (int)Math.Max(numericHeight.Minimum, ((decimal)zLayout.height * dScale));
                numericScale.Value  = Math.Max(numericScale.Minimum, (1m * dScale));
            };

            zQuery.AddVerticalSpace(10);
            zQuery.AddPullDownBox("Element Adjustment", new string[] { ELEMENTS_ADJUST_NOTHING, ELEMENTS_ADJUST_SCALE, ELEMENTS_ADJUST_CENTER }, 0, ELEMENTS_ADJUST);

            // remove the accept button so the enter key does not automatically accept/close the dialog
            zQuery.Form.AcceptButton = null;

            if (DialogResult.OK == zQuery.ShowDialog(zParentForm))
            {
                var listUserActions = new List <Action <bool> >();
                var zLayoutAdjusted = bCreateNew ? new ProjectLayout(zQuery.GetString(LAYOUT_NAME)) : zLayout;

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

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

                int nNewWidth, nNewHeight;
                var nNewDPI = nOriginalDPI;

                switch (comboResizeType.Text)
                {
                case RESIZE_ADJUST_DIMENSIONS:
                    MeasurementUtil.GetPixelMeasurement(zQuery.GetDecimal(WIDTH), zQuery.GetDecimal(HEIGHT), zLayout.dpi, comboUnitMeasure.Text, out nNewWidth, out nNewHeight);
                    break;

                case RESIZE_ADJUST_DPI:
                    nNewWidth  = (int)zQuery.GetDecimal(WIDTH);
                    nNewHeight = (int)zQuery.GetDecimal(HEIGHT);
                    // this is the only path where the DPI actually changes
                    nNewDPI = (int)zQuery.GetDecimal(DPI);
                    break;

                default:
                    nNewWidth  = (int)zQuery.GetDecimal(WIDTH);
                    nNewHeight = (int)zQuery.GetDecimal(HEIGHT);
                    break;
                }

                zLayoutAdjusted.width  = nNewWidth;
                zLayoutAdjusted.height = nNewHeight;
                zLayoutAdjusted.dpi    = nNewDPI;

                // create the user action for adjusting the layout settings
                listUserActions.Add((performAction) =>
                {
                    if (performAction)
                    {
                        zLayoutAdjusted.width  = nNewWidth;
                        zLayoutAdjusted.height = nNewHeight;
                        zLayoutAdjusted.dpi    = nNewDPI;
                    }
                    else
                    {
                        zLayoutAdjusted.width  = nOriginalWidth;
                        zLayoutAdjusted.height = nOriginalHeight;
                        zLayoutAdjusted.dpi    = nOriginalDPI;
                    }
                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                });

                var bProcessedElementChange = false;
                // create the user action for adjusting the elements
                if (zLayout.Element != null)
                {
                    switch (zQuery.GetString(ELEMENTS_ADJUST))
                    {
                    case ELEMENTS_ADJUST_CENTER:
                        var nXAdjust = (int)(zLayoutAdjusted.width / 2) - (int)(nOriginalWidth / 2);
                        var nYAdjust = (int)(zLayoutAdjusted.height / 2) - (int)(nOriginalHeight / 2);
                        ElementManager.ProcessElementsChange(zLayoutAdjusted.Element, nXAdjust, nYAdjust, 0, 0, 1, 1, true, listUserActions);
                        bProcessedElementChange = true;
                        break;

                    case ELEMENTS_ADJUST_SCALE:
                        var dHorizontalScale = (decimal)zLayoutAdjusted.width / (decimal)nOriginalWidth;
                        var dVerticalScale   = (decimal)zLayoutAdjusted.height / (decimal)nOriginalHeight;
                        ElementManager.ProcessElementsChange(zLayoutAdjusted.Element, 0, 0, 0, 0, dHorizontalScale, dVerticalScale, true, listUserActions);
                        bProcessedElementChange = true;
                        break;
                    }
                }
                if (!bProcessedElementChange)
                {
                    UserAction.PushActions(listUserActions);
                }

                if (bCreateNew)
                {
                    ProjectManager.Instance.AddLayout(zLayoutAdjusted);
                }
                else
                {
                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                }
            }
        }
コード例 #28
0
ファイル: CardMakerMDI.cs プロジェクト: ksuquix/cardmaker
        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!");
                }
            }
        }
コード例 #29
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void pasteSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (1 != m_listClipboardElements.Count)
            {
                return;
            }
            var zSourceElement = m_listClipboardElements[0];
            var zQuery         = new QueryPanelDialog("Apply Element Settings", 400, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            const string SETTINGS_TO_COPY = "settings_to_copy";

            // TODO: if this ever expands to more fields just use a dictionary.contains
            var listProperties = ProjectLayoutElement.SortedPropertyInfos.Where(x => !x.Name.Equals("name")).ToList();

            zQuery.AddLabel("Select the settings to apply to the selected Elements.", 40);
            zQuery.AddListBox("Settings to apply", listProperties.Select(x => x.Name).ToArray(), null, true, 400, SETTINGS_TO_COPY);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                var dictionaryNewElementValues  = new Dictionary <PropertyInfo, object>();
                var dictionaryOldElementsValues = new Dictionary <ProjectLayoutElement, Dictionary <PropertyInfo, object> >();
                // construct the set of values from the source element
                foreach (var nIdx in zQuery.GetIndices(SETTINGS_TO_COPY))
                {
                    dictionaryNewElementValues.Add(listProperties[nIdx], listProperties[nIdx].GetValue(zSourceElement, null));
                }
                // construct the set of values from the destination element(s)
                foreach (var zElement in ElementManager.Instance.SelectedElements)
                {
                    var dictionaryOldValues = new Dictionary <PropertyInfo, object>();
                    dictionaryOldElementsValues.Add(zElement, dictionaryOldValues);
                    foreach (var zEntry in dictionaryNewElementValues)
                    {
                        dictionaryOldValues.Add(zEntry.Key, zEntry.Key.GetValue(zElement, null));
                    }
                }

                UserAction.PushAction(bRedo =>
                {
                    CardMakerInstance.ProcessingUserAction = true;

                    foreach (var zElementToValue in dictionaryOldElementsValues)
                    {
                        foreach (var zEntry in zElementToValue.Value)
                        {
                            // pull the value from the old element dictionary or the source element
                            var zValue = bRedo ? dictionaryNewElementValues[zEntry.Key] : zEntry.Value;
                            zEntry.Key.SetValue(zElementToValue.Key, zValue, null);
                        }
                        // re-init any translated string values (colors/fonts)
                        // TODO: consider using an event for this kind of thing...
                        zElementToValue.Key.InitializeTranslatedFields();
                    }

                    CardMakerInstance.ProcessingUserAction = false;

                    // clear the deck cache so element translations are re-processed
                    LayoutManager.Instance.ActiveDeck.ResetDeckCache();
                    // trigger a re-select (this will cause the element window to update)
                    listViewElements_SelectedIndexChanged(null, null);
                    LayoutManager.Instance.FireLayoutUpdatedEvent(true);
                }, true);
            }
        }