1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 // (c) 2008-2011 Moz (@syo68k)
4 // (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 // (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 // (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 // (c) 2014 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
8 // All rights reserved.
10 // This file is part of OpenTween.
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
30 using System.Collections.Generic;
31 using System.ComponentModel;
36 using System.Windows.Forms;
38 namespace OpenTween.Setting.Panel
40 public partial class GetPeriodPanel : SettingPanelBase
42 public event EventHandler<IntervalChangedEventArgs> IntervalChanged;
44 public GetPeriodPanel()
45 => this.InitializeComponent();
47 public void LoadConfig(SettingCommon settingCommon)
49 this.StartupUserstreamCheck.Checked = settingCommon.UserstreamStartup;
50 this.CheckPostAndGet.Checked = settingCommon.PostAndGet;
51 this.UserstreamPeriod.Text = settingCommon.UserstreamPeriod.ToString();
52 this.TimelinePeriod.Text = settingCommon.TimelinePeriod.ToString();
53 this.ReplyPeriod.Text = settingCommon.ReplyPeriod.ToString();
54 this.DMPeriod.Text = settingCommon.DMPeriod.ToString();
55 this.PubSearchPeriod.Text = settingCommon.PubSearchPeriod.ToString();
56 this.ListsPeriod.Text = settingCommon.ListsPeriod.ToString();
57 this.UserTimelinePeriod.Text = settingCommon.UserTimelinePeriod.ToString();
60 public void SaveConfig(SettingCommon settingCommon)
62 settingCommon.UserstreamStartup = this.StartupUserstreamCheck.Checked;
63 settingCommon.PostAndGet = this.CheckPostAndGet.Checked;
65 var arg = new IntervalChangedEventArgs();
66 var isIntervalChanged = false;
68 var userstreamPeriod = int.Parse(this.UserstreamPeriod.Text);
69 if (settingCommon.UserstreamPeriod != userstreamPeriod)
71 settingCommon.UserstreamPeriod = userstreamPeriod;
72 arg.UserStream = true;
73 isIntervalChanged = true;
76 var timelinePeriod = int.Parse(this.TimelinePeriod.Text);
77 if (settingCommon.TimelinePeriod != timelinePeriod)
79 settingCommon.TimelinePeriod = timelinePeriod;
81 isIntervalChanged = true;
84 var dmPeriod = int.Parse(this.DMPeriod.Text);
85 if (settingCommon.DMPeriod != dmPeriod)
87 settingCommon.DMPeriod = dmPeriod;
88 arg.DirectMessage = true;
89 isIntervalChanged = true;
92 var pubSearchPeriod = int.Parse(this.PubSearchPeriod.Text);
93 if (settingCommon.PubSearchPeriod != pubSearchPeriod)
95 settingCommon.PubSearchPeriod = pubSearchPeriod;
96 arg.PublicSearch = true;
97 isIntervalChanged = true;
100 var listsPeriod = int.Parse(this.ListsPeriod.Text);
101 if (settingCommon.ListsPeriod != listsPeriod)
103 settingCommon.ListsPeriod = listsPeriod;
105 isIntervalChanged = true;
108 var replyPeriod = int.Parse(this.ReplyPeriod.Text);
109 if (settingCommon.ReplyPeriod != replyPeriod)
111 settingCommon.ReplyPeriod = replyPeriod;
113 isIntervalChanged = true;
116 var userTimelinePeriod = int.Parse(this.UserTimelinePeriod.Text);
117 if (settingCommon.UserTimelinePeriod != userTimelinePeriod)
119 settingCommon.UserTimelinePeriod = userTimelinePeriod;
120 arg.UserTimeline = true;
121 isIntervalChanged = true;
124 if (isIntervalChanged)
125 this.IntervalChanged?.Invoke(this, arg);
128 private void UserstreamPeriod_Validating(object sender, CancelEventArgs e)
133 prd = int.Parse(UserstreamPeriod.Text);
137 MessageBox.Show(Properties.Resources.UserstreamPeriod_ValidatingText1);
142 if (prd < 0 || prd > 60)
144 MessageBox.Show(Properties.Resources.UserstreamPeriod_ValidatingText1);
150 private void TimelinePeriod_Validating(object sender, CancelEventArgs e)
155 prd = int.Parse(TimelinePeriod.Text);
159 MessageBox.Show(Properties.Resources.TimelinePeriod_ValidatingText1);
164 if (prd != 0 && (prd < 15 || prd > 6000))
166 MessageBox.Show(Properties.Resources.TimelinePeriod_ValidatingText2);
172 private void ReplyPeriod_Validating(object sender, CancelEventArgs e)
177 prd = int.Parse(ReplyPeriod.Text);
181 MessageBox.Show(Properties.Resources.TimelinePeriod_ValidatingText1);
186 if (prd != 0 && (prd < 15 || prd > 6000))
188 MessageBox.Show(Properties.Resources.TimelinePeriod_ValidatingText2);
194 private void DMPeriod_Validating(object sender, CancelEventArgs e)
199 prd = int.Parse(DMPeriod.Text);
203 MessageBox.Show(Properties.Resources.DMPeriod_ValidatingText1);
208 if (prd != 0 && (prd < 15 || prd > 6000))
210 MessageBox.Show(Properties.Resources.DMPeriod_ValidatingText2);
216 private void PubSearchPeriod_Validating(object sender, CancelEventArgs e)
221 prd = int.Parse(PubSearchPeriod.Text);
225 MessageBox.Show(Properties.Resources.PubSearchPeriod_ValidatingText1);
230 if (prd != 0 && (prd < 30 || prd > 6000))
232 MessageBox.Show(Properties.Resources.PubSearchPeriod_ValidatingText2);
237 private void ListsPeriod_Validating(object sender, CancelEventArgs e)
242 prd = int.Parse(ListsPeriod.Text);
246 MessageBox.Show(Properties.Resources.DMPeriod_ValidatingText1);
251 if (prd != 0 && (prd < 15 || prd > 6000))
253 MessageBox.Show(Properties.Resources.DMPeriod_ValidatingText2);
259 private void UserTimeline_Validating(object sender, CancelEventArgs e)
264 prd = int.Parse(UserTimelinePeriod.Text);
268 MessageBox.Show(Properties.Resources.DMPeriod_ValidatingText1);
273 if (prd != 0 && (prd < 15 || prd > 6000))
275 MessageBox.Show(Properties.Resources.DMPeriod_ValidatingText2);