private void CompleteDocTypeChange(string docTypeName) { // Reset the override folder _overrideFolderForFiling = ""; if (btnMoveToUndo.IsEnabled != false) btnMoveToUndo.IsEnabled = false; // Show email password txtEmailPassword.Password = _scanDocHandler.GetEmailPassword(); // Extract date info again and update latest match result int bestDateIdx = 0; List<ExtractedDate> extractedDates = DocTextAndDateExtractor.ExtractDatesFromDoc(_curDocScanPages, (_curSelectedDocType == null) ? "" : _curSelectedDocType.dateExpression, out bestDateIdx); DateTime docDate = docDate = DateTime.MinValue; if (extractedDates.Count > 0) docDate = extractedDates[bestDateIdx].dateTime; // Show doc type txtDocTypeName.IsEnabled = false; string docTypeNameStr = (_curSelectedDocType == null) ? "" : _curSelectedDocType.docTypeName; if (txtDocTypeName.Text != docTypeNameStr) txtDocTypeName.Text = docTypeNameStr; // Field enables SetFieldEnable(txtDestFilePrefix, false); SetFieldEnable(btnChangePrefix, true); string destFilePrefixStr = (_curSelectedDocType == null) ? "" : DocType.GetFileNamePrefix(_curSelectedDocType.docTypeName); if (txtDestFilePrefix.Text != destFilePrefixStr) txtDestFilePrefix.Text = destFilePrefixStr; if (txtDestFileSuffix.Text != "") { txtDestFileSuffix.IsEnabled = false; txtDestFileSuffix.Text = ""; txtDestFileSuffix.IsEnabled = true; } if (txtMoneySum.Text != "") txtMoneySum.Text = ""; SetFieldEnable(txtMoneySum, true); chkFollowUpA.IsChecked = false; chkFollowUpB.IsChecked = false; chkCalendarEntry.IsChecked = false; _touchFromPageText = TouchFromPageText.TOUCH_NONE; // Display email addresses List<MailAddress> mailTo = ScanDocHandler.GetEmailToAddresses(); if (chkFollowUpA.Visibility != System.Windows.Visibility.Hidden) chkFollowUpA.Visibility = System.Windows.Visibility.Hidden; if (mailTo.Count > 0) { string[] nameSplit = mailTo[0].DisplayName.Split(' '); if (nameSplit.Length > 0) { chkFollowUpA.Content = "Follow up " + nameSplit[0]; chkFollowUpA.Tag = nameSplit[0]; chkFollowUpA.Visibility = System.Windows.Visibility.Visible; } } if (chkFollowUpB.Visibility != System.Windows.Visibility.Hidden) chkFollowUpB.Visibility = System.Windows.Visibility.Hidden; if (mailTo.Count > 1) { string[] nameSplit = mailTo[1].DisplayName.Split(' '); if (nameSplit.Length > 0) { chkFollowUpB.Content = "Follow up " + nameSplit[0]; chkFollowUpB.Tag = nameSplit[0]; chkFollowUpB.Visibility = System.Windows.Visibility.Visible; } } // Visibility of event fields SetEventVisibility(false, false); SetFieldText(lblEventDuration, "1 Hour"); SetFieldText(txtEventName, (txtDestFileSuffix.Text.Trim() != "") ? txtDestFileSuffix.Text.Trim() : txtDestFilePrefix.Text.Trim()); SetFieldText(txtEventLocn, ""); SetFieldText(txtEventDesc, ""); SetFieldText(txtEventTime, "08:00"); chkAttachFile.IsChecked = true; // Set doc date DateTime dateToUse = DateTime.Now; if (docDate != DateTime.MinValue) dateToUse = docDate; SetDateRollers(dateToUse.Year, dateToUse.Month, dateToUse.Day, dateRollerChange.none); // Show File number in list if (_scanDocHandler.GetCountOfUnfiledDocs() == 0) SetLabelContent(lblStatusBarFileNo, "None"); else SetLabelContent(lblStatusBarFileNo, (_curDocToBeFiledIdxInList + 1).ToString() + " / " + _scanDocHandler.GetCountOfUnfiledDocs().ToString()); // Show status of filing string statusStr = "Unfiled"; Brush foreColour = Brushes.Black; bool processButtonsEnabled = true; SetFieldEnable(btnDeleteDoc, true); SetFieldEnable(btnProcessDoc, true); if (_curFiledDocInfo != null) { switch (_curFiledDocInfo.filedAt_finalStatus) { case FiledDocInfo.DocFinalStatus.STATUS_DELETED: statusStr = "DELETED"; foreColour = Brushes.Red; SetFieldEnable(btnProcessDoc, false); SetFieldEnable(btnDeleteDoc, false); break; case FiledDocInfo.DocFinalStatus.STATUS_DELETED_AFTER_EDIT: statusStr = "REPLACED/EDITED"; foreColour = Brushes.Red; SetFieldEnable(btnProcessDoc, false); SetFieldEnable(btnDeleteDoc, false); break; case FiledDocInfo.DocFinalStatus.STATUS_FILED: statusStr = "FILED"; foreColour = Brushes.Red; SetFieldEnable(btnProcessDoc, false); SetFieldEnable(btnDeleteDoc, false); break; } } else if ((_curDocScanDocInfo != null) && (_curDocScanDocInfo.flagForHelpFiling)) { statusStr = "FLAGGED"; foreColour = Brushes.Red; } else if (_curDocScanDocInfo != null) { if (!File.Exists(_curDocScanDocInfo.GetOrigFileNameWin())) { string archiveFileName = ScanDocHandler.GetArchiveFileName(_curDocScanDocInfo.uniqName); if (!File.Exists(archiveFileName)) { statusStr = "ORIGINAL MISSING!"; foreColour = Brushes.Red; btnEditPdf.IsEnabled = false; processButtonsEnabled = false; } else { statusStr = "Unfiled (original moved but backup ok)"; } } } btnEditPdf.IsEnabled = processButtonsEnabled; btnProcessDoc.IsEnabled = processButtonsEnabled; SetLabelContent(lblStatusBarFileName, (_curDocScanDocInfo != null) ? (_curDocScanDocInfo.uniqName + " " + statusStr) : ""); lblStatusBarFileName.Foreground = foreColour; ShowFilingPath(); }
private void btnMoneySumFromPageText_Click(object sender, RoutedEventArgs e) { _touchFromPageText = TouchFromPageText.TOUCH_MONEY; }
private void btnSuffixFromPageText_Click(object sender, RoutedEventArgs e) { _touchFromPageText = TouchFromPageText.TOUCH_SUFFIX; }
private void btnEventNameFromPageText_Click(object sender, RoutedEventArgs e) { _touchFromPageText = TouchFromPageText.TOUCH_EVENT_NAME; }
private void btnEventLocnFromPageText_Click(object sender, RoutedEventArgs e) { _touchFromPageText = TouchFromPageText.TOUCH_EVENT_LOCN; }
private void btnEventDescFromPageText_Click(object sender, RoutedEventArgs e) { _touchFromPageText = TouchFromPageText.TOUCH_EVENT_DESC; }
private void btnDateFromPageText_Click(object sender, RoutedEventArgs e) { _touchFromPageText = TouchFromPageText.TOUCH_DATE; }
private void imageDocToFile_MouseDown(object sender, MouseButtonEventArgs e) { e.Handled = true; if (_curDocScanPages == null) return; if (_touchFromPageText == TouchFromPageText.TOUCH_NONE) return; // Check for touch point Point curMousePoint = e.GetPosition(imageDocToFile); Point docCoords = ConvertImagePointToDocPoint(imageDocToFile, curMousePoint.X, curMousePoint.Y); DocRectangle docRect = new DocRectangle(docCoords.X, docCoords.Y, 0, 0); int pgNum = _curDocDisplay_pageNum; if (_curDocDisplay_pageNum < 1) pgNum = 1; if (_curDocDisplay_pageNum >= _curDocScanPages.scanPagesText.Count) pgNum = _curDocScanPages.scanPagesText.Count; // Check for date if ((_touchFromPageText == TouchFromPageText.TOUCH_DATE) || (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_DATE)) { bool earliestDateReq = false; bool latestDateReq = false; List<ExtractedDate> extractedDates = new List<ExtractedDate>(); DocTextAndDateExtractor.SearchForDateItem(_curDocScanPages, "", docRect, 0, extractedDates, ref latestDateReq, ref earliestDateReq, pgNum, false); if (extractedDates.Count <= 0) DocTextAndDateExtractor.SearchForDateItem(_curDocScanPages, "", docRect, 0, extractedDates, ref latestDateReq, ref earliestDateReq, pgNum, true); if (extractedDates.Count > 0) { if (_touchFromPageText == TouchFromPageText.TOUCH_DATE) SetDateRollers(extractedDates[0].dateTime.Year, extractedDates[0].dateTime.Month, extractedDates[0].dateTime.Day, dateRollerChange.none); else datePickerEventDate.SelectedDate = new DateTime(extractedDates[0].dateTime.Year, extractedDates[0].dateTime.Month, extractedDates[0].dateTime.Day); } } else if ((_touchFromPageText == TouchFromPageText.TOUCH_SUFFIX) || (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_NAME) || (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_DESC) || (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_LOCN)) { string extractedText = DocTextAndDateExtractor.ExtractTextFromPage(_curDocScanPages, docRect, pgNum); if (extractedText != "") { if (_touchFromPageText == TouchFromPageText.TOUCH_SUFFIX) txtDestFileSuffix.Text = txtDestFileSuffix.Text + (txtDestFileSuffix.Text.Trim() == "" ? "" : " ") + extractedText; else if (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_NAME) txtEventName.Text = txtEventName.Text + (txtEventName.Text.Trim() == "" ? "" : " ") + extractedText; else if (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_DESC) txtEventDesc.Text = txtEventDesc.Text + (txtEventDesc.Text.Trim() == "" ? "" : " ") + extractedText; else if (_touchFromPageText == TouchFromPageText.TOUCH_EVENT_LOCN) txtEventLocn.Text = txtEventLocn.Text + (txtEventLocn.Text.Trim() == "" ? "" : " ") + extractedText; } } else if (_touchFromPageText == TouchFromPageText.TOUCH_MONEY) { string extractedText = DocTextAndDateExtractor.ExtractTextFromPage(_curDocScanPages, docRect, pgNum); if (extractedText != "") { // Get currency symbol if available int currencyLen = 1; int currencyPos = extractedText.IndexOf('$'); if (currencyPos < 0) currencyPos = extractedText.IndexOf('£'); if (currencyPos < 0) currencyPos = extractedText.IndexOf('€'); // Find number matching money format string noCurrencyStr = extractedText; if ((currencyPos >= 0) && (extractedText.Length > currencyPos + 1)) { noCurrencyStr = extractedText.Substring(currencyPos + 1); int whitespacePos = noCurrencyStr.IndexOf(' '); if (whitespacePos > 0) noCurrencyStr = noCurrencyStr.Substring(0, whitespacePos); } Match match = Regex.Match(noCurrencyStr, @"((?:^\d{1,3}(?:\.?\d{3})*(?:,\d{2})?$))|((?:^\d{1,3}(?:,?\d{3})*(?:\.\d{2})?$)((\d+)?(\.\d{1,2})?))"); if ((match.Success) && (match.Groups.Count > 1)) { // Found string may be ###,###.## or ###.###,## string foundStr = match.Groups[1].Value; if (foundStr.Trim() == "") { foundStr = match.Groups[2].Value; foundStr = foundStr.Replace(",", ""); } else { foundStr = foundStr.Replace(".", ""); } // Form string string numberText = (currencyPos >= 0 ? extractedText.Substring(currencyPos, currencyLen) : "") + foundStr; txtMoneySum.Text = txtMoneySum.Text + (txtMoneySum.Text.Trim() == "" ? "" : " ") + numberText; } else if (currencyPos >= 0) { txtMoneySum.Text = extractedText.Substring(currencyPos, currencyLen) + txtMoneySum.Text; } } } // Cancel touch activity _touchFromPageText = TouchFromPageText.TOUCH_NONE; }