/// <summary> /// Sets up the basic controls /// </summary> /// <param name="nProgressBarCount"></param> /// <param name="sTitle"></param> /// <param name="arrayDescriptions"></param> /// <param name="nWidth"></param> private void Initialize(int nProgressBarCount, string sTitle, string[] arrayDescriptions, int nWidth) { Text = sTitle; if (null != arrayDescriptions) { if (nProgressBarCount == arrayDescriptions.Length) { m_arrayDescriptions = arrayDescriptions; } } m_zWaitDialog = this; // // btnCancel // btnCancel = new Button { DialogResult = DialogResult.Cancel, Location = new Point(88, 56), Name = "btnCancel", Size = new Size(75, 23), TabIndex = 1, Text = "Cancel" }; btnCancel.Click += btnCancel_Click; // // lblStatus // lblStatus = new Label { Location = new Point(8, 8), Name = "lblStatus", Size = new Size(232, 40), TabIndex = 3, Text = "Loading..." }; // // WaitDialog // CancelButton = btnCancel; ClientSize = new Size(756, 430); ControlBox = false; Controls.Add(lblStatus); Controls.Add(btnCancel); FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; Name = "WaitDialog"; ShowInTaskbar = false; StartPosition = FormStartPosition.CenterParent; if (100 < nWidth) { Width = nWidth; } AddProgressBars(nProgressBarCount); Load += WaitDialog_Load; }
public void UpdateProjects() { if (Directory.Exists(txtFolder.Text)) { var zWait = new WaitDialog(0, UpdateThread, "Scanning Directory", new string[] { string.Empty }, 300); zWait.ShowDialog(this); } }
void Refresh_Requested(object sender, IssueRefreshEventArgs args) { ClearIssues(); m_bTrackIssues = true; var zWait = new WaitDialog( 2, new CompilerCardExporter(0, ProjectManager.Instance.LoadedProject.Layout.Length).ExportThread, "Compile", new string[] { "Layout", "Card" }, 450); zWait.ShowDialog(ParentForm); m_bTrackIssues = false; Show(); }
private void GoogleSpreadsheetBrowser_Load(object sender, EventArgs e) { var zWait = new WaitDialog(1, () => { AtomEntryCollection zSheetAtomCollection = getAtomEntryCollection( () => GoogleSpreadsheet.GetSpreadsheetList(m_zSpreadsheetsService), () => listViewSpreadsheets.InvokeAction(() => listViewSpreadsheets.Clear())); if (null == zSheetAtomCollection) { this.InvokeAction( () => MessageBox.Show(this, "Failed to access Google Spreadsheets", "Access Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)); this.InvokeAction(Close); WaitDialog.Instance.CloseWaitDialog(); return; } m_zAllEntries = zSheetAtomCollection; var listNewItems = new List <ListViewItem>(); foreach (var entry in zSheetAtomCollection) { var zLvi = new ListViewItem(entry.Title.Text) { Tag = entry }; listNewItems.Add(zLvi); } listViewSpreadsheets.InvokeAction(() => { listViewSpreadsheets.Items.AddRange(listNewItems.ToArray()); }); WaitDialog.Instance.CloseWaitDialog(); }, "Getting Google Spreadsheets...", null, 400); zWait.ShowDialog(this); }
/// <summary> /// Used in place of the Close method to avoid threading issues /// </summary> public void CloseWaitDialog() { this.InvokeAction(Close); m_zWaitDialog = null; }
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; }
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 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); } }
/// <summary> /// Used in place of the Close method to avoid threading issues /// </summary> public void CloseWaitDialog() { this.InvokeAction(() => Close()); m_zWaitDialog = null; }
private void GoogleSpreadsheetBrowser_Load(object sender, EventArgs e) { var zWait = new WaitDialog(1, () => { AtomEntryCollection zSheetAtomCollection = getAtomEntryCollection( () => GoogleSpreadsheet.GetSpreadsheetList(m_zSpreadsheetsService), () => listViewSpreadsheets.InvokeAction(() => listViewSpreadsheets.Clear())); if (null == zSheetAtomCollection) { this.InvokeAction( () => MessageBox.Show(this, "Failed to access Google Spreadsheets", "Access Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)); this.InvokeAction(Close); WaitDialog.Instance.CloseWaitDialog(); return; } m_zAllEntries = zSheetAtomCollection; var listNewItems = new List<ListViewItem>(); foreach (var entry in zSheetAtomCollection) { var zLvi = new ListViewItem(entry.Title.Text) { Tag = entry }; listNewItems.Add(zLvi); } listViewSpreadsheets.InvokeAction(() => { listViewSpreadsheets.Items.AddRange(listNewItems.ToArray()); }); WaitDialog.Instance.CloseWaitDialog(); }, "Getting Google Spreadsheets...", null, 400); zWait.ShowDialog(this); }
private void ExportImages(bool bExportAllLayouts) { ICardExporter zFileCardExporter = FileCardExporterFactory.BuildFileCardExporter(bExportAllLayouts); if (null == zFileCardExporter) { return; } #if true var zWait = new WaitDialog( 2, zFileCardExporter.ExportThread, "Export", new string[] { "Layout", "Card" }, 450); zWait.ShowDialog(this); #else // non threaded zFileCardExporter.ExportThread(); #endif }
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)); } }
private void updateIssuesToolStripMenuItem_Click(object sender, EventArgs e) { InitSave(false); if (Dirty) { return; } MDIIssues.Instance.ClearIssues(); MDIIssues.Instance.TrackIssues = true; var zWait = new WaitDialog( 2, new CompilerCardExporter(0, MDIProject.Instance.LayoutCount).ExportThread, "Compile", new string[] { "Layout", "Card" }, 450); zWait.ShowDialog(this); MDIIssues.Instance.TrackIssues = false; MDIIssues.Instance.Show(); }