OSDN Git Service

フォント・色変更のダイアログ表示等の処理を各設定パネルに移動
[opentween/open-tween.git] / OpenTween / Setting / Panel / SettingPanelBase.cs
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.
9 //
10 // This file is part of OpenTween.
11 //
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)
15 // any later version.
16 //
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
20 // for more details.
21 //
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.
26
27 using System;
28 using System.Collections.Generic;
29 using System.ComponentModel;
30 using System.Drawing;
31 using System.Data;
32 using System.Linq;
33 using System.Text;
34 using System.Windows.Forms;
35
36 namespace OpenTween.Setting.Panel
37 {
38     public partial class SettingPanelBase : UserControl
39     {
40         public SettingPanelBase()
41         {
42             InitializeComponent();
43         }
44
45         protected void ShowFontDialog(Label targetLabel)
46         {
47             var dialog = ((AppendSettingDialog)this.ParentForm).FontDialog1;
48
49             dialog.Font = targetLabel.Font;
50             dialog.Color = targetLabel.ForeColor;
51
52             DialogResult ret;
53             try
54             {
55                 ret = dialog.ShowDialog(this.ParentForm);
56             }
57             catch (ArgumentException ex)
58             {
59                 MessageBox.Show(this.ParentForm, ex.Message);
60                 return;
61             }
62
63             if (ret == DialogResult.OK)
64             {
65                 targetLabel.Font = dialog.Font;
66                 targetLabel.ForeColor = dialog.Color;
67             }
68         }
69
70         protected void ShowForeColorDialog(Label targetLabel)
71         {
72             var dialog = ((AppendSettingDialog)this.ParentForm).ColorDialog1;
73
74             dialog.Color = targetLabel.ForeColor;
75
76             var ret = dialog.ShowDialog(this.ParentForm);
77
78             if (ret == DialogResult.OK)
79             {
80                 targetLabel.ForeColor = dialog.Color;
81             }
82         }
83
84         protected void ShowBackColorDialog(Label targetLabel)
85         {
86             var dialog = ((AppendSettingDialog)this.ParentForm).ColorDialog1;
87
88             dialog.Color = targetLabel.BackColor;
89
90             var ret = dialog.ShowDialog(this.ParentForm);
91
92             if (ret == DialogResult.OK)
93             {
94                 targetLabel.BackColor = dialog.Color;
95             }
96         }
97     }
98 }