• R/O
  • SSH
  • HTTPS

kotoli: Commit


Commit MetaInfo

Revision219 (tree)
Time2010-08-21 23:37:39
Authorsgry

Log Message

検索クエリー編集GUIの仮作成を開始

Change Summary

Incremental Difference

--- branches/experimental/1e/Kotoli/QueryPanel.cs (revision 218)
+++ branches/experimental/1e/Kotoli/QueryPanel.cs (revision 219)
@@ -6,7 +6,7 @@
66 using System.Text;
77 using System.Windows.Forms;
88
9-namespace QueuePanelTestDrive
9+namespace Kotoli
1010 {
1111 public partial class QueryPanel : UserControl
1212 {
--- branches/experimental/1e/Kotoli/KotoliForm.cs (revision 218)
+++ branches/experimental/1e/Kotoli/KotoliForm.cs (revision 219)
@@ -1,9 +1,7 @@
11 using System;
22 using System.Collections.Generic;
33 using System.ComponentModel;
4-using System.Data;
54 using System.Drawing;
6-using System.Text;
75 using System.IO;
86 using System.Windows.Forms;
97 using System.Reflection;
@@ -11,6 +9,7 @@
119 using ThreadStart = System.Threading.ThreadStart;
1210 using Timeout = System.Threading.Timeout;
1311 using Sgry;
12+using Kotoli.Query;
1413
1514 #if PocketPC
1615 using Microsoft.WindowsCE.Forms;
@@ -20,6 +19,8 @@
2019 {
2120 partial class KotoliForm : Form
2221 {
22+ const int Indent = 6;
23+
2324 KotoliLogic _logic;
2425 TreeNode _selectedNode = null; // Copy, Cutの一時保存用 _LastSelectedNodeと共用できそうならする方針で
2526 bool? _isCopy = null;
@@ -91,6 +92,7 @@
9192 this.browserView.GotFocus += new EventHandler( browserView_GotFocus );
9293 this.bvDeleteNode.Click += new EventHandler( bvDeleteNode_Click );
9394 this.bvCreateNode.Click += new EventHandler(miFileNewFolder_Click);
95+ this.bvCreateSearchFolder.Click += new EventHandler(bvCreateSearchFolder_Click);
9496 this.browserView.AfterExpand += new TreeViewEventHandler(browserView_AfterExpand);
9597 #if !PocketPC
9698 this.browserView.NodeMouseClick += new TreeNodeMouseClickEventHandler(browserView_NodeMouseClick);
@@ -171,6 +173,132 @@
171173 #endif
172174 }
173175
176+ // ToDo : Queryの仕様変更に対応する(2010/08/03)
177+ void bvCreateSearchFolder_Click(object sender, EventArgs e)
178+ {
179+ // Formを作成
180+ Form searchForm = new Form();
181+ Panel rootPanel = new Panel();
182+ rootPanel.Height = 0;
183+ rootPanel.Tag = "RootPanel";
184+
185+ // QueryTreeの作成
186+ IQuery q = QueryStringParser.Parse(
187+@"AND{
188+ filename = ""hoge""
189+ OR{
190+  filename = ""foo""
191+  date > 2010/08/05
192+ }
193+}" );
194+
195+ // UIをQueryTreeから作成
196+ CreateSearchPanel(q, rootPanel);
197+
198+ // レイアウトロジックを中断
199+ this.SuspendLayout();
200+
201+ // Formに追加
202+ searchForm.Controls.Add(rootPanel);
203+
204+ // 高さ、幅、座標を計算
205+ SetPanelHeight(rootPanel, 0);
206+
207+ // Formのサイズを更新
208+ searchForm.Size = new Size(rootPanel.Width, rootPanel.Height+111);
209+
210+ // 戻す
211+ this.ResumeLayout();
212+
213+ searchForm.Show();
214+ }
215+
216+ private Control CreateSearchPanel(IQuery queryNode, Control parent)
217+ {
218+ CompositeQuery composite = queryNode as CompositeQuery;
219+ if (composite != null)
220+ {
221+ // AND/ORのパネルを作成
222+ ContainerPanel cPanel = new ContainerPanel();
223+ parent.Controls.Add(cPanel);
224+
225+ // 配下の要素にも再帰
226+ foreach(IQuery child in composite.Children)
227+ {
228+ CreateSearchPanel(child, cPanel);
229+ }
230+ }
231+ else
232+ {
233+ UserControl qPanel = new QueryPanel();
234+ //qPanel.Tag = queryNode.ToString();
235+ parent.Controls.Add(qPanel);
236+ }
237+
238+ return parent;
239+ }
240+
241+ private void SetPanelHeight(Control parent, int depth)
242+ {
243+ int tabIndex = 0;
244+ Control prevControl = null;
245+ parent.Height = 0;
246+
247+ // 全ての子コントロールを再帰的に列挙
248+ foreach (Control c in parent.Controls)
249+ {
250+ // 子コントロールのうちPanelについて処理する
251+ if (c.GetType().ToString().IndexOf("Panel") != -1)
252+ {
253+ // Containerの場合
254+ if (c is ContainerPanel)
255+ {
256+ SetPanelHeight(c, depth++);
257+
258+ if (prevControl != null)
259+ {
260+ c.Top = prevControl.Top + prevControl.Height;
261+ }
262+
263+ // 入れ子構造の場合オフセット
264+ c.Left = Indent * depth;
265+ c.Width += c.Left * 2; // たぶん左右で2倍
266+ c.Height += Indent; // 余白の設定
267+ c.TabIndex = tabIndex;
268+
269+
270+ // 親要素のサイズを設定
271+ int pHeight = parent.ClientSize.Height + c.Height;
272+ int pWidth = c.Width + (c.Left * 2);
273+
274+ parent.ClientSize = new Size(pWidth, pHeight);
275+
276+ tabIndex++;
277+
278+ //MessageBox.Show("Parent Height : " + parent.Height + "\n" + panelType + " Height : " + c.Height);
279+ }
280+ else // container以外のパネルの場合
281+ {
282+ // QueryPanelの場合
283+ //MessageBox.Show("Parent Height : " + parent.Height + "\n" + panelType + " Height : " + c.Height);
284+ parent.Height += c.Height;
285+ parent.Width = c.Width;
286+
287+ if (prevControl != null)
288+ {
289+ c.Top = prevControl.Top + prevControl.Height;
290+ }
291+
292+ c.TabIndex = tabIndex;
293+ tabIndex++;
294+ }
295+
296+ prevControl = c;
297+ }
298+ }
299+ }
300+
301+
174302 void Localize()
175303 {
176304 // 言語ファイルの読み込みと適用
@@ -218,6 +346,7 @@
218346 localizer.TryGetString("bvRename.Text", bvRename);
219347 localizer.TryGetString("bvCreateNode.Text", bvCreateNode);
220348 localizer.TryGetString("bvDeleteNode.Text", bvDeleteNode);
349+ localizer.TryGetString("bvCreateSearchFolder.Text", bvCreateSearchFolder);
221350
222351 localizer.TryGetString("FindLabel.Text", FindLabel);
223352 localizer.TryGetString("Prev.Text", Prev);
--- branches/experimental/1e/Kotoli/ContainerPanel.Designer.cs (revision 218)
+++ branches/experimental/1e/Kotoli/ContainerPanel.Designer.cs (revision 219)
@@ -1,4 +1,4 @@
1-namespace QueuePanelTestDrive
1+namespace Kotoli
22 {
33 partial class ContainerPanel
44 {
--- branches/experimental/1e/Kotoli/ContainerPanel.cs (revision 218)
+++ branches/experimental/1e/Kotoli/ContainerPanel.cs (revision 219)
@@ -6,9 +6,9 @@
66 using System.Text;
77 using System.Windows.Forms;
88
9-namespace QueuePanelTestDrive
9+namespace Kotoli
1010 {
11- public partial class ContainerPanel : UserControl
11+ partial class ContainerPanel : UserControl
1212 {
1313 public ContainerPanel()
1414 {
--- branches/experimental/1e/Kotoli/KotoliForm.Designer.cs (revision 218)
+++ branches/experimental/1e/Kotoli/KotoliForm.Designer.cs (revision 219)
@@ -413,6 +413,8 @@
413413 this.bvCreateNode = new System.Windows.Forms.MenuItem();
414414 this.bvDeleteNode = new System.Windows.Forms.MenuItem();
415415 this.bvRename = new System.Windows.Forms.MenuItem();
416+ this.bvSep2 = new System.Windows.Forms.MenuItem();
417+ this.bvCreateSearchFolder = new System.Windows.Forms.MenuItem();
416418 //searchpanel
417419 this.SearchPanel = new System.Windows.Forms.Panel();
418420 this.Next = new System.Windows.Forms.Button();
@@ -571,6 +573,8 @@
571573 this.bvCreateNode.Text = "Create &Folder...";
572574 this.bvDeleteNode.Text = "&Delete Node";
573575 this.bvRename.Text = "&Rename Node";
576+ this.bvCreateSearchFolder.Text = "Create &Search Folder";
577+ this.bvSep2.Text = "-";
574578 this.bvMenu.MenuItems.Add(bvCut);
575579 this.bvMenu.MenuItems.Add(bvCopy);
576580 this.bvMenu.MenuItems.Add(bvPaste);
@@ -578,6 +582,8 @@
578582 this.bvMenu.MenuItems.Add(bvCreateNode);
579583 this.bvMenu.MenuItems.Add(bvDeleteNode);
580584 this.bvMenu.MenuItems.Add(bvRename);
585+ this.bvMenu.MenuItems.Add(bvSep2);
586+ this.bvMenu.MenuItems.Add(bvCreateSearchFolder);
581587 //
582588 // browserView
583589 //
@@ -757,6 +763,8 @@
757763 private System.Windows.Forms.MenuItem bvRename;
758764 private System.Windows.Forms.MenuItem bvCreateNode;
759765 private System.Windows.Forms.MenuItem bvDeleteNode;
766+ private System.Windows.Forms.MenuItem bvSep2;
767+ private System.Windows.Forms.MenuItem bvCreateSearchFolder;
760768
761769 // Search Panel
762770 private System.Windows.Forms.Panel SearchPanel;
--- branches/experimental/1e/Kotoli/QueryPanel.Designer.cs (revision 218)
+++ branches/experimental/1e/Kotoli/QueryPanel.Designer.cs (revision 219)
@@ -1,4 +1,4 @@
1-namespace QueuePanelTestDrive
1+namespace Kotoli
22 {
33 partial class QueryPanel
44 {
@@ -88,7 +88,6 @@
8888 //
8989 this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
9090 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
91- this.BackColor = System.Drawing.Color.White;
9291 this.Controls.Add(this.detailButton);
9392 this.Controls.Add(this.removeButton);
9493 this.Controls.Add(this.addButton);
Show on old repository browser