OSDN Git Service

3eb90c481667094f319b566b667384fb8882cd28
[opentween/open-tween.git] / OpenTween / Setting / SettingLocal.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) 2011      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 #nullable enable
28
29 using System;
30 using System.Collections.Generic;
31 using System.Drawing;
32 using System.Linq;
33 using System.Text;
34 using System.Xml.Serialization;
35 using OpenTween.Connection;
36
37 namespace OpenTween
38 {
39     public class SettingLocal : SettingBase<SettingLocal>
40     {
41         #region Settingクラス基本
42         public static SettingLocal Load(string settingsPath)
43             => LoadSettings(settingsPath);
44
45         public void Save(string settingsPath)
46             => SaveSettings(this, settingsPath);
47         #endregion
48
49         /// <summary>
50         /// ウィンドウサイズ等の保存時のDPI
51         /// </summary>
52         public SizeF ScaleDimension = SizeF.Empty;
53
54         public Point FormLocation = new(0, 0);
55         public int SplitterDistance = 200;
56         public Size FormSize = new(600, 500);
57
58         /// <summary>
59         /// 文末ステータス
60         /// </summary>
61         public string StatusText = "";
62
63         public bool UseRecommendStatus = false;
64
65         [XmlIgnore]
66         public int[] ColumnsWidth { get; } = { 48, 80, 290, 120, 50, 16, 32, 50 };
67
68         public int Width1
69         {
70             get => this.ColumnsWidth[0];
71             set => this.ColumnsWidth[0] = value;
72         }
73
74         public int Width2
75         {
76             get => this.ColumnsWidth[1];
77             set => this.ColumnsWidth[1] = value;
78         }
79
80         public int Width3
81         {
82             get => this.ColumnsWidth[2];
83             set => this.ColumnsWidth[2] = value;
84         }
85
86         public int Width4
87         {
88             get => this.ColumnsWidth[3];
89             set => this.ColumnsWidth[3] = value;
90         }
91
92         public int Width5
93         {
94             get => this.ColumnsWidth[4];
95             set => this.ColumnsWidth[4] = value;
96         }
97
98         public int Width6
99         {
100             get => this.ColumnsWidth[5];
101             set => this.ColumnsWidth[5] = value;
102         }
103
104         public int Width7
105         {
106             get => this.ColumnsWidth[6];
107             set => this.ColumnsWidth[6] = value;
108         }
109
110         public int Width8
111         {
112             get => this.ColumnsWidth[7];
113             set => this.ColumnsWidth[7] = value;
114         }
115
116         [XmlIgnore]
117         public int[] ColumnsOrder { get; } = { 2, 3, 4, 5, 6, 1, 0, 7 };
118
119         public int DisplayIndex1
120         {
121             get => this.ColumnsOrder[0];
122             set => this.ColumnsOrder[0] = value;
123         }
124
125         public int DisplayIndex2
126         {
127             get => this.ColumnsOrder[1];
128             set => this.ColumnsOrder[1] = value;
129         }
130
131         public int DisplayIndex3
132         {
133             get => this.ColumnsOrder[2];
134             set => this.ColumnsOrder[2] = value;
135         }
136
137         public int DisplayIndex4
138         {
139             get => this.ColumnsOrder[3];
140             set => this.ColumnsOrder[3] = value;
141         }
142
143         public int DisplayIndex5
144         {
145             get => this.ColumnsOrder[4];
146             set => this.ColumnsOrder[4] = value;
147         }
148
149         public int DisplayIndex6
150         {
151             get => this.ColumnsOrder[5];
152             set => this.ColumnsOrder[5] = value;
153         }
154
155         public int DisplayIndex7
156         {
157             get => this.ColumnsOrder[6];
158             set => this.ColumnsOrder[6] = value;
159         }
160
161         public int DisplayIndex8
162         {
163             get => this.ColumnsOrder[7];
164             set => this.ColumnsOrder[7] = value;
165         }
166
167         public string BrowserPath = "";
168         public ProxyType ProxyType = ProxyType.IE;
169         public string ProxyAddress = "127.0.0.1";
170         public int ProxyPort = 80;
171         public string ProxyUser = "";
172         public bool StatusMultiline = false;
173         public int StatusTextHeight = 38;
174         public int PreviewDistance = -1;
175
176         public string? FontUnreadStr { get; set; }
177
178         public string? ColorUnreadStr { get; set; }
179
180         public string? FontReadStr { get; set; }
181
182         public string? ColorReadStr { get; set; }
183
184         public string? ColorFavStr { get; set; }
185
186         public string? ColorOWLStr { get; set; }
187
188         public string? ColorRetweetStr { get; set; }
189
190         public string? FontDetailStr { get; set; }
191
192         public string? ColorSelfStr { get; set; }
193
194         public string? ColorAtSelfStr { get; set; }
195
196         public string? ColorTargetStr { get; set; }
197
198         public string? ColorAtTargetStr { get; set; }
199
200         public string? ColorAtFromTargetStr { get; set; }
201
202         public string? ColorAtToStr { get; set; }
203
204         public string? ColorInputBackcolorStr { get; set; }
205
206         public string? ColorInputFontStr { get; set; }
207
208         public string? FontInputFontStr { get; set; }
209
210         public string? ColorListBackcolorStr { get; set; }
211
212         public string? ColorDetailBackcolorStr { get; set; }
213
214         public string? ColorDetailStr { get; set; }
215
216         public string? ColorDetailLinkStr { get; set; }
217
218         /// <summary>
219         /// [隠し設定] UI フォントを指定します
220         /// </summary>
221         /// <remarks>
222         /// フォントによっては一部レイアウトが崩れるためこっそり追加
223         /// </remarks>
224         public string? FontUIGlobalStr { get; set; }
225
226         [XmlIgnore]
227         public string ProxyPassword = "";
228
229         public string EncryptProxyPassword
230         {
231             get
232             {
233                 var pwd = this.ProxyPassword;
234                 if (MyCommon.IsNullOrEmpty(pwd)) pwd = "";
235                 if (pwd.Length > 0)
236                 {
237                     try
238                     {
239                         return MyCommon.EncryptString(pwd);
240                     }
241                     catch (Exception)
242                     {
243                         return "";
244                     }
245                 }
246                 else
247                 {
248                     return "";
249                 }
250             }
251
252             set
253             {
254                 var pwd = value;
255                 if (MyCommon.IsNullOrEmpty(pwd)) pwd = "";
256                 if (pwd.Length > 0)
257                 {
258                     try
259                     {
260                         pwd = MyCommon.DecryptString(pwd);
261                     }
262                     catch (Exception)
263                     {
264                         pwd = "";
265                     }
266                 }
267                 this.ProxyPassword = pwd;
268             }
269         }
270
271         /// <summary>
272         /// 絵文字の表示に Twemoji (https://github.com/twitter/twemoji) を使用するか
273         /// </summary>
274         public bool UseTwemoji = true;
275
276         /// <summary>
277         /// 指定されたスケールと SettingLocal.ScaleDimension のスケールとの拡大比を返します
278         /// </summary>
279         public SizeF GetConfigScaleFactor(SizeF currentSizeDimension)
280             => new(
281                 currentSizeDimension.Width / this.ScaleDimension.Width,
282                 currentSizeDimension.Height / this.ScaleDimension.Height);
283     }
284 }