OSDN Git Service

ShowUserInfoのフォロー状態の取得・表示処理をTaskによる非同期処理に移行
[opentween/open-tween.git] / OpenTween / OTPictureBox.cs
1 // OpenTween - Client of Twitter
2 // Copyright (c) 2013 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
3 // All rights reserved.
4 //
5 // This file is part of OpenTween.
6 //
7 // This program is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by the Free
9 // Software Foundation; either version 3 of the License, or (at your option)
10 // any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 // for more details.
16 //
17 // You should have received a copy of the GNU General Public License along
18 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
19 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
20 // Boston, MA 02110-1301, USA.
21
22 using System;
23 using System.Collections.Generic;
24 using System.Linq;
25 using System.Text;
26 using System.Windows.Forms;
27 using System.ComponentModel;
28 using System.Drawing;
29 using System.Threading.Tasks;
30 using System.Threading;
31 using System.Net;
32 using System.IO;
33
34 namespace OpenTween
35 {
36     public class OTPictureBox : PictureBox
37     {
38         [Browsable(false)]
39         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
40         public new MemoryImage Image
41         {
42             get { return this.memoryImage; }
43             set
44             {
45                 this.memoryImage = value;
46                 base.Image = value != null ? value.Image : null;
47
48                 this.RestoreSizeMode();
49             }
50         }
51         private MemoryImage memoryImage;
52
53         [Localizable(true)]
54         [DefaultValue(PictureBoxSizeMode.Normal)]
55         public new PictureBoxSizeMode SizeMode
56         {
57             get { return this.currentSizeMode; }
58             set
59             {
60                 this.currentSizeMode = value;
61
62                 if (base.Image != base.InitialImage && base.Image != base.ErrorImage)
63                 {
64                     base.SizeMode = value;
65                 }
66             }
67         }
68
69         /// <summary>
70         /// InitialImage や ErrorImage の表示に SizeMode を一時的に変更するため、
71         /// 現在の SizeMode を記憶しておくためのフィールド
72         /// </summary>
73         private PictureBoxSizeMode currentSizeMode;
74
75         public void ShowInitialImage()
76         {
77             base.Image = base.InitialImage;
78
79             // InitialImage は SizeMode の値に依らず中央等倍に表示する必要がある
80             base.SizeMode = PictureBoxSizeMode.CenterImage;
81         }
82
83         public void ShowErrorImage()
84         {
85             base.Image = base.ErrorImage;
86
87             // ErrorImage は SizeMode の値に依らず中央等倍に表示する必要がある
88             base.SizeMode = PictureBoxSizeMode.CenterImage;
89         }
90
91         private void RestoreSizeMode()
92         {
93             base.SizeMode = this.currentSizeMode;
94         }
95
96         [Browsable(false)]
97         [EditorBrowsable(EditorBrowsableState.Never)]
98         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
99         public new string ImageLocation
100         {
101             get { throw new NotImplementedException(); }
102             set { throw new NotImplementedException(); }
103         }
104
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         public new void Load(string url)
107         {
108             throw new NotImplementedException();
109         }
110     }
111 }