static void Main() { Logging.Info("+static Main()"); try { splashscreen_window.UpdateMessage("Logging in"); LoginWindow login_window = new LoginWindow(); login_window.ChooseLogin(splashscreen_window); splashscreen_window.Close(); WPFDoEvents.DoEvents(); try { application.Run(); } catch (Exception ex) { Logging.Error(ex, "Exception caught at Main() application.Run(). Disaster."); } DoShutdown(); } catch (Exception ex) { Logging.Error(ex, "Exception caught at Main(). Disaster."); } Logging.Info("-static Main()"); }
public static PivotResult GeneratePivot(MultiMapSet <string, string> map_y_axis, MultiMapSet <string, string> map_x_axis) { List <string> y_keys = new List <string>(map_y_axis.Keys); List <string> x_keys = new List <string>(map_x_axis.Keys); y_keys.Sort(); x_keys.Sort(); List <string>[,] common_fingerprints = new List <string> [y_keys.Count, x_keys.Count]; StatusManager.Instance.ClearCancelled("LibraryPivot"); int y_progress = 0; Parallel.For(0, y_keys.Count, (y, loop_state) => //for (int y = 0; y < y_keys.Count; ++y) { int y_progress_locked = Interlocked.Increment(ref y_progress); if (General.HasPercentageJustTicked(y_progress_locked, y_keys.Count)) { StatusManager.Instance.UpdateStatusBusy("LibraryPivot", "Building library pivot", y_progress_locked, y_keys.Count, true); WPFDoEvents.DoEvents();// HackityHack if (StatusManager.Instance.IsCancelled("LibraryPivot")) { Logging.Warn("User cancelled library pivot generation"); loop_state.Break(); } } string y_key = y_keys[y]; HashSet <string> y_values = map_y_axis.Get(y_key); for (int x = 0; x < x_keys.Count; ++x) { string x_key = x_keys[x]; HashSet <string> x_values = map_x_axis.Get(x_key); var common_fingerprint = y_values.Intersect(x_values); if (0 < common_fingerprint.Count()) { common_fingerprints[y, x] = new List <string>(common_fingerprint); } } }); StatusManager.Instance.UpdateStatus("LibraryPivot", "Built library pivot"); PivotResult pivot_result = new PivotResult(); pivot_result.y_keys = y_keys; pivot_result.x_keys = x_keys; pivot_result.common_fingerprints = common_fingerprints; return(pivot_result); }
public override DocumentPage GetPage(int page_zero_based) { // Hackity hack WPFDoEvents.DoEvents(); if (null != last_document_page) { last_document_page.Dispose(); last_document_page = null; } int page = page_from + page_zero_based; StatusManager.Instance.UpdateStatus("PDFPrinter", String.Format("Printing page {0} of {1}", page_zero_based + 1, this.PageCount), page_zero_based + 1, this.PageCount, true); // Render a page at 300 DPI... using (Image image = Image.FromStream(new MemoryStream(pdf_renderer.GetPageByDPIAsImage(page, 300)))) { PDFOverlayRenderer.RenderAnnotations(image, pdf_document, page, null); PDFOverlayRenderer.RenderHighlights(image, pdf_document, page); PDFOverlayRenderer.RenderInks(image, pdf_document, page); BitmapSource image_page = BitmapImageTools.CreateBitmapSourceFromImage(image); image_page.Freeze(); DrawingVisual dv = new DrawingVisual(); using (DrawingContext dc = dv.RenderOpen()) { // Rotate the image if its orientation does not match the printer if ( page_size.Width < page_size.Height && image_page.Width > image_page.Height || page_size.Width > page_size.Height && image_page.Width < image_page.Height ) { image_page = new TransformedBitmap(image_page, new RotateTransform(90)); image_page.Freeze(); } dc.DrawImage(image_page, new Rect(0, 0, page_size.Width, page_size.Height)); } ++total_pages_printed; last_document_page = new DocumentPage(dv); return(last_document_page); } }
void Regenerate() { HashSet <string> parent_fingerprints = null; if (null != PDFDocuments && 0 < PDFDocuments.Count) { parent_fingerprints = new HashSet <string>(); foreach (var pdf_document in PDFDocuments) { parent_fingerprints.Add(pdf_document.Fingerprint); } } MultiMapSet <string, string> map_y_axis = LibraryPivotReportBuilder.GenerateAxisMap((string)ObjYAxis.SelectedItem, Library, parent_fingerprints); MultiMapSet <string, string> map_x_axis = LibraryPivotReportBuilder.GenerateAxisMap((string)ObjXAxis.SelectedItem, Library, parent_fingerprints); LibraryPivotReportBuilder.IdentifierImplementations.IdentifierImplementationDelegate identifier_implementation = LibraryPivotReportBuilder.IdentifierImplementations.GetIdentifierImplementation((string)ObjIdentifier.SelectedItem); LibraryPivotReportBuilder.PivotResult pivot_result = LibraryPivotReportBuilder.GeneratePivot(map_y_axis, map_x_axis); GridControl ObjGridControl = new GridControl(); ObjGridControlHolder.Content = ObjGridControl; ObjGridControl.Model.RowCount = map_y_axis.Count + 2; ObjGridControl.Model.ColumnCount = map_x_axis.Count + 2; // ROW/COLUMN Titles for (int y = 0; y < pivot_result.y_keys.Count; ++y) { ObjGridControl.Model[y + 1, 0].CellValue = pivot_result.y_keys[y]; ObjGridControl.Model[y + 1, 0].CellValueType = typeof(string); } for (int x = 0; x < pivot_result.x_keys.Count; ++x) { ObjGridControl.Model[0, x + 1].CellValue = pivot_result.x_keys[x]; ObjGridControl.Model[0, x + 1].CellValueType = typeof(string); } // Grid contents StatusManager.Instance.ClearCancelled("LibraryPivot"); for (int y = 0; y < pivot_result.y_keys.Count; ++y) { if (General.HasPercentageJustTicked(y, pivot_result.y_keys.Count)) { StatusManager.Instance.UpdateStatusBusy("LibraryPivot", "Building library pivot grid", y, pivot_result.y_keys.Count, true); WPFDoEvents.DoEvents();// HackityHack if (StatusManager.Instance.IsCancelled("LibraryPivot")) { Logging.Warn("User cancelled library pivot grid generation"); break; } } for (int x = 0; x < pivot_result.x_keys.Count; ++x) { identifier_implementation(Library, pivot_result.common_fingerprints[y, x], ObjGridControl.Model[y + 1, x + 1]); } } StatusManager.Instance.UpdateStatus("LibraryPivot", "Finished library pivot"); // ROW/COLUMN Totals { int y_total = 0; { for (int y = 0; y < pivot_result.y_keys.Count; ++y) { int total = 0; for (int x = 0; x < pivot_result.x_keys.Count; ++x) { if (null != pivot_result.common_fingerprints[y, x]) { total += pivot_result.common_fingerprints[y, x].Count; } } ObjGridControl.Model[y + 1, pivot_result.x_keys.Count + 1].CellValue = total; ObjGridControl.Model[y + 1, pivot_result.x_keys.Count + 1].CellValueType = typeof(int); y_total += total; } } int x_total = 0; { for (int x = 0; x < pivot_result.x_keys.Count; ++x) { int total = 0; for (int y = 0; y < pivot_result.y_keys.Count; ++y) { if (null != pivot_result.common_fingerprints[y, x]) { total += pivot_result.common_fingerprints[y, x].Count; } } ObjGridControl.Model[pivot_result.y_keys.Count + 1, x + 1].CellValue = total; ObjGridControl.Model[pivot_result.y_keys.Count + 1, x + 1].CellValueType = typeof(int); x_total += total; } } int common_total = (x_total + y_total) / 2; if (common_total != x_total || common_total != y_total) { throw new GenericException("X and Y totals do not match?!"); } ObjGridControl.Model[pivot_result.y_keys.Count + 1, pivot_result.x_keys.Count + 1].CellValue = common_total; ObjGridControl.Model[pivot_result.y_keys.Count + 1, pivot_result.x_keys.Count + 1].CellValueType = typeof(int); ObjGridControl.Model[0, pivot_result.x_keys.Count + 1].CellValue = "TOTAL"; ObjGridControl.Model[0, pivot_result.x_keys.Count + 1].CellValueType = typeof(string); ObjGridControl.Model[pivot_result.y_keys.Count + 1, 0].CellValue = "TOTAL"; ObjGridControl.Model[pivot_result.y_keys.Count + 1, 0].CellValueType = typeof(string); } // Store the results for the toolbar buttons last_pivot_result = pivot_result; last_ObjGridControl = ObjGridControl; }
public void UpdateMessage(string message) { TxtMessage.Text = message; WPFDoEvents.DoEvents(); }