Example #1
0
 public TestDeck()
 {
     CardLayout = new ProjectLayout()
     {
         defaultCount = 10
     };
 }
Example #2
0
 public TestDeck(ITranslatorFactory zTranslatorFactory)
 {
     CardLayout = new ProjectLayout()
     {
         defaultCount = 10
     };
     TranslatorFactory = zTranslatorFactory;
 }
Example #3
0
        /// <summary>
        /// Translates a file export string for naming a file
        /// </summary>
        /// <param name="sRawString"></param>
        /// <param name="nCardNumber"></param>
        /// <param name="nLeftPad"></param>
        /// <returns></returns>
        public static string TranslateFileNameString(string sRawString, int nCardNumber, int nLeftPad, DeckLine zCurrentPrintLine, Dictionary<string, string> dictionaryDefines,
            Dictionary<string, int> dictionaryColumnNameToIndex, ProjectLayout zLayout)
        {
            string sOutput = sRawString;
            var listLine = zCurrentPrintLine.LineColumns;

            // Translate named items (column names / defines)
            //Groups
            //    1    2    3   4   5
            //@"(.*)(@\[)(.+?)(\])(.*)"
            while (s_regexColumnVariable.IsMatch(sOutput))
            {
                var zMatch = s_regexColumnVariable.Match(sOutput);
                int nIndex;
                string sDefineValue;
                string sKey = zMatch.Groups[3].ToString().ToLower();
                if (dictionaryDefines.TryGetValue(sKey, out sDefineValue))
                {
                    sOutput = zMatch.Groups[1] + sDefineValue.Trim() + zMatch.Groups[5];
                }
                else if (dictionaryColumnNameToIndex.TryGetValue(sKey, out nIndex))
                {
                    sOutput = zMatch.Groups[1] + listLine[nIndex].Trim() + zMatch.Groups[5];
                }
                else
                {
                    sOutput = zMatch.Groups[1] + "[UNKNOWN]" + zMatch.Groups[5];
                }
            }
            // replace ##, #L, Newlines
            sOutput = sOutput.Replace("##", nCardNumber.ToString(CultureInfo.InvariantCulture).PadLeft(nLeftPad, '0')).Replace("#L", zLayout.Name).Replace(Environment.NewLine, String.Empty);

            // last chance: replace unsupported characters (for file name)
            var zBuilder = new StringBuilder();
            foreach (char c in sOutput)
            {
                string sReplace;
                if (s_dictionaryCharReplacement.TryGetValue(c, out sReplace))
                {
                    // quadruple check against bad chars!
                    if (-1 == sReplace.IndexOfAny(DISALLOWED_FILE_CHARS_ARRAY, 0))
                    {
                        zBuilder.Append(sReplace);
                    }
                }
                else
                {
                    if (-1 == c.ToString().IndexOfAny(DISALLOWED_FILE_CHARS_ARRAY))
                    {
                        zBuilder.Append(c);
                    }
                }
            }
            return zBuilder.ToString();
        }
Example #4
0
 /// <summary>
 /// Initialize the cache for each element in the ProjectLayout
 /// </summary>
 /// <param name="zLayout">The layout to initialize the cache</param>
 public static void InitializeElementCache(ProjectLayout zLayout)
 {
     // mark all fields as specified
     if (null != zLayout.Element)
     {
         foreach (var zElement in zLayout.Element)
         {
             zElement.InitializeCache();
         }
     }
 }
Example #5
0
        /// <summary>
        /// Performs a partial deepy copy based on the input element, the name field is left unchanged
        /// </summary>
        /// <param name="zLayout">The layout to copy from</param>
        /// <param name="bCopyRefs">Flag indicating whether to copy the refereces</param>
        public void DeepCopy(ProjectLayout zLayout, bool bCopyRefs = true)
        {
            width                       = zLayout.width;
            height                      = zLayout.height;
            defaultCount                = zLayout.defaultCount;
            dpi                         = zLayout.dpi;
            drawBorder                  = zLayout.drawBorder;
            buffer                      = zLayout.buffer;
            zoom                        = zLayout.zoom;
            exportCropDefinition        = zLayout.exportCropDefinition;
            combineReferences           = zLayout.combineReferences;
            exportNameFormat            = zLayout.exportNameFormat;
            exportRotation              = zLayout.exportRotation;
            exportWidth                 = zLayout.exportWidth;
            exportHeight                = zLayout.exportHeight;
            exportTransparentBackground = zLayout.exportTransparentBackground;
            if (null != zLayout.Element)
            {
                var listElements = new List <ProjectLayoutElement>();
                foreach (ProjectLayoutElement zElement in zLayout.Element)
                {
                    var zElementCopy = new ProjectLayoutElement(zElement.name);
                    zElementCopy.DeepCopy(zElement, true);
                    listElements.Add(zElementCopy);
                }
                Element = listElements.ToArray();
            }
            if (bCopyRefs && null != zLayout.Reference)
            {
                var listReferences = new List <ProjectLayoutReference>();
                foreach (var zReference in zLayout.Reference)
                {
                    var zReferenceCopy = new ProjectLayoutReference();
                    zReferenceCopy.DeepCopy(zReference);
                    listReferences.Add(zReferenceCopy);
                }
                Reference = listReferences.ToArray();
            }

            InitializeElementLookup();
        }
Example #6
0
        public LayoutEventArgs(ProjectLayout zLayout)
            : this(zLayout, null, false)
        {

        }
Example #7
0
        /// <summary>
        /// Adds a project layout tree node
        /// </summary>
        /// <param name="zLayout"></param>
        /// <returns></returns>
        private void AddProjectLayout(ProjectLayout zLayout)
        {
            TreeNode tnLayout = treeView.Nodes[0].Nodes.Add(zLayout.Name);
            tnLayout.Tag = zLayout;

            if (null != zLayout.Reference)
            {
                foreach (ProjectLayoutReference zReference in zLayout.Reference)
                {
                    // no need to update the layout
                    AddReferenceNode(tnLayout, zReference, null);
                }
                tnLayout.Expand();
            }
        }
Example #8
0
        public void SetAndLoadLayout(ProjectLayout zLayout, bool bExporting)
        {
            CardLayout = zLayout;

            ResetPrintCardIndex();

            var bReferenceFound = false;

            if (null != CardLayout.Reference)
            {
                ProjectLayoutReference[] zReferenceData = null;

                if (CardLayout.combineReferences)
                {
                    var listReferences = new List<ProjectLayoutReference>();
                    ProjectLayoutReference zDefaultReference = null;
                    foreach (var zReference in CardLayout.Reference)
                    {
                        if (zReference.Default)
                        {
                            zDefaultReference = zReference;
                        }
                        else
                        {
                            listReferences.Add(zReference);
                        }
                    }
                    // move the default reference to the front of the set
                    if (null != zDefaultReference)
                    {
                        listReferences.Insert(0, zDefaultReference);
                    }
                    zReferenceData = listReferences.Count == 0 ? null : listReferences.ToArray();
                }
                else
                {
                    foreach (var zReference in CardLayout.Reference)
                    {
                        if (zReference.Default)
                        {
                            zReferenceData = new ProjectLayoutReference[] { zReference };
                            break;
                        }
                    }
                }
                var zWait = new WaitDialog(
                    1,
                    ReadData,
                    zReferenceData,
                    "Loading Data",
                    null,
                    400);
#warning this needs to be pulled into a deck loader
                CardMakerInstance.ApplicationForm.InvokeAction(() => zWait.ShowDialog(CardMakerInstance.ApplicationForm));
                if (!bExporting)
                {
                    if (CardMakerInstance.GoogleCredentialsInvalid)
                    {
                        CardMakerInstance.GoogleCredentialsInvalid = false;
                        GoogleAuthManager.Instance.FireGoogleAuthCredentialsErrorEvent(
                            () => LayoutManager.Instance.InitializeActiveLayout());
                    }
                }
                bReferenceFound = zWait.ThreadSuccess;
            }

            if (!bReferenceFound)
            {
                // setup the placeholder single card
                var zWait = new WaitDialog(
                    1,
                    ReadData,
                    null,
                    "Loading Data",
                    null,
                    400)
                {
                    CancelButtonVisibile = false
                };
                CardMakerInstance.ApplicationForm.InvokeAction(() => zWait.ShowDialog(CardMakerInstance.ApplicationForm));
            }
        }
Example #9
0
 /// <summary>
 /// Performs a partial deepy copy based on the input element, the name field is left unchanged
 /// </summary>
 /// <param name="zLayout">The layout to copy from</param>
 /// <param name="bCopyRefs">Flag indicating whether to copy the refereces</param>
 public void DeepCopy(ProjectLayout zLayout, bool bCopyRefs = true)
 {
     width = zLayout.width;
     height = zLayout.height;
     defaultCount = zLayout.defaultCount;
     dpi = zLayout.dpi;
     drawBorder = zLayout.drawBorder;
     buffer = zLayout.buffer;
     combineReferences = zLayout.combineReferences;
     exportNameFormat = zLayout.exportNameFormat;
     exportRotation = zLayout.exportRotation;
     exportWidth = zLayout.exportWidth;
     exportHeight = zLayout.exportHeight;
     exportTransparentBackground = zLayout.exportTransparentBackground;
     if (null != zLayout.Element)
     {
         var listElements = new List<ProjectLayoutElement>();
         foreach (ProjectLayoutElement zElement in zLayout.Element)
         {
             var zElementCopy = new ProjectLayoutElement(zElement.name);
             zElementCopy.DeepCopy(zElement, true);
             listElements.Add(zElementCopy);
         }
         Element = listElements.ToArray();
     }
     if (bCopyRefs && null != zLayout.Reference)
     {
         var listReferences = new List<ProjectLayoutReference>();
         foreach (var zReference in zLayout.Reference)
         {
             var zReferenceCopy = new ProjectLayoutReference();
             zReferenceCopy.DeepCopy(zReference);
             listReferences.Add(zReferenceCopy);
         }
         Reference = listReferences.ToArray();
     }
 }
Example #10
0
 private void RotateImageBuffer(Bitmap zBuffer, ProjectLayout zLayout, bool postTransition)
 {
     switch (zLayout.exportRotation)
     {
         case 90:
             zBuffer.RotateFlip(postTransition ? RotateFlipType.Rotate270FlipNone : RotateFlipType.Rotate90FlipNone);
             break;
         case -90:
             zBuffer.RotateFlip(postTransition ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipNone);
             break;
     }
 }
Example #11
0
        /// <summary>
        /// Configures the controls to match the Layout settings
        /// </summary>
        /// <param name="zLayout"></param>
        private void UpdateLayoutInfo(ProjectLayout zLayout)
        {
            if (null != zLayout)
            {
                // don't trigger any events (this is just setup)
                m_bFireLayoutChangeEvents = false;

                // get the destination index before changing the controls
                // (the value is lost when the controls are adjusted)
                int nDestinationCardIndex = m_nDestinationCardIndex;

                // configure the UI based on the newly loaded item
                numericCardSetBuffer.Value = zLayout.buffer;
                numericCardSetWidth.Value = zLayout.width;
                numericCardSetHeight.Value = zLayout.height;
                numericCardSetDPI.Value = zLayout.dpi;
                checkCardSetDrawBorder.Checked = zLayout.drawBorder;
                checkLoadAllReferences.Checked = zLayout.combineReferences;
                SetupCardIndices(LayoutManager.Instance.ActiveDeck.CardCount);
                groupBoxCardCount.Enabled = true;
                groupBoxCardSet.Enabled = true;

                // update the list of elements
                listViewElements.Items.Clear();
                m_dictionaryItems.Clear();
                if (null != zLayout.Element)
                {
                    foreach (ProjectLayoutElement zElement in zLayout.Element)
                    {
                        ListViewItem zLvi = CreateListViewItem(zElement);
                        UpdateListViewItemState(zLvi, zElement);
                        listViewElements.Items.Add(zLvi);
                    }
                    if (0 < listViewElements.Items.Count)
                    {
                        listViewElements.Items[0].Selected = true;
                    }
                }
                else
                {
                    ElementManager.Instance.FireElementSelectedEvent(null);
                }
                m_bFireLayoutChangeEvents = true;

                // these adjustments will trigger the events necessary to adjust to the given index
                if (LayoutManager.Instance.ActiveLayout == m_zLastProjectLayout && -1 != nDestinationCardIndex &&
                    LayoutManager.Instance.ActiveDeck.CardCount > nDestinationCardIndex)
                {
                    numericCardIndex.Value = nDestinationCardIndex + 1;
                }
                else
                {
                    numericCardIndex.Value = 1;
                }
                // just in case the value is considered unchanged, fire off the event
                ChangeCardIndex((int)numericCardIndex.Value - 1);
            }
            else
            {
                groupBoxCardCount.Enabled = false;
                groupBoxCardSet.Enabled = false;
            }
        }
Example #12
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();
            }
        }
Example #13
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;
            }
        }
Example #14
0
        /// <summary>
        /// Internal/Project load handling for adding a reference node.
        /// </summary>
        /// <param name="tnLayout"></param>
        /// <param name="zReference"></param>
        /// <param name="zLayout">The layout to update the references for (may be null if no update is needed - ie. project loading)</param>
        /// <returns></returns>
        private static TreeNode AddReferenceNode(TreeNode tnLayout, ProjectLayoutReference zReference,
            ProjectLayout zLayout)
        {
            var sProjectPath = CardMakerMDI.ProjectPath;
            var sFullReferencePath = zReference.RelativePath;
            if (!String.IsNullOrEmpty(sProjectPath))
            {
                sFullReferencePath = sProjectPath + Path.DirectorySeparatorChar + zReference.RelativePath;
            }

            if (zLayout != null && zLayout.Reference != null)
            {
                // duplicate check
                foreach (var zExistingReference in zLayout.Reference)
                {
                    if (zExistingReference.RelativePath.Equals(zReference.RelativePath,
                        StringComparison.CurrentCultureIgnoreCase))
                    {
                        return null;
                    }
                }
            }

            var tnReference = new TreeNode(Path.GetFileName(sFullReferencePath))
            {
                BackColor = zReference.Default ? DEFAULT_REFERENCE_COLOR : Color.White,
                ToolTipText = zReference.RelativePath,
                Tag = zReference
            };
            tnLayout.Nodes.Add(tnReference);

            if (null != zLayout)
            {
                // update the ProjectLayout
                var listReferences = new List<ProjectLayoutReference>();
                if (null != zLayout.Reference)
                {
                    listReferences.AddRange(zLayout.Reference);
                }
                listReferences.Add(zReference);
                zLayout.Reference = listReferences.ToArray();
            }

            return tnReference;
        }
Example #15
0
        /// <summary>
        /// Adds a project layout tree node
        /// </summary>
        /// <param name="tnRoot"></param>
        /// <param name="zLayout"></param>
        /// <param name="zProject"></param>
        /// <returns></returns>
        public TreeNode AddProjectLayout(ProjectLayout zLayout, Project zProject)
        {
            TreeNode tnLayout = treeView.Nodes[0].Nodes.Add(zLayout.Name);
            tnLayout.Tag = zLayout;

            if (null != zProject)
            {
                // update the Project (no null check on zProject.Layout necessary... can never have 0 layouts)
                var listLayouts = new List<ProjectLayout>(zProject.Layout);
                listLayouts.Add(zLayout);
                zProject.Layout = listLayouts.ToArray();
            }

            if (null != zLayout.Reference)
            {
                foreach (ProjectLayoutReference zReference in zLayout.Reference)
                {
                    // no need to update the layout
                    AddReferenceNode(tnLayout, zReference, null);
                }
                tnLayout.Expand();
            }

            return tnLayout;
        }
Example #16
0
 /// <summary>
 /// UI facing method for adding a reference node (for use from the context menu to add a new reference)
 /// </summary>
 /// <param name="tnLayout"></param>
 /// <param name="sFile"></param>
 /// <param name="bSetAsDefault"></param>
 /// <param name="zLayout"></param>
 /// <returns>The new Reference tree node or null if there is an existing reference by the same definition</returns>
 public static TreeNode AddReferenceNode(TreeNode tnLayout, string sFile, bool bSetAsDefault,
     ProjectLayout zLayout)
 {
     var sProjectPath = CardMakerMDI.ProjectPath;
     var zReference = new ProjectLayoutReference
     {
         Default = bSetAsDefault,
         RelativePath = IOUtils.GetRelativePath(sProjectPath,
             sFile)
     };
     return AddReferenceNode(tnLayout, zReference, zLayout);
 }
Example #17
0
 private void duplicateLayoutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var zLayout = (ProjectLayout)treeView.SelectedNode.Tag;
     var zLayoutCopy = new ProjectLayout(zLayout.Name + " copy");
     zLayoutCopy.DeepCopy(zLayout);
     ProjectManager.Instance.AddLayout(zLayoutCopy);
 }
Example #18
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);
                }
            }
        }
Example #19
0
 /// <summary>
 /// Adds the specified layout to the project (new data)
 /// </summary>
 /// <param name="zLayout"></param>
 public void AddLayout(ProjectLayout zLayout)
 {
     // update the Project (no null check on zProject.Layout necessary... can never have 0 layouts)
     var listLayouts = new List<ProjectLayout>(LoadedProject.Layout);
     listLayouts.Add(zLayout);
     LoadedProject.Layout = listLayouts.ToArray();
     LayoutManager.InitializeElementCache(zLayout);
     if (null != LayoutAdded)
     {
         LayoutAdded(this, new LayoutEventArgs(zLayout, null));
     }
     FireProjectUpdated(true);
 }
Example #20
0
 /// <summary>
 /// Returns the layout index based on the active project
 /// </summary>
 /// <param name="zLayout"></param>
 /// <returns>The index, or -1 if not found</returns>
 public int GetLayoutIndex(ProjectLayout zLayout)
 {
     if (null != LoadedProject)
     {
         for (int nIdx = 0; nIdx < LoadedProject.Layout.Length; nIdx++)
         {
             if (LoadedProject.Layout[nIdx] == zLayout)
             {
                 return nIdx;
             }
         }
     }
     return -1;
 }
Example #21
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(CardMakerMDI.StartupPath, zTemplate))
         {
             LayoutTemplateManager.Instance.LayoutTemplates.Add(zTemplate);
         }
     }
 }
Example #22
0
 private void numericCardIndex_ValueChanged(object sender, EventArgs e)
 {
     var nTargetIndex = (int)numericCardIndex.Value - 1;
     m_nDestinationCardIndex = nTargetIndex;
     m_zLastProjectLayout = LayoutManager.Instance.ActiveLayout;
     ChangeCardIndex(nTargetIndex);
     m_bFireLayoutChangeEvents = false;
     numericRowIndex.Value = m_arrayIndexToRow[nTargetIndex] + 1;
     m_bFireLayoutChangeEvents = true;
 }
Example #23
0
 private void duplicateLayoutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var zLayout = (ProjectLayout)treeView.SelectedNode.Tag;
     var zLayoutCopy = new ProjectLayout(zLayout.Name + " copy");
     zLayoutCopy.DeepCopy(zLayout);
     var tnLayout = AddProjectLayout(zLayoutCopy, CardMakerMDI.Instance.LoadedProject);
     tnLayout.ExpandAll();
     CardMakerMDI.Instance.MarkDirty();
 }
Example #24
0
        private void ConfigurePointSizes(ProjectLayout zLayout)
        {
            int nWidth = zLayout.width;
            int nHeight = zLayout.height;
            switch (zLayout.exportRotation)
            {
                case 90:
                case -90:
                    nWidth = zLayout.height;
                    nHeight = zLayout.width;
                    break;
            }

            double dPointsPerInchWidth = (double)m_zCurrentPage.Width / (double)m_zCurrentPage.Width.Inch;
            double dInchesWidthPerLayoutItem = (double)nWidth / (double)zLayout.dpi;
            m_dLayoutPointWidth = dInchesWidthPerLayoutItem * dPointsPerInchWidth;

            double dPointsPerInchHeight = (double)m_zCurrentPage.Height / (double)m_zCurrentPage.Height.Inch;
            double dInchesHeightPerLayoutItem = (double)nHeight / (double)zLayout.dpi;
            m_dLayoutPointHeight = dInchesHeightPerLayoutItem * dPointsPerInchHeight;

            m_dBufferX = ((double)zLayout.buffer / (double)zLayout.dpi) * dPointsPerInchWidth;
            m_dBufferY = ((double)zLayout.buffer / (double)zLayout.dpi) * dPointsPerInchHeight;
        }
Example #25
0
        public bool SetAndLoadLayout(ProjectLayout zLayout, bool bExporting)
        {
            CardLayout = zLayout;

            ResetPrintCardIndex();
            ResetDeckCache();

            var bReferenceFound = false;

            if (null != m_zCardLayout.Reference)
            {
                ProjectLayoutReference[] zReferenceData = null;

                if (m_zCardLayout.combineReferences)
                {
                    var listReferences = new List<ProjectLayoutReference>();
                    ProjectLayoutReference zDefaultReference = null;
                    foreach (var zReference in m_zCardLayout.Reference)
                    {
                        if (zReference.Default)
                        {
                            zDefaultReference = zReference;
                        }
                        else
                        {
                            listReferences.Add(zReference);
                        }
                    }
                    // move the default reference to the front of the set
                    if (null != zDefaultReference)
                    {
                        listReferences.Insert(0, zDefaultReference);
                    }
                    zReferenceData = listReferences.Count == 0 ? null : listReferences.ToArray();
                }
                else
                {
                    foreach (var zReference in m_zCardLayout.Reference)
                    {
                        if (zReference.Default)
                        {
                            zReferenceData = new ProjectLayoutReference[] { zReference };
                            break;
                        }
                    }
                }
                var zWait = new WaitDialog(
                    1,
                    ReadData,
                    zReferenceData,
                    "Loading Data",
                    null,
                    400);
                CardMakerMDI.Instance.InvokeAction(() => zWait.ShowDialog(CardMakerMDI.Instance));
                if (!bExporting)
                {
                    if (CardMakerMDI.Instance.InvokeFunc(() => CardMakerMDI.Instance.HandleInvalidGoogleCredentials()))
                    {
                        return true;
                    }
                }
                bReferenceFound = zWait.ThreadSuccess;
            }

            if (!bReferenceFound)
            {
                // setup the placeholder single card
                var zWait = new WaitDialog(
                    1,
                    ReadData,
                    null,
                    "Loading Data",
                    null,
                    400)
                {
                    CancelButtonVisibile = false
                };
                CardMakerMDI.Instance.InvokeAction(() => zWait.ShowDialog(CardMakerMDI.Instance));
            }
            return false;
        }
Example #26
0
 public void SetCardLayout(ProjectLayout zCardLayout)
 {
     ActiveDeck.SetAndLoadLayout(zCardLayout ?? ActiveDeck.CardLayout, false);
     Size = new Size(ActiveDeck.CardLayout.width, ActiveDeck.CardLayout.height);
 }
Example #27
0
 public LayoutEventArgs(ProjectLayout zLayout, Deck zDeck, bool bDataChange)
 {
     Layout = zLayout;
     Deck = zDeck;
     DataChange = bDataChange;
 }
Example #28
0
 /// <summary>
 /// Rotates the export buffer based on the Layout exportRotation setting
 /// </summary>
 /// <param name="zBuffer"></param>
 /// <param name="zLayout"></param>
 /// <param name="postTransition"></param>
 protected void ProcessRotateExport(Bitmap zBuffer, ProjectLayout zLayout, bool postTransition)
 {
     switch (zLayout.exportRotation)
     {
         case 90:
             zBuffer.RotateFlip(postTransition ? RotateFlipType.Rotate270FlipNone : RotateFlipType.Rotate90FlipNone);
             break;
         case -90:
             zBuffer.RotateFlip(postTransition ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipNone);
             break;
     }
 }
Example #29
0
        public LayoutEventArgs(ProjectLayout zLayout, Deck zDeck)
            : this(zLayout, zDeck, false)
        {

        }
Example #30
0
 protected void ProcessRotateExport(ProjectLayout zLayout, bool preExport)
 {
     switch (zLayout.exportRotation)
     {
         case 90:
             m_zExportCardBuffer.RotateFlip(preExport ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipNone);
             break;
         case -90:
             m_zExportCardBuffer.RotateFlip(preExport ? RotateFlipType.Rotate270FlipNone : RotateFlipType.Rotate90FlipNone);
             break;
     }
 }
Example #31
0
 /// <summary>
 /// UI facing method for adding a reference node (for use from the context menu to add a new reference)
 /// </summary>
 /// <param name="tnLayout"></param>
 /// <param name="sFile"></param>
 /// <param name="bSetAsDefault"></param>
 /// <param name="zLayout"></param>
 /// <returns>The new Reference tree node or null if there is an existing reference by the same definition</returns>
 private static TreeNode AddReferenceNode(TreeNode tnLayout, string sFile, bool bSetAsDefault,
     ProjectLayout zLayout)
 {
     var sProjectPath = ProjectManager.Instance.ProjectPath;
     var zReference = new ProjectLayoutReference
     {
         Default = bSetAsDefault,
         RelativePath = IOUtils.GetRelativePath(sProjectPath,
             sFile)
     };
     return AddReferenceNode(tnLayout, zReference, zLayout);
 }