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