markus / KCOM / Controls / SearchPanel.xaml.cs @ 9380813b
이력 | 보기 | 이력해설 | 다운로드 (18.6 KB)
1 | 9380813b | swate0609 | using Bytescout.PDFExtractor; |
---|---|---|---|
2 | using KCOM.Common; |
||
3 | e0cfc73c | ljiyeon | using MarkupToPDF.Common; |
4 | 787a4489 | KangIngu | using System; |
5 | using System.Collections.Generic; |
||
6 | 136851cb | djkim | using System.ComponentModel; |
7 | 0c997b99 | ljiyeon | using System.Diagnostics; |
8 | 787a4489 | KangIngu | using System.Linq; |
9 | using System.Text; |
||
10 | 136851cb | djkim | using System.Threading; |
11 | 6af42ff0 | taeseongkim | using System.Threading.Tasks; |
12 | 787a4489 | KangIngu | using System.Windows; |
13 | using System.Windows.Controls; |
||
14 | using System.Windows.Data; |
||
15 | using System.Windows.Documents; |
||
16 | using System.Windows.Input; |
||
17 | using System.Windows.Media; |
||
18 | using System.Windows.Media.Imaging; |
||
19 | using System.Windows.Navigation; |
||
20 | using System.Windows.Shapes; |
||
21 | 136851cb | djkim | using Telerik.Windows.Controls; |
22 | 9380813b | swate0609 | using Telerik.Windows.Controls.Rating; |
23 | 787a4489 | KangIngu | |
24 | namespace KCOM.Controls |
||
25 | { |
||
26 | 992a98b4 | KangIngu | public class SearchText |
27 | { |
||
28 | public Bytescout.PDFExtractor.ISearchResult searchResult { get; set; } |
||
29 | public int PageNo { get; set; } |
||
30 | } |
||
31 | 787a4489 | KangIngu | /// <summary> |
32 | /// Interaction logic for SearchPanel.xaml |
||
33 | /// </summary> |
||
34 | public partial class SearchPanel : UserControl |
||
35 | { |
||
36 | 992a98b4 | KangIngu | //List<HoneyheadTEXT> txtSet = new List<HoneyheadTEXT>(); |
37 | public System.Collections.ObjectModel.ObservableCollection<SearchText> SearchSet { get; set; } |
||
38 | string RegistrationKey = "193B-FD48-42F4-68E6-2D35-4C94-D07"; |
||
39 | string RegistrationName = "license@doftech.co.kr"; |
||
40 | Bytescout.PDFExtractor.TextExtractor extractor; |
||
41 | 401a87f8 | taeseongkim | //Bytescout.PDFExtractor.OCRAnalyzer ocrAnalyzer; |
42 | 136851cb | djkim | private BackgroundWorker worker = new BackgroundWorker(); |
43 | 6af42ff0 | taeseongkim | private bool IsCancelWork = false; |
44 | |||
45 | 787a4489 | KangIngu | public SearchPanel() |
46 | { |
||
47 | e0cfc73c | ljiyeon | App.splashString(ISplashMessage.SEARCHPANEL); |
48 | 79f3f21a | djkim | InitializeComponent(); |
49 | LibInit(); |
||
50 | //this.Loaded += SearchPanel_Loaded; |
||
51 | btnSearch.Click += BtnSearch_Click; |
||
52 | btnSearchPDFDownload.Click += BtnSearchPDFDownload_Click; |
||
53 | SearchSet = new System.Collections.ObjectModel.ObservableCollection<SearchText>(); |
||
54 | 136851cb | djkim | |
55 | 79f3f21a | djkim | tbSearch.KeyDown += tbSearch_KeyDown; |
56 | |||
57 | 136851cb | djkim | worker.DoWork += Worker_DoWork; |
58 | worker.RunWorkerCompleted += Worker_RunWorkerCompleted; |
||
59 | 79f3f21a | djkim | |
60 | 6af42ff0 | taeseongkim | this.DataContext = this; |
61 | 79f3f21a | djkim | /* |
62 | if (Common.ViewerDataModel.Instance.searchPDF ==null) |
||
63 | { |
||
64 | |||
65 | } |
||
66 | else |
||
67 | { |
||
68 | border_Overlap.Visibility = Visibility.Collapsed; |
||
69 | tbSearch.Focus(); |
||
70 | |||
71 | } |
||
72 | */ |
||
73 | |||
74 | 6af42ff0 | taeseongkim | if (ViewerDataModel.Instance.IsDownloadOriginal) |
75 | 79f3f21a | djkim | { |
76 | 6af42ff0 | taeseongkim | SetSerachPDFFile(ViewerDataModel.Instance.OriginalTempFile); |
77 | 79f3f21a | djkim | } |
78 | 787a4489 | KangIngu | } |
79 | |||
80 | 136851cb | djkim | private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
81 | { |
||
82 | Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
83 | 29010418 | ljiyeon | { |
84 | 6af42ff0 | taeseongkim | btnSearch.Content = "Search"; |
85 | IsCancelWork = false; |
||
86 | |||
87 | this.searchIndicator.IsIndeterminate = false; |
||
88 | 9380813b | swate0609 | |
89 | //Debuging용 데이터 |
||
90 | //SearchSet.Add(new SearchText() { PageNo = 1, searchResult = null }); |
||
91 | //SearchSet.Add(new SearchText() { PageNo = 2, searchResult = null }); |
||
92 | //SearchSet.Add(new SearchText() { PageNo = 3, searchResult = null }); |
||
93 | //SearchSet.Add(new SearchText() { PageNo = 4, searchResult = null }); |
||
94 | |||
95 | 136851cb | djkim | this.DataContext = this; |
96 | 6af42ff0 | taeseongkim | //tbSearch.Text = ""; |
97 | 136851cb | djkim | tbSearch.Focus(); |
98 | |||
99 | 6af42ff0 | taeseongkim | txtSearchMsg.Text = "search has completed."; |
100 | })); |
||
101 | 136851cb | djkim | } |
102 | //private System.Collections.ObjectModel.ObservableCollection<SearchText> searchTexts = null; |
||
103 | private void Worker_DoWork(object sender, DoWorkEventArgs e) |
||
104 | { |
||
105 | string searchString = string.Empty; |
||
106 | bool pageoption = false; |
||
107 | |||
108 | Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
109 | { |
||
110 | SearchSet.Clear(); |
||
111 | searchString = tbSearch.Text; |
||
112 | pageoption = chkCurrentPageOnly.IsChecked.Value; |
||
113 | })); |
||
114 | 29010418 | ljiyeon | |
115 | 136851cb | djkim | extractor.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
116 | 401a87f8 | taeseongkim | extractor.RegexSearch = true; |
117 | |||
118 | 223975f7 | taeseongkim | //ocrAnalyzer.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
119 | 136851cb | djkim | |
120 | if (pageoption) |
||
121 | { |
||
122 | var currentPage = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber - 1; |
||
123 | |||
124 | 223975f7 | taeseongkim | //Bytescout.PDFExtractor.OCRAnalysisResults analysisResults = ocrAnalyzer.AnalyzeByOCRConfidence(currentPage); |
125 | //ocrAnalyzer.ApplyResults(analysisResults, extractor); |
||
126 | 136851cb | djkim | |
127 | if (extractor.Find(currentPage, searchString, false)) |
||
128 | do |
||
129 | { |
||
130 | Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
131 | { |
||
132 | SearchSet.Add(new SearchText { PageNo = currentPage + 1, searchResult = extractor.FoundText }); |
||
133 | 29010418 | ljiyeon | })); |
134 | 136851cb | djkim | } |
135 | while (extractor.FindNext()); |
||
136 | } |
||
137 | else |
||
138 | { |
||
139 | int pageCount = extractor.GetPageCount(); |
||
140 | 6af42ff0 | taeseongkim | |
141 | 136851cb | djkim | for (int i = 0; i < pageCount; i++) |
142 | { |
||
143 | 6af42ff0 | taeseongkim | txtSearchMsg.Dispatcher.Invoke(()=> txtSearchMsg.Text = $"Search Pages {i + 1}/{pageCount}"); |
144 | |||
145 | //Bytescout.PDFExtractor.OCRAnalysisResults analysisResults = ocrAnalyzer.AnalyzeByOCRConfidence(i); |
||
146 | 223975f7 | taeseongkim | //ocrAnalyzer.ApplyResults(analysisResults, extractor); |
147 | 136851cb | djkim | if (extractor.Find(i, searchString, false)) |
148 | do |
||
149 | { |
||
150 | Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
151 | { |
||
152 | SearchSet.Add(new SearchText { PageNo = i + 1, searchResult = extractor.FoundText }); |
||
153 | 29010418 | ljiyeon | })); |
154 | 6af42ff0 | taeseongkim | |
155 | if(IsCancelWork) |
||
156 | { |
||
157 | break; |
||
158 | } |
||
159 | 136851cb | djkim | } |
160 | while (extractor.FindNext()); |
||
161 | 6af42ff0 | taeseongkim | |
162 | if (IsCancelWork) |
||
163 | { |
||
164 | break; |
||
165 | } |
||
166 | 136851cb | djkim | } |
167 | 29010418 | ljiyeon | } |
168 | 136851cb | djkim | } |
169 | |||
170 | 992a98b4 | KangIngu | private void tbSearch_KeyDown(object sender, KeyEventArgs e) |
171 | 787a4489 | KangIngu | { |
172 | 992a98b4 | KangIngu | if (e.Key == Key.Enter) |
173 | { |
||
174 | SearchMethod(); |
||
175 | } |
||
176 | 787a4489 | KangIngu | } |
177 | 79f3f21a | djkim | private void LibInit() |
178 | { |
||
179 | 136851cb | djkim | try |
180 | { |
||
181 | extractor = new Bytescout.PDFExtractor.TextExtractor(RegistrationName, RegistrationKey); |
||
182 | 401a87f8 | taeseongkim | //ocrAnalyzer = new Bytescout.PDFExtractor.OCRAnalyzer(RegistrationName, RegistrationKey); |
183 | extractor.OCRMode = Bytescout.PDFExtractor.OCRMode.Off; |
||
184 | //extractor.OCRLanguage = "eng"; |
||
185 | //extractor.OCRLanguageDataFolder = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "tessdata"); |
||
186 | 3b938959 | taeseongkim | |
187 | extractor.OCRResolution = 100; |
||
188 | 136851cb | djkim | |
189 | 401a87f8 | taeseongkim | //ocrAnalyzer.OCRLanguage = "eng"; |
190 | //ocrAnalyzer.OCRLanguageDataFolder = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "tessdata"); |
||
191 | 136851cb | djkim | |
192 | } |
||
193 | catch (Exception ex) |
||
194 | { |
||
195 | 664ea2e1 | taeseongkim | //Logger.sendResLog("LibInit", ex.Message, 0); |
196 | 136851cb | djkim | } |
197 | 787a4489 | KangIngu | |
198 | 79f3f21a | djkim | } |
199 | 6af42ff0 | taeseongkim | |
200 | 787a4489 | KangIngu | private void SearchPanel_Loaded(object sender, RoutedEventArgs e) |
201 | { |
||
202 | 6af42ff0 | taeseongkim | //// |
203 | /// 이벤트 안 들어옴 |
||
204 | |||
205 | |||
206 | 0c997b99 | ljiyeon | //측정 |
207 | //Stopwatch sw = new Stopwatch(); |
||
208 | //sw.Start(); |
||
209 | InitializeComponent(); |
||
210 | //System.Diagnostics.Debug.WriteLine("SearchPanel() : " + sw.ElapsedMilliseconds.ToString() + "ms"); |
||
211 | 136851cb | djkim | |
212 | 0c997b99 | ljiyeon | btnSearch.Click += BtnSearch_Click; |
213 | btnSearchPDFDownload.Click += BtnSearchPDFDownload_Click; |
||
214 | SearchSet = new System.Collections.ObjectModel.ObservableCollection<SearchText>(); |
||
215 | extractor = new Bytescout.PDFExtractor.TextExtractor(RegistrationName, RegistrationKey); |
||
216 | tbSearch.KeyDown += tbSearch_KeyDown; |
||
217 | 6af42ff0 | taeseongkim | |
218 | 0c997b99 | ljiyeon | this.DataContext = this; |
219 | |||
220 | 992a98b4 | KangIngu | } |
221 | |||
222 | private void BtnSearchPDFDownload_Click(object sender, RoutedEventArgs e) |
||
223 | { |
||
224 | 136851cb | djkim | try |
225 | 992a98b4 | KangIngu | { |
226 | 6af42ff0 | taeseongkim | Common.ViewerDataModel.Instance.IsDownloadCancel = true; |
227 | |||
228 | |||
229 | 136851cb | djkim | using (System.Net.WebClient client = new System.Net.WebClient()) |
230 | { |
||
231 | string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp"); |
||
232 | client.DownloadFileCompleted += Client_DownloadFileCompleted; |
||
233 | client.DownloadProgressChanged += Client_DownloadProgressChanged; |
||
234 | 223975f7 | taeseongkim | string downloadurl = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.GetOriginalPDFURL(); |
235 | 6af42ff0 | taeseongkim | |
236 | client.DownloadFileAsync(new Uri(downloadurl), instnaceFile); |
||
237 | 136851cb | djkim | } |
238 | } |
||
239 | catch (Exception ex) |
||
240 | { |
||
241 | 664ea2e1 | taeseongkim | //Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0); |
242 | 992a98b4 | KangIngu | } |
243 | } |
||
244 | |||
245 | 6af42ff0 | taeseongkim | |
246 | 992a98b4 | KangIngu | private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) |
247 | { |
||
248 | 6af42ff0 | taeseongkim | SetSerachPDFFile(e.UserState.ToString()); |
249 | } |
||
250 | |||
251 | public void SetSerachPDFFile(string FileFullPath) |
||
252 | { |
||
253 | 992a98b4 | KangIngu | border_Overlap.Visibility = Visibility.Collapsed; |
254 | 6af42ff0 | taeseongkim | Common.ViewerDataModel.Instance.searchPDF = new System.IO.FileInfo(FileFullPath); |
255 | 401a87f8 | taeseongkim | //OcrAnalyzer(); |
256 | |||
257 | 6af42ff0 | taeseongkim | tbSearch.Focus(); |
258 | 992a98b4 | KangIngu | } |
259 | |||
260 | 401a87f8 | taeseongkim | //private void OcrAnalyzer() |
261 | //{ |
||
262 | // System.Drawing.RectangleF rectangle = System.Drawing.RectangleF.Empty; |
||
263 | |||
264 | // // Display analysis progress |
||
265 | // ocrAnalyzer.ProgressChanged += (object sender, string message, double progress, ref bool cancel)=> |
||
266 | // { |
||
267 | // System.Diagnostics.Debug.WriteLine(message); |
||
268 | // }; |
||
269 | |||
270 | // // Load document to OCRAnalyzer |
||
271 | // ocrAnalyzer.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
||
272 | |||
273 | // // Set page area for analysis (optional) |
||
274 | // ocrAnalyzer.SetExtractionArea(rectangle); |
||
275 | |||
276 | // // Perform analysis and get results |
||
277 | // Bytescout.PDFExtractor.OCRAnalysisResults analysisResults = ocrAnalyzer.AnalyzeByOCRConfidence(0); |
||
278 | |||
279 | // // Now extract the text using detected OCR parameters |
||
280 | |||
281 | // string outputDocument = @".\result.txt"; |
||
282 | |||
283 | // // Create TextExtractor instance |
||
284 | |||
285 | // // Load document to TextExtractor |
||
286 | // extractor.LoadDocumentFromFile(Common.ViewerDataModel.Instance.searchPDF.FullName); |
||
287 | |||
288 | // // Setup TextExtractor |
||
289 | // extractor.OCRMode = Bytescout.PDFExtractor.OCRMode.TextFromImagesAndVectorsAndFonts; |
||
290 | // extractor.OCRLanguageDataFolder = ocrAnalyzer.OCRLanguageDataFolder; |
||
291 | // extractor.OCRLanguage = ocrAnalyzer.OCRLanguage; |
||
292 | |||
293 | // // Apply analysys results to TextExtractor instance |
||
294 | // ocrAnalyzer.ApplyResults(analysisResults, extractor); |
||
295 | |||
296 | // // Set extraction area (optional) |
||
297 | // extractor.SetExtractionArea(rectangle); |
||
298 | |||
299 | // // Save extracted text to file |
||
300 | // extractor.SaveTextToFile(outputDocument); |
||
301 | |||
302 | //} |
||
303 | |||
304 | 992a98b4 | KangIngu | private void Client_DownloadProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e) |
305 | { |
||
306 | tlDonwloadState.Text = "문서를 다운로드 중입니다 : " + e.ProgressPercentage; |
||
307 | 136851cb | djkim | |
308 | 992a98b4 | KangIngu | } |
309 | |||
310 | private void BtnSearch_Click(object sender, RoutedEventArgs e) |
||
311 | { |
||
312 | SearchMethod(); |
||
313 | } |
||
314 | 136851cb | djkim | |
315 | 992a98b4 | KangIngu | private void SearchMethod() |
316 | { |
||
317 | 6af42ff0 | taeseongkim | string _strCancel = "Cancel"; // 나중에 정리 |
318 | |||
319 | 136851cb | djkim | try |
320 | 992a98b4 | KangIngu | { |
321 | 6af42ff0 | taeseongkim | if (btnSearch.Content.ToString() == _strCancel) |
322 | { |
||
323 | IsCancelWork = true; |
||
324 | c5519c44 | taeseongkim | worker.CancelAsync(); |
325 | 6af42ff0 | taeseongkim | } |
326 | |||
327 | 136851cb | djkim | if (!worker.IsBusy) |
328 | 992a98b4 | KangIngu | { |
329 | 136851cb | djkim | SearchSet.Clear(); |
330 | 6af42ff0 | taeseongkim | |
331 | this.searchIndicator.IsIndeterminate = true; |
||
332 | btnSearch.Content = _strCancel; |
||
333 | |||
334 | 136851cb | djkim | worker.RunWorkerAsync(); |
335 | 992a98b4 | KangIngu | } |
336 | } |
||
337 | 136851cb | djkim | catch (Exception ex) |
338 | { |
||
339 | 664ea2e1 | taeseongkim | //Logger.sendResLog("SearchMethod", ex.Message, 0); |
340 | 136851cb | djkim | } |
341 | 992a98b4 | KangIngu | |
342 | } |
||
343 | 136851cb | djkim | private void DialogMessage_Alert(string Msg) |
344 | { |
||
345 | RadWindow CheckPop = new RadWindow(); |
||
346 | Alert check = new Alert(Msg); |
||
347 | 992a98b4 | KangIngu | |
348 | 136851cb | djkim | CheckPop = new RadWindow |
349 | { |
||
350 | Owner = Application.Current.MainWindow, |
||
351 | MinWidth = 400, |
||
352 | MinHeight = 100, |
||
353 | //Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args), |
||
354 | Header = "Alert", |
||
355 | Content = check, |
||
356 | ResizeMode = System.Windows.ResizeMode.NoResize, |
||
357 | WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen, |
||
358 | IsTopmost = true, |
||
359 | }; |
||
360 | StyleManager.SetTheme(CheckPop, new Office2013Theme()); |
||
361 | CheckPop.ShowDialog(); |
||
362 | } |
||
363 | 992a98b4 | KangIngu | private void chkSelectionChangeEvent(object sender, RoutedEventArgs e) |
364 | { |
||
365 | 136851cb | djkim | try |
366 | 992a98b4 | KangIngu | { |
367 | 136851cb | djkim | if (Common.ViewerDataModel.Instance.searchPDF != null) |
368 | 992a98b4 | KangIngu | { |
369 | 136851cb | djkim | if (sender is RadioButton) |
370 | 992a98b4 | KangIngu | { |
371 | 136851cb | djkim | switch ((sender as RadioButton).Tag.ToString()) |
372 | { |
||
373 | case "0": |
||
374 | extractor.WordMatchingMode = Bytescout.PDFExtractor.WordMatchingMode.None; |
||
375 | break; |
||
376 | case "1": |
||
377 | extractor.WordMatchingMode = Bytescout.PDFExtractor.WordMatchingMode.ExactMatch; |
||
378 | break; |
||
379 | case "2": |
||
380 | extractor.WordMatchingMode = Bytescout.PDFExtractor.WordMatchingMode.SmartMatch; |
||
381 | break; |
||
382 | default: |
||
383 | break; |
||
384 | } |
||
385 | 992a98b4 | KangIngu | } |
386 | } |
||
387 | } |
||
388 | 136851cb | djkim | catch (Exception ex) |
389 | { |
||
390 | 664ea2e1 | taeseongkim | //Logger.sendResLog("chkSelectionChangeEvent", ex.Message, 0); |
391 | 136851cb | djkim | } |
392 | |||
393 | 992a98b4 | KangIngu | } |
394 | |||
395 | 9380813b | swate0609 | private void lstSearchWord_PreviewKeyDown(object sender, KeyEventArgs e) |
396 | { |
||
397 | int iIndex = this.lstSearchWord.SelectedIndex; |
||
398 | |||
399 | if (iIndex > -1) |
||
400 | { |
||
401 | if (e.Key == Key.Up) |
||
402 | { |
||
403 | int iUpIndex = iIndex- 1; |
||
404 | if(iUpIndex > -1) |
||
405 | { |
||
406 | this.lstSearchWord.SelectedIndex = iUpIndex; |
||
407 | } |
||
408 | } |
||
409 | else if (e.Key == Key.Down) |
||
410 | { |
||
411 | int iDownIndex = iIndex + 1; |
||
412 | if(iDownIndex < this.lstSearchWord.Items.Count-1) |
||
413 | { |
||
414 | this.lstSearchWord.SelectedIndex = iDownIndex; |
||
415 | } |
||
416 | } |
||
417 | } |
||
418 | } |
||
419 | |||
420 | 992a98b4 | KangIngu | private void lstSearchWord_SelectionChanged(object sender, SelectionChangedEventArgs e) |
421 | { |
||
422 | 136851cb | djkim | try |
423 | 992a98b4 | KangIngu | { |
424 | 136851cb | djkim | if (e.AddedItems.Count > 0) |
425 | { |
||
426 | SearchText item = (e.AddedItems[0] as SearchText); |
||
427 | 992a98b4 | KangIngu | |
428 | 6af42ff0 | taeseongkim | if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber == item.PageNo) |
429 | { |
||
430 | GotoPosition(item); |
||
431 | } |
||
432 | else |
||
433 | 136851cb | djkim | { |
434 | 5a00ee8e | taeseongkim | var pageNavigator = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator; |
435 | 136851cb | djkim | |
436 | eeb0a39c | taeseongkim | EventHandler<EventArgs> handler = null; |
437 | 5a00ee8e | taeseongkim | |
438 | handler = (snd, evt) => |
||
439 | 6af42ff0 | taeseongkim | { |
440 | GotoPosition(item); |
||
441 | eeb0a39c | taeseongkim | ViewerDataModel.Instance.PageLoaded -= handler; |
442 | 6af42ff0 | taeseongkim | }; |
443 | 5a00ee8e | taeseongkim | |
444 | eeb0a39c | taeseongkim | ViewerDataModel.Instance.PageLoaded += handler; |
445 | 5a00ee8e | taeseongkim | pageNavigator.GotoPage(item.PageNo); |
446 | |||
447 | 6af42ff0 | taeseongkim | } |
448 | 136851cb | djkim | } |
449 | 992a98b4 | KangIngu | } |
450 | 136851cb | djkim | catch (Exception ex) |
451 | { |
||
452 | 664ea2e1 | taeseongkim | //Logger.sendResLog("lstSearchWord_SelectionChanged", ex.Message, 0); |
453 | 136851cb | djkim | } |
454 | |||
455 | 787a4489 | KangIngu | } |
456 | 6af42ff0 | taeseongkim | |
457 | private void GotoPosition(SearchText item) |
||
458 | { |
||
459 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Dispatcher.Invoke(() => { |
||
460 | |||
461 | 4f017ed3 | taeseongkim | for (int i = 0; i < (Common.ViewerDataModel.Instance.MarkupAngle / 90); i++) |
462 | 5beaf28e | taeseongkim | { |
463 | Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true); |
||
464 | } |
||
465 | |||
466 | 6af42ff0 | taeseongkim | var width = Convert.ToDouble(Common.ViewerDataModel.Instance.Document_Info[item.PageNo - 1].PAGE_WIDTH); |
467 | var height = Convert.ToDouble(Common.ViewerDataModel.Instance.Document_Info[item.PageNo - 1].PAGE_HEIGHT); |
||
468 | 3b938959 | taeseongkim | |
469 | 6af42ff0 | taeseongkim | var widthScale = width / Convert.ToDouble(extractor.GetPageRect_Width(item.PageNo - 1)); |
470 | var heightScale = height / Convert.ToDouble(extractor.GetPageRect_Height(item.PageNo - 1)); |
||
471 | |||
472 | f4ec4218 | taeseongkim | var searchFocus = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SearchFocusBorder; |
473 | searchFocus.Visibility = Visibility; |
||
474 | |||
475 | 9380813b | swate0609 | if (item.searchResult != null) |
476 | 6af42ff0 | taeseongkim | { |
477 | 9380813b | swate0609 | Canvas.SetLeft(searchFocus, item.searchResult.Left * widthScale); |
478 | Canvas.SetTop(searchFocus, item.searchResult.Top * heightScale); |
||
479 | searchFocus.Width = item.searchResult.Width * widthScale; |
||
480 | searchFocus.Height = item.searchResult.Height * widthScale; |
||
481 | |||
482 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect |
||
483 | { |
||
484 | X = item.searchResult.Left * widthScale, |
||
485 | Y = item.searchResult.Top * heightScale, |
||
486 | Width = (item.searchResult.Width * widthScale * 7), |
||
487 | Height = (item.searchResult.Height * heightScale * 7) |
||
488 | }); |
||
489 | } |
||
490 | 3b938959 | taeseongkim | |
491 | //extractor.SavePageTextToFile(item.PageNo - 1, @"C:\Users\kts\AppData\Local\Temp\MARKUS\savepageText\text.txt"); |
||
492 | //extractor.SavePreprocessedPagePreview(item.PageNo - 1, $"C:\\Users\\kts\\AppData\\Local\\Temp\\MARKUS\\savepageText\\{(item.PageNo - 1).ToString()}.png"); |
||
493 | 6af42ff0 | taeseongkim | }); |
494 | } |
||
495 | 9380813b | swate0609 | |
496 | |||
497 | 787a4489 | KangIngu | } |
498 | } |