public GoogleReferenceReader(ProjectLayoutReference zReference) { ReferencePath = (File.Exists(zReference.RelativePath) ? Path.GetFullPath(zReference.RelativePath) : CardMakerMDI.ProjectPath + zReference.RelativePath); m_zSpreadsheetsService = GoogleSpreadsheet.GetSpreadsheetsService(APP_NAME, CLIENT_ID, CardMakerMDI.GoogleAccessToken); }
public GoogleReferenceReader(ProjectLayoutReference zReference) { ReferencePath = zReference.RelativePath; m_zSpreadsheetsService = GoogleSpreadsheet.GetSpreadsheetsService(APP_NAME, CLIENT_ID, CardMakerInstance.GoogleAccessToken); LoadCache(); if (!IsAllDataCached() || CardMakerInstance.ForceDataCacheRefresh) { // local cache is not enough to load this reference, check token access if (!GoogleApi.VerifyAccessToken(CardMakerInstance.GoogleAccessToken)) { CardMakerInstance.GoogleCredentialsInvalid = true; } } }
public CSVReferenceReader(ProjectLayoutReference zReference) { var previousCurrentDirectory = Directory.GetCurrentDirectory(); if (null != ProjectManager.Instance.ProjectPath && Directory.Exists(ProjectManager.Instance.ProjectPath)) { Directory.SetCurrentDirectory(ProjectManager.Instance.ProjectPath); ReferencePath = (File.Exists(zReference.RelativePath) ? Path.GetFullPath(zReference.RelativePath) : ProjectManager.Instance.ProjectPath + zReference.RelativePath); } else { ReferencePath = File.Exists(zReference.RelativePath) ? Path.GetFullPath(zReference.RelativePath) : zReference.RelativePath; } Directory.SetCurrentDirectory(previousCurrentDirectory); }
public static ReferenceReader GetReader(ProjectLayoutReference zReference) { if (zReference == null) { return null; } ReferenceReader zReader; if (zReference.RelativePath.StartsWith(CardMakerConstants.GOOGLE_REFERENCE + CardMakerConstants.GOOGLE_REFERENCE_SPLIT_CHAR)) { zReader = new GoogleReferenceReader(zReference); if (!CardMakerInstance.GoogleCredentialsInvalid) { return zReader; } } return new CSVReferenceReader(zReference); }
public static ReferenceReader GetReader(ProjectLayoutReference zReference) { if (zReference == null) { return null; } if (zReference.RelativePath.StartsWith(CardMakerMDI.GOOGLE_REFERENCE + CardMakerMDI.GOOGLE_REFERENCE_SPLIT_CHAR)) { if (GoogleApi.VerifyAccessToken(CardMakerMDI.GoogleAccessToken)) { return new GoogleReferenceReader(zReference); } else { CardMakerMDI.GoogleCredentialsInvalid = true; } } return new CSVReferenceReader(zReference); }
/// <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(); }
public void GetReferenceData(ProjectLayoutReference zReference, List<List<string>> listReferenceData) { GetData(ReferencePath, listReferenceData, false); }
public void GetProjectDefineData(ProjectLayoutReference zReference, List<List<string>> listDefineData) { var sProjectDefineSheetReference = CardMakerMDI.GOOGLE_REFERENCE + CardMakerMDI.GOOGLE_REFERENCE_SPLIT_CHAR + Path.GetFileNameWithoutExtension(CardMakerMDI.Instance.LoadedFile) + CardMakerMDI.GOOGLE_REFERENCE_SPLIT_CHAR + "defines"; GetData(sProjectDefineSheetReference, listDefineData, true); }
public void GetDefineData(ProjectLayoutReference zReference, List<List<string>> listDefineData) { GetData(ReferencePath, listDefineData, true, Deck.DEFINES_DATA_POSTFIX); }
public GoogleReferenceReader(ProjectLayoutReference zReference) : this() { ReferencePath = zReference.RelativePath; }
public void GetProjectDefineData(ProjectLayoutReference zReference, List<List<string>> listDefineData) { if (null == ProjectManager.Instance.ProjectFilePath) { return; } var sProjectDefineSheetReference = GetDefinesReference(); GetData(sProjectDefineSheetReference, listDefineData, true); }
public void DeepCopy(ProjectLayoutReference zReference) { Default = zReference.Default; RelativePath = zReference.RelativePath; }
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)); } }
public void GetProjectDefineData(ProjectLayoutReference zReference, List<List<string>> listDefineData) { var sReferencePath = Path.GetDirectoryName(ProjectManager.Instance.ProjectFilePath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(ProjectManager.Instance.ProjectFilePath) + ".csv"; GetData(sReferencePath, listDefineData, false, 1, Deck.DEFINES_DATA_POSTFIX); }
/// <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; }
/// <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); }
/// <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); }
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; }
/// <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(); } }
public void GetProjectDefineData(ProjectLayoutReference zReference, List<List<string>> listDefineData) { var sProjectDefineSheetReference = GetDefinesReference(); GetData(sProjectDefineSheetReference, listDefineData, true); }