private void btnOpen_Click(object sender, EventArgs e) { bool timerStarted = timer1.Enabled; timer1.Stop(); uint oldDocId = 0; if (pdfCtl.HasDoc) { oldDocId = pdfCtl.Doc.ID; } pdfCtl.OpenDocWithDlg(); uint newDocId = 0; if (pdfCtl.HasDoc) { newDocId = pdfCtl.Doc.ID; } if (wordsRanges == null) { PDFXEdit.IAUX_Inst auxInst = (PDFXEdit.IAUX_Inst)pdfCtl.Inst.GetExtension("AUX"); wordsRanges = auxInst.CreateNumArray(); wordRange = auxInst.CreateNumArray(); } if (newDocId != oldDocId) // new document opened { // restart endReached = false; curPage = -1; curWord = -1; docHighlighter = null; pageSolidHighlight = null; dhp.Stop(false); } if (pdfCtl.HasDoc) { if (timerStarted) { timer1.Start(); } } UpdateStartBtn(); }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { ///////////////////////////////////////////////////////////////////////////////////// // Forced release of all COM-objects that may still captured by Garbage Collector. // // It is critical to release them before destroying of pdfCtl! // ///////////////////////////////////////////////////////////////////////////////////// wordsRanges = null; docHighlighter = null; brush = null; pen = null; dhp.Stop(true); dhp = null; mh = null; GC.Collect(); GC.WaitForPendingFinalizers(); }