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