Develop and Download Open Source Software

Browse Subversion Repository

Contents of /SettingsWindow.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations) (download)
Mon Mar 28 01:33:42 2011 UTC (13 years, 1 month ago) by aqua877
File size: 25331 byte(s)
・URL短縮機能の追加(bit.ly j.mp is.gd ux.nu p.tl)
・コメントを朗読する際に、同じコメントが読まれたり、読まれる順序が不順だったのを修正
・バグ修正等
1 using System;
2 using System.Linq;
3 using System.Text.RegularExpressions;
4 using System.Windows.Forms;
5
6 namespace Aqua877.WinApp.IronLivetube
7 {
8 public partial class SettingsWindow : Form
9 {
10 private LivetubeCommentReader LivetubeData;
11
12 public SettingsWindow(LivetubeCommentReader data)
13 {
14 this.LivetubeData = data;
15
16 this.InitializeComponent();
17
18 #region 基本タブの内容の初期化
19 if (GlobalValues.Setting.LivetubeUserID != "" && GlobalValues.Setting.LivetubePassword != "")
20 {
21 this.LivetubeUserIDTextBox.ReadOnly = true;
22 this.LivetubeUserIDTextBox.Text = GlobalValues.Setting.LivetubeUserID;
23 this.LivetubePasswordTextBox.ReadOnly = true;
24 this.LivetubePasswordTextBox.Text = GlobalValues.Setting.LivetubePassword;
25
26 this.LivetubeIsLoggedLabel.Text = "認証済み";
27 this.LivetubeLoginButton.Enabled = false;
28 }
29 else
30 {
31 this.LivetubeIsLoggedLabel.Text = "未認証";
32 this.LivetubeLogoffButton.Enabled = false;
33 }
34
35 if (GlobalValues.Setting.IsPlayNotifySound)
36 {
37 this.IsPlayNotifySoundCheckBox.Checked = GlobalValues.Setting.IsPlayNotifySound;
38 this.SoundFilePathTextBox.Text = GlobalValues.Setting.NotifySoundPath;
39 this.ReferSoundFilePathButton.Enabled = true;
40 }
41 else
42 {
43 this.ReferSoundFilePathButton.Enabled = false;
44 }
45
46 this.ShowCommentAnchorCheckBox.Checked = GlobalValues.Setting.IsShowCommentAnchor;
47
48 if (GlobalValues.Setting.IsShowAllComments)
49 {
50 this.ShowAllCommentsCheckBox.Checked = GlobalValues.Setting.IsShowAllComments;
51 this.ShowCommentCountTextBox.Enabled = false;
52 }
53 else
54 {
55 this.ShowCommentCountTextBox.Value = GlobalValues.Setting.ShowCommentCount;
56 }
57
58 if (GlobalValues.Setting.IsSelectServer)
59 {
60 this.SelectServerCheckBox.Checked = GlobalValues.Setting.IsSelectServer;
61
62 switch (GlobalValues.Setting.SelectedServer)
63 {
64 case LivetubeServers.Default:
65 {
66 this.ServerListComboBox.Text = "livetube.cc";
67 break;
68 }
69
70 case LivetubeServers.H:
71 {
72 this.ServerListComboBox.Text = "h.livetube.cc";
73 break;
74 }
75
76 case LivetubeServers.Large03:
77 {
78 this.ServerListComboBox.Text = "large03.livetube.cc";
79 break;
80 }
81
82 case LivetubeServers.Large04:
83 {
84 this.ServerListComboBox.Text = "large04.livetube.cc";
85 break;
86 }
87
88 case LivetubeServers.Large05:
89 {
90 this.ServerListComboBox.Text = "large05.livetube.cc";
91 break;
92 }
93
94 case LivetubeServers.Tes01:
95 {
96 this.ServerListComboBox.Text = "tes01.livetube.cc";
97 break;
98 }
99 }
100 }
101 else
102 {
103 this.ServerListComboBox.Enabled = false;
104 }
105
106 this.IsUseShortenURLSiteCheckBox.Checked = GlobalValues.Setting.IsUseShortenURLSite;
107 #endregion
108
109 #region 表示タブの内容の初期化
110 this.IsShowWindowMostTopCheckBox.Checked = GlobalValues.Setting.IsShowWindowMostTop;
111
112 this.IsEnableSemitransparentModeCheckBox.Checked = GlobalValues.Setting.IsEnableSemitransparentMode;
113
114 this.IsEnablePutWindowIntoTaskTrayCheckBox.Checked = GlobalValues.Setting.IsEnablePutWindowIntoTaskTrayCheckBox;
115
116 this.IsLockSortOrderCheckBox.Checked = GlobalValues.Setting.IsLockSortOrder;
117
118 this.SortOrderTextBox.Text =
119 (GlobalValues.Setting.CommentsSortOrder == SortOrder.Ascending) ? "昇順" : "降順";
120
121 this.IsShowGridLineCheckBox.Checked = GlobalValues.Setting.IsShowGridLines;
122
123 this.IsEnableAutoScrollCheckBox.Checked = GlobalValues.Setting.IsEnableAutoScroll;
124 #endregion
125
126 #region コマンドタブの内容の初期化
127 if (GlobalValues.Setting.IsEnableCommand)
128 {
129 this.CommandsGroupBox.Enabled = true;
130 this.IsEnableCommandsCheckBox.Checked = true;
131 }
132 else
133 {
134 this.CommandsGroupBox.Enabled = false;
135 this.IsEnableCommandsCheckBox.Checked = false;
136 }
137
138 #endregion
139
140 #region 朗読設定タブの内容の初期化
141 if (GlobalValues.Setting.IsEnableReading)
142 {
143 this.IsEnableReadingCheckBox.Checked = true;
144 }
145 else
146 {
147 this.IsEnableReadingCheckBox.Checked = false;
148 this.groupBox4.Enabled = false;
149 }
150
151 this.SoftalkPathTextBox.Text = GlobalValues.Setting.SoftalkPath;
152
153 this.ReadingTemplateTextBox.Text = GlobalValues.Setting.ReadingTemplate;
154
155 this.ReplacementWordsListView.Items.AddRange(
156 GlobalValues.Setting.ReplacementWords.Select(
157 r => new ListViewItem(new string[]
158 {
159 r.Before,
160 r.After,
161 r.AddedByUser ? "ユーザー" : "コメント",
162 r.ReplacementTarget == MatchTarget.All ? "全体" : r.ReplacementTarget == MatchTarget.ToText ? "コメント本文" : "本文以外",
163 r.IsUseRegex ? "使用" : "不使用"
164 }
165 )
166 ).ToArray()
167 );
168
169 this.IsReadCommentAtFirstCheckBox.Checked = GlobalValues.Setting.IsReadCommentAtFirst;
170 this.IsEnableAdjustReadSpeedCheckBox.Checked = GlobalValues.Setting.IsEnableAdjustReadSpeed;
171 #endregion
172
173 #region 効果音設定タブの内容の初期化
174 if (GlobalValues.Setting.IsEnableSoundEffect)
175 {
176 this.IsPlaySoundEffectCheckBox.Checked = true;
177 }
178 else
179 {
180 this.IsPlaySoundEffectCheckBox.Checked = false;
181 this.groupBox6.Enabled = false;
182 }
183
184 this.SoundEffectRulesListView.Items.AddRange(
185 GlobalValues.Setting.SoundEffectRules.Select(
186 r => new ListViewItem(new string[]
187 {
188 r.PlaySoundEffectCondition,
189 r.SoundFilePath,
190 r.ExactMatch ? "完全一致" : "部分一致"
191 }
192 )
193 ).ToArray()
194 );
195
196 #endregion
197
198 #region NGワードタブの内容の初期化
199 if (GlobalValues.Setting.IsEnableFiltering)
200 {
201 this.IsEnableFilteringCheckBox.Checked = true;
202 }
203 else
204 {
205 this.IsEnableFilteringCheckBox.Checked = false;
206 this.groupBox5.Enabled = false;
207 }
208
209 this.FilteringRulesListView.Items.AddRange(
210 GlobalValues.Setting.FilteringRules.Select(
211 r => new ListViewItem(new string[]
212 {
213 r.Rule,
214 r.IsEnableAutoBan ? "有効" : "無効",
215 r.IsEnableAutoUnBan ? "有効" : "無効",
216 r.IsEnableAutoUnBan ? r.UnBanDelayCount.ToString() : "(なし)",
217 r.AddedByUser ? "ユーザー" : "コメント",
218 r.FilteringTarget == MatchTarget.All ? "全体" : r.FilteringTarget == MatchTarget.ToText ? "コメント本文" : "本文以外",
219 r.IsUseRegularExpression ? "使用" : "不使用"
220 }
221 )
222 ).ToArray()
223 );
224
225 this.IsExceptMatchedCommentCheckBox.Checked = GlobalValues.Setting.IsExceptMatchedComment;
226 #endregion
227 }
228
229 #region 基本タブのイベント
230 private void LivetubeLoginButton_Click(object sender, EventArgs e)
231 {
232 if (this.LivetubeUserIDTextBox.Text == "")
233 {
234 this.LivetubeCredentialErrorLabel.Visible = true;
235 this.LivetubeCredentialErrorLabel.Text = " ユーザーIDが入力されていません";
236 return;
237 }
238
239 if (this.LivetubePasswordTextBox.Text == "")
240 {
241 this.LivetubeCredentialErrorLabel.Visible = true;
242 this.LivetubeCredentialErrorLabel.Text = " パスワードが入力されていません";
243 return;
244 }
245
246 Action<bool, Exception> finishedLoginCallBack = null;
247 finishedLoginCallBack = (success, error) =>
248 {
249 if (!success)
250 {
251 this.LivetubeCredentialErrorLabel.Visible = true;
252 this.LivetubeCredentialErrorLabel.Text = " " + error.Message;
253 }
254 else
255 {
256 this.LivetubeUserIDTextBox.ReadOnly = true;
257 GlobalValues.Setting.LivetubeUserID = this.LivetubeUserIDTextBox.Text;
258 this.LivetubePasswordTextBox.ReadOnly = true;
259 GlobalValues.Setting.LivetubePassword = this.LivetubePasswordTextBox.Text;
260 this.LivetubeIsLoggedLabel.Text = "認証済み";
261 this.LivetubeLoginButton.Enabled = false;
262 this.LivetubeLogoffButton.Enabled = true;
263
264 this.LivetubeCredentialErrorLabel.Visible = false;
265 }
266 this.LivetubeData.OnLoginFinished -= finishedLoginCallBack;
267 };
268
269 this.LivetubeData.OnLoginFinished += finishedLoginCallBack;
270 this.LivetubeData.LoginAsync(this.LivetubeUserIDTextBox.Text, this.LivetubePasswordTextBox.Text);
271 }
272
273 private void LivetubeLogoffButton_Click(object sender, EventArgs e)
274 {
275 this.LivetubeUserIDTextBox.ReadOnly = false;
276 this.LivetubeUserIDTextBox.Text = "";
277 this.LivetubePasswordTextBox.ReadOnly = false;
278 this.LivetubePasswordTextBox.Text = "";
279 this.LivetubeIsLoggedLabel.Text = "未認証";
280 this.LivetubeLoginButton.Enabled = true;
281 this.LivetubeLogoffButton.Enabled = false;
282
283 this.LivetubeData.Logout();
284 }
285
286 private void IsPlayNotifySoundCheckBox_CheckedChanged(object sender, EventArgs e)
287 {
288 GlobalValues.Setting.IsPlayNotifySound = this.IsPlayNotifySoundCheckBox.Checked;
289
290 if (this.IsPlayNotifySoundCheckBox.Checked)
291 {
292 this.ReferSoundFilePathButton.Enabled = true;
293 }
294 else
295 {
296 this.ReferSoundFilePathButton.Enabled = false;
297 }
298 }
299
300 private void ReferSoundFilePathButton_Click(object sender, EventArgs e)
301 {
302 var result = this.ReferNotifySoundFilePathDialog.ShowDialog();
303
304 if (result == DialogResult.OK)
305 {
306 GlobalValues.Setting.NotifySoundPath = this.ReferNotifySoundFilePathDialog.FileName;
307 this.SoundFilePathTextBox.Text = this.ReferNotifySoundFilePathDialog.FileName;
308 }
309 else
310 {
311 GlobalValues.Setting.NotifySoundPath = "";
312 this.SoundFilePathTextBox.Text = "";
313 }
314 }
315
316 private void ShowCommentAnchorCheckBox_CheckedChanged(object sender, EventArgs e)
317 {
318 GlobalValues.Setting.IsShowCommentAnchor = this.ShowCommentAnchorCheckBox.Checked;
319 }
320
321 private void ShowAllCommentsCheckBox_CheckedChanged(object sender, EventArgs e)
322 {
323 GlobalValues.Setting.IsShowAllComments = this.ShowAllCommentsCheckBox.Checked;
324
325 if (this.ShowAllCommentsCheckBox.Checked)
326 {
327 this.ShowCommentCountTextBox.Enabled = false;
328 }
329 else
330 {
331 this.ShowCommentCountTextBox.Enabled = true;
332 }
333 }
334
335 private void ShowCommentCountTextBox_ValueChanged(object sender, EventArgs e)
336 {
337 GlobalValues.Setting.ShowCommentCount = (int)this.ShowCommentCountTextBox.Value;
338 }
339
340 private void SelectServerCheckBox_CheckedChanged(object sender, EventArgs e)
341 {
342 GlobalValues.Setting.IsSelectServer = this.SelectServerCheckBox.Checked;
343
344 if (this.SelectServerCheckBox.Checked)
345 {
346 this.ServerListComboBox.Enabled = true;
347 }
348 else
349 {
350 this.ServerListComboBox.Enabled = false;
351 }
352 }
353
354 private void ServerListComboBox_SelectedIndexChanged(object sender, EventArgs e)
355 {
356 switch (this.ServerListComboBox.Text)
357 {
358 case "livetube.cc":
359 {
360 GlobalValues.Setting.SelectedServer = LivetubeServers.Default;
361 break;
362 }
363
364 case "h.livetube.cc":
365 {
366 GlobalValues.Setting.SelectedServer = LivetubeServers.H;
367 break;
368 }
369
370 case "tes01.livetube.cc":
371 {
372 GlobalValues.Setting.SelectedServer = LivetubeServers.Tes01;
373 break;
374 }
375
376 case "large03.livetube.cc":
377 {
378 GlobalValues.Setting.SelectedServer = LivetubeServers.Large03;
379 break;
380 }
381
382 case "large04.livetube.cc":
383 {
384 GlobalValues.Setting.SelectedServer = LivetubeServers.Large04;
385 break;
386 }
387
388 case "large05.livetube.cc":
389 {
390 GlobalValues.Setting.SelectedServer = LivetubeServers.Large05;
391 break;
392 }
393 }
394 }
395
396 private void IsEnableAutoBanContinuousCommentsCheckBox_CheckedChanged(object sender, EventArgs e)
397 {
398 GlobalValues.Setting.IsEnableAutoBanContinuousComments = this.IsEnableAutoBanContinuousCommentsCheckBox.Checked;
399 }
400 #endregion
401
402 #region 表示タブのイベント
403 private void IsShowWindowMostTopCheckBox_CheckedChanged(object sender, EventArgs e)
404 {
405 GlobalValues.Setting.IsShowWindowMostTop = this.IsShowWindowMostTopCheckBox.Checked;
406 }
407
408 private void IsEnableSemitransparentModeCheckBox_CheckedChanged(object sender, EventArgs e)
409 {
410 GlobalValues.Setting.IsEnableSemitransparentMode = this.IsEnableSemitransparentModeCheckBox.Checked;
411 }
412
413 private void IsEnablePutWindowIntoTaskTrayCheckBox_CheckedChanged(object sender, EventArgs e)
414 {
415 GlobalValues.Setting.IsEnablePutWindowIntoTaskTrayCheckBox = this.IsEnablePutWindowIntoTaskTrayCheckBox.Checked;
416 }
417
418 private void IsLockSortOrderCheckBox_CheckedChanged(object sender, EventArgs e)
419 {
420 GlobalValues.Setting.IsLockSortOrder = this.IsLockSortOrderCheckBox.Checked;
421 }
422
423 private void SortOrderTextBox_SelectedIndexChanged(object sender, EventArgs e)
424 {
425 if (this.SortOrderTextBox.Text == "昇順")
426 {
427 GlobalValues.Setting.CommentsSortOrder = SortOrder.Ascending;
428 }
429 else if(this.SortOrderTextBox.Text == "降順")
430 {
431 GlobalValues.Setting.CommentsSortOrder = SortOrder.Descending;
432 }
433 }
434
435 private void IsShowGridLineCheckBox_CheckedChanged(object sender, EventArgs e)
436 {
437 GlobalValues.Setting.IsShowGridLines = this.IsShowGridLineCheckBox.Checked;
438 }
439
440 private void IsEnableAutoScroll_CheckedChanged(object sender, EventArgs e)
441 {
442 GlobalValues.Setting.IsEnableAutoScroll = this.IsEnableAutoScrollCheckBox.Checked;
443 }
444 #endregion
445
446 #region コマンドタブのイベント
447 private void IsEnableCommandsCheckBox_CheckedChanged(object sender, EventArgs e)
448 {
449 GlobalValues.Setting.IsEnableCommand = this.IsEnableCommandsCheckBox.Checked;
450
451 if (this.IsEnableCommandsCheckBox.Checked)
452 {
453 this.CommandsGroupBox.Enabled = true;
454 }
455 else
456 {
457 this.CommandsGroupBox.Enabled = false;
458 }
459 }
460
461 private void IsUseReplaceCommandCheckBox_CheckedChanged(object sender, EventArgs e)
462 {
463 GlobalValues.Setting.IsUseReplaceCommand = this.IsUseReplaceCommandCheckBox.Checked;
464 }
465
466 private void IsUseUnreplaceCommandCheckBox_CheckedChanged(object sender, EventArgs e)
467 {
468 GlobalValues.Setting.IsUseUnreplaceCommand = this.IsUseUnreplaceCommandCheckBox.Checked;
469 }
470
471 private void ShowReplaceCommandOptionButton_Click(object sender, EventArgs e)
472 {
473 using (var repWindow = new global::Aqua877.WinApp.IronLivetube.CommandOptionWindows.ReplaceCommandOptionWindow())
474 {
475 repWindow.ShowDialog();
476 }
477 }
478
479 private void IsUseVoteBanCommandCheckBox_CheckedChanged(object sender, EventArgs e)
480 {
481 GlobalValues.Setting.IsUseVoteBanCommand = this.IsUseVoteBanCommandCheckBox.Checked;
482 }
483
484 private void IsUseVoteUnBanCommandCheckBox_CheckedChanged(object sender, EventArgs e)
485 {
486 GlobalValues.Setting.IsUseVoteUnBanCommand = this.IsUseVoteUnBanCommandCheckBox.Checked;
487 }
488
489 private void ShowVoteBanCommandOptionButton_Click(object sender, EventArgs e)
490 {
491 using (var voteBanWindow = new global::Aqua877.WinApp.IronLivetube.CommandOptionWindows.VoteBanCommandOptionWindow())
492 {
493 voteBanWindow.ShowDialog();
494 }
495 }
496
497 private void IsUseCancelPlayingSoundCheckBox_CheckedChanged(object sender, EventArgs e)
498 {
499 GlobalValues.Setting.IsUseCancelPlayingSoundCommand = this.IsUseCancelPlayingSoundCheckBox.Checked;
500 }
501
502 private void IsUseAddFilteringRuleCommandCheckBox_CheckedChanged(object sender, EventArgs e)
503 {
504 GlobalValues.Setting.IsUseAddFilteringRuleCommand = this.IsUseAddFilteringRuleCommandCheckBox.Checked;
505 }
506
507 private void IsUseDeleteFilteringRuleCommandCheckBox_CheckedChanged(object sender, EventArgs e)
508 {
509 GlobalValues.Setting.IsUseRemoveFilteringRuleCommand = this.IsUseDeleteFilteringRuleCommandCheckBox.Checked;
510 }
511 #endregion
512
513
514 #region 朗読設定タブのイベント
515 private void IsEnableReadingCheckBox_CheckedChanged(object sender, EventArgs e)
516 {
517 if (this.IsEnableReadingCheckBox.Checked)
518 {
519 GlobalValues.Setting.IsEnableReading = true;
520 this.groupBox4.Enabled = true;
521 }
522 else
523 {
524 GlobalValues.Setting.IsEnableReading = false;
525 this.groupBox4.Enabled = false;
526 }
527 }
528
529 private void ReferSoftalkPathButton_Click(object sender, EventArgs e)
530 {
531 var result = this.ReferSoftalkPathDialog.ShowDialog();
532
533 if (result == DialogResult.OK)
534 {
535 GlobalValues.Setting.SoftalkPath = this.ReferSoftalkPathDialog.FileName;
536 this.SoftalkPathTextBox.Text = this.ReferSoftalkPathDialog.FileName;
537 }
538 else
539 {
540 GlobalValues.Setting.SoftalkPath = "";
541 this.SoftalkPathTextBox.Text = "";
542 }
543 }
544
545 private void SetReadingTemplateButton_Click(object sender, EventArgs e)
546 {
547 GlobalValues.Setting.ReadingTemplate = this.ReadingTemplateTextBox.Text;
548 }
549
550 private void AddReplacementWordButton_Click(object sender, EventArgs e)
551 {
552 if (this.AddReplacementBeforeWordTextBox.Text.Trim() == "" || this.AddReplacementAfterWordTextBox.Text.Trim() == "")
553 {
554 this.EditingReplacementErrorLabel.Visible = true;
555 this.EditingReplacementErrorLabel.Text = " 読み替え前文字列と読み替え後文字列を入力してください。";
556 return;
557 }
558
559 if (this.IsUseRegularExpressionToAddReplacementWordCheckBox.Checked)
560 {
561 try
562 {
563 new Regex(this.AddReplacementBeforeWordTextBox.Text);
564 new Regex(this.AddReplacementAfterWordTextBox.Text);
565 }
566 catch
567 {
568 this.EditingReplacementErrorLabel.Visible = true;
569 this.EditingReplacementErrorLabel.Text = " 入力された正規表現パターンが正しくありません。";
570 }
571 }
572
573 GlobalValues.Setting.ReplacementWords.Add(
574 new Replacement
575 {
576 Before = this.AddReplacementBeforeWordTextBox.Text,
577 After = this.AddReplacementAfterWordTextBox.Text,
578 AddedByUser = true,
579 ReplacementTarget = (this.ReplacementMatchToAllRadioButton.Checked ? MatchTarget.All : this.ReplacementMatchToTextRadioButton.Checked ? MatchTarget.ToText : MatchTarget.ExceptText),
580 IsUseRegex = this.IsUseRegularExpressionToAddReplacementWordCheckBox.Checked,
581 IsApplyToListView = this.IsApplyToListViewCheckBox.Checked
582 }
583 );
584
585 this.ReplacementWordsListView.Items.Add(
586 new ListViewItem(
587 new string[]
588 {
589 this.AddReplacementBeforeWordTextBox.Text,
590 this.AddReplacementAfterWordTextBox.Text,
591 "ユーザー",
592 (this.ReplacementMatchToAllRadioButton.Checked ? "全体" : this.ReplacementMatchToTextRadioButton.Checked ? "コメント本文" : "本文以外"),
593 (this.IsUseRegularExpressionToAddReplacementWordCheckBox.Checked ? "使用" : "不使用"),
594 (this.IsApplyToListViewCheckBox.Checked.ToString())
595 }
596 )
597 );
598 }
599
600 private void RemoveReplacementWordButton_Click(object sender, EventArgs e)
601 {
602 if (this.ReplacementWordsListView.SelectedItems.Count > 0)
603 {
604 int removeIndex = this.ReplacementWordsListView.SelectedItems[0].Index;
605 GlobalValues.Setting.ReplacementWords.RemoveAt(removeIndex);
606 this.ReplacementWordsListView.Items.RemoveAt(removeIndex);
607 }
608 }
609
610 private void IsReadCommentAtFirstCheckBox_CheckedChanged(object sender, EventArgs e)
611 {
612 GlobalValues.Setting.IsReadCommentAtFirst = this.IsReadCommentAtFirstCheckBox.Checked;
613 }
614
615 private void IsEnableAdjustReadSpeedCheckBox_CheckedChanged(object sender, EventArgs e)
616 {
617 GlobalValues.Setting.IsEnableAdjustReadSpeed = this.IsEnableAdjustReadSpeedCheckBox.Checked;
618 }
619 #endregion
620
621 #region 効果音設定タブのイベント
622 private void IsPlaySoundEffectCheckBox_CheckedChanged(object sender, EventArgs e)
623 {
624 if (this.IsPlaySoundEffectCheckBox.Checked)
625 {
626 GlobalValues.Setting.IsEnableSoundEffect = true;
627 this.groupBox6.Enabled = true;
628 }
629 else
630 {
631 //表のソート対応時には改善が必要
632 GlobalValues.Setting.IsEnableSoundEffect = false;
633 this.groupBox6.Enabled = false;
634 }
635 }
636
637 private void ReferSoundEffectPathButton_Click(object sender, EventArgs e)
638 {
639 var result = this.ReferSoundEffectPathDialog.ShowDialog();
640
641 if (result == DialogResult.OK)
642 {
643 this.SoundEffectPathTextBox.Text = this.ReferSoundEffectPathDialog.FileName;
644 }
645 else
646 {
647 this.SoundEffectPathTextBox.Text = "";
648 }
649 }
650
651 private void AddSoundEffectRuleButton_Click(object sender, EventArgs e)
652 {
653 if (this.SoundEffectPathTextBox.Text.Trim() == "" || this.PlaySoundEffectConditionTextBox.Text.Trim() == "")
654 {
655 this.EditingReplacementErrorLabel.Visible = true;
656 this.EditingReplacementErrorLabel.Text = " 効果音の場所と効果音の再生条件を入力してください。";
657 return;
658 }
659
660 if (this.IsUseRegularExpressionToAddReplacementWordCheckBox.Checked)
661 {
662 try
663 {
664 new Regex(this.PlaySoundEffectConditionTextBox.Text);
665 }
666 catch
667 {
668 this.EditingSoundEffectSettingErrorLabel.Visible = true;
669 this.EditingSoundEffectSettingErrorLabel.Text = " 入力された正規表現パターンが正しくありません。";
670 }
671 }
672
673 GlobalValues.Setting.SoundEffectRules.Add(
674 new SoundEffectRule
675 {
676 SoundFilePath = this.SoundEffectPathTextBox.Text,
677 PlaySoundEffectCondition = this.PlaySoundEffectConditionTextBox.Text,
678 ExactMatch = this.PartialMatchRadioButton.Checked,
679 IsUseRegularExpression = this.IsUseRegularExpressionToPlaySoundEffectCheckBox.Checked
680 }
681 );
682
683 this.ReplacementWordsListView.Items.Add(
684 new ListViewItem(
685 new string[]
686 {
687 this.AddReplacementBeforeWordTextBox.Text,
688 this.AddReplacementAfterWordTextBox.Text,
689 "ユーザー",
690 (this.ReplacementMatchToAllRadioButton.Checked ? "全体" : this.ReplacementMatchToTextRadioButton.Checked ? "コメント本文" : "本文以外"),
691 (this.IsUseRegularExpressionToAddReplacementWordCheckBox.Checked ? "使用" : "不使用")
692 }
693 )
694 );
695 }
696
697 private void RemoveSoundEffectRuleButton_Click(object sender, EventArgs e)
698 {
699 if (this.SoundEffectRulesListView.SelectedItems.Count > 0)
700 {
701 int removeIndex = this.SoundEffectRulesListView.SelectedItems[0].Index;
702 GlobalValues.Setting.SoundEffectRules.RemoveAt(removeIndex);
703 this.SoundEffectRulesListView.Items.RemoveAt(removeIndex);
704 }
705
706 }
707 #endregion
708
709 #region NGワードタブのイベント
710 private void IsEnableFilteringCheckBox_CheckedChanged(object sender, EventArgs e)
711 {
712 if (this.IsEnableFilteringCheckBox.Checked)
713 {
714 GlobalValues.Setting.IsEnableFiltering = true;
715 this.groupBox5.Enabled = true;
716 }
717 else
718 {
719 GlobalValues.Setting.IsEnableFiltering = false;
720 this.groupBox5.Enabled = false;
721 }
722 }
723
724 private void AddFilteringRuleButton_Click(object sender, EventArgs e)
725 {
726 if (this.AddFilteringRuleTextBox.Text.Trim() == "")
727 {
728 this.EditingFilteringRuleErrorLabel.Visible = true;
729 this.EditingFilteringRuleErrorLabel.Text = " NGワードとなる文字列を入力してください。";
730 return;
731 }
732
733 if (this.IsUseRegularExpressionToAddFilteringRuleCheckBox.Checked)
734 {
735 try
736 {
737 new Regex(this.AddFilteringRuleTextBox.Text);
738 }
739 catch
740 {
741 this.EditingFilteringRuleErrorLabel.Visible = true;
742 this.EditingFilteringRuleErrorLabel.Text = " 入力された正規表現パターンが正しくありません。";
743 }
744 }
745
746 GlobalValues.Setting.FilteringRules.Add(
747 new FilteringRule()
748 {
749 Rule = this.EditingFilteringRuleErrorLabel.Text,
750 IsUseRegularExpression = this.IsUseRegularExpressionToAddFilteringRuleCheckBox.Checked,
751 IsEnableAutoBan = this.IsEnableBanAsMatchedCheckBox.Checked,
752 IsEnableAutoUnBan = this.IsEnableAutoUnBanCheckBox.Checked,
753 UnBanDelayCount = (int)this.DelayUnbanSecondTextBox.Value,
754 FilteringTarget = (this.FilteringMatchToAllRadioButton.Checked ? MatchTarget.All : this.FilteringMatchToTextRadioButton.Checked ? MatchTarget.ToText : MatchTarget.ExceptText)
755 }
756 );
757
758 this.FilteringRulesListView.Items.Add(
759 new ListViewItem(
760 new string[]
761 {
762 this.EditingFilteringRuleErrorLabel.Text,
763 this.IsEnableBanAsMatchedCheckBox.Checked ? "有効" : "無効",
764 this.IsEnableAutoUnBanCheckBox.Checked ? "有効" : "無効",
765 this.IsEnableAutoUnBanCheckBox.Checked ? this.DelayUnbanSecondTextBox.Value.ToString() : "(なし)",
766 "ユーザー",
767 (this.FilteringMatchToAllRadioButton.Checked ? "全体" : this.FilteringMatchToTextRadioButton.Checked ? "コメント本文" : "本文以外"),
768 this.IsUseRegularExpressionToPlaySoundEffectCheckBox.Checked ? "使用" : "不使用"
769 }
770 )
771 );
772 }
773
774 private void RemoveFilteringRuleButton_Click(object sender, EventArgs e)
775 {
776 if (this.FilteringRulesListView.SelectedItems.Count > 0)
777 {
778 int removeIndex = this.FilteringRulesListView.SelectedItems[0].Index;
779 GlobalValues.Setting.FilteringRules.RemoveAt(removeIndex);
780 this.FilteringRulesListView.Items.RemoveAt(removeIndex);
781 }
782 }
783
784 private void IsExceptMatchedCommentCheckBox_CheckedChanged(object sender, EventArgs e)
785 {
786 GlobalValues.Setting.IsExceptMatchedComment = this.IsExceptMatchedCommentCheckBox.Checked;
787 }
788 #endregion
789
790
791
792
793 }
794 }

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