개정판 24c5e56c
- final pdf Font 추가
- Markus navi 속도 최적화 Key input 최적화
Change-Id: I7f2cf1933e86017d7b1df9ef4bd3048a8e80a653
KCOM/PageManager/PageStorage.cs | ||
---|---|---|
62 | 62 |
StartPageNo = values[0]; |
63 | 63 |
TalkCount = values[1]; |
64 | 64 |
|
65 |
DownloadPagesAsync(StartPageNo, TalkCount); |
|
65 |
DownloadPagesAsync( StartPageNo, TalkCount);
|
|
66 | 66 |
} |
67 | 67 |
} |
68 | 68 |
} |
... | ... | |
78 | 78 |
|
79 | 79 |
} |
80 | 80 |
|
81 |
public async Task<BitmapFrame> GetPageImageAsync(int PageNo,bool IsRestart =false) |
|
81 |
public async Task<BitmapFrame> GetPageImageAsync(System.Threading.CancellationToken cts,int PageNo,bool IsRestart =false)
|
|
82 | 82 |
{ |
83 | 83 |
try |
84 | 84 |
{ |
85 | 85 |
|
86 |
var localUri = await GetPageUriAsync(PageNo); |
|
86 |
var localUri = await GetPageUriAsync(cts,PageNo);
|
|
87 | 87 |
|
88 |
PageImage = BitmapFrame.Create(localUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); |
|
88 |
if (localUri != null || !cts.IsCancellationRequested) |
|
89 |
{ |
|
90 |
PageImage = BitmapFrame.Create(localUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); |
|
91 |
} |
|
89 | 92 |
} |
90 | 93 |
catch (Exception ex) |
91 | 94 |
{ |
... | ... | |
98 | 101 |
return PageImage; |
99 | 102 |
} |
100 | 103 |
|
101 |
public async Task<Uri> GetPageUriAsync(int PageNo, bool IsRestart = false) |
|
104 |
public async Task<Uri> GetPageUriAsync( System.Threading.CancellationToken cts, int PageNo, bool IsRestart = false)
|
|
102 | 105 |
{ |
103 | 106 |
Uri result = null; |
104 | 107 |
|
... | ... | |
106 | 109 |
{ |
107 | 110 |
System.Diagnostics.Debug.WriteLine("GetPageAsync"); |
108 | 111 |
|
109 |
var pageItem = await DownloadPageAsync(PageNo); |
|
112 |
var pageItem = await DownloadPageAsync(PageNo,cts);
|
|
110 | 113 |
|
111 | 114 |
if (!IsRunWork && pageItem != null) |
112 | 115 |
{ |
... | ... | |
137 | 140 |
} |
138 | 141 |
catch (Exception ex) |
139 | 142 |
{ |
140 |
if (!IsRestart) |
|
143 |
if (!IsRestart || !cts.IsCancellationRequested)
|
|
141 | 144 |
{ |
142 | 145 |
await Task.Delay(100); |
143 | 146 |
|
144 |
result = await GetPageUriAsync(PageNo, true); |
|
147 |
result = await GetPageUriAsync(cts,PageNo, true);
|
|
145 | 148 |
} |
146 | 149 |
//throw new Exception("GetPageAsync(string BasePageUri,int PageNo)", ex); |
147 | 150 |
} |
... | ... | |
167 | 170 |
{ |
168 | 171 |
try |
169 | 172 |
{ |
170 |
await DownloadPageAsync(i); |
|
173 |
await DownloadPageAsync(i,null);
|
|
171 | 174 |
System.Threading.Thread.Sleep(200); |
172 | 175 |
} |
173 | 176 |
catch (Exception ex) |
... | ... | |
192 | 195 |
} |
193 | 196 |
} |
194 | 197 |
|
195 |
public async Task<PageItem> DownloadPageAsync(int PageNo) |
|
198 |
public async Task<PageItem> DownloadPageAsync(int PageNo,System.Threading.CancellationToken? cts)
|
|
196 | 199 |
{ |
197 | 200 |
PageItem result = new PageItem { PageNo = PageNo }; |
198 | 201 |
|
... | ... | |
215 | 218 |
{ |
216 | 219 |
fileItems.Remove(item); |
217 | 220 |
|
218 |
result = await DownloadPageAsync(PageNo); |
|
221 |
result = await DownloadPageAsync(PageNo,cts);
|
|
219 | 222 |
} |
220 | 223 |
} |
221 | 224 |
else |
... | ... | |
228 | 231 |
|
229 | 232 |
|
230 | 233 |
using (System.Net.WebClient client = new System.Net.WebClient()) |
231 |
{
|
|
234 |
{ |
|
232 | 235 |
client.UseDefaultCredentials = true; |
233 | 236 |
System.Net.IWebProxy webProxy = client.Proxy; |
234 | 237 |
|
... | ... | |
240 | 243 |
|
241 | 244 |
//client.DownloadFileCompleted += (snd, evt) => |
242 | 245 |
//{ |
243 |
|
|
246 |
|
|
244 | 247 |
|
245 | 248 |
// //(snd as System.Net.WebClient).Dispose(); |
246 | 249 |
//}; |
247 | 250 |
|
251 |
if(cts != null) |
|
252 |
client.DownloadProgressChanged += (snd, ect) => |
|
253 |
{ |
|
254 |
if(cts.Value.IsCancellationRequested) |
|
255 |
{ |
|
256 |
client.CancelAsync(); |
|
257 |
} |
|
258 |
}; |
|
259 |
|
|
248 | 260 |
System.Diagnostics.Debug.WriteLine("Download : " + downloadFilePath); |
249 | 261 |
|
250 | 262 |
await client.DownloadFileTaskAsync(originalUri, downloadFilePath); |
내보내기 Unified diff