public void OpenFile() { SyncContext.Post( _ => { if (OpenFileSemaphore.Wait(0) == false) { return; } if (PdfWindow == null) { CreatePdfWindow(null); } string filePath = PdfWindow.OpenFileDialog(); if (filePath != null) { PDFElement.Create(filePath); } OpenFileSemaphore.Release(); }, null ); }
private void OpenElement(PDFElement pdfElem) { if (pdfElem == null) { return; } LastElement = pdfElem; EnsurePdfWindow(); PdfWindow.OpenDocument(pdfElem); PdfWindow.ForceActivate(); }
public void OnElementChanged(IElement newElem, IControlHtml ctrlHtml) { PdfWindow?.CancelSave(); if (newElem == null) { return; } if (LastElement?.ElementId == newElem.Id) { return; } var html = ctrlHtml?.Text ?? string.Empty; var pdfEl = newElem.Type == ElementType.Topic ? PDFElement.TryReadElement(html, newElem.Id) : null; bool noNewElem = pdfEl == null; bool noLastElem = LastElement == null || (Svc.SM.Registry.Element[LastElement.ElementId]?.Deleted ?? true); if (noNewElem && noLastElem) { return; } SyncContext.Send( delegate { bool close = LastElement != null && pdfEl == null; CloseElement(); OpenElement(pdfEl); if (close) { PdfWindow?.Close(); } }, null); }
public void OpenFile() { SyncContext.Post( _ => { if (PdfWindow == null) { CreatePdfWindow(null); } string filePath = PdfWindow.OpenFileDialog(); if (filePath != null) { PDFElement.Create(filePath); } }, null ); }