개정판 e6c46927
issue #0000 print&export Cancel event
Change-Id: I2a76519720a26759073c98b90a09c223fe6eea46
KCOM/Controls/PrintControl.xaml.cs | ||
---|---|---|
21 | 21 |
using iTextSharp.text.pdf; |
22 | 22 |
using System.Net; |
23 | 23 |
using Image = System.Windows.Controls.Image; |
24 |
using System.ComponentModel; |
|
24 | 25 | |
25 | 26 |
namespace KCOM.Control |
26 | 27 |
{ |
... | ... | |
122 | 123 |
System.Windows.Threading.DispatcherTimer tm = new System.Windows.Threading.DispatcherTimer(); |
123 | 124 |
bool _initializeComponentFinished; //이벤트 |
124 | 125 |
bool _IsDagSlider = false; //드래그 상태인가 |
125 |
bool IsExportOrPrint = false; |
|
126 |
bool IsExportOrPrint = false; |
|
127 |
bool IsStop = false; |
|
126 | 128 | |
127 | 129 |
List<DisplayColorInfo> colorList = new List<DisplayColorInfo>(); |
128 | 130 |
DefinedPages DocumentInfo { get; set; } //문서정보 정의 |
... | ... | |
151 | 153 |
#endregion |
152 | 154 | |
153 | 155 |
#region Static Property Defines |
156 | ||
157 |
public static readonly DependencyProperty BusyContentProperty = |
|
158 |
DependencyProperty.RegisterAttached("BusyContent", typeof(string), typeof(PrintControl), |
|
159 |
new PropertyMetadata(new PropertyChangedCallback(BusyContentPropertyChanged))); |
|
160 |
#endregion |
|
161 | ||
162 |
#region Property |
|
163 |
public string BusyContent |
|
164 |
{ |
|
165 |
get { return (string)GetValue(BusyContentProperty); } |
|
166 |
set { SetValue(BusyContentProperty, value); } |
|
167 |
} |
|
168 |
#endregion |
|
169 | ||
170 |
#region PropertyChangeMethod |
|
171 |
private static void BusyContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|
172 |
{ |
|
173 |
} |
|
174 | ||
154 | 175 |
public static readonly DependencyProperty CurrentPageNoProperty = |
155 | 176 |
DependencyProperty.Register("CurrentPageNo", typeof(int), typeof(PrintControl), |
156 | 177 |
new PropertyMetadata(new PropertyChangedCallback(CurrentPageNoPropertyChanged))); |
... | ... | |
592 | 613 | |
593 | 614 |
await this.Dispatcher.InvokeAsync(() => { |
594 | 615 |
this.printIndy.IsBusy = true; |
595 |
printIndy.BusyContent = "Printing. . .";
|
|
616 |
this.BusyContent = "Printing. . .";
|
|
596 | 617 |
}); |
597 | 618 | |
598 | 619 | |
... | ... | |
629 | 650 | |
630 | 651 |
foreach (int PageNo in _lstPrintPageNo) |
631 | 652 |
{ |
653 |
if (IsStop) |
|
654 |
break; |
|
655 | ||
632 | 656 |
cnt++; |
633 | 657 |
sliderPages.Value = PageNo; |
634 | 658 |
await PageChangeAsync(token,PageNo, true, true); |
... | ... | |
637 | 661 |
PrintName = cbPrint.SelectedItem.ToString(); |
638 | 662 | |
639 | 663 |
await this.Dispatcher.InvokeAsync(() => { |
640 |
if (cnt == _lstPrintPageNo.Count) |
|
664 |
if (cnt == _lstPrintPageNo.Count && !IsStop)
|
|
641 | 665 |
{ |
642 | 666 |
Printing(); |
643 | 667 |
} |
... | ... | |
651 | 675 |
} |
652 | 676 |
finally |
653 | 677 |
{ |
678 |
if (IsStop) |
|
679 |
{ |
|
680 |
printIndy.IsBusy = false; |
|
681 |
IsStop = false; |
|
682 |
} |
|
654 | 683 |
(this.Parent as RadWindow).CanClose = true; |
655 | 684 |
} |
656 | 685 | |
... | ... | |
671 | 700 |
(this.Parent as RadWindow).CanClose = false; |
672 | 701 | |
673 | 702 |
this.printIndy.IsBusy = true; |
674 |
printIndy.BusyContent = "Exporting. . .";
|
|
703 |
this.BusyContent = "Exporting. . .";
|
|
675 | 704 | |
676 | 705 |
Export export = new Export(); |
677 | 706 |
_lstPrintPageNo = PrintPageCreate(); |
... | ... | |
723 | 752 | |
724 | 753 |
foreach (int PageNo in _lstPrintPageNo) |
725 | 754 |
{ |
755 |
if (IsStop) |
|
756 |
break; |
|
757 | ||
726 | 758 |
await Dispatcher.InvokeAsync(() => |
727 | 759 |
{ |
728 | 760 |
sliderPages.Value = PageNo; |
... | ... | |
762 | 794 | |
763 | 795 |
foreach (var item in PrintimgPath_List) |
764 | 796 |
{ |
797 |
if (IsStop) |
|
798 |
break; |
|
799 | ||
765 | 800 |
System.Drawing.Image image = System.Drawing.Image.FromFile(item.Value); |
766 | 801 |
Export_img = iTextSharp.text.Image.GetInstance(image,System.Drawing.Imaging.ImageFormat.Jpeg); |
767 | 802 | |
... | ... | |
789 | 824 |
{ |
790 | 825 |
foreach (var item in PrintimgPath_List) |
791 | 826 |
{ |
827 |
if (IsStop) |
|
828 |
break; |
|
829 | ||
792 | 830 |
File.Copy(item.Value, SaveDig.FileName.Replace(".jpg", "_" + item.Key.ToString()) + ".jpg"); |
793 | 831 |
} |
794 | 832 |
break; |
... | ... | |
837 | 875 |
GC.Collect(); |
838 | 876 |
GC.WaitForPendingFinalizers(); |
839 | 877 |
GC.Collect(); |
840 | ||
878 |
IsStop = false; |
|
841 | 879 |
(this.Parent as RadWindow).CanClose = true; |
842 | 880 |
} |
843 | 881 |
} |
... | ... | |
1023 | 1061 |
currentPage++; |
1024 | 1062 | |
1025 | 1063 |
////인쇄를 계속 할지 말지 확인 |
1026 |
if (currentPage <= printDocument.PrinterSettings.ToPage) |
|
1064 |
if (currentPage <= printDocument.PrinterSettings.ToPage && !IsStop)
|
|
1027 | 1065 |
e.HasMorePages = true; |
1028 | 1066 |
else |
1029 | 1067 |
e.HasMorePages = false; |
... | ... | |
1039 | 1077 | |
1040 | 1078 |
sliderPages.Value = 1; |
1041 | 1079 |
printIndy.IsBusy = false; |
1042 | ||
1080 |
IsStop = false; |
|
1043 | 1081 |
})); |
1044 | 1082 |
} |
1045 | 1083 |
#endregion |
... | ... | |
1092 | 1130 |
#endregion |
1093 | 1131 | |
1094 | 1132 |
#endregion |
1133 | ||
1134 |
private void btPrintCancel_click(object sender, RoutedEventArgs e) |
|
1135 |
{ |
|
1136 |
IsStop = true; |
|
1137 |
} |
|
1095 | 1138 |
} |
1096 | 1139 |
} |
내보내기 Unified diff