private void SourceLTDFilesNextPage() { // Check if any of the added LTD files in the list matches the globally selected // LTD document type from the combo box, if non, then stay on this page. LtdDocumentType globalLTDType = (LtdDocumentType)_ltdDocumentTypeComboBox.SelectedIndex; bool validLTDFilesFound = false; foreach (ListViewItem item in _sourceLTDFileListView.Items) { LtdDocumentInfo ltdFileInfo = DocumentWriter.GetLtdInfo(item.Text); if (ltdFileInfo.Type == globalLTDType) { validLTDFilesFound = true; break; } } if (validLTDFilesFound) { _mainWizardControl.SelectedTab = _outputOptionsTabPage; } else { Messager.ShowInformation(this, "Non of the source LTD files you added matches the chosen global LTD document type.\nYou can either change the global LTD document type to match the type of your LTD files or add some LTD files that matches the global LTD document type to be able to move to the next page."); } }
private void _nextButton_Click(object sender, EventArgs e) { if (_mainWizardControl.SelectedTab == _sourceLTDFilesTabPage) { SourceLTDFilesNextPage(); UpdateUIState(false); } else if (_mainWizardControl.SelectedTab == _outputOptionsTabPage) { _abort = false; if (_nextButton.Text.Equals("&Abort")) { _abort = true; } if (!_abort) { _nextButton.Text = "&Abort"; Application.DoEvents(); _documentFormatOptionsControl.UpdateDocumentWriterOptions(); DocumentFormat format = _documentFormatOptionsControl.SelectedDocumentFormat; string outputFileName = _outputFileNameTextBox.Text; bool viewFinalDocument = _viewDocumentCheckBox.Checked; List <string> sourceLTDFiles = new List <string>(); LtdDocumentType globalLTDType = (LtdDocumentType)_ltdDocumentTypeComboBox.SelectedIndex; int totalPagesCount = 0; foreach (ListViewItem item in _sourceLTDFileListView.Items) { LtdDocumentInfo ltdFileInfo = DocumentWriter.GetLtdInfo(item.Text); if (ltdFileInfo.Type == globalLTDType) { sourceLTDFiles.Add(item.Text); totalPagesCount += ltdFileInfo.PageCount; } } _progressBar.Maximum = totalPagesCount + 2 /* The document writer provides progress for two extra operations (BeginDocument and EndDocument) and hence the number 2 */; ThreadPool.QueueUserWorkItem((object sender1) => { MergeLTDFiles(format, outputFileName, sourceLTDFiles.ToArray(), viewFinalDocument, globalLTDType); }); UpdateUIState(true); } } }
private void _sourceLTDFileListView_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { // remove selection marks from all items in the list in order to select the newly added ones _sourceLTDFileListView.SelectedItems.Clear(); int insertionIndex = (_sourceLTDFileListView.InsertionMark.Index != -1) ? ((_sourceLTDFileListView.InsertionMark.AppearsAfterItem) ? _sourceLTDFileListView.InsertionMark.Index + 1 : _sourceLTDFileListView.InsertionMark.Index) : _sourceLTDFileListView.Items.Count; string[] filesList = (string[])e.Data.GetData(DataFormats.FileDrop, false); // Filter the dropped files list and only add the supported files types foreach (string file in filesList) { if (IsLTDFile(file)) { LtdDocumentInfo ltdFileInfo = DocumentWriter.GetLtdInfo(file); ListViewItem insertedItem = _sourceLTDFileListView.Items.Insert(insertionIndex, file); insertedItem.SubItems.Add(ltdFileInfo.Type.ToString()); insertedItem.Selected = true; insertionIndex++; } } _sourceLTDFileListView.Select(); _sourceLTDFileListView.EnsureVisible(insertionIndex - 1); UpdateUIState(false); } else { if (_sourceLTDFileListView.InsertionMark.Index != -1) { int insertionIndex = (_sourceLTDFileListView.InsertionMark.Index < _sourceLTDFileListView.SelectedIndices[0]) ? _sourceLTDFileListView.InsertionMark.Index : _sourceLTDFileListView.InsertionMark.Index - _sourceLTDFileListView.SelectedItems.Count + 1; SwapItems(insertionIndex); _sourceLTDFileListView.InsertionMark.Index = -1; } } }
private void _sourceLTDFilesAddButton_Click(object sender, EventArgs e) { string[] ltdFiles = ShowLTDOpenFilesDialog(); if (ltdFiles != null) { foreach (string ltdFile in ltdFiles) { if (IsLTDFile(ltdFile)) { LtdDocumentInfo ltdFileInfo = DocumentWriter.GetLtdInfo(ltdFile); _sourceLTDFileListView.Items.Add(ltdFile).SubItems.Add(ltdFileInfo.Type.ToString()); } } } // set the focus to the source LTD files list view _sourceLTDFileListView.Select(); if (_sourceLTDFileListView.Items.Count - 1 >= 0) { _sourceLTDFileListView.EnsureVisible(_sourceLTDFileListView.Items.Count - 1); } UpdateUIState(false); }