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.
28 using System.Collections.Generic;
29 using System.ComponentModel;
34 using System.Windows.Forms;
36 namespace OpenTween.Setting.Panel
38 public partial class TweetPrvPanel : SettingPanelBase
40 public TweetPrvPanel()
42 InitializeComponent();
45 public void LoadConfig(SettingCommon settingCommon)
47 switch (settingCommon.IconSize)
49 case MyCommon.IconSizes.IconNone:
50 this.IconSize.SelectedIndex = 0;
52 case MyCommon.IconSizes.Icon16:
53 this.IconSize.SelectedIndex = 1;
55 case MyCommon.IconSizes.Icon24:
56 this.IconSize.SelectedIndex = 2;
58 case MyCommon.IconSizes.Icon48:
59 this.IconSize.SelectedIndex = 3;
61 case MyCommon.IconSizes.Icon48_2:
62 this.IconSize.SelectedIndex = 4;
66 this.OneWayLv.Checked = settingCommon.OneWayLove;
67 this.CheckSortOrderLock.Checked = settingCommon.SortOrderLock;
68 this.CheckViewTabBottom.Checked = settingCommon.ViewTabBottom;
69 this.chkUnreadStyle.Checked = settingCommon.UseUnreadStyle;
72 var dateTimeFormat = settingCommon.DateTimeFormat;
75 if (DateTime.Now.ToString(dateTimeFormat).Length == 0)
78 // 変換が成功した場合にLengthが0にならない
79 dateTimeFormat = "yyyy/MM/dd H:mm:ss";
82 catch (FormatException)
84 // FormatExceptionが発生したら初期値を設定 (=yyyy/MM/dd H:mm:ssとみなされる)
85 dateTimeFormat = "yyyy/MM/dd H:mm:ss";
87 this.CmbDateTimeFormat.Text = dateTimeFormat;
89 this.CheckShowGrid.Checked = settingCommon.ShowGrid;
90 this.HideDuplicatedRetweetsCheck.Checked = settingCommon.HideDuplicatedRetweets;
91 this.IsListsIncludeRtsCheckBox.Checked = settingCommon.IsListsIncludeRts;
94 public void SaveConfig(SettingCommon settingCommon)
96 switch (this.IconSize.SelectedIndex)
99 settingCommon.IconSize = MyCommon.IconSizes.IconNone;
102 settingCommon.IconSize = MyCommon.IconSizes.Icon16;
105 settingCommon.IconSize = MyCommon.IconSizes.Icon24;
108 settingCommon.IconSize = MyCommon.IconSizes.Icon48;
111 settingCommon.IconSize = MyCommon.IconSizes.Icon48_2;
115 settingCommon.OneWayLove = this.OneWayLv.Checked;
116 settingCommon.SortOrderLock = this.CheckSortOrderLock.Checked;
117 settingCommon.ViewTabBottom = this.CheckViewTabBottom.Checked;
118 settingCommon.UseUnreadStyle = this.chkUnreadStyle.Checked;
119 settingCommon.DateTimeFormat = this.CmbDateTimeFormat.Text;
120 settingCommon.ShowGrid = this.CheckShowGrid.Checked;
121 settingCommon.HideDuplicatedRetweets = this.HideDuplicatedRetweetsCheck.Checked;
122 settingCommon.IsListsIncludeRts = this.IsListsIncludeRtsCheckBox.Checked;
125 private bool CreateDateTimeFormatSample()
129 LabelDateTimeFormatApplied.Text = DateTime.Now.ToString(CmbDateTimeFormat.Text);
131 catch (FormatException)
133 LabelDateTimeFormatApplied.Text = Properties.Resources.CreateDateTimeFormatSampleText1;
139 private void CmbDateTimeFormat_TextUpdate(object sender, EventArgs e)
141 CreateDateTimeFormatSample();
144 private void CmbDateTimeFormat_SelectedIndexChanged(object sender, EventArgs e)
146 CreateDateTimeFormatSample();
149 private void CmbDateTimeFormat_Validating(object sender, CancelEventArgs e)
151 if (!CreateDateTimeFormatSample())
153 MessageBox.Show(Properties.Resources.CmbDateTimeFormat_Validating);
158 private void LabelDateTimeFormatApplied_VisibleChanged(object sender, EventArgs e)
160 CreateDateTimeFormatSample();