Develop and Download Open Source Software

Browse Subversion Repository

Contents of /MainWindow.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (show annotations) (download)
Thu Apr 21 13:23:22 2011 UTC (13 years ago) by aqua877
File size: 42831 byte(s)


1 using System;
2 using System.Collections.Generic;
3 using System.Drawing;
4 using System.Linq;
5 using System.Windows.Forms;
6 using System.Text.RegularExpressions;
7 using System.Diagnostics;
8
9 namespace Aqua877.WinApp.IronLivetube
10 {
11 public partial class MainWindow : Form
12 {
13 private LivetubeCommentReader LivetubeComments;
14 private LivetubeInformation LivetubeLiveInfo;
15 private TextReaderServices TextReader;
16 private FilteringHelper FilterService;
17 private CommandHelper CommandService;
18 private MainWindowListViewSorter SortHelper;
19 private SendersWiki SendersWikiCollector;
20
21 private bool IsShowingFindWindow = false;
22 private FindConditionsData FindConditions;
23 private List<int> FindResult = new List<int>();
24 private int CurrentShowingFindResultIndex = -1;
25
26 public MainWindow()
27 {
28 this.SortHelper = new MainWindowListViewSorter();
29 this.SendersWikiCollector = new SendersWiki();
30
31 this.InitializeComponent();
32
33 //イベント登録
34 this.LivetubeComments = new LivetubeCommentReader();
35 this.LivetubeComments.OnLoaded += this.OnLoaded;
36 this.LivetubeComments.OnCaughtComment += this.OnCaughtComment;
37 this.LivetubeComments.OnStatusTextChanged += this.OnStatusTextChanged;
38 this.LivetubeComments.OnPostCommentFinished += this.OnPostCommentFinished;
39 this.LivetubeComments.OnBanCommentFinished += this.OnBanCommentFinished;
40 this.LivetubeComments.OnUnBanCommentFinished += this.OnUnBanCommentFinished;
41 this.LivetubeComments.OnBannedCommentsListRefreshed += this.OnBannedCommentsListFinished;
42 this.LivetubeComments.OnGetHostFinished += this.OnGetHostFinished;
43
44 this.LivetubeLiveInfo = new LivetubeInformation();
45 this.LivetubeLiveInfo.OnInformationRefreshed += this.OnInformationRefreshed;
46 this.LivetubeLiveInfo.OnLiveEnded += this.OnLiveEnded;
47 this.LivetubeComments.LiveInfo = this.LivetubeLiveInfo;
48
49 //ヘルパークラスの初期化
50 this.TextReader = new TextReaderServices();
51 this.FilterService = new FilteringHelper();
52 #warning //this.FilterService.OnMatchedFilteringCondition +=
53 this.CommandService = new CommandHelper();
54 #warning //this.CommandService.OnCommandExecuted +=
55
56 //ソート設定
57 this.LivetubeCommentsList.ListViewItemSorter = this.SortHelper;
58
59 //設定の反映
60 this.TopMost = GlobalValues.Setting.IsShowWindowMostTop;
61 this.LivetubeCommentsList.GridLines = GlobalValues.Setting.IsShowGridLines;
62 this.UseCommandsMenuItem.Checked = GlobalValues.Setting.IsEnableCommand;
63 this.UseReadingMenuItem.Checked = GlobalValues.Setting.IsEnableReading;
64 this.UseSoundEffectMenuItem.Checked = GlobalValues.Setting.IsEnableSoundEffect;
65 this.UseFilteringMenuItem.Checked = GlobalValues.Setting.IsEnableFiltering;
66
67 if (!string.IsNullOrWhiteSpace(GlobalValues.Setting.LivetubeUserID))
68 {
69 this.NameTextBox.Text = GlobalValues.Setting.LivetubeUserID;
70 this.NameTextBox.Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128);
71 this.NameTextBox.ForeColor = Color.Green;
72 }
73 else
74 {
75 this.NameTextBox.Text = "";
76 this.NameTextBox.Font = new Font("メイリオ", 9F, FontStyle.Regular, GraphicsUnit.Point, 128);
77 this.NameTextBox.ForeColor = SystemColors.WindowText;
78 }
79 this.SetProcessingText("初期化完了");
80 }
81
82 #region イベントハンドラ
83 #region ファイルメニュー
84 //設定ウィンドウを開く
85 private void SettingsMenuItem_Click(object sender, EventArgs e)
86 {
87 using (var settingsWindow = new SettingsWindow(this.LivetubeComments))
88 {
89 this.TopMost = false;
90 settingsWindow.ShowDialog();
91 }
92
93 //設定の反映等
94 this.TopMost = GlobalValues.Setting.IsShowWindowMostTop;
95 this.LivetubeCommentsList.GridLines = GlobalValues.Setting.IsShowGridLines;
96 this.UseCommandsMenuItem.Checked = GlobalValues.Setting.IsEnableCommand;
97 this.UseSoundEffectMenuItem.Checked = GlobalValues.Setting.IsEnableSoundEffect;
98 this.UseReadingMenuItem.Checked = GlobalValues.Setting.IsEnableReading;
99 this.UseFilteringMenuItem.Checked = GlobalValues.Setting.IsEnableFiltering;
100
101 if (GlobalValues.Setting.CredentialData.Length > 0)
102 {
103 this.NameTextBox.Text = GlobalValues.Setting.LivetubeUserID;
104 this.NameTextBox.ForeColor = Color.Green;
105 this.NameTextBox.Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128);
106 }
107 else
108 {
109 this.NameTextBox.ForeColor = SystemColors.WindowText;
110 this.NameTextBox.Font = new Font("メイリオ", 9F, FontStyle.Regular, GraphicsUnit.Point, 128);
111 this.NameTextBox.ReadOnly = false;
112 }
113
114 if (GlobalValues.Setting.IsEnableReading && this.LivetubeComments.IsReading)
115 {
116 this.StartReadingMenuItem.Enabled = true;
117 this.StopReadingMenuItem.Enabled = false;
118 this.RestartReadingMenuItem.Enabled = false;
119 this.SuspendReadingMenuItem.Enabled = false;
120 this.TextReader.Start();
121 }
122 else
123 {
124 this.StartReadingMenuItem.Enabled = false;
125 this.StopReadingMenuItem.Enabled = false;
126 this.RestartReadingMenuItem.Enabled = false;
127 this.SuspendReadingMenuItem.Enabled = false;
128 if (this.TextReader.IsEnable)
129 {
130 this.TextReader.Stop();
131 }
132 }
133
134 //全件表示の切り替え
135 if(this.LivetubeComments.IsReading)
136 {
137 if (!GlobalValues.Setting.IsShowAllComments)
138 {
139 //全件表示オフ時には過分を削除
140 while (this.LivetubeCommentsList.Items.Count > GlobalValues.Setting.ShowCommentCount)
141 {
142 if (this.SortHelper.Order == SortOrder.Ascending)
143 {
144 this.LivetubeCommentsList.Items.RemoveAt(0);
145 }
146 else
147 {
148 int lastOfIndex = this.LivetubeCommentsList.Items.Count - 1;
149 this.LivetubeCommentsList.Items.RemoveAt(lastOfIndex);
150 }
151 }
152 }
153 else
154 {
155 //全件表示オン時には不足分を追加
156 this.LivetubeCommentsList.BeginUpdate();
157 this.LivetubeCommentsList.ListViewItemSorter = null;
158
159 int shortage = this.LivetubeComments.CommentContainer.Count - this.LivetubeCommentsList.Items.Count;
160 if (shortage > 0)
161 {
162 this.LivetubeComments.CommentContainer
163 .TakeLast(shortage)
164 .ToObservable().Let(
165 xs =>
166 {
167 xs.Where(c => c.Name == "")//名無しコメント
168 .Select(d => new ListViewItem(new[]
169 {
170 new ListViewItem.ListViewSubItem { Text = d.Number.ToString() },
171 new ListViewItem.ListViewSubItem { Text = "" },
172 new ListViewItem.ListViewSubItem { Text = d.Text },
173 new ListViewItem.ListViewSubItem { Text = "" },
174 new ListViewItem.ListViewSubItem { Text = d.PostedDate.ToString("M/d H:mm:ss") },
175 new ListViewItem.ListViewSubItem { Text = d.ID, Font = new Font("メイリオ", 9F, FontStyle.Italic, GraphicsUnit.Point, 128) },
176 new ListViewItem.ListViewSubItem { Text = "" }
177 }, 0) { UseItemStyleForSubItems = false })
178 .Merge(
179 xs.Where(c => c.Name != "" && !c.ContributorCanBroadcasting)//黒コテ
180 .Select(d => new ListViewItem(new[]
181 {
182 new ListViewItem.ListViewSubItem { Text = d.Number.ToString() },
183 new ListViewItem.ListViewSubItem { Text = "" },
184 new ListViewItem.ListViewSubItem { Text = d.Text },
185 new ListViewItem.ListViewSubItem { Text = d.Name, Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128) },
186 new ListViewItem.ListViewSubItem { Text = d.PostedDate.ToString("M/d H:mm:ss") },
187 new ListViewItem.ListViewSubItem { Text = d.ID, Font = new Font("メイリオ", 9F, FontStyle.Italic, GraphicsUnit.Point, 128) },
188 new ListViewItem.ListViewSubItem { Text = "" }
189 }, 0) { UseItemStyleForSubItems = false })
190 .Merge(
191 xs.Where(c => c.Name != "" && c.ContributorCanBroadcasting)//緑コテ
192 .Select(d => new ListViewItem(new[]
193 {
194 new ListViewItem.ListViewSubItem { Text = d.Number.ToString() },
195 new ListViewItem.ListViewSubItem { Text = "" },
196 new ListViewItem.ListViewSubItem { Text = d.Text },
197 new ListViewItem.ListViewSubItem { Text = d.Name, Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128), ForeColor = Color.Green },
198 new ListViewItem.ListViewSubItem { Text = d.PostedDate.ToString("M/d H:mm:ss") },
199 new ListViewItem.ListViewSubItem { Text = d.ID, Font = new Font("メイリオ", 9F, FontStyle.Italic, GraphicsUnit.Point, 128) },
200 new ListViewItem.ListViewSubItem { Text = "" }
201 }, 0) { UseItemStyleForSubItems = false })
202 )
203 ).Subscribe(
204 //すべて追加
205 d => this.LivetubeCommentsList.Items.Add(d)
206 );
207 return xs;
208 }
209 );
210 }
211 }
212 this.LivetubeCommentsList.ListViewItemSorter = this.SortHelper;
213 this.LivetubeCommentsList.Sort();
214 this.LivetubeCommentsList.EndUpdate();
215 }
216 }
217
218 //配信をURLから開く
219 private void OpenLiveFromURLMenu_Click(object sender, EventArgs e)
220 {
221 DialogResult result;
222 var resultUrl = "";
223
224 using (var openLive = new OpenLiveFromURLWindow())
225 {
226 this.TopMost = false;
227 result = openLive.ShowDialog();
228
229 if (GlobalValues.Setting.IsShowWindowMostTop)
230 {
231 this.TopMost = true;
232 }
233
234 resultUrl = openLive.Tag as string;
235 }
236
237 if (result == DialogResult.OK)
238 {
239 this.OpenLiveFromURLMenu.Enabled = false;
240 this.OpenLiveFromStreamIDMenuItem.Enabled = false;
241 this.OpenLiveFromLiveListMenuItem.Enabled = false;
242
243 this.LivetubeComments.LoadAsync(new Uri(resultUrl));
244 this.LivetubeLiveInfo.LoadAsync(new Uri(resultUrl));
245 }
246 }
247
248 //配信をStreamIDから開く
249 private void OpenLiveFromStreamIDMenuItem_Click(object sender, EventArgs e)
250 {
251 var result = DialogResult.None;
252 var resultStreamID = "";
253
254 using (var openLive = new OpenLiveFromStreamIDWindow())
255 {
256 this.TopMost = false;
257 result = openLive.ShowDialog();
258
259 if (GlobalValues.Setting.IsShowWindowMostTop)
260 {
261 this.TopMost = true;
262 }
263 resultStreamID = openLive.Tag as string;
264 }
265
266 if (result == DialogResult.OK)
267 {
268 this.OpenLiveFromURLMenu.Enabled = false;
269 this.OpenLiveFromStreamIDMenuItem.Enabled = false;
270 this.OpenLiveFromLiveListMenuItem.Enabled = false;
271
272 this.LivetubeComments.LoadAsync(resultStreamID);
273 }
274 }
275
276 //配信を閉じる
277 private void CloseLiveMenuItem_Click(object sender, EventArgs e)
278 {
279 this.LivetubeComments.StopLoad();
280 this.LivetubeLiveInfo.StopLoad();
281 this.TextReader.Stop();
282
283 this.Text = "IronLivetube";
284 this.OpenLiveFromURLMenu.Enabled = true;
285 this.OpenLiveFromStreamIDMenuItem.Enabled = true;
286 this.OpenLiveFromLiveListMenuItem.Enabled = true;
287 this.CloseLiveMenuItem.Enabled = false;
288 this.PlayLiveMenuItem.Enabled = false;
289 this.CloseLiveMenuItem.Enabled = true;
290 this.PlayLiveMenuItem.Enabled = true;
291 this.splitContainer1.Panel2.Enabled = false;
292 this.CopyCommentMenuItem.Enabled = false;
293 this.CopyCommentContextMenuItem.Enabled = false;
294 this.CopyCommentTextMenuItem.Enabled = false;
295 this.CopyCommentTextContextMenuItem.Enabled = false;
296 this.CopyCommentURLMenuItem.Enabled = false;
297 this.CopyCommentURLContextMenuItem.Enabled = false;
298 this.FindMenuItem.Enabled = false;
299 this.FindNextMenuitem.Enabled = false;
300 this.FindPreviousMenuItem.Enabled = false;
301 this.MarkCommentAsNGMenuItem.Enabled = false;
302 this.MarkCommentAsNGContextMenuItem.Enabled = false;
303 this.MarkCommentAsNotNGMenuItem.Enabled = false;
304 this.MarkCommentAsNotNGContextMenuItem.Enabled = false;
305 this.ShowHostMenuItem.Enabled = false;
306 this.ShowHostContextMenuItem.Enabled = false;
307 this.LiveAuthorMenuItem.Enabled = false;
308 this.LiveAuthorContextMenuItem.Enabled = false;
309 this.SelectAllMenuItem.Enabled = false;
310 this.SelectAllContextMenuItem.Enabled = false;
311 this.RefreshConnectionMenuItem.Enabled = false;
312 this.RefreshConnectionContextMenuItem.Enabled = false;
313 this.LivetubeCommentsList.Items.Clear();
314 this.LiveStatusText.Text = "[視/見]?/? [流速(Livetube)]?コメ/h [流速(したらば)]?コメ/h";
315 this.StartReadingMenuItem.Enabled = false;
316 this.StopReadingMenuItem.Enabled = false;
317 this.RestartReadingMenuItem.Enabled = false;
318 this.SuspendReadingMenuItem.Enabled = false;
319 this.TextReader.Stop();
320 }
321
322 //配信を再生
323 private void PlayLiveMenuItem_Click(object sender, EventArgs e)
324 {
325
326 }
327
328 //プログラムを終了
329 private void ExitApplicationMenuItem_Click(object sender, EventArgs e)
330 {
331 this.LivetubeComments.StopLoad();
332 Application.Exit();
333 }
334 #endregion
335
336 #region 編集メニュー
337 //コメント全体をコピー
338 private void CopyCommentMenuItem_Click(object sender, EventArgs e)
339 {
340 string textToCopy = "";
341
342 foreach (var comment in this.LivetubeCommentsList.SelectedItems.Cast<ListViewItem>())
343 {
344 textToCopy += String.Format("{0} : {1}{2} {3}\n{4}\n----------\n",
345 comment.SubItems[0].Text,
346 comment.SubItems[3].Text, ((comment.SubItems[5].Text != "") ? "(" + comment.SubItems[5].Text + ")" : ""),
347 comment.SubItems[4].Text, comment.SubItems[2].Text
348 );
349 }
350 textToCopy = textToCopy.TrimEnd('\n');
351 textToCopy = textToCopy.TrimEnd('-');
352 textToCopy = textToCopy.TrimEnd('\n');
353
354 Clipboard.SetDataObject(textToCopy, true);
355 }
356
357 //コメント本文のみをコピー
358 private void CopyCommentTextMenuItem_Click(object sender, EventArgs e)
359 {
360 string textToCopy = "";
361
362 foreach (var comment in this.LivetubeCommentsList.SelectedItems.Cast<ListViewItem>())
363 {
364 textToCopy += comment.SubItems[2].Text + "\n----------\n";
365 }
366 textToCopy = textToCopy.TrimEnd('\n');
367 textToCopy = textToCopy.TrimEnd('-');
368 textToCopy = textToCopy.TrimEnd('\n');
369
370 Clipboard.SetDataObject(textToCopy, true);
371 }
372
373 //コメントに含まれるURLをコピー
374 private void CopyCommentURLMenuItem_Click(object sender, EventArgs e)
375 {
376 string textToCopy = "";
377
378 foreach (var comment in this.LivetubeCommentsList.SelectedItems.Cast<ListViewItem>())
379 {
380 foreach (var url in Regex.Matches(comment.SubItems[2].Text, @"^s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+$").Cast<Match>().Select(m => m.Value))
381 {
382 textToCopy += url + "\n----------\n";
383 }
384 }
385 textToCopy = textToCopy.TrimEnd('\n');
386 textToCopy = textToCopy.TrimEnd('-');
387 textToCopy = textToCopy.TrimEnd('\n');
388
389 Clipboard.SetDataObject(textToCopy, true);
390 }
391
392 //検索
393 private void FindMenuItem_Click(object sender, EventArgs e)
394 {
395 if (this.IsShowingFindWindow)
396 {
397 return;
398 }
399
400 this.TopMost = false;
401 this.IsShowingFindWindow = true;
402 this.CurrentShowingFindResultIndex = -1;
403
404 var findWindow = new FindWindow() { FindConditions = this.FindConditions };
405
406 findWindow.FormClosed += (args, fce) =>
407 {
408 if (GlobalValues.Setting.IsShowWindowMostTop)
409 {
410 this.TopMost = true;
411 }
412
413 this.LivetubeCommentsList.Select();
414 this.IsShowingFindWindow = false;
415 };
416
417 findWindow.OnFindConditionsChanged += () =>
418 {
419 this.FindConditions = findWindow.FindConditions;
420 this.FindResult.Clear();
421 this.LivetubeCommentsList.Items
422 .Cast<ListViewItem>().ForEach(i =>
423 i.SubItems.Cast<ListViewItem.ListViewSubItem>()
424 .Where(xs => xs.BackColor == Color.LemonChiffon)
425 .ForEach(xs =>
426 {
427 xs.BackColor = SystemColors.Window;
428 xs.ForeColor = SystemColors.WindowText;
429 })
430 );
431
432 if (!this.FindConditions.IsUseRegex)
433 {
434 this.LivetubeCommentsList.Items
435 .Cast<ListViewItem>()
436 .Select((l, i) =>
437 new
438 {
439 Item = new string(
440 l.SubItems
441 .Cast<ListViewItem.ListViewSubItem>()
442 .Let(xs =>
443 {
444 var str = "";
445 xs.ForEach(xi => str += xi.Text + " ");
446 return str;
447 })
448 .ToArray()),
449 Index = i
450 }
451 ).Let(ts => this.FindConditions.IgnoreCase ? ts.Where(xs => xs.Item.Contains(this.FindConditions.Pattern.ToLower())) : ts.Where(xs => xs.Item.Contains(this.FindConditions.Pattern))).Select(xs => xs.Index)
452 .ForEach(i => this.FindResult.Add(i));
453
454 if (this.FindResult.Count > 0)
455 {
456 this.CurrentShowingFindResultIndex = 0;
457 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex]].Selected = true;
458 this.LivetubeCommentsList.EnsureVisible(this.CurrentShowingFindResultIndex);
459
460 this.FindResult.ForEach(i =>
461 this.LivetubeCommentsList.Items[i].SubItems
462 .Cast<ListViewItem.ListViewSubItem>().ForEach(s => { s.BackColor = Color.LemonChiffon; s.ForeColor = SystemColors.WindowText; })
463 );
464 }
465 }
466 else
467 {
468 #warning TODO : 正規表現による検索
469 }
470 };
471
472 findWindow.Show();
473 }
474
475 //次を検索
476 private void FindNextMenuitem_Click(object sender, EventArgs e)
477 {
478 if (this.CurrentShowingFindResultIndex + 1 <= this.FindResult.Count - 1)
479 {
480 this.CurrentShowingFindResultIndex++;
481 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex - 1]].Selected = false;
482 }
483 else
484 {
485 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex]].Selected = false;
486 this.CurrentShowingFindResultIndex = 0;
487 }
488
489 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex]].Selected = true;
490 this.LivetubeCommentsList.EnsureVisible(this.FindResult[this.CurrentShowingFindResultIndex]);
491 }
492
493 //前を検索
494 private void FindPreviousMenuItem_Click(object sender, EventArgs e)
495 {
496 if (this.CurrentShowingFindResultIndex - 1 >= 0)
497 {
498 this.CurrentShowingFindResultIndex--;
499 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex + 1]].Selected = false;
500 }
501 else
502 {
503 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex]].Selected = false;
504 this.CurrentShowingFindResultIndex = this.FindResult.Count - 1;
505 }
506
507
508 this.LivetubeCommentsList.Items[this.FindResult[this.CurrentShowingFindResultIndex]].Selected = true;
509 }
510 #endregion
511
512 #region 操作メニュー
513 private void MarkCommentAsNGMenuItem_Click(object sender, EventArgs e)
514 {
515 this.LivetubeComments.BanCommentAsync(
516 this.LivetubeCommentsList.SelectedItems.Cast<ListViewItem>()
517 .Select(s => s.SubItems[0].Text)
518 .Select(int.Parse)
519 );
520
521 }
522
523 private void MarkCommentAsNotNGMenuItem_Click(object sender, EventArgs e)
524 {
525 this.LivetubeComments.UnBanCommentAsync(
526 this.LivetubeCommentsList.SelectedItems.Cast<ListViewItem>()
527 .Select(s => s.SubItems[0].Text)
528 .Select(int.Parse)
529 );
530 }
531
532 private void ShowHostMenuItem_Click(object sender, EventArgs e)
533 {
534 var comment = this.LivetubeComments.CommentContainer.Single(
535 d => d.Number == int.Parse(this.LivetubeCommentsList.SelectedItems[0].SubItems[0].Text)
536 );
537
538 if (string.IsNullOrWhiteSpace(comment.Host))
539 {
540 return;
541 }
542 else
543 {
544 MessageBox.Show(String.Format("書き込み元ホスト({0}) : {1}", comment.Number, comment.Host), "書き込み元表示", MessageBoxButtons.OK, MessageBoxIcon.Information);
545 }
546 }
547
548 private void OpenLiveAuthorsPageMenuItem_Click(object sender, EventArgs e)
549 {
550 Process.Start("http://livetube.cc/" + this.LivetubeCommentsList.SelectedItems[0].SubItems[3].Text);
551 }
552
553 private void OpenLiveAuthorWikiMenuItem_Click(object sender, EventArgs e)
554 {
555 if (this.SendersWikiCollector.SendersWikiList.Keys.Contains(this.LivetubeCommentsList.SelectedItems[0].SubItems[3].Text))
556 {
557 Process.Start(this.SendersWikiCollector.SendersWikiList[this.LivetubeCommentsList.SelectedItems[0].SubItems[3].Text].ToString());
558 }
559 }
560
561 private void SelectAllMenuItem_Click(object sender, EventArgs e)
562 {
563 this.LivetubeCommentsList.Items.Cast<ListViewItem>().ForEach(i => i.Selected = true);
564 }
565
566 private void RefreshConnectionMenuItem_Click(object sender, EventArgs e)
567 {
568 this.LivetubeComments.RefreshConnection();
569 }
570 #endregion
571
572 #region その他機能メニュー
573 private void UseCommandsMenuItem_CheckedChanged(object sender, EventArgs e)
574 {
575 GlobalValues.Setting.IsEnableCommand = this.UseCommandsMenuItem.Checked;
576 }
577
578 private void UseSoundEffectMenuItem_CheckedChanged(object sender, EventArgs e)
579 {
580 GlobalValues.Setting.IsEnableSoundEffect = this.UseSoundEffectMenuItem.Checked;
581 }
582
583 private void UseReadingMenuItem_Click(object sender, EventArgs e)
584 {
585 GlobalValues.Setting.IsEnableReading = this.UseReadingMenuItem.Checked;
586 }
587
588 private void UseFilteringMenuItem_CheckedChanged(object sender, EventArgs e)
589 {
590 GlobalValues.Setting.IsEnableFiltering = this.UseFilteringMenuItem.Checked;
591 }
592
593 private void StartReadingMenuItem_Click(object sender, EventArgs e)
594 {
595 this.TextReader.Start();
596 this.StartReadingMenuItem.Enabled = false;
597 this.StopReadingMenuItem.Enabled = true;
598 this.RestartReadingMenuItem.Enabled = false;
599 this.SuspendReadingMenuItem.Enabled = true;
600 }
601
602 private void StopReadingMenuItem_Click(object sender, EventArgs e)
603 {
604 this.TextReader.Stop();
605 this.StartReadingMenuItem.Enabled = true;
606 this.StopReadingMenuItem.Enabled = false;
607 this.RestartReadingMenuItem.Enabled = false;
608 this.SuspendReadingMenuItem.Enabled = false;
609 }
610
611 private void SuspendReadingMenuItem_Click(object sender, EventArgs e)
612 {
613 this.TextReader.Suspend();
614 this.StartReadingMenuItem.Enabled = false;
615 this.StopReadingMenuItem.Enabled = true;
616 this.RestartReadingMenuItem.Enabled = true;
617 this.SuspendReadingMenuItem.Enabled = false;
618 }
619
620 private void RestartReadingMenuItem_Click(object sender, EventArgs e)
621 {
622 this.TextReader.Restart();
623 this.StartReadingMenuItem.Enabled = false;
624 this.StopReadingMenuItem.Enabled = true;
625 this.RestartReadingMenuItem.Enabled = false;
626 this.SuspendReadingMenuItem.Enabled = true;
627 }
628
629 private void ShortenURLBitlyMenuItem_Click(object sender, EventArgs e)
630 {
631 Regex.Matches(this.CommentTextBox.Text, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")
632 .Cast<Match>()
633 .ForEach(ms =>
634 {
635 if (GlobalValues.SupportedShortenServices.Any(ms.Value.Contains))
636 {
637 return;
638 }
639
640 var shortener = new global::Aqua877.WinApp.Lib.BitLyURLShortener(GlobalValues.BitLyUserName, GlobalValues.BitLyApiKey);
641 shortener.ShortenURLFinished += (sSender, se) =>
642 {
643 if (se.Error == null)
644 {
645 this.CommentTextBox.Text = this.CommentTextBox.Text.Replace(ms.Value, se.URLAfterShortening.ToString());
646 }
647 else
648 {
649 MessageBox.Show("URLの短縮に失敗しました。", "URL短縮失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
650 }
651 };
652 shortener.BeginShortenURL(new Uri(ms.Value));
653 });
654 }
655
656 private void ShortenURLJMpMenuItem_Click(object sender, EventArgs e)
657 {
658 Regex.Matches(this.CommentTextBox.Text, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")
659 .Cast<Match>()
660 .ForEach(ms =>
661 {
662 if (GlobalValues.SupportedShortenServices.Any(ms.Value.Contains))
663 {
664 return;
665 }
666
667 var shortener = new global::Aqua877.WinApp.Lib.JMpURLShortener(GlobalValues.BitLyUserName, GlobalValues.BitLyApiKey);
668 shortener.ShortenURLFinished += (sSender, se) =>
669 {
670 if (se.Error == null)
671 {
672 this.CommentTextBox.Text = this.CommentTextBox.Text.Replace(ms.Value, se.URLAfterShortening.ToString());
673 }
674 else
675 {
676 MessageBox.Show("URLの短縮に失敗しました。", "URL短縮失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
677 }
678 };
679 shortener.BeginShortenURL(new Uri(ms.Value));
680 });
681 }
682
683 private void ShortenURLIsGdMenuItem_Click(object sender, EventArgs e)
684 {
685 Regex.Matches(this.CommentTextBox.Text, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")
686 .Cast<Match>()
687 .ForEach(ms =>
688 {
689 if (GlobalValues.SupportedShortenServices.Any(ms.Value.Contains))
690 {
691 return;
692 }
693
694 var shortener = new global::Aqua877.WinApp.Lib.IsGdURLShortener();
695 shortener.ShortenURLFinished += (sSender, se) =>
696 {
697 if (se.Error == null)
698 {
699 this.CommentTextBox.Text = this.CommentTextBox.Text.Replace(ms.Value, se.URLAfterShortening.ToString());
700 }
701 else
702 {
703 MessageBox.Show("URLの短縮に失敗しました。", "URL短縮失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
704 }
705 };
706 shortener.BeginShortenURL(new Uri(ms.Value));
707 });
708 }
709
710 private void ShortenURLUxNuMenuItem_Click(object sender, EventArgs e)
711 {
712 Regex.Matches(this.CommentTextBox.Text, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")
713 .Cast<Match>()
714 .ForEach(ms =>
715 {
716 if (GlobalValues.SupportedShortenServices.Any(ms.Value.Contains))
717 {
718 return;
719 }
720
721 var shortener = new global::Aqua877.WinApp.Lib.UxNuURLShortener();
722 shortener.ShortenURLFinished += (sSender, se) =>
723 {
724 if (se.Error == null)
725 {
726 this.CommentTextBox.Text = this.CommentTextBox.Text.Replace(ms.Value, se.URLAfterShortening.ToString());
727 }
728 else
729 {
730 MessageBox.Show("URLの短縮に失敗しました。", "URL短縮失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
731 }
732 };
733 shortener.BeginShortenURL(new Uri(ms.Value));
734 });
735 }
736
737 private void ShortenURLPTlMenuItem_Click(object sender, EventArgs e)
738 {
739 Regex.Matches(this.CommentTextBox.Text, @"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")
740 .Cast<Match>()
741 .ForEach(ms =>
742 {
743 if (GlobalValues.SupportedShortenServices.Any(ms.Value.Contains))
744 {
745 return;
746 }
747
748 var shortener = new global::Aqua877.WinApp.Lib.PTlURLShortener(GlobalValues.PTlApiKey);
749 shortener.ShortenURLFinished += (sSender, se) =>
750 {
751 if (se.Error == null)
752 {
753 this.CommentTextBox.Text = this.CommentTextBox.Text.Replace(ms.Value, se.URLAfterShortening.ToString());
754 }
755 else
756 {
757 MessageBox.Show("URLの短縮に失敗しました。", "URL短縮失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
758 }
759 };
760 shortener.BeginShortenURL(new Uri(ms.Value));
761 });
762 }
763 #endregion
764
765 #region ヘルプメニュー
766 private void ViewCachingDataMenuItem_Click(object sender, EventArgs e)
767 {
768 using (var cm = new CacheManageWindow())
769 {
770 cm.ShowDialog();
771 }
772 }
773
774 private void CheckUpdateMenuItem_Click(object sender, EventArgs e)
775 {
776
777 }
778
779 private void ShowVersionInformationMenuItem_Click(object sender, EventArgs e)
780 {
781 using (var about = new AboutIronLivetube())
782 {
783 about.ShowDialog();
784 }
785 }
786 #endregion
787
788 #region コメント欄
789 private void NameTextBox_TextChanged(object sender, EventArgs e)
790 {
791 if (this.NameTextBox.Text == GlobalValues.Setting.LivetubeUserID)
792 {
793 this.NameTextBox.ForeColor = Color.Green;
794 this.NameTextBox.Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128);
795 }
796 else
797 {
798 this.NameTextBox.ForeColor = SystemColors.WindowText;
799 this.NameTextBox.Font = new Font("メイリオ", 9F, FontStyle.Regular, GraphicsUnit.Point, 128);
800 }
801 }
802
803 private void PostCommentButton_Click(object sender, EventArgs e)
804 {
805 if (this.CommentTextBox.Text.Trim() == "")
806 {
807 this.SetPostCommentErrorText("コメント本文が入力されていません。");
808 return;
809 }
810
811 this.PostCommentButton.Enabled = false;
812 this.LivetubeComments.PostCommentAsync(this.CommentTextBox.Text, this.NameTextBox.Text);
813 }
814
815 private void CommentTextBox_KeyDown(object sender, KeyEventArgs e)
816 {
817 Console.WriteLine(e.KeyData);
818 if (e.KeyCode == Keys.Enter && e.Modifiers == Keys.Shift)
819 {
820 this.PostCommentButton.PerformClick();
821 }
822 }
823 #endregion
824
825 #region コメントリストのコンテキストメニュー
826 private void CopyCommentContextMenuItem_Click(object sender, EventArgs e)
827 {
828 this.CopyCommentMenuItem.PerformClick();
829 }
830
831 private void CopyCommentTextContextMenuItem_Click(object sender, EventArgs e)
832 {
833 this.CopyCommentTextMenuItem.PerformClick();
834 }
835
836 private void CopyCommentURLContextMenuItem_Click(object sender, EventArgs e)
837 {
838 this.CopyCommentURLMenuItem.PerformClick();
839 }
840
841 private void MarkCommentAsNGContextMenuItem_Click(object sender, EventArgs e)
842 {
843 this.MarkCommentAsNGMenuItem.PerformClick();
844 }
845
846 private void MarkCommentAsNotNGContextMenuItem_Click(object sender, EventArgs e)
847 {
848 this.MarkCommentAsNotNGMenuItem.PerformClick();
849 }
850
851 private void ShowHostContextMenuItem_Click(object sender, EventArgs e)
852 {
853 this.ShowHostMenuItem.PerformClick();
854 }
855
856 private void OpenLiveAuthorsPageContextMenuItem_Click(object sender, EventArgs e)
857 {
858 this.OpenLiveAuthorsPageMenuItem.PerformClick();
859 }
860
861 private void OpenLiveAuthorWikiContextMenuItem_Click(object sender, EventArgs e)
862 {
863 this.OpenLiveAuthorWikiMenuItem.PerformClick();
864 }
865
866 private void SelectAllContextMenuItem_Click(object sender, EventArgs e)
867 {
868 this.SelectAllMenuItem.PerformClick();
869 }
870
871 private void RefreshConnectionContextMenuItem_Click(object sender, EventArgs e)
872 {
873 this.RefreshConnectionMenuItem.PerformClick();
874 }
875 #endregion
876 #endregion
877
878 #region イベントのコールバック
879 //コメントのロード準備が完了
880 private void OnLoaded(bool result)
881 {
882 if (!result)
883 {
884 this.OpenLiveFromURLMenu.Enabled = true;
885 this.OpenLiveFromStreamIDMenuItem.Enabled = true;
886 this.OpenLiveFromLiveListMenuItem.Enabled = true;
887
888 MessageBox.Show("ロード中にエラーが発生したため配信を開けませんでした。", "エラー発生", MessageBoxButtons.OK, MessageBoxIcon.Error);
889 }
890 else
891 {
892 this.CloseLiveMenuItem.Enabled = true;
893 this.PlayLiveMenuItem.Enabled = true;
894 this.splitContainer1.Panel2.Enabled = true;
895 //this.CopyCommentMenuItem.Enabled = true;
896 //this.CopyCommentTextMenuItem.Enabled = true;
897 //this.CopyCommentURLMenuItem.Enabled = true;
898 this.FindMenuItem.Enabled = true;
899 this.FindNextMenuitem.Enabled = true;
900 this.FindPreviousMenuItem.Enabled = true;
901 //this.MarkCommentAsNGMenuItem.Enabled = true;
902 //this.MarkCommentAsNotNGMenuItem.Enabled = true;
903 //this.ShowHostMenuItem.Enabled = true;
904 //this.LiveAuthorMenuItem.Enabled = true;
905 this.SelectAllMenuItem.Enabled = true;
906 this.SelectAllContextMenuItem.Enabled = true;
907 this.RefreshConnectionMenuItem.Enabled = true;
908 this.RefreshConnectionContextMenuItem.Enabled = true;
909
910 if (GlobalValues.Setting.IsEnableReading)
911 {
912 this.TextReader.Start();
913 this.StartReadingMenuItem.Enabled = false;
914 this.StopReadingMenuItem.Enabled = true;
915 this.RestartReadingMenuItem.Enabled = false;
916 this.SuspendReadingMenuItem.Enabled = true;
917 }
918 }
919 }
920
921 //コメントの取得時
922 private void OnCaughtComment(IEnumerable<LivetubeCommentData> comments)
923 {
924 this.LivetubeCommentsList.BeginUpdate();
925 this.LivetubeCommentsList.ListViewItemSorter = null;
926
927 //リストへのコメントの反映
928 comments.ToObservable().Let(
929 xs =>
930 {
931 xs.Where(c => c.Name == "")//名無しコメント
932 .Select(d => new ListViewItem(new[]
933 {
934 new ListViewItem.ListViewSubItem { Text = d.Number.ToString() },
935 new ListViewItem.ListViewSubItem { Text = "" },
936 new ListViewItem.ListViewSubItem { Text = d.Text },
937 new ListViewItem.ListViewSubItem { Text = "" },
938 new ListViewItem.ListViewSubItem { Text = d.PostedDate.ToString("M/d H:mm:ss") },
939 new ListViewItem.ListViewSubItem { Text = d.ID, Font = new Font("メイリオ", 9F, FontStyle.Italic, GraphicsUnit.Point, 128) },
940 new ListViewItem.ListViewSubItem { Text = "" }
941 }, 0) { UseItemStyleForSubItems = false })
942 .Merge(
943 xs.Where(c => c.Name != "" && !c.ContributorCanBroadcasting)//黒コテ
944 .Select(d => new ListViewItem(new[]
945 {
946 new ListViewItem.ListViewSubItem { Text = d.Number.ToString() },
947 new ListViewItem.ListViewSubItem { Text = "" },
948 new ListViewItem.ListViewSubItem { Text = d.Text },
949 new ListViewItem.ListViewSubItem { Text = d.Name, Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128) },
950 new ListViewItem.ListViewSubItem { Text = d.PostedDate.ToString("M/d H:mm:ss") },
951 new ListViewItem.ListViewSubItem { Text = d.ID, Font = new Font("メイリオ", 9F, FontStyle.Italic, GraphicsUnit.Point, 128) },
952 new ListViewItem.ListViewSubItem { Text = "" }
953 }, 0) { UseItemStyleForSubItems = false })
954 .Merge(
955 xs.Where(c => c.Name != "" && c.ContributorCanBroadcasting)//緑コテ
956 .Select(d => new ListViewItem(new[]
957 {
958 new ListViewItem.ListViewSubItem { Text = d.Number.ToString() },
959 new ListViewItem.ListViewSubItem { Text = "" },
960 new ListViewItem.ListViewSubItem { Text = d.Text },
961 new ListViewItem.ListViewSubItem { Text = d.Name, Font = new Font("メイリオ", 9F, FontStyle.Bold, GraphicsUnit.Point, 128), ForeColor = Color.Green },
962 new ListViewItem.ListViewSubItem { Text = d.PostedDate.ToString("M/d H:mm:ss") },
963 new ListViewItem.ListViewSubItem { Text = d.ID, Font = new Font("メイリオ", 9F, FontStyle.Italic, GraphicsUnit.Point, 128) },
964 new ListViewItem.ListViewSubItem { Text = "" }
965 }, 0) { UseItemStyleForSubItems = false })
966 )
967 ).Subscribe(
968 //すべて追加
969 d => this.LivetubeCommentsList.Items.Add(d)
970 );
971 return xs;
972 }
973 );
974
975 this.LivetubeCommentsList.ListViewItemSorter = this.SortHelper;
976 this.LivetubeCommentsList.Sort();
977 this.LivetubeCommentsList.EndUpdate();
978
979 //自動スクロール
980 if (GlobalValues.Setting.IsEnableAutoScroll)
981 {
982 if (this.SortHelper.Order == SortOrder.Ascending)
983 {
984 this.LivetubeCommentsList.EnsureVisible(this.LivetubeCommentsList.Items.Count - 1);
985 }
986 else if (this.SortHelper.Order == SortOrder.Descending)
987 {
988 this.LivetubeCommentsList.EnsureVisible(0);
989 }
990 }
991
992 #warning TODO : フィルタリング
993
994 //朗読
995 if (GlobalValues.Setting.IsEnableReading)
996 {
997 this.TextReader.Read(comments);
998 }
999
1000 //コメントの部分表示
1001 if (!GlobalValues.Setting.IsShowAllComments)
1002 {
1003 while (this.LivetubeCommentsList.Items.Count > GlobalValues.Setting.ShowCommentCount)
1004 {
1005 if (this.SortHelper.Order == SortOrder.Ascending)
1006 {
1007 this.LivetubeCommentsList.Items.RemoveAt(0);
1008 }
1009 else
1010 {
1011 int lastOfIndex = this.LivetubeCommentsList.Items.Count - 1;
1012 this.LivetubeCommentsList.Items.RemoveAt(lastOfIndex);
1013 }
1014 }
1015 }
1016
1017
1018 }
1019
1020 //ステータステキスト変更時
1021 private void OnStatusTextChanged(string text)
1022 {
1023 this.SetProcessingText(text);
1024 }
1025
1026 //配信終了時
1027 private void OnLiveEnded()
1028 {
1029 DialogResult result = MessageBox.Show("配信の終了を検知しました。配信を閉じますか?", "配信終了検知", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
1030
1031 if (result == DialogResult.Yes)
1032 {
1033 this.CloseLiveMenuItem.PerformClick();
1034 }
1035 }
1036
1037 //配信情報更新時
1038 private void OnInformationRefreshed()
1039 {
1040 this.Text = String.Format("IronLivetube - {0} : {1}", this.LivetubeLiveInfo.LiveAuthor, this.LivetubeLiveInfo.LiveTitle);
1041 this.LiveStatusText.Text =
1042 String.Format("[視/見]{0}/{1} [流速(Livetube)]{2:f1}コメ/h [流速(したらば)]?コメ/h", this.LivetubeLiveInfo.Listeners, this.LivetubeLiveInfo.Visitors, this.LivetubeLiveInfo.CatchCommentsPerHour);
1043 }
1044
1045 private void OnPostCommentFinished(bool success, Exception errorReason)
1046 {
1047 if (!success)
1048 {
1049 this.SetPostCommentErrorText(errorReason.Message);
1050 }
1051 else
1052 {
1053 this.CommentTextBox.Text = "";
1054 }
1055
1056 this.PostCommentButton.Enabled = true;
1057 }
1058
1059 private void OnBanCommentFinished(int id, bool success, Exception error)
1060 {
1061 if (success)
1062 {
1063 //MessageBox.Show("コメント(ID : " + id + ")は荒らしコメントとしてマークされました。", "マーク成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
1064 this.LivetubeCommentsList.Items[id].SubItems.Cast<ListViewItem>()
1065 .ForEach(s => s.BackColor = Color.Gray);
1066
1067 this.SetProcessingText("コメント(ID : " + id + ")は荒らしコメントとしてマークされました。");
1068 }
1069 else
1070 {
1071 //MessageBox.Show("コメント(ID : " + id + ")のマークに失敗しました。", "マーク失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1072 this.SetProcessingText("コメント(ID : " + id + ")のマークに失敗しました。");
1073 }
1074 }
1075
1076 private void OnUnBanCommentFinished(int id, bool success, Exception error)
1077 {
1078 if (success)
1079 {
1080 //MessageBox.Show("コメント(ID : " + id + ")は荒らしコメントではないとしてマークを解除されました。", "マーク解除成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
1081 this.LivetubeCommentsList.Items[id].SubItems.Cast<ListViewItem>()
1082 .ForEach(s => s.BackColor = SystemColors.Window);
1083 this.SetProcessingText("コメント(ID : " + id + ")は荒らしコメントではないとしてマークを解除されました。");
1084 }
1085 else
1086 {
1087 //MessageBox.Show("コメント(ID : " + id + ")のマーク解除に失敗しました", "マーク失敗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1088 this.SetProcessingText("コメント(ID : " + id + ")のマーク解除に失敗しました");
1089 }
1090 }
1091
1092 private void OnBannedCommentsListFinished(IEnumerable<int> unBannedComment, IEnumerable<int> bannedComment)
1093 {
1094 unBannedComment.ForEach(i =>
1095 {
1096 if (this.LivetubeCommentsList.Items.Count > i)
1097 {
1098 this.LivetubeCommentsList.Items[i].SubItems.Cast<ListViewItem.ListViewSubItem>()
1099 .ForEach(s => s.BackColor = SystemColors.Window);
1100 }
1101 });
1102
1103 bannedComment.ForEach(i =>
1104 {
1105 if (this.LivetubeCommentsList.Items.Count > i)
1106 {
1107 this.LivetubeCommentsList.Items[i].SubItems.Cast<ListViewItem.ListViewSubItem>()
1108 .ForEach(s => s.BackColor = Color.Gray);
1109 }
1110 });
1111 }
1112
1113 private void OnGetHostFinished(int id, string host)
1114 {
1115 this.LivetubeCommentsList.Items
1116 .Cast<ListViewItem>()
1117 .Single(s => s.SubItems[0].Text == id.ToString())
1118 .Let(s => s.SubItems[6].Text = host);
1119 }
1120 #endregion
1121
1122 #region 見た目に関するイベント
1123 private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
1124 {
1125 this.splitContainer1.Panel2MinSize = this.splitContainer1.Panel2.ClientSize.Height;
1126 }
1127
1128 private void splitContainer1_SplitterMoving(object sender, SplitterCancelEventArgs e)
1129 {
1130 this.splitContainer1.Panel2MinSize = 0;
1131 }
1132
1133 private void LivetubeCommentsList_ColumnClick(object sender, ColumnClickEventArgs e)
1134 {
1135 if (!GlobalValues.Setting.IsLockSortOrder)
1136 {
1137 this.SortHelper.Column = e.Column;
1138 GlobalValues.Setting.CommentsSortOrder = this.SortHelper.Order;
1139
1140 this.LivetubeCommentsList.Sort();
1141 }
1142 }
1143
1144 private void LivetubeCommentsList_SelectedIndexChanged(object sender, EventArgs e)
1145 {
1146 if (this.LivetubeCommentsList.SelectedItems.Count > 0)
1147 {
1148 this.CopyCommentMenuItem.Enabled = true;
1149 this.CopyCommentContextMenuItem.Enabled = true;
1150 this.CopyCommentTextMenuItem.Enabled = true;
1151 this.CopyCommentTextContextMenuItem.Enabled = true;
1152 this.CopyCommentURLMenuItem.Enabled = true;
1153 this.CopyCommentURLContextMenuItem.Enabled = true;
1154 this.MarkCommentAsNGMenuItem.Enabled = true;
1155 this.MarkCommentAsNGContextMenuItem.Enabled = true;
1156 this.MarkCommentAsNotNGMenuItem.Enabled = true;
1157 this.MarkCommentAsNotNGContextMenuItem.Enabled = true;
1158 this.ShowHostMenuItem.Enabled = true;
1159 this.ShowHostContextMenuItem.Enabled = true;
1160
1161 var comment = this.LivetubeComments.CommentContainer.Single(
1162 s => s.Number.ToString() == this.LivetubeCommentsList.SelectedItems[0].SubItems[0].Text
1163 );
1164
1165 if (comment.ContributorCanBroadcasting)
1166 {
1167 this.LiveAuthorMenuItem.Enabled = true;
1168 this.LiveAuthorContextMenuItem.Enabled = true;
1169 }
1170 else
1171 {
1172 this.LiveAuthorMenuItem.Enabled = false;
1173 this.LiveAuthorContextMenuItem.Enabled = false;
1174 }
1175 }
1176 else
1177 {
1178 this.CopyCommentMenuItem.Enabled = false;
1179 this.CopyCommentContextMenuItem.Enabled = false;
1180 this.CopyCommentTextMenuItem.Enabled = false;
1181 this.CopyCommentTextContextMenuItem.Enabled = false;
1182 this.CopyCommentURLMenuItem.Enabled = false;
1183 this.CopyCommentURLContextMenuItem.Enabled = false;
1184 this.MarkCommentAsNGMenuItem.Enabled = false;
1185 this.MarkCommentAsNGContextMenuItem.Enabled = false;
1186 this.MarkCommentAsNotNGMenuItem.Enabled = false;
1187 this.MarkCommentAsNotNGContextMenuItem.Enabled = false;
1188 this.ShowHostMenuItem.Enabled = false;
1189 this.ShowHostContextMenuItem.Enabled = false;
1190 }
1191 }
1192 #endregion
1193
1194 public void SetProcessingText(string text)
1195 {
1196 this.ProcessingText.Text = text;
1197
1198 Observable.Return(text)
1199 .Delay(TimeSpan.FromSeconds(3))
1200 .ObserveOnDispatcher()
1201 .Subscribe(
1202 s =>
1203 {
1204 if (this.ProcessingText.Text == s)
1205 {
1206 this.ProcessingText.Text = "";
1207 }
1208 }
1209 );
1210 }
1211
1212 public void SetPostCommentErrorText(string errorText)
1213 {
1214 this.PostCommentErrorLabel.Visible = true;
1215 this.PostCommentErrorLabel.Text = " " + errorText;
1216
1217 Observable.Return(errorText)
1218 .Delay(TimeSpan.FromSeconds(5))
1219 .ObserveOnDispatcher()
1220 .Subscribe(
1221 s =>
1222 {
1223 if (this.PostCommentErrorLabel.Text == s)
1224 {
1225 this.PostCommentErrorLabel.Visible = false;
1226 }
1227 }
1228 );
1229 }
1230 }
1231 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26