1 // OpenTween - Client of Twitter
2 // Copyright (c) 2014 spx (@5px)
3 // All rights reserved.
5 // This file is part of OpenTween.
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)
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
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.
23 using System.Windows.Forms;
24 using System.Collections.Generic;
26 using System.ComponentModel;
30 public class OTSplitContainer : SplitContainer
33 /// Panel1 と Panel2 の中身が入れ替わった状態かどうかを取得または設定する。
34 /// true が設定された場合、Panel に関連するプロパティの処理内容も入れ替わるので注意。
37 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
38 public bool IsPanelInverted
40 get { return _isPanelInverted; }
43 if (_isPanelInverted == value) return;
44 _isPanelInverted = value;
46 // Panel1 と Panel2 の中身を入れ替え
47 using (ControlTransaction.Layout(this, false))
48 using (ControlTransaction.Layout(base.Panel1, false))
49 using (ControlTransaction.Layout(base.Panel2, false))
51 var cont1 = new List<Control>(base.Panel1.Controls.Cast<Control>());
52 var cont2 = new List<Control>(base.Panel2.Controls.Cast<Control>());
53 base.Panel1.Controls.Clear();
54 base.Panel2.Controls.Clear();
57 if (base.FixedPanel != FixedPanel.None)
58 base.FixedPanel = (base.FixedPanel == FixedPanel.Panel1) ? FixedPanel.Panel2 : FixedPanel.Panel1;
60 base.SplitterDistance = SplitterTotalWidth - (base.SplitterDistance + SplitterWidth);
62 var tmpMinSize = base.Panel1MinSize;
63 base.Panel1MinSize = base.Panel2MinSize;
64 base.Panel2MinSize = tmpMinSize;
66 var tmpCollapsed = base.Panel1Collapsed;
67 base.Panel1Collapsed = base.Panel2Collapsed;
68 base.Panel2Collapsed = tmpCollapsed;
70 base.Panel1.Controls.AddRange(cont2.ToArray());
71 base.Panel2.Controls.AddRange(cont1.ToArray());
75 private bool _isPanelInverted = false;
78 /// SplitContainer.Orientation プロパティの設定に応じて、スプリッタが移動する方向の幅を返す。
80 private int SplitterTotalWidth
82 get { return (base.Orientation == Orientation.Horizontal) ? base.Height : base.Width; }
86 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.Panel1 または SplitContainer.Panel2 を返す。
88 public new SplitterPanel Panel1
90 get { return IsPanelInverted ? base.Panel2 : base.Panel1; }
94 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.Panel1 または SplitContainer.Panel2 を返す。
96 public new SplitterPanel Panel2
98 get { return IsPanelInverted ? base.Panel1 : base.Panel2; }
102 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.FixedPanel を返す。
104 public new FixedPanel FixedPanel
108 if (base.FixedPanel != FixedPanel.None && IsPanelInverted)
109 return (base.FixedPanel == FixedPanel.Panel1) ? FixedPanel.Panel2 : FixedPanel.Panel1;
111 return base.FixedPanel;
115 if (value != FixedPanel.None && IsPanelInverted)
116 base.FixedPanel = (value == FixedPanel.Panel1) ? FixedPanel.Panel2 : FixedPanel.Panel1;
118 base.FixedPanel = value;
123 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.SplitterDistance を返す。
125 public new int SplitterDistance
130 return SplitterTotalWidth - (base.SplitterDistance + SplitterWidth);
132 return base.SplitterDistance;
137 base.SplitterDistance = SplitterTotalWidth - (value + SplitterWidth);
139 base.SplitterDistance = value;
144 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.Panel1MinSize または SplitContainer.Panel2MinSize を返す。
146 public new int Panel1MinSize
148 get { return IsPanelInverted ? base.Panel2MinSize : base.Panel1MinSize; }
152 base.Panel2MinSize = value;
154 base.Panel1MinSize = value;
159 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.Panel1MinSize または SplitContainer.Panel2MinSize を返す。
161 public new int Panel2MinSize
163 get { return IsPanelInverted ? base.Panel1MinSize : base.Panel2MinSize; }
167 base.Panel1MinSize = value;
169 base.Panel2MinSize = value;
174 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.Panel1Collapsed または SplitContainer.Panel2Collapsed を返す。
176 public new bool Panel1Collapsed
178 get { return IsPanelInverted ? base.Panel2Collapsed : base.Panel1Collapsed; }
182 base.Panel2Collapsed = value;
184 base.Panel1Collapsed = value;
189 /// IsPanelInverted プロパティの設定に応じて、SplitContainer.Panel1Collapsed または SplitContainer.Panel2Collapsed を返す。
191 public new bool Panel2Collapsed
193 get { return IsPanelInverted ? base.Panel1Collapsed : base.Panel2Collapsed; }
197 base.Panel1Collapsed = value;
199 base.Panel2Collapsed = value;