Beispiel #1
0
 private void resize_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 Adjust", 0, -65536, 65536, WIDTH_ADJUST);
     zQuery.AddNumericBox("Height Adjust", 0, -65536, 65536, HEIGHT_ADJUST);
     if (DialogResult.OK == zQuery.ShowDialog(this))
     {
         var nWidthAdjust = (int)zQuery.GetDecimal(WIDTH_ADJUST);
         var nHeightAdjust = (int)zQuery.GetDecimal(HEIGHT_ADJUST);
         ElementManager.Instance.ProcessSelectedElementsChange(0, 0, nWidthAdjust, nHeightAdjust);
     }
 }
Beispiel #2
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);
        }
 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(CardMakerMDI.Instance.Icon);
     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);
         MDICanvas.Instance.ProcessSelectedElementsChange(0, 0, 0, 0, dWidthAdjust, dHeightAdjust);
     }
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
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!");
                }
            }
        }
 private void btnGenCards_Click(object sender, EventArgs e)
 {
     if (CardMakerMDI.Instance.DrawCardCanvas.ActiveDeck.CardLayout.Reference != null &&
         CardMakerMDI.Instance.DrawCardCanvas.ActiveDeck.CardLayout.Reference.Length > 0)
     {
         CardMakerMDI.Instance.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(CardMakerMDI.Instance.Icon);
     zQuery.AddNumericBox("Card Count", 10, 1, int.MaxValue, CARD_COUNT);
     if (DialogResult.OK == zQuery.ShowDialog(this))
     {
         MDIProject.Instance.GetCurrentProjectLayout().defaultCount = (int)zQuery.GetDecimal(CARD_COUNT);
         CardMakerMDI.Instance.RefreshLayout();
         CardMakerMDI.Instance.MarkDirty();
     }
 }
Beispiel #7
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);
                    AddProjectLayout(zLayout, CardMakerMDI.Instance.LoadedProject);
                }
                break;
            }
        }
Beispiel #8
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)
                };
                AddProjectLayout(zLayout, CardMakerMDI.Instance.LoadedProject);
                CardMakerMDI.Instance.MarkDirty();
            }
        }
Beispiel #9
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);
                }
            }
        }
Beispiel #10
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var zQuery = new QueryPanelDialog("CardMaker Settings", 450, 250, true);
            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            zQuery.SetMaxHeight(600);
            zQuery.AddTab("General");
            zQuery.AddCheckBox("Enable Google Cache", CardMakerSettings.EnableGoogleCache, IniSettings.EnableGoogleCache);
            zQuery.AddCheckBox("Print/Export Layout Border", CardMakerSettings.PrintLayoutBorder, IniSettings.PrintLayoutBorder);

            zQuery.AddTab("PDF Export");
            zQuery.AddNumericBox("Page Width (inches)", CardMakerSettings.PrintPageWidth, 1, 1024, 1, 2, IniSettings.PrintPageWidth);
            zQuery.AddNumericBox("Page Height (inches)", CardMakerSettings.PrintPageHeight, 1, 1024, 1, 2, IniSettings.PrintPageHeight);
            zQuery.AddNumericBox("Page Horizontal Margin (inches)", CardMakerSettings.PrintPageHorizontalMargin, 0, 1024, 0.01m, 2, IniSettings.PrintPageHorizontalMargin);
            zQuery.AddNumericBox("Page Vertical Margin (inches)", CardMakerSettings.PrintPageVerticalMargin, 0, 1024, 0.01m, 2, IniSettings.PrintPageVerticalMargin);
            zQuery.AddCheckBox("Auto-Center Layouts on Page", CardMakerSettings.PrintAutoHorizontalCenter, IniSettings.PrintAutoCenterLayout);
            zQuery.AddCheckBox("Print Layouts On New Page", CardMakerSettings.PrintLayoutsOnNewPage, IniSettings.PrintLayoutsOnNewPage);
            zQuery.SetIcon(Icon);

            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                CardMakerSettings.PrintPageWidth = zQuery.GetDecimal(IniSettings.PrintPageWidth);
                CardMakerSettings.PrintPageHeight = zQuery.GetDecimal(IniSettings.PrintPageHeight);
                CardMakerSettings.PrintPageHorizontalMargin = zQuery.GetDecimal(IniSettings.PrintPageHorizontalMargin);
                CardMakerSettings.PrintPageVerticalMargin = zQuery.GetDecimal(IniSettings.PrintPageVerticalMargin);
                CardMakerSettings.PrintAutoHorizontalCenter = zQuery.GetBool(IniSettings.PrintAutoCenterLayout);
                CardMakerSettings.PrintLayoutBorder = zQuery.GetBool(IniSettings.PrintLayoutBorder);
                CardMakerSettings.PrintLayoutsOnNewPage = zQuery.GetBool(IniSettings.PrintLayoutsOnNewPage);

                var bWasGoogleCacheEnabled = CardMakerSettings.EnableGoogleCache;
                CardMakerSettings.EnableGoogleCache = zQuery.GetBool(IniSettings.EnableGoogleCache);
                if (!CardMakerSettings.EnableGoogleCache && bWasGoogleCacheEnabled)
                {
                    DeleteGoogleCache();
                }
            }
        }
Beispiel #11
0
        private void customVerticalAlignButton_Click(object sender, EventArgs e)
        {
            var listSelectedElements = ElementManager.Instance.SelectedElements;
            if (listSelectedElements == null || listSelectedElements.Count == 0)
            {
                return;
            }

            const string VERTICAL_SPACING = "vertical_spacing";
            const string APPLY_ELEMENT_HEIGHTS = "apply_element_heights";
            const string ELEMENT_CENTERING = "element_centering";

            var zQuery = new QueryPanelDialog("Custom Vertical 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.AddPullDownBox("Horizontal Centering", Enum.GetNames(typeof (ElementCenterAlign)), 0,
                ELEMENT_CENTERING);

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

            var nVerticalSpace = (int)zQuery.GetDecimal(VERTICAL_SPACING);
            var bApplyElementHeights = zQuery.GetBool(APPLY_ELEMENT_HEIGHTS);
            var eCenterAlignment = (ElementCenterAlign) zQuery.GetIndex(ELEMENT_CENTERING);

            // determine the centering
            var nCenterX = 0;
            switch (eCenterAlignment)
            {
                case ElementCenterAlign.FirstElement:
                    nCenterX = listSelectedElements[0].x + (listSelectedElements[0].width/2);
                    break;
                case ElementCenterAlign.Layout:
                    nCenterX = LayoutManager.Instance.ActiveLayout.width / 2;
                    break;
            }

            // apply the translation
            var dictionaryOriginalPositions = ElementManager.Instance.GetUndoRedoPoints();
            var nY = listSelectedElements[0].y;
            for (var nIdx = 0; nIdx < listSelectedElements.Count; nIdx++)
            {
                var zElement = listSelectedElements[nIdx];
                zElement.y = nY;
                nY += bApplyElementHeights ? zElement.height : 0;
                nY += nVerticalSpace;
                switch (eCenterAlignment)
                {
                    case ElementCenterAlign.FirstElement:
                        if (0 < nIdx)
                        {
                            zElement.x = nCenterX - (zElement.width / 2);
                        }
                        break;
                    case ElementCenterAlign.Layout:
                        zElement.x = nCenterX - (zElement.width / 2);
                        break;
                }
            }
            ElementManager.Instance.ConfigureUserAction(dictionaryOriginalPositions,
                ElementManager.Instance.GetUndoRedoPoints());

            ElementManager.Instance.FireElementBoundsUpdateEvent();
        }
Beispiel #12
0
        private void customAlignElementButton_Click(object sender, EventArgs e)
        {
            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.Instance.ConfigureUserAction(dictionaryOriginalPositions,
                ElementManager.Instance.GetUndoRedoPoints());

            ElementManager.Instance.FireElementBoundsUpdateEvent();
        }
Beispiel #13
0
 private void btnAssist_Click(object sender, EventArgs e)
 {
     contextMenuStripAssist.Items.Clear();
     contextMenuStripAssist.Items.Add("Add Empty", null, (os, ea) => InsertVariableText("#empty"));
     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;
     }
     contextMenuStripAssist.Show(btnAssist, new Point(btnAssist.Width, 0), ToolStripDropDownDirection.AboveLeft);
 }
        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)]);
        }
        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)]);
        }