markus / KCOM / Controls / PrintControl.xaml.cs @ 274cde11
이력 | 보기 | 이력해설 | 다운로드 (39.3 KB)
1 | 787a4489 | KangIngu | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Windows; |
||
5 | using System.Windows.Controls; |
||
6 | using System.Windows.Media; |
||
7 | using Telerik.Windows.Controls; |
||
8 | using System.Collections.ObjectModel; |
||
9 | using System.Drawing.Printing; |
||
10 | using System.Windows.Media.Imaging; |
||
11 | using KCOMDataModel.DataModel; |
||
12 | using Microsoft.Win32; |
||
13 | using System.IO; |
||
14 | using System.Timers; |
||
15 | //using IKCOM.Common; |
||
16 | using KCOM.Event; |
||
17 | using iTextSharp; |
||
18 | using iTextSharp.text; |
||
19 | //using Leadtools.Windows.Controls; |
||
20 | using IKCOM; |
||
21 | using iTextSharp.text.pdf; |
||
22 | using Microsoft.Office.Core; |
||
23 | 481c3fb9 | djkim | using System.Net; |
24 | 86bff326 | taeseongkim | using Image = System.Windows.Controls.Image; |
25 | e3a15e22 | djkim | |
26 | 787a4489 | KangIngu | namespace KCOM.Control |
27 | { |
||
28 | public class DefinedPages |
||
29 | { |
||
30 | 86bff326 | taeseongkim | public DOCINFO DocumentInfo { get; set; } |
31 | |||
32 | 787a4489 | KangIngu | public int PagesCount { get; set; } |
33 | public string vpSlip { get; set; } |
||
34 | public string vpTitle { get; set; } |
||
35 | public string fileUrl { get; set; } |
||
36 | public ImageBrush Back_Image { get; set; } |
||
37 | |||
38 | 86bff326 | taeseongkim | public double CurrentValue { get; set; } |
39 | |||
40 | 787a4489 | KangIngu | string _DefinedPagesStrings; |
41 | /// <summary> |
||
42 | /// 사용자 정의 페이지를 입력시 오류를 방지하기 위해 적용 |
||
43 | /// </summary> |
||
44 | public string DefinedPagesStrings |
||
45 | { |
||
46 | get { return _DefinedPagesStrings; } |
||
47 | set |
||
48 | { |
||
49 | if (string.IsNullOrWhiteSpace(value)) return; |
||
50 | |||
51 | var _definedPages = value.Replace('-', ',').Split(','); |
||
52 | List<char> _NotEx = new List<char>(); |
||
53 | |||
54 | foreach (var item in _definedPages) |
||
55 | { |
||
56 | bool _isNum = true; |
||
57 | |||
58 | foreach (var chr in item) |
||
59 | { |
||
60 | if (!char.IsNumber(chr)) |
||
61 | { |
||
62 | _NotEx.Add(chr); |
||
63 | _isNum = false; |
||
64 | } |
||
65 | } |
||
66 | |||
67 | if (_isNum) |
||
68 | { |
||
69 | if (Convert.ToInt32(item) > PagesCount) |
||
70 | throw new Exception(string.Format("Max Page Number is '{0}'!!.", PagesCount)); |
||
71 | } |
||
72 | } |
||
73 | |||
74 | if (_NotEx.Count() > 0) |
||
75 | { |
||
76 | string _notString = ""; |
||
77 | _NotEx.ForEach(s => _notString += s.ToString()); |
||
78 | throw new Exception(string.Format("'{0}' Can not be added.", _notString)); |
||
79 | } |
||
80 | |||
81 | |||
82 | try |
||
83 | { |
||
84 | |||
85 | string _notString2 = ""; |
||
86 | _NotEx.ForEach(s => _notString2 += s.ToString()); |
||
87 | _DefinedPagesStrings = value; |
||
88 | } |
||
89 | catch (Exception) |
||
90 | { |
||
91 | throw new Exception(string.Format("Can not be added.")); |
||
92 | } |
||
93 | |||
94 | } |
||
95 | } |
||
96 | } |
||
97 | |||
98 | /// <summary> |
||
99 | /// Interaction logic for Print.xaml |
||
100 | /// </summary> |
||
101 | public partial class PrintControl : UserControl |
||
102 | { |
||
103 | #region Data |
||
104 | |||
105 | string ProjectNo = null; //프로젝트 넘버 |
||
106 | string _DefaultTileUri = null; //기본 타일 경로 |
||
107 | int _StartPageNo; //시작페이지 |
||
108 | DOCINFO _DocInfo; //문서 정보 |
||
109 | //DocInfo _DocInfo; //문서 정보 |
||
110 | bool currentPagePrint = false; //현재 페이지 수 |
||
111 | int PageCount { get; set; } //총 페이지수 |
||
112 | DefinedPages _definePages = null; //인쇄 설정 범위 지정 |
||
113 | public bool IsPrint { get; set; } |
||
114 | |||
115 | PrintDocument printDocument = new PrintDocument(); //프린터도큐먼트 생성 |
||
116 | |||
117 | //LayerControl LayerControl = null; // 레이어 컨트롤 |
||
118 | ObservableCollection<IKCOM.MarkupInfoItem> _markupInfo = new ObservableCollection<IKCOM.MarkupInfoItem>(); //마크업 정보 |
||
119 | List<MarkupPageItem> _PageMarkupList = new List<MarkupPageItem>(); |
||
120 | List<SetColorMarkupItem> _LoadMakupList = new List<SetColorMarkupItem>(); |
||
121 | List<int> _lstPrintPageNo = new List<int>(); |
||
122 | |||
123 | System.Windows.Threading.DispatcherTimer tm = new System.Windows.Threading.DispatcherTimer(); |
||
124 | bool _initializeComponentFinished; //이벤트 |
||
125 | bool _IsDagSlider = false; //드래그 상태인가 |
||
126 | List<DisplayColorInfo> colorList = new List<DisplayColorInfo>(); |
||
127 | DefinedPages DocumentInfo { get; set; } //문서정보 정의 |
||
128 | //PdfSharp.Pdf.PdfDocument document { get; set; } // pdfsharp 인데 아직 왜 넣었는지 모름 |
||
129 | delegate void PrintEventHandler(); //프린트 핸들러 |
||
130 | SaveFileDialog SaveDig = new SaveFileDialog(); //파일 세이브 다이얼로그 |
||
131 | //SaveFileDialog SaveFile { get; set; } //저장할 때 사용 |
||
132 | |||
133 | //RasterImageViewer _viewer; //이미지 뷰어 |
||
134 | 53880c83 | ljiyeon | //System.Windows.Controls.Image backimg; //백그라운드 이미지 |
135 | 787a4489 | KangIngu | System.Drawing.Image Printimg; //프린트 이미지 |
136 | System.Drawing.Image p_img; //프린트 이미지 |
||
137 | iTextSharp.text.Image Export_img; |
||
138 | 481c3fb9 | djkim | Dictionary<int, System.Drawing.Image> Printimg_List; //프린트 이미지 |
139 | 787a4489 | KangIngu | |
140 | //RasterCodecs codecs; |
||
141 | int currentPage; |
||
142 | public string PrintName; |
||
143 | public string Type; |
||
144 | |||
145 | public System.Timers.Timer timm = new System.Timers.Timer(); |
||
146 | |||
147 | |||
148 | #endregion |
||
149 | |||
150 | #region Static Property Defines |
||
151 | public static readonly DependencyProperty CurrentPageNoProperty = |
||
152 | DependencyProperty.Register("CurrentPageNo", typeof(int), typeof(PrintControl), |
||
153 | new PropertyMetadata(new PropertyChangedCallback(CurrentPageNoPropertyChanged))); |
||
154 | #endregion |
||
155 | |||
156 | #region Property |
||
157 | public int CurrentPageNo |
||
158 | { |
||
159 | get { return (int)GetValue(CurrentPageNoProperty); } |
||
160 | set { SetValue(CurrentPageNoProperty, value); } |
||
161 | } |
||
162 | #endregion |
||
163 | |||
164 | #region PropertyChangeMethod |
||
165 | private static void CurrentPageNoPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||
166 | { |
||
167 | var printPage = (PrintControl)d; |
||
168 | var newValue = (int)e.NewValue; |
||
169 | |||
170 | printPage.sliderPages.Value = newValue; |
||
171 | printPage.SetLoadMakupList(newValue); |
||
172 | |||
173 | } |
||
174 | #endregion |
||
175 | |||
176 | #region 생성자 |
||
177 | 481c3fb9 | djkim | |
178 | 787a4489 | KangIngu | public PrintControl(string TileSourceUri, string ProjectNo, DOCINFO DocInfo, List<IKCOM.MarkupInfoItem> markupInfo, int CurrentPageNo, string slip, string title, string fileurl, bool isPrint) |
179 | { |
||
180 | InitializeComponent(); |
||
181 | 481c3fb9 | djkim | |
182 | 787a4489 | KangIngu | this.IsEnabled = true; |
183 | |||
184 | //Layer Control을 통째로 가져와야 하는건가 |
||
185 | this._DocInfo = DocInfo; |
||
186 | this._DefaultTileUri = TileSourceUri; |
||
187 | this.ProjectNo = ProjectNo; |
||
188 | this._StartPageNo = CurrentPageNo; |
||
189 | |||
190 | markupInfo.ForEach(info => this._markupInfo.Add(info)); |
||
191 | |||
192 | foreach (var info in _markupInfo) |
||
193 | { |
||
194 | if (info.Consolidate == 1) |
||
195 | { |
||
196 | info.UserName = "Consolidation"; |
||
197 | } |
||
198 | info.MarkupList.ForEach(makup => |
||
199 | { |
||
200 | var _pageMarkup = _PageMarkupList.Where(item => item.PageNumber == makup.PageNumber); |
||
201 | var _SetMarkupItem = new SetColorMarkupItem { markupID = makup.ID, DisplayColor = info.DisplayColor }; |
||
202 | |||
203 | if (_pageMarkup.Count() > 0) |
||
204 | _pageMarkup.First().DisplayColorItems.Add(_SetMarkupItem); |
||
205 | else |
||
206 | _PageMarkupList.Add(new MarkupPageItem |
||
207 | { |
||
208 | PageNumber = makup.PageNumber, |
||
209 | DisplayColorItems = new List<SetColorMarkupItem> { _SetMarkupItem } |
||
210 | }); |
||
211 | }); |
||
212 | |||
213 | colorList.Add(new DisplayColorInfo |
||
214 | { |
||
215 | UserID = info.UserID, |
||
216 | DisplayColor = info.DisplayColor, |
||
217 | Department = info.Depatment, |
||
218 | UserName = info.UserName, |
||
219 | }); |
||
220 | } |
||
221 | |||
222 | gridViewMarkup.ItemsSource = this._markupInfo; |
||
223 | SetLoadMakupList(this._StartPageNo); |
||
224 | if (_LoadMakupList.Count() == 0) |
||
225 | chkOnlyMarkup.IsChecked = false; |
||
226 | |||
227 | this.CurrentPageNo = _StartPageNo; |
||
228 | 86bff326 | taeseongkim | |
229 | _definePages = new DefinedPages { DefinedPagesStrings = "", DocumentInfo = this._DocInfo |
||
230 | , PagesCount = Convert.ToInt32(this._DocInfo.PAGE_COUNT), vpSlip = slip, vpTitle = title, fileUrl = fileurl }; |
||
231 | |||
232 | 787a4489 | KangIngu | DocumentInfo = _definePages; |
233 | this.DataContext = _definePages; |
||
234 | |||
235 | CheckCommentPages(); |
||
236 | |||
237 | //초기화면 Comment Check된 상태로 보여주기 |
||
238 | foreach (var item in _markupInfo) |
||
239 | { |
||
240 | gridViewMarkup.SelectedItems.Add(item); |
||
241 | } |
||
242 | |||
243 | 24c5e56c | taeseongkim | PageChangeAsync(Common.ViewerDataModel.Instance.NewCancellationToken(), _StartPageNo).ConfigureAwait(true); |
244 | 787a4489 | KangIngu | |
245 | sliderPages.Maximum = Convert.ToDouble(this._DocInfo.PAGE_COUNT); |
||
246 | this.stPageNo.Maximum = Convert.ToDouble(this._DocInfo.PAGE_COUNT); |
||
247 | this.edPageNo.Maximum = Convert.ToDouble(this._DocInfo.PAGE_COUNT); |
||
248 | this.IsPrint = isPrint; |
||
249 | |||
250 | if (!IsPrint) |
||
251 | { |
||
252 | GetPrint(false); |
||
253 | btnWholeExport.Visibility = Visibility.Visible; |
||
254 | btnWholePrint.Visibility = Visibility.Collapsed; |
||
255 | Selected_Print.Header = "Export Type"; |
||
256 | } |
||
257 | else |
||
258 | { |
||
259 | //PrintList 가져오기 |
||
260 | GetPrint(true); |
||
261 | btnWholePrint.Visibility = Visibility.Visible; |
||
262 | btnWholeExport.Visibility = Visibility.Collapsed; |
||
263 | } |
||
264 | |||
265 | _initializeComponentFinished = true; |
||
266 | |||
267 | //timm.Interval = 10; |
||
268 | //timm.Elapsed += new System.Timers.ElapsedEventHandler(_Timer_Elapsed); |
||
269 | //timm.Enabled = true; |
||
270 | } |
||
271 | |||
272 | #endregion |
||
273 | |||
274 | #region Control Event |
||
275 | 86bff326 | taeseongkim | private async void sliderPages_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
276 | 787a4489 | KangIngu | { |
277 | if (_initializeComponentFinished) |
||
278 | { |
||
279 | if (!_IsDagSlider) |
||
280 | { |
||
281 | this.CurrentPageNo = (int)this.sliderPages.Value; |
||
282 | 24c5e56c | taeseongkim | |
283 | await PageChangeAsync(Common.ViewerDataModel.Instance.NewCancellationToken(), this.CurrentPageNo); |
||
284 | 90865212 | taeseongkim | //await App.PageStorage.GetPageUriAsync(this.CurrentPageNo); |
285 | 53deabaf | taeseongkim | |
286 | 481c3fb9 | djkim | if (_ButtonName == "Current") |
287 | 114015fd | ljiyeon | { |
288 | stPageNo.Value = CurrentPageNo; |
||
289 | edPageNo.Value = CurrentPageNo; |
||
290 | 481c3fb9 | djkim | } |
291 | 114015fd | ljiyeon | |
292 | 787a4489 | KangIngu | //CheckCommentPages(); |
293 | } |
||
294 | } |
||
295 | } |
||
296 | |||
297 | 86bff326 | taeseongkim | private async void sliderPages_DragCompleted(object sender, RadDragCompletedEventArgs e) |
298 | 787a4489 | KangIngu | { |
299 | _IsDagSlider = false; |
||
300 | this.CurrentPageNo = (int)this.sliderPages.Value; |
||
301 | if (_initializeComponentFinished) |
||
302 | { |
||
303 | 90865212 | taeseongkim | |
304 | 787a4489 | KangIngu | } |
305 | } |
||
306 | |||
307 | private void sliderPages_DragStarted(object sender, RadDragStartedEventArgs e) |
||
308 | { |
||
309 | _IsDagSlider = true; |
||
310 | } |
||
311 | |||
312 | private void chkOnlyMarkup_Checked(object sender, RoutedEventArgs e) |
||
313 | { |
||
314 | if (_initializeComponentFinished) //GridRangePages |
||
315 | { |
||
316 | CheckCommentPages(); |
||
317 | } |
||
318 | } |
||
319 | 114015fd | ljiyeon | string _ButtonName; |
320 | 787a4489 | KangIngu | private void PageSelect_Checked(object sender, RoutedEventArgs e) |
321 | { |
||
322 | if (!_initializeComponentFinished) return; |
||
323 | |||
324 | 114015fd | ljiyeon | _ButtonName = (sender as RadRadioButton).Tag.ToString(); |
325 | 787a4489 | KangIngu | CommentPageList.ItemsSource = null; |
326 | |||
327 | switch (_ButtonName) |
||
328 | { |
||
329 | case "Current": |
||
330 | stPageNo.Value = CurrentPageNo; |
||
331 | edPageNo.Value = CurrentPageNo; |
||
332 | |||
333 | GridCurrentPage.Visibility = Visibility.Visible; |
||
334 | GridDefinePages.Visibility = Visibility.Collapsed; |
||
335 | GridRangePages.Visibility = Visibility.Collapsed; |
||
336 | GridAllPages.Visibility = Visibility.Collapsed; |
||
337 | |||
338 | break; |
||
339 | case "RangePrint": |
||
340 | GridCurrentPage.Visibility = Visibility.Collapsed; |
||
341 | GridDefinePages.Visibility = Visibility.Visible; |
||
342 | GridRangePages.Visibility = Visibility.Collapsed; |
||
343 | GridAllPages.Visibility = Visibility.Collapsed; |
||
344 | break; |
||
345 | case "UserDefined": |
||
346 | GridCurrentPage.Visibility = Visibility.Collapsed; |
||
347 | GridDefinePages.Visibility = Visibility.Collapsed; |
||
348 | GridRangePages.Visibility = Visibility.Visible; |
||
349 | GridAllPages.Visibility = Visibility.Collapsed; |
||
350 | break; |
||
351 | case "AllPrint": |
||
352 | stPageNo.Value = 1; |
||
353 | edPageNo.Value = Convert.ToDouble(_DocInfo.PAGE_COUNT); |
||
354 | GridCurrentPage.Visibility = Visibility.Collapsed; |
||
355 | GridDefinePages.Visibility = Visibility.Collapsed; |
||
356 | GridRangePages.Visibility = Visibility.Collapsed; |
||
357 | GridAllPages.Visibility = Visibility.Visible; |
||
358 | break; |
||
359 | } |
||
360 | |||
361 | CheckCommentPages(); |
||
362 | } |
||
363 | |||
364 | private void PageNo_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e) |
||
365 | { |
||
366 | if (_initializeComponentFinished) //GridRangePages |
||
367 | { |
||
368 | if (stPageNo.Value > edPageNo.Value) |
||
369 | { |
||
370 | if (sender.Equals(stPageNo)) |
||
371 | edPageNo.Value = stPageNo.Value; |
||
372 | else |
||
373 | stPageNo.Value = edPageNo.Value; |
||
374 | } |
||
375 | |||
376 | //뷰어잠시제외(강인구) |
||
377 | //this.LayoutRoot.Dispatcher.BeginInvoke(delegate() |
||
378 | //{ |
||
379 | CheckCommentPages(); |
||
380 | //}); |
||
381 | } |
||
382 | } |
||
383 | |||
384 | private void txtDefinedPages_TextChanged(object sender, TextChangedEventArgs e) |
||
385 | { |
||
386 | CheckCommentPages(); |
||
387 | } |
||
388 | |||
389 | private void btnClearDefinedPages_Click(object sender, RoutedEventArgs e) |
||
390 | { |
||
391 | txtDefinedPages.Text = ""; |
||
392 | } |
||
393 | |||
394 | private void CommentPageList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) |
||
395 | { |
||
396 | if (_initializeComponentFinished) |
||
397 | if (CommentPageList.SelectedItem != null) |
||
398 | this.CurrentPageNo = (CommentPageList.SelectedItem as MarkupPageItem).PageNumber; |
||
399 | } |
||
400 | |||
401 | 86bff326 | taeseongkim | private async void gridViewMarkup_SelectionChanged(object sender, SelectionChangeEventArgs e) |
402 | 787a4489 | KangIngu | { |
403 | if (_initializeComponentFinished) |
||
404 | { |
||
405 | 24c5e56c | taeseongkim | await PageChangeAsync(Common.ViewerDataModel.Instance.NewCancellationToken(),this.CurrentPageNo); |
406 | 787a4489 | KangIngu | } |
407 | } |
||
408 | |||
409 | #endregion |
||
410 | |||
411 | 24c5e56c | taeseongkim | public async System.Threading.Tasks.Task<bool> PageChangeAsync(System.Threading.CancellationToken cts, int PageNo, bool Flag = false) |
412 | 787a4489 | KangIngu | { |
413 | 53deabaf | taeseongkim | System.Diagnostics.Debug.WriteLine("PageChangeAsync " + PageNo); |
414 | 86bff326 | taeseongkim | bool result = false; |
415 | //Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
416 | //{ |
||
417 | try |
||
418 | 787a4489 | KangIngu | { |
419 | 86bff326 | taeseongkim | Load load = new Load(); |
420 | |||
421 | _definePages.Back_Image = new ImageBrush(); |
||
422 | //var defaultBitmapImage = new BitmapImage(new Uri(_DefaultTileUri + PageNo + ".png")); |
||
423 | |||
424 | var pages = _definePages.DocumentInfo.DOCPAGE.Where(x => x.PAGE_NUMBER == PageNo); |
||
425 | |||
426 | if(pages.Count() > 0) |
||
427 | 481c3fb9 | djkim | { |
428 | 86bff326 | taeseongkim | var currentPage = pages.First(); |
429 | 787a4489 | KangIngu | |
430 | 86bff326 | taeseongkim | //var buffer = await new WebClient().DownloadDataTaskAsync(_DefaultTileUri + PageNo + ".png"); |
431 | |||
432 | //var bitmap = new BitmapImage(); |
||
433 | //using (var stream = new MemoryStream(buffer)) |
||
434 | //{ |
||
435 | 90865212 | taeseongkim | //bitmap.BeginInit(); |
436 | //bitmap.CacheOption = BitmapCacheOption.OnLoad; |
||
437 | //bitmap.StreamSource = stream; |
||
438 | //bitmap.EndInit(); |
||
439 | |||
440 | |||
441 | 24c5e56c | taeseongkim | var uri = await App.PageStorage.GetPageUriAsync(cts, currentPage.PAGE_NUMBER); |
442 | 90865212 | taeseongkim | //Image bitmap = new Image(); |
443 | //bitmap.Stretch = Stretch.Fill; |
||
444 | //bitmap.Source = bitmapframe; |
||
445 | //bitmap.Width = Convert.ToDouble(currentPage.PAGE_WIDTH); |
||
446 | //bitmap.Height = Convert.ToDouble(currentPage.PAGE_HEIGHT); |
||
447 | 00143658 | taeseongkim | printCanvas.Children.Clear(); |
448 | printCanvas.Width = Convert.ToDouble(currentPage.PAGE_WIDTH); |
||
449 | printCanvas.Height = Convert.ToDouble(currentPage.PAGE_HEIGHT); |
||
450 | printCanvas.Background = new ImageBrush { ImageSource = new BitmapImage(uri)}; |
||
451 | 90865212 | taeseongkim | |
452 | 00143658 | taeseongkim | //printCanvas.RenderTransformOrigin = new Point(0.5, 0.5); |
453 | //printCanvas.RenderTransform = new RotateTransform(currentPage.PAGE_ANGLE); |
||
454 | //ImageBrush background = new ImageBrush(bitmap); |
||
455 | //printCanvas.Background = background; |
||
456 | //printCanvas.Background = new SolidColorBrush(Colors.Transparent); |
||
457 | 787a4489 | KangIngu | |
458 | 481c3fb9 | djkim | |
459 | 00143658 | taeseongkim | foreach (var info in gridViewMarkup.SelectedItems.Cast<IKCOM.MarkupInfoItem>()) |
460 | { |
||
461 | load.User_Id = info.UserID; |
||
462 | load.document_id = _DocInfo.DOCUMENT_ID; |
||
463 | load.Page_No = PageNo; |
||
464 | load.DisplayColor = info.DisplayColor; |
||
465 | load.Markupinfoid = info.MarkupInfoID; |
||
466 | e1c892f7 | taeseongkim | var IsLoad = await load.Markup_LoadAsync(printCanvas); |
467 | 00143658 | taeseongkim | } |
468 | 90865212 | taeseongkim | //await Dispatcher.InvokeAsync(() => { |
469 | // printCanvas.UpdateLayout(); |
||
470 | //}); |
||
471 | 481c3fb9 | djkim | |
472 | d04e8ee9 | taeseongkim | if (Flag) |
473 | 481c3fb9 | djkim | { |
474 | d04e8ee9 | taeseongkim | //MemoryStream ms = new MemoryStream(); |
475 | //BmpBitmapEncoder bbe = new BmpBitmapEncoder(); |
||
476 | //bbe.Frames.Add(BitmapFrame.Create(new Uri(_DefaultTileUri + PageNo + ".png"))); |
||
477 | //bbe.Save(ms); |
||
478 | |||
479 | //System.Drawing.Image.FromFile() |
||
480 | //Printimg = System.Drawing.Image.FromStream(stream); |
||
481 | 53deabaf | taeseongkim | //await System.Threading.Tasks.Task.Run(() => |
482 | //{ |
||
483 | await Dispatcher.InvokeAsync(() => |
||
484 | d04e8ee9 | taeseongkim | { |
485 | Export export = new Export(); |
||
486 | p_img = export.Exporting(PrintView, printCanvas.Width, printCanvas.Height); |
||
487 | Printimg_List.Add(Printimg_List.Count() + 1, p_img); |
||
488 | e1c892f7 | taeseongkim | },System.Windows.Threading.DispatcherPriority.Render); |
489 | 53deabaf | taeseongkim | //}); |
490 | d04e8ee9 | taeseongkim | } |
491 | 481c3fb9 | djkim | |
492 | 86bff326 | taeseongkim | result = true; |
493 | //} |
||
494 | } |
||
495 | } |
||
496 | catch (Exception ex) |
||
497 | { |
||
498 | 664ea2e1 | taeseongkim | //Logger.sendResLog("PrintControl.PageChanged", ex.Message, 0); |
499 | 86bff326 | taeseongkim | } |
500 | |||
501 | return result; |
||
502 | //})); |
||
503 | 787a4489 | KangIngu | } |
504 | 481c3fb9 | djkim | public static MemoryStream ByteBufferFromImage(BitmapImage imageSource) |
505 | { |
||
506 | var ms = new MemoryStream(); |
||
507 | var pngEncoder = new PngBitmapEncoder(); |
||
508 | pngEncoder.Frames.Add(BitmapFrame.Create(imageSource)); |
||
509 | pngEncoder.Save(ms); |
||
510 | 787a4489 | KangIngu | |
511 | 481c3fb9 | djkim | return ms; |
512 | } |
||
513 | 787a4489 | KangIngu | //Print 버튼 클릭 이벤트 |
514 | #region Method - 명령 |
||
515 | 86bff326 | taeseongkim | async void PrintMethod(object sender, RoutedEventArgs e) |
516 | 787a4489 | KangIngu | { |
517 | 481c3fb9 | djkim | try |
518 | { |
||
519 | 24c5e56c | taeseongkim | var token = Common.ViewerDataModel.Instance.NewCancellationToken(); |
520 | |||
521 | 481c3fb9 | djkim | if (this.printIndy.IsBusy == true) |
522 | return; |
||
523 | 787a4489 | KangIngu | |
524 | 00143658 | taeseongkim | (this.Parent as RadWindow).CanClose = false; |
525 | |||
526 | 86bff326 | taeseongkim | await this.Dispatcher.InvokeAsync(() => { |
527 | 481c3fb9 | djkim | this.printIndy.IsBusy = true; |
528 | printIndy.BusyContent = "Printing. . ."; |
||
529 | }); |
||
530 | 787a4489 | KangIngu | |
531 | 481c3fb9 | djkim | |
532 | _lstPrintPageNo = PrintPageCreate(); |
||
533 | |||
534 | if (_lstPrintPageNo.Count == 0) |
||
535 | 787a4489 | KangIngu | { |
536 | 481c3fb9 | djkim | RadWindow.Alert(new DialogParameters |
537 | { |
||
538 | Owner = Application.Current.MainWindow, |
||
539 | Theme = new VisualStudio2013Theme(), |
||
540 | eeb0a39c | taeseongkim | Header = "Info", |
541 | Content = "Not specified the page." |
||
542 | 481c3fb9 | djkim | }); |
543 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
544 | 481c3fb9 | djkim | this.printIndy.IsBusy = false; |
545 | return; |
||
546 | } |
||
547 | 86bff326 | taeseongkim | |
548 | 481c3fb9 | djkim | int cnt = 0; |
549 | 787a4489 | KangIngu | |
550 | 481c3fb9 | djkim | Printimg_List = new Dictionary<int, System.Drawing.Image>(); |
551 | 787a4489 | KangIngu | |
552 | 481c3fb9 | djkim | foreach (int PageNo in _lstPrintPageNo) |
553 | { |
||
554 | cnt++; |
||
555 | sliderPages.Value = PageNo; |
||
556 | 24c5e56c | taeseongkim | await PageChangeAsync(token,PageNo, true); |
557 | 481c3fb9 | djkim | //PageChanged(cnt, true); |
558 | } |
||
559 | PrintName = cbPrint.SelectedItem.ToString(); |
||
560 | 787a4489 | KangIngu | |
561 | 86bff326 | taeseongkim | await this.Dispatcher.InvokeAsync(() => { |
562 | 481c3fb9 | djkim | if (cnt == _lstPrintPageNo.Count) |
563 | { |
||
564 | Printing(); |
||
565 | } |
||
566 | 787a4489 | KangIngu | }); |
567 | } |
||
568 | 481c3fb9 | djkim | catch (Exception ex) |
569 | 787a4489 | KangIngu | { |
570 | 664ea2e1 | taeseongkim | //Logger.sendResLog("PrintMethod", ex.Message, 0); |
571 | 787a4489 | KangIngu | } |
572 | 00143658 | taeseongkim | finally |
573 | { |
||
574 | (this.Parent as RadWindow).CanClose = true; |
||
575 | } |
||
576 | 787a4489 | KangIngu | |
577 | } |
||
578 | |||
579 | //Export 버튼 클릭 이벤트 |
||
580 | 86bff326 | taeseongkim | async void ExportMethod(object sender, RoutedEventArgs e) |
581 | 787a4489 | KangIngu | { |
582 | 481c3fb9 | djkim | try |
583 | { |
||
584 | if (this.printIndy.IsBusy == true) |
||
585 | return; |
||
586 | 787a4489 | KangIngu | |
587 | 24c5e56c | taeseongkim | var token = Common.ViewerDataModel.Instance.NewCancellationToken(); |
588 | |||
589 | 00143658 | taeseongkim | (this.Parent as RadWindow).CanClose = false; |
590 | |||
591 | 481c3fb9 | djkim | this.printIndy.IsBusy = true; |
592 | printIndy.BusyContent = "Exporting. . ."; |
||
593 | 787a4489 | KangIngu | |
594 | 481c3fb9 | djkim | Export export = new Export(); |
595 | _lstPrintPageNo = PrintPageCreate(); |
||
596 | 787a4489 | KangIngu | |
597 | 481c3fb9 | djkim | if (_lstPrintPageNo.Count == 0) |
598 | 787a4489 | KangIngu | { |
599 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
600 | 481c3fb9 | djkim | this.printIndy.IsBusy = false; |
601 | RadWindow.Alert(new DialogParameters |
||
602 | 787a4489 | KangIngu | { |
603 | 481c3fb9 | djkim | Owner = Application.Current.MainWindow, |
604 | Theme = new VisualStudio2013Theme(), |
||
605 | eeb0a39c | taeseongkim | Header = "Info", |
606 | Content = "Not specified the page.", |
||
607 | 481c3fb9 | djkim | }); |
608 | return; |
||
609 | } |
||
610 | 787a4489 | KangIngu | |
611 | 481c3fb9 | djkim | //FileDialogFilter filterImage = new FileDialogFilter("Image Files", "*.jpg", "*.png"); |
612 | 787a4489 | KangIngu | |
613 | switch (cbPrint.SelectedIndex) |
||
614 | { |
||
615 | case (0): |
||
616 | { |
||
617 | 481c3fb9 | djkim | SaveDig.Filter = "PDF file format|*.pdf"; |
618 | break; |
||
619 | } |
||
620 | case (1): |
||
621 | { |
||
622 | SaveDig.Filter = "Image Files (*.jpg, *.Jpeg)|*.jpg;*.Jpeg|Image Files (*.png)|*.png"; |
||
623 | break; |
||
624 | } |
||
625 | } |
||
626 | |||
627 | SaveDig.Title = "Save an PDF File"; |
||
628 | if(SaveDig.ShowDialog().Value) |
||
629 | { |
||
630 | Printimg_List = new Dictionary<int, System.Drawing.Image>(); |
||
631 | |||
632 | foreach (int PageNo in _lstPrintPageNo) |
||
633 | { |
||
634 | d04e8ee9 | taeseongkim | await Dispatcher.InvokeAsync(() => |
635 | { |
||
636 | sliderPages.Value = PageNo; |
||
637 | }); |
||
638 | 53deabaf | taeseongkim | |
639 | 24c5e56c | taeseongkim | await PageChangeAsync(token,PageNo, true); |
640 | 53deabaf | taeseongkim | System.Diagnostics.Debug.WriteLine("Export Page : " + PageNo); |
641 | 481c3fb9 | djkim | } |
642 | |||
643 | //using (FileStream fs = new FileStream(@"D:\Temp\Text.pdf", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) |
||
644 | |||
645 | if (SaveDig.FileName != "") |
||
646 | { |
||
647 | switch (cbPrint.SelectedIndex) |
||
648 | { |
||
649 | case (0): |
||
650 | 787a4489 | KangIngu | { |
651 | 481c3fb9 | djkim | using (FileStream fs = new FileStream(SaveDig.FileName, FileMode.Create, FileAccess.Write, FileShare.None)) |
652 | 787a4489 | KangIngu | { |
653 | 481c3fb9 | djkim | using (Document doc = new Document()) |
654 | 787a4489 | KangIngu | { |
655 | 481c3fb9 | djkim | using (PdfWriter writer = PdfWriter.GetInstance(doc, fs)) |
656 | e3a15e22 | djkim | { |
657 | 481c3fb9 | djkim | doc.Open(); |
658 | 00143658 | taeseongkim | |
659 | 481c3fb9 | djkim | float height = doc.PageSize.Height; |
660 | float width = doc.PageSize.Width; |
||
661 | |||
662 | foreach (var item in Printimg_List) |
||
663 | { |
||
664 | Export_img = iTextSharp.text.Image.GetInstance(item.Value, System.Drawing.Imaging.ImageFormat.Png); |
||
665 | |||
666 | if (Export_img.Width > Export_img.Height) |
||
667 | { |
||
668 | doc.SetPageSize(new Rectangle(height, width)); |
||
669 | Export_img.ScaleToFit(height, width); |
||
670 | } |
||
671 | else |
||
672 | { |
||
673 | doc.SetPageSize(new Rectangle(width, height)); |
||
674 | Export_img.ScaleToFit(width, height); |
||
675 | } |
||
676 | |||
677 | Export_img.SetAbsolutePosition(0, 0); |
||
678 | |||
679 | doc.NewPage(); |
||
680 | doc.Add(Export_img); |
||
681 | 00143658 | taeseongkim | |
682 | await System.Threading.Tasks.Task.Delay(100); |
||
683 | |||
684 | 481c3fb9 | djkim | } |
685 | doc.Close(); |
||
686 | } |
||
687 | 787a4489 | KangIngu | } |
688 | } |
||
689 | 481c3fb9 | djkim | break; |
690 | 787a4489 | KangIngu | } |
691 | 481c3fb9 | djkim | case (1): |
692 | 787a4489 | KangIngu | { |
693 | 481c3fb9 | djkim | foreach (var item in Printimg_List) |
694 | { |
||
695 | switch (SaveDig.FilterIndex) |
||
696 | 787a4489 | KangIngu | { |
697 | 481c3fb9 | djkim | case (1): |
698 | { |
||
699 | //(item.Value as System.Drawing.Image).Save(SaveDig.FileName + item.Key, System.Drawing.Imaging.ImageFormat.Jpeg); |
||
700 | (item.Value as System.Drawing.Image).Save(SaveDig.FileName.Replace(".jpg", "_" + item.Key.ToString()) + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); |
||
701 | } |
||
702 | break; |
||
703 | case (2): |
||
704 | { |
||
705 | //(item.Value as System.Drawing.Image).Save(SaveDig.FileName, System.Drawing.Imaging.ImageFormat.Png); |
||
706 | (item.Value as System.Drawing.Image).Save(SaveDig.FileName.Replace(".png", "_" + item.Key.ToString()) + ".png", System.Drawing.Imaging.ImageFormat.Png); |
||
707 | } |
||
708 | break; |
||
709 | 787a4489 | KangIngu | } |
710 | 481c3fb9 | djkim | } |
711 | break; |
||
712 | 787a4489 | KangIngu | } |
713 | } |
||
714 | 481c3fb9 | djkim | } |
715 | else |
||
716 | { |
||
717 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
718 | 481c3fb9 | djkim | this.printIndy.IsBusy = false; |
719 | return; |
||
720 | } |
||
721 | 86bff326 | taeseongkim | |
722 | await this.Dispatcher.InvokeAsync(() => |
||
723 | 481c3fb9 | djkim | { |
724 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
725 | 481c3fb9 | djkim | printIndy.IsBusy = false; |
726 | 86bff326 | taeseongkim | }); |
727 | |||
728 | 24c5e56c | taeseongkim | await PageChangeAsync(token,_StartPageNo); |
729 | 787a4489 | KangIngu | |
730 | 481c3fb9 | djkim | (Application.Current.MainWindow as MainWindow).dzMainMenu.DialogMessage_Alert("Success", "Alert"); |
731 | }else |
||
732 | { |
||
733 | Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
734 | { |
||
735 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
736 | 481c3fb9 | djkim | printIndy.IsBusy = false; |
737 | })); |
||
738 | 787a4489 | KangIngu | |
739 | 481c3fb9 | djkim | (Application.Current.MainWindow as MainWindow).dzMainMenu.DialogMessage_Alert("Cancel", "Alert"); |
740 | } |
||
741 | } |
||
742 | catch (Exception ex) |
||
743 | 787a4489 | KangIngu | { |
744 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
745 | 86bff326 | taeseongkim | printIndy.IsBusy = false; |
746 | |||
747 | 664ea2e1 | taeseongkim | //Logger.sendResLog("Export Method", ex.Message, 0); |
748 | 481c3fb9 | djkim | //(Application.Current.MainWindow as MainWindow).dzMainMenu.DialogMessage_Alert("Alert", "관리자 확인이 필요합니다. 다시 시도해 주세요.\n"+ex.Message); |
749 | } |
||
750 | 00143658 | taeseongkim | finally |
751 | { |
||
752 | (this.Parent as RadWindow).CanClose = true; |
||
753 | } |
||
754 | |||
755 | 787a4489 | KangIngu | |
756 | } |
||
757 | #endregion |
||
758 | |||
759 | #region Method - 처리 |
||
760 | void CheckCommentPages() |
||
761 | { |
||
762 | List<MarkupPageItem> _pages = new List<MarkupPageItem>(); |
||
763 | DoubleCollection _Ticks = new DoubleCollection(); |
||
764 | |||
765 | |||
766 | if (GridCurrentPage.Visibility == System.Windows.Visibility.Visible) |
||
767 | { |
||
768 | |||
769 | _pages = (from commPage in this._PageMarkupList |
||
770 | where commPage.PageNumber == CurrentPageNo |
||
771 | orderby commPage.PageNumber |
||
772 | select commPage).ToList(); |
||
773 | } |
||
774 | else if (GridRangePages.Visibility == System.Windows.Visibility.Visible) |
||
775 | { |
||
776 | stPageNo.Value = stPageNo.Value == null ? 1 : stPageNo.Value; |
||
777 | edPageNo.Value = edPageNo.Value == null ? 1 : edPageNo.Value; |
||
778 | |||
779 | int _stPage = (int)stPageNo.Value; |
||
780 | int _edPage = (int)edPageNo.Value; |
||
781 | |||
782 | _pages = (from commPage in this._PageMarkupList |
||
783 | where commPage.PageNumber >= _stPage && commPage.PageNumber <= _edPage |
||
784 | orderby commPage.PageNumber |
||
785 | select commPage).ToList(); |
||
786 | } |
||
787 | else if (GridDefinePages.Visibility == System.Windows.Visibility.Visible) |
||
788 | { |
||
789 | stPageNo.Value = stPageNo.Value == null ? 1 : stPageNo.Value; |
||
790 | edPageNo.Value = edPageNo.Value == null ? 1 : edPageNo.Value; |
||
791 | |||
792 | int _stPage = (int)stPageNo.Value; |
||
793 | int _edPage = (int)edPageNo.Value; |
||
794 | |||
795 | //Using DeepView.Common.RangeParser |
||
796 | var lst = RangeParser.Parse(txtDefinedPages.Text, _stPage, _definePages.PagesCount); |
||
797 | _pages = (from commPage in this._PageMarkupList |
||
798 | from compareData in lst |
||
799 | where commPage.PageNumber == compareData |
||
800 | orderby commPage.PageNumber |
||
801 | select commPage).ToList(); |
||
802 | } |
||
803 | else |
||
804 | { |
||
805 | _pages = (from commPage in this._PageMarkupList |
||
806 | orderby commPage.PageNumber |
||
807 | select commPage).ToList(); |
||
808 | } |
||
809 | CommentPageList.ItemsSource = _pages.ToList(); |
||
810 | } |
||
811 | |||
812 | void SetLoadMakupList(int PageNo) |
||
813 | { |
||
814 | _LoadMakupList.Clear(); |
||
815 | var _markupList = _PageMarkupList.Where(page => page.PageNumber == PageNo); |
||
816 | |||
817 | if (_markupList.Count() > 0) |
||
818 | _LoadMakupList = _markupList.First().DisplayColorItems.ToList(); |
||
819 | } |
||
820 | |||
821 | #region 프린트 리스트 가져오기 |
||
822 | public void GetPrint(bool flag) |
||
823 | { |
||
824 | if (flag) |
||
825 | { |
||
826 | foreach (string printer in PrinterSettings.InstalledPrinters) |
||
827 | { |
||
828 | this.cbPrint.Items.Add(printer); |
||
829 | } |
||
830 | printDocument = new PrintDocument(); |
||
831 | this.cbPrint.SelectedItem = printDocument.PrinterSettings.PrinterName; |
||
832 | } |
||
833 | else |
||
834 | { |
||
835 | this.cbPrint.Items.Add("PDF"); |
||
836 | this.cbPrint.Items.Add("IMAGE"); |
||
837 | |||
838 | this.cbPrint.SelectedItem = "PDF"; |
||
839 | } |
||
840 | } |
||
841 | #endregion |
||
842 | |||
843 | #region 프린트 실행 |
||
844 | 86bff326 | taeseongkim | public async void Printing() |
845 | 787a4489 | KangIngu | { |
846 | 24c5e56c | taeseongkim | var token = Common.ViewerDataModel.Instance.NewCancellationToken(); |
847 | |||
848 | await PageChangeAsync(token,1); |
||
849 | 86bff326 | taeseongkim | |
850 | 787a4489 | KangIngu | if (PrinterSettings.InstalledPrinters != null && PrinterSettings.InstalledPrinters.Count > 0) |
851 | { |
||
852 | 481c3fb9 | djkim | printDocument = new PrintDocument(); |
853 | 408e4218 | ljiyeon | printDocument.OriginAtMargins = true; |
854 | 787a4489 | KangIngu | printDocument.BeginPrint += new System.Drawing.Printing.PrintEventHandler(printDocument_BeginPrint); |
855 | printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument_PrintPage); |
||
856 | printDocument.EndPrint += new System.Drawing.Printing.PrintEventHandler(printDocument_EndPrint); |
||
857 | } |
||
858 | else |
||
859 | printDocument = null; |
||
860 | |||
861 | #region 인쇄 미리보기 테스트 |
||
862 | using (System.Windows.Forms.PrintPreviewDialog dlg = new System.Windows.Forms.PrintPreviewDialog()) |
||
863 | { |
||
864 | printDocument.PrinterSettings.MinimumPage = 1; |
||
865 | printDocument.PrinterSettings.MaximumPage = _lstPrintPageNo.Count(); |
||
866 | printDocument.PrinterSettings.FromPage = 1; |
||
867 | 408e4218 | ljiyeon | printDocument.PrinterSettings.ToPage = _lstPrintPageNo.Count(); |
868 | 787a4489 | KangIngu | printDocument.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); |
869 | 481c3fb9 | djkim | printDocument.PrinterSettings.PrinterName = PrintName; |
870 | dlg.Document = printDocument; |
||
871 | 787a4489 | KangIngu | dlg.WindowState = System.Windows.Forms.FormWindowState.Maximized; |
872 | dlg.ShowDialog(); |
||
873 | } |
||
874 | #endregion |
||
875 | |||
876 | #region 인쇄 |
||
877 | //printDocument.PrinterSettings.MinimumPage = 1; |
||
878 | //printDocument.PrinterSettings.MaximumPage = _lstPrintPageNo.Count(); |
||
879 | //printDocument.PrinterSettings.FromPage = 1; |
||
880 | //printDocument.PrinterSettings.ToPage = _lstPrintPageNo.Count(); |
||
881 | |||
882 | //printDocument.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); |
||
883 | //printDocument.PrinterSettings.PrinterName = PrintName; |
||
884 | |||
885 | //printDocument.Print(); |
||
886 | #endregion |
||
887 | } |
||
888 | |||
889 | private void printDocument_BeginPrint(object sender, PrintEventArgs e) |
||
890 | { |
||
891 | //Printimg_List = new Dictionary<int, System.Drawing.Image>(); |
||
892 | // This demo only loads one page at a time, so no need to re-set the print page number |
||
893 | 481c3fb9 | djkim | PrintDocument document = sender as PrintDocument; |
894 | 787a4489 | KangIngu | currentPage = document.PrinterSettings.FromPage; |
895 | } |
||
896 | 481c3fb9 | djkim | |
897 | 787a4489 | KangIngu | private void printDocument_PrintPage(object sender, PrintPageEventArgs e) |
898 | { |
||
899 | //e.Graphics.DrawImage(Printimg_List.Where(info => info.Key == currentPage).FirstOrDefault().Value, 0, 0); |
||
900 | |||
901 | Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
902 | { |
||
903 | p_img = Printimg_List.Where(data => data.Key == currentPage).FirstOrDefault().Value; |
||
904 | 2024d8d1 | ljiyeon | |
905 | 481c3fb9 | djkim | if (p_img.Width > p_img.Height) |
906 | 2024d8d1 | ljiyeon | { |
907 | p_img.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone); |
||
908 | } |
||
909 | 408e4218 | ljiyeon | |
910 | //iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(p_img, System.Drawing.Imaging.ImageFormat.Jpeg); |
||
911 | System.Drawing.Image pic = p_img; |
||
912 | 787a4489 | KangIngu | System.Drawing.Rectangle m = e.MarginBounds; |
913 | |||
914 | 408e4218 | ljiyeon | //if ((double)pic.Width / (double)pic.Height > (double)m.Width / (double)m.Height) // image is wider |
915 | //{ |
||
916 | // m.Height = 1135;//(int)((double)pic.Height / (double)pic.Width * (double)m.Width) - 16; |
||
917 | //} |
||
918 | //else |
||
919 | //{ |
||
920 | // m.Width = 793;//(int)((double)pic.Width / (double)pic.Height * (double)m.Height) - 16; |
||
921 | //} |
||
922 | m.Width = (int)e.PageSettings.PrintableArea.Width; |
||
923 | m.Height = (int)e.PageSettings.PrintableArea.Height; |
||
924 | m.X = (int)e.PageSettings.HardMarginX; |
||
925 | m.Y = (int)e.PageSettings.HardMarginY; |
||
926 | |||
927 | e.Graphics.DrawImage(pic, m); |
||
928 | 787a4489 | KangIngu | //e.Graphics.DrawImage(p_img, e.MarginBounds); |
929 | //e.Graphics.DrawImage(p_img, 0, 0); |
||
930 | })); |
||
931 | 481c3fb9 | djkim | |
932 | 787a4489 | KangIngu | //다음 페이지 |
933 | currentPage++; |
||
934 | 481c3fb9 | djkim | |
935 | 787a4489 | KangIngu | ////인쇄를 계속 할지 말지 확인 |
936 | if (currentPage <= printDocument.PrinterSettings.ToPage) |
||
937 | e.HasMorePages = true; |
||
938 | else |
||
939 | e.HasMorePages = false; |
||
940 | |||
941 | } |
||
942 | |||
943 | private void printDocument_EndPrint(object sender, PrintEventArgs e) |
||
944 | { |
||
945 | Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
||
946 | { |
||
947 | 9d5b4bc2 | taeseongkim | sliderPages.Value = 1; |
948 | 787a4489 | KangIngu | printIndy.IsBusy = false; |
949 | })); |
||
950 | } |
||
951 | #endregion |
||
952 | |||
953 | #region Selected Pages Check |
||
954 | List<int> PrintPageCreate() |
||
955 | { |
||
956 | List<int> Result = new List<int>(); |
||
957 | |||
958 | if (GridCurrentPage.Visibility == System.Windows.Visibility.Visible || currentPagePrint) |
||
959 | { |
||
960 | Result.Add(CurrentPageNo); |
||
961 | } |
||
962 | else if (GridRangePages.Visibility == System.Windows.Visibility.Visible) |
||
963 | { |
||
964 | for (int i = Convert.ToInt32(stPageNo.Value); i <= Convert.ToInt32(edPageNo.Value); i++) |
||
965 | { |
||
966 | Result.Add(i); |
||
967 | } |
||
968 | } |
||
969 | else if (GridDefinePages.Visibility == System.Windows.Visibility.Visible) |
||
970 | { |
||
971 | int _stPage = (int)stPageNo.Value; |
||
972 | int _edPage = (int)edPageNo.Value; |
||
973 | |||
974 | var lst = RangeParser.Parse(txtDefinedPages.Text, _stPage, _definePages.PagesCount); |
||
975 | Result.AddRange(lst); |
||
976 | } |
||
977 | else |
||
978 | { |
||
979 | for (int i = 1; i <= _definePages.PagesCount; i++) |
||
980 | { |
||
981 | Result.Add(i); |
||
982 | } |
||
983 | } |
||
984 | if (currentPagePrint) |
||
985 | { |
||
986 | return Result; |
||
987 | } |
||
988 | |||
989 | if (chkOnlyMarkup.IsChecked.Value) |
||
990 | { |
||
991 | var _result = from result in Result |
||
992 | where _PageMarkupList.Where(page => page.PageNumber == result).Count() > 0 |
||
993 | select result; |
||
994 | Result = _result.ToList(); |
||
995 | } |
||
996 | return Result; |
||
997 | } |
||
998 | #endregion |
||
999 | |||
1000 | #endregion |
||
1001 | } |
||
1002 | } |