markus / KCOM / Controls / PageNavigator.xaml.cs @ a0bab669
이력 | 보기 | 이력해설 | 다운로드 (7.32 KB)
1 | 787a4489 | KangIngu | using KCOM.Common; |
---|---|---|---|
2 | using KCOMDataModel.DataModel; |
||
3 | using System; |
||
4 | using System.Collections.Generic; |
||
5 | using System.Collections.ObjectModel; |
||
6 | using System.ComponentModel; |
||
7 | using System.Linq; |
||
8 | using System.Text; |
||
9 | using System.Windows; |
||
10 | using System.Windows.Controls; |
||
11 | using System.Windows.Data; |
||
12 | using System.Windows.Documents; |
||
13 | using System.Windows.Input; |
||
14 | using System.Windows.Media; |
||
15 | using System.Windows.Media.Imaging; |
||
16 | using System.Windows.Navigation; |
||
17 | using System.Windows.Shapes; |
||
18 | |||
19 | namespace KCOM.Controls |
||
20 | { |
||
21 | /// <summary> |
||
22 | /// Interaction logic for PageNavigator.xaml |
||
23 | /// </summary> |
||
24 | public partial class PageNavigator : UserControl, INotifyPropertyChanged |
||
25 | { |
||
26 | public event PropertyChangedEventHandler PropertyChanged; |
||
27 | public PageNavigator() |
||
28 | { |
||
29 | InitializeComponent(); |
||
30 | _Initialize = true; |
||
31 | } |
||
32 | public ObservableCollection<ThumbnailItem> _thumbnailItems; |
||
33 | private List<DOCPAGE> _PageList = null; |
||
34 | private string _DefaultUri = null; |
||
35 | public ThumbnailItem CurrentPage = null; |
||
36 | public ThumbnailItem _NextPage = null; |
||
37 | |||
38 | private bool _Initialize; |
||
39 | public event EventHandler<PageChangeEventArgs> PageChanged; |
||
40 | public event EventHandler<PageChangeEventArgs> PageChanging; |
||
41 | |||
42 | public class PageChangeEventArgs : EventArgs |
||
43 | { |
||
44 | public DOCPAGE CurrentPage { get; set; } |
||
45 | public string PageUri { get; set; } |
||
46 | public int PageNumber { get; set; } |
||
47 | } |
||
48 | |||
49 | private bool _IsFitOn { get; set; } |
||
50 | public bool IsFitOn |
||
51 | { |
||
52 | get |
||
53 | { |
||
54 | return _IsFitOn; |
||
55 | } |
||
56 | set |
||
57 | { |
||
58 | _IsFitOn = value; |
||
59 | RaisePropertyChanged("IsFitOn"); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | public void RaisePropertyChanged(string propName) |
||
64 | { |
||
65 | if (PropertyChanged != null) |
||
66 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
67 | } |
||
68 | |||
69 | public void SetPageNavi(List<DOCPAGE> PageList, string DefaultUri) |
||
70 | { |
||
71 | this._PageList = PageList; |
||
72 | this._DefaultUri = DefaultUri; |
||
73 | ThumbnailSet(); |
||
74 | //ThumbNmailSet(); |
||
75 | //rdoAllPages.Checked += new RoutedEventHandler(rdoCommented_Checked); |
||
76 | //rdoFavoritePages.Checked += new RoutedEventHandler(rdoFavoritePages_Checked); |
||
77 | //expCommentPages.PreviewCollapsed += new RadRoutedEventHandler(expCommentPages_PreviewCollapsed); |
||
78 | //expCommentPages.PreviewExpanded += new RadRoutedEventHandler(expCommentPages_PreviewExpanded); |
||
79 | } |
||
80 | private void ImgListbox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) |
||
81 | { |
||
82 | //tmStart = false; |
||
83 | //tm.Stop(); |
||
84 | //tm.Tick -= new EventHandler(tm_Tick); |
||
85 | int _PageNo = -1; |
||
86 | |||
87 | if (this.CurrentPage != null) |
||
88 | { |
||
89 | _PageNo = this.CurrentPage.PageNumber; |
||
90 | }; |
||
91 | |||
92 | if (_PageNo != (ImgListbox.SelectedItem as ThumbnailItem).PageNumber) |
||
93 | { |
||
94 | GotoPage((ImgListbox.SelectedItem as ThumbnailItem).PageNumber); |
||
95 | } |
||
96 | } |
||
97 | |||
98 | public bool GotoPageFlag = false; |
||
99 | |||
100 | public void GotoPage(int _pageNumber) |
||
101 | { |
||
102 | int _PageNo = -1; |
||
103 | if (int.TryParse(_pageNumber.ToString(), out _PageNo)) |
||
104 | { |
||
105 | var _page = _thumbnailItems.Where(item => item.PageNumber == _PageNo); |
||
106 | if (_page.Count() > 0) |
||
107 | { |
||
108 | ThumbnailItem _item = _page.First(); |
||
109 | setPageChange(_item); |
||
110 | } |
||
111 | } |
||
112 | } |
||
113 | |||
114 | private void setPageChange(ThumbnailItem thumbnailItem) |
||
115 | { |
||
116 | if (thumbnailItem != null) |
||
117 | { |
||
118 | if (PageChanging != null) |
||
119 | { |
||
120 | CurrentPage = _NextPage; |
||
121 | _NextPage = thumbnailItem; |
||
122 | PageChanging(this, new PageChangeEventArgs |
||
123 | { |
||
124 | CurrentPage = _PageList.Where(p => p.PAGE_NUMBER == thumbnailItem.PageNumber).First(), |
||
125 | PageNumber = Convert.ToInt32(thumbnailItem.PageNumber), |
||
126 | PageUri = null |
||
127 | }); |
||
128 | |||
129 | } |
||
130 | } |
||
131 | } |
||
132 | |||
133 | private void Grid_LeftButtonDown(object sender, MouseButtonEventArgs e) |
||
134 | { |
||
135 | |||
136 | } |
||
137 | private void ThumbnailSet() |
||
138 | { |
||
139 | if (!_Initialize) return; |
||
140 | |||
141 | this._thumbnailItems = new ObservableCollection<ThumbnailItem>(); |
||
142 | |||
143 | //if (this.lstSelectComment.ItemsSource != null) |
||
144 | //{ |
||
145 | // var _pages = from commentPage in this.lstSelectComment.ItemsSource.Cast<UsersCommentPagesMember>() |
||
146 | // where commentPage.IsSelected == true |
||
147 | // select commentPage.PageNumber; |
||
148 | |||
149 | // foreach (var item in _pages) |
||
150 | // { |
||
151 | // item.ForEach(pp => _selectComment.Add(pp)); |
||
152 | // } |
||
153 | |||
154 | // _selectComment.Distinct(); |
||
155 | //} |
||
156 | |||
157 | var uri = _DefaultUri.Replace("{0}/{1}_{2}", "8/0_0"); |
||
158 | this._PageList = this._PageList.OrderBy(data => data.PAGE_NUMBER).ToList(); |
||
159 | this._PageList.ForEach(page => |
||
160 | { |
||
161 | var _pageNo = page.PAGE_NUMBER; |
||
162 | bool _addFlag = false; |
||
163 | |||
164 | this._thumbnailItems.Add(new ThumbnailItem |
||
165 | { |
||
166 | ImageUri = new Uri(uri.Replace("{PageNo}", _pageNo.ToString())), |
||
167 | |||
168 | //ImageUri = new Uri(@"http://www.honeyhead.net/Pages/000000/111111/11111111/1.cmp"), |
||
169 | |||
170 | //ImageUri = new Uri(@"https://image.freepik.com/free-vector/abstract-logo-in-flame-shape_1043-44.jpg"), |
||
171 | |||
172 | |||
173 | PageNumber = Convert.ToInt32(_pageNo), |
||
174 | Angle = Convert.ToInt32(page.PAGE_ANGLE), |
||
175 | }); |
||
176 | }); |
||
177 | |||
178 | txtTotPageNo.Text = this._PageList.Count().ToString(); |
||
179 | |||
180 | txtThumbCount.Text = String.Format("Count : {0}", (this._thumbnailItems.Count).ToString()); |
||
181 | |||
182 | if (ImgListbox.ItemsSource == null) |
||
183 | { |
||
184 | ImgListbox.ItemsSource = this._thumbnailItems; |
||
185 | |||
186 | |||
187 | if (ImgListbox.Items.Count > 0) |
||
188 | { |
||
189 | //int StartPageIdx = Convert.ToInt32(App.ViewInfo.StartPage) - 1; |
||
190 | int StartPageIdx = 1; |
||
191 | //if (App.ViewInfo.IsCustomPage) |
||
192 | //{ |
||
193 | // ImgListbox.SelectedItem = ImgListbox.Items.Where(data => (data as ThumbnailItem).PageNumber == Convert.ToInt32(App.ViewInfo.StartPage)).FirstOrDefault(); |
||
194 | //} |
||
195 | //else |
||
196 | //{ |
||
197 | |||
198 | if (StartPageIdx <= 0 || StartPageIdx > ImgListbox.Items.Count || StartPageIdx == 1) |
||
199 | { |
||
200 | ImgListbox.SelectedItem = ImgListbox.Items[0]; |
||
201 | } |
||
202 | else |
||
203 | { |
||
204 | ImgListbox.SelectedItem = ImgListbox.Items[StartPageIdx]; |
||
205 | } |
||
206 | //} |
||
207 | } |
||
208 | } |
||
209 | else |
||
210 | { |
||
211 | ImgListbox.UpdateLayout(); |
||
212 | ImgListbox.ItemsSource = this._thumbnailItems; |
||
213 | } |
||
214 | } |
||
215 | } |
||
216 | } |