mod ExplorerForm with able to open dirTree
| @@ -14,6 +14,9 @@ | ||
| 14 | 14 | OpenDir, |
| 15 | 15 | OpenFile, |
| 16 | 16 | JumpLine, |
| 17 | + ExpandExplorerNode, | |
| 18 | + ApplyPreferences, | |
| 19 | + | |
| 17 | 20 | } |
| 18 | 21 | |
| 19 | 22 | public class SomaliActionArgs : EventArgs |
| @@ -30,6 +33,12 @@ | ||
| 30 | 33 | get { return this._arg; } |
| 31 | 34 | } |
| 32 | 35 | |
| 36 | + private Type _argType; | |
| 37 | + public Type ArgType | |
| 38 | + { | |
| 39 | + get { return this._argType; } | |
| 40 | + } | |
| 41 | + | |
| 33 | 42 | private string _path; |
| 34 | 43 | public string Path |
| 35 | 44 | { |
| @@ -36,8 +45,8 @@ | ||
| 36 | 45 | get { return this._path; } |
| 37 | 46 | } |
| 38 | 47 | |
| 39 | - private int _lineNum; | |
| 40 | - public int LineNumber | |
| 48 | + private ulong _lineNum; | |
| 49 | + public ulong LineNumber | |
| 41 | 50 | { |
| 42 | 51 | get { return this._lineNum; } |
| 43 | 52 | } |
| @@ -49,7 +58,11 @@ | ||
| 49 | 58 | { |
| 50 | 59 | this._actionID = actionID; |
| 51 | 60 | this._arg = arg; |
| 61 | + this._argType = (arg == null ? null : arg.GetType()); | |
| 52 | 62 | |
| 63 | + this._path = String.Empty; | |
| 64 | + this._lineNum = 0UL; | |
| 65 | + | |
| 53 | 66 | switch ( actionID ) |
| 54 | 67 | { |
| 55 | 68 | case SomaliAction.OpenSolution: |
| @@ -56,20 +69,12 @@ | ||
| 56 | 69 | case SomaliAction.OpenDir: |
| 57 | 70 | case SomaliAction.OpenFile: |
| 58 | 71 | this._path = arg.ToString(); |
| 59 | - this._lineNum = 0; | |
| 60 | 72 | break; |
| 61 | 73 | case SomaliAction.JumpLine: |
| 62 | - this._path = String.Empty; | |
| 63 | - Int32.TryParse( arg.ToString(), out this._lineNum ); | |
| 74 | + UInt64.TryParse( arg.ToString(), out this._lineNum ); | |
| 64 | 75 | break; |
| 65 | - case SomaliAction.ShowExplorer: | |
| 66 | - case SomaliAction.ShowOutlineAnalizer: | |
| 67 | - case SomaliAction.Exit: | |
| 68 | - default: | |
| 69 | - this._path = String.Empty; | |
| 70 | - this._lineNum = 0; | |
| 71 | - break; | |
| 72 | 76 | } |
| 73 | 77 | } |
| 78 | + | |
| 74 | 79 | } |
| 75 | 80 | } |
| @@ -0,0 +1,18 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | + | |
| 6 | +namespace Somali.Models | |
| 7 | +{ | |
| 8 | + class OutlineModel : Somali.Base.Model | |
| 9 | + { | |
| 10 | + private Dictionary<string, int> _outlineMap = null; | |
| 11 | + public Dictionary<string, int> OutlineMap | |
| 12 | + { | |
| 13 | + get { return this._outlineMap; } | |
| 14 | + set { this._outlineMap = value; } | |
| 15 | + } | |
| 16 | + | |
| 17 | + } | |
| 18 | +} |
| @@ -7,11 +7,11 @@ | ||
| 7 | 7 | { |
| 8 | 8 | class ExplorerModel : Somali.Base.Model |
| 9 | 9 | { |
| 10 | - private System.Windows.Forms.TreeNode _fileTree; | |
| 11 | - public System.Windows.Forms.TreeNode Filetree | |
| 10 | + private System.Windows.Forms.TreeNode _explorerTree = null; | |
| 11 | + public System.Windows.Forms.TreeNode ExplorerTree | |
| 12 | 12 | { |
| 13 | - get { return this._fileTree; } | |
| 14 | - set { this._fileTree = value; } | |
| 13 | + get { return this._explorerTree; } | |
| 14 | + set { this._explorerTree = value; } | |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | } |
| @@ -38,6 +38,7 @@ | ||
| 38 | 38 | this.refleshToolButton = new System.Windows.Forms.ToolStripButton(); |
| 39 | 39 | this.togglePlusButton = new System.Windows.Forms.ToolStripButton(); |
| 40 | 40 | this.toggleMinusButton = new System.Windows.Forms.ToolStripButton(); |
| 41 | + this.explorerTreeIcons = new System.Windows.Forms.ImageList( this.components ); | |
| 41 | 42 | this.contextMenuExplorer.SuspendLayout(); |
| 42 | 43 | this.toolPanelExplorer.SuspendLayout(); |
| 43 | 44 | this.exploreToolStrip.SuspendLayout(); |
| @@ -48,10 +49,15 @@ | ||
| 48 | 49 | this.treeExplorer.ContextMenuStrip = this.contextMenuExplorer; |
| 49 | 50 | this.treeExplorer.Dock = System.Windows.Forms.DockStyle.Fill; |
| 50 | 51 | this.treeExplorer.Font = new System.Drawing.Font( "メイリオ", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)) ); |
| 52 | + this.treeExplorer.ImageIndex = 2; | |
| 53 | + this.treeExplorer.ImageList = this.explorerTreeIcons; | |
| 51 | 54 | this.treeExplorer.Location = new System.Drawing.Point( 0, 25 ); |
| 52 | 55 | this.treeExplorer.Name = "treeExplorer"; |
| 56 | + this.treeExplorer.SelectedImageIndex = 0; | |
| 53 | 57 | this.treeExplorer.Size = new System.Drawing.Size( 276, 374 ); |
| 54 | 58 | this.treeExplorer.TabIndex = 0; |
| 59 | + this.treeExplorer.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler( this.treeExplorer_NodeMouseDoubleClick ); | |
| 60 | + this.treeExplorer.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler( this.treeExplorer_BeforeExpand ); | |
| 55 | 61 | // |
| 56 | 62 | // contextMenuExplorer |
| 57 | 63 | // |
| @@ -86,7 +92,7 @@ | ||
| 86 | 92 | this.toggleMinusButton} ); |
| 87 | 93 | this.exploreToolStrip.Location = new System.Drawing.Point( 3, 0 ); |
| 88 | 94 | this.exploreToolStrip.Name = "exploreToolStrip"; |
| 89 | - this.exploreToolStrip.Size = new System.Drawing.Size( 103, 25 ); | |
| 95 | + this.exploreToolStrip.Size = new System.Drawing.Size( 72, 25 ); | |
| 90 | 96 | this.exploreToolStrip.TabIndex = 0; |
| 91 | 97 | // |
| 92 | 98 | // refleshToolButton |
| @@ -116,6 +122,15 @@ | ||
| 116 | 122 | this.toggleMinusButton.Size = new System.Drawing.Size( 23, 22 ); |
| 117 | 123 | this.toggleMinusButton.Text = "展開"; |
| 118 | 124 | // |
| 125 | + // explorerTreeIcons | |
| 126 | + // | |
| 127 | + this.explorerTreeIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject( "explorerTreeIcons.ImageStream" ))); | |
| 128 | + this.explorerTreeIcons.TransparentColor = System.Drawing.Color.Transparent; | |
| 129 | + this.explorerTreeIcons.Images.SetKeyName( 0, "folder.png" ); | |
| 130 | + this.explorerTreeIcons.Images.SetKeyName( 1, "folder_page.png" ); | |
| 131 | + this.explorerTreeIcons.Images.SetKeyName( 2, "page_error.png" ); | |
| 132 | + this.explorerTreeIcons.Images.SetKeyName( 3, "page_white_text.png" ); | |
| 133 | + // | |
| 119 | 134 | // ExplorerForm |
| 120 | 135 | // |
| 121 | 136 | this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 12F ); |
| @@ -128,6 +143,7 @@ | ||
| 128 | 143 | | WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop) |
| 129 | 144 | | WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom))); |
| 130 | 145 | this.Font = new System.Drawing.Font( "MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)) ); |
| 146 | + this.HideOnClose = true; | |
| 131 | 147 | this.Icon = ((System.Drawing.Icon)(resources.GetObject( "$this.Icon" ))); |
| 132 | 148 | this.Name = "ExplorerForm"; |
| 133 | 149 | this.Text = "SolutionExplorer"; |
| @@ -151,5 +167,6 @@ | ||
| 151 | 167 | private System.Windows.Forms.ToolStripButton refleshToolButton; |
| 152 | 168 | private System.Windows.Forms.ToolStripButton togglePlusButton; |
| 153 | 169 | private System.Windows.Forms.ToolStripButton toggleMinusButton; |
| 170 | + private System.Windows.Forms.ImageList explorerTreeIcons; | |
| 154 | 171 | } |
| 155 | 172 | } |
| \ No newline at end of file |
| @@ -12,6 +12,14 @@ | ||
| 12 | 12 | { |
| 13 | 13 | public partial class ExplorerForm : WeifenLuo.WinFormsUI.Docking.DockContent, IActionColleague |
| 14 | 14 | { |
| 15 | + public enum NodeIcon : int | |
| 16 | + { | |
| 17 | + FolderClose = 0, | |
| 18 | + FolderOpen, | |
| 19 | + FileError, | |
| 20 | + FilePlain, | |
| 21 | + } | |
| 22 | + | |
| 15 | 23 | private IActionMediator _mediator; |
| 16 | 24 | public void SetMediator( IActionMediator mediator ) |
| 17 | 25 | { |
| @@ -32,13 +40,20 @@ | ||
| 32 | 40 | } |
| 33 | 41 | #endregion |
| 34 | 42 | |
| 35 | - public void Reflesh() { } | |
| 43 | + public WeifenLuo.WinFormsUI.Docking.DockState DefaultDockState | |
| 44 | + { | |
| 45 | + get { return WeifenLuo.WinFormsUI.Docking.DockState.DockLeft; } | |
| 46 | + } | |
| 47 | + public void Reflesh() | |
| 48 | + { | |
| 49 | + this.treeExplorer.Refresh(); | |
| 50 | + } | |
| 36 | 51 | public void Bind( Model model ) |
| 37 | 52 | { |
| 38 | 53 | ExplorerModel exModel; |
| 39 | 54 | if ( model.TryGetModelImpl( out exModel ) ) |
| 40 | 55 | { |
| 41 | - BindExplorerTree( exModel.Filetree ); | |
| 56 | + BindExplorerTree( exModel.ExplorerTree ); | |
| 42 | 57 | } |
| 43 | 58 | } |
| 44 | 59 | public void Initialize() { } |
| @@ -62,5 +77,15 @@ | ||
| 62 | 77 | } |
| 63 | 78 | } |
| 64 | 79 | |
| 80 | + private void treeExplorer_NodeMouseDoubleClick( object sender, TreeNodeMouseClickEventArgs e ) | |
| 81 | + { | |
| 82 | + | |
| 83 | + } | |
| 84 | + | |
| 85 | + private void treeExplorer_BeforeExpand( object sender, TreeViewCancelEventArgs e ) | |
| 86 | + { | |
| 87 | + this._mediator.DispatchAction( new SomaliActionArgs( SomaliAction.ExpandExplorerNode, e.Node ) ); | |
| 88 | + } | |
| 89 | + | |
| 65 | 90 | } |
| 66 | 91 | } |
| @@ -5,16 +5,38 @@ | ||
| 5 | 5 | using System.Drawing; |
| 6 | 6 | using System.Text; |
| 7 | 7 | using System.Windows.Forms; |
| 8 | +using Somali.Base; | |
| 9 | +using Somali.Models; | |
| 8 | 10 | |
| 9 | 11 | namespace Somali |
| 10 | 12 | { |
| 11 | - public partial class OutlineForm : WeifenLuo.WinFormsUI.Docking.DockContent | |
| 13 | + public partial class OutlineForm : WeifenLuo.WinFormsUI.Docking.DockContent, IActionColleague | |
| 12 | 14 | { |
| 15 | + private IActionMediator _mediator; | |
| 16 | + public void SetMediator( IActionMediator mediator ) | |
| 17 | + { | |
| 18 | + this._mediator = mediator; | |
| 19 | + } | |
| 20 | + | |
| 13 | 21 | public OutlineForm() |
| 14 | 22 | { |
| 15 | 23 | InitializeComponent(); |
| 16 | 24 | } |
| 17 | 25 | |
| 26 | + public WeifenLuo.WinFormsUI.Docking.DockState DefaultDockState | |
| 27 | + { | |
| 28 | + get { return WeifenLuo.WinFormsUI.Docking.DockState.Float; } | |
| 29 | + } | |
| 30 | + public void Reflesh() { } | |
| 31 | + public void Bind( Model model ) | |
| 32 | + { | |
| 33 | + OutlineModel exModel; | |
| 34 | + if ( model.TryGetModelImpl( out exModel ) ) | |
| 35 | + { | |
| 36 | + } | |
| 37 | + } | |
| 38 | + public void Initialize() { } | |
| 39 | + | |
| 18 | 40 | private void buttonClose_Click(object sender, EventArgs e) |
| 19 | 41 | { |
| 20 | 42 | this.Close(); |
| @@ -48,6 +48,11 @@ | ||
| 48 | 48 | { |
| 49 | 49 | get { return this.dockPanelMain; } |
| 50 | 50 | } |
| 51 | + | |
| 52 | + public DockState DefaultDockState | |
| 53 | + { | |
| 54 | + get { return DockState.Unknown; } | |
| 55 | + } | |
| 51 | 56 | #endregion |
| 52 | 57 | |
| 53 | 58 | public SomaliForm() |
| @@ -119,7 +124,7 @@ | ||
| 119 | 124 | #region analyze |
| 120 | 125 | private void outlineMenuItem_Click( object sender, EventArgs e ) |
| 121 | 126 | { |
| 122 | - | |
| 127 | + this._mediator.DispatchAction( new SomaliActionArgs( SomaliAction.ShowOutlineAnalizer ) ); | |
| 123 | 128 | } |
| 124 | 129 | #endregion |
| 125 | 130 |
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | |
| 17 | 17 | private PreferencesSecretary prefSec; |
| 18 | 18 | private LayoutSecretary layoutSec; |
| 19 | + private ResourceSecretary resSec; | |
| 19 | 20 | private DockPanel _mainDockPanel; |
| 20 | 21 | |
| 21 | 22 | private SomaliForm _mainForm; |
| @@ -34,6 +35,7 @@ | ||
| 34 | 35 | |
| 35 | 36 | prefSec = new PreferencesSecretary(); |
| 36 | 37 | layoutSec = new LayoutSecretary( this._mainForm, this._mainDockPanel ); |
| 38 | + resSec = new ResourceSecretary(); | |
| 37 | 39 | |
| 38 | 40 | InitializeActionMap(); |
| 39 | 41 |
| @@ -55,6 +57,8 @@ | ||
| 55 | 57 | this._actionMap.Add( SomaliAction.Exit, ExitApplication ); |
| 56 | 58 | this._actionMap.Add( SomaliAction.OpenDir, OpenDirectory ); |
| 57 | 59 | this._actionMap.Add( SomaliAction.ShowExplorer, ShowExplorer ); |
| 60 | + this._actionMap.Add( SomaliAction.ShowOutlineAnalizer, ShowOutline ); | |
| 61 | + this._actionMap.Add( SomaliAction.ExpandExplorerNode, ExpandExplorerNode ); | |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | private void InitializeColleagues() |
| @@ -87,36 +91,20 @@ | ||
| 87 | 91 | } |
| 88 | 92 | } |
| 89 | 93 | |
| 90 | - private void InitializeExplorer( TreeNode root ) | |
| 94 | + private void ShowColleague<T>( Model model ) | |
| 95 | + where T : DockContent, IDockContent, IActionColleague, new() | |
| 91 | 96 | { |
| 92 | - ExplorerForm frmExplore = layoutSec.GetFormIfExists( typeof( ExplorerForm ) ) as ExplorerForm; | |
| 93 | - if ( frmExplore == null ) | |
| 97 | + T colleague; | |
| 98 | + if ( layoutSec.GetDockFormImpl( out colleague ) ) | |
| 94 | 99 | { |
| 95 | - frmExplore = new ExplorerForm( root ); | |
| 96 | - frmExplore.Show( this._mainDockPanel, DockState.DockLeft ); | |
| 100 | + colleague.SetMediator( this ); | |
| 101 | + colleague.Bind( model ); | |
| 102 | + DockState ds = (colleague.DockState != DockState.Unknown && colleague.DockState != DockState.Hidden) | |
| 103 | + ? colleague.DockState : colleague.DefaultDockState; | |
| 104 | + colleague.Show( this._mainDockPanel, ds ); | |
| 97 | 105 | } |
| 98 | - else | |
| 99 | - { | |
| 100 | - ExplorerModel model = new ExplorerModel(); | |
| 101 | - model.Filetree = root; | |
| 102 | - frmExplore.Bind( model ); | |
| 103 | - frmExplore.Show( this._mainDockPanel ); | |
| 104 | - } | |
| 105 | 106 | } |
| 106 | 107 | |
| 107 | - private void InitializeOutline() | |
| 108 | - { | |
| 109 | - OutlineForm frmOutline = layoutSec.GetFormIfExists( typeof( OutlineForm ) ) as OutlineForm; | |
| 110 | - if ( frmOutline == null ) | |
| 111 | - { | |
| 112 | - frmOutline = new OutlineForm(); | |
| 113 | - frmOutline.Show( this._mainDockPanel, new Rectangle( 150, 150, 580, 350 ) ); | |
| 114 | - } | |
| 115 | - else | |
| 116 | - { | |
| 117 | - frmOutline.Show(); | |
| 118 | - } | |
| 119 | - } | |
| 120 | 108 | |
| 121 | 109 | } |
| 122 | 110 | } |
| @@ -211,8 +211,8 @@ | ||
| 211 | 211 | /// 指定したTypeのDockContentを取得 |
| 212 | 212 | /// </summary> |
| 213 | 213 | /// <param name="formType">DockContentを継承するオブジェクトのType</param> |
| 214 | - /// <returns>DockPanelに存在すればDockContentを返却します。<br/>存在しない場合は、nullを返却します。</returns> | |
| 215 | - public IDockContent GetFormIfExists( Type formType ) | |
| 214 | + /// <returns>DockPanelに存在すればDockContentを返却します。存在しない場合は、nullを返却します。</returns> | |
| 215 | + public IDockContent GetDockFormIfExists( Type formType ) | |
| 216 | 216 | { |
| 217 | 217 | DockContentCollection dc = this._dockPanel.Contents; |
| 218 | 218 | foreach ( IDockContent d in dc ) |
| @@ -226,5 +226,84 @@ | ||
| 226 | 226 | return null; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | + /// <summary> | |
| 230 | + /// 指定したTypeのDockContentを取得 | |
| 231 | + /// </summary> | |
| 232 | + /// <typeparam name="T"></typeparam> | |
| 233 | + /// <returns>DockPanelに存在すればDockContentを返却します。存在しない場合は、nullを返却します。</returns> | |
| 234 | + public T GetDockFormIfExists<T>() | |
| 235 | + where T : class, IDockContent | |
| 236 | + { | |
| 237 | + DockContentCollection dc = this._dockPanel.Contents; | |
| 238 | + foreach ( IDockContent d in dc ) | |
| 239 | + { | |
| 240 | + if ( d.GetType().Equals( typeof( T ) ) ) | |
| 241 | + { | |
| 242 | + return (T)d; | |
| 243 | + } | |
| 244 | + } | |
| 245 | + return null; | |
| 246 | + //return default( T ); | |
| 247 | + } | |
| 248 | + | |
| 249 | + /// <summary> | |
| 250 | + /// IDockContentを継承するFormを取得 | |
| 251 | + /// </summary> | |
| 252 | + /// <typeparam name="T"></typeparam> | |
| 253 | + /// <param name="dockForm"></param> | |
| 254 | + /// <returns>true:取得成功<br/>false:取得失敗</returns> | |
| 255 | + /// <remarks>DockPanelに存在しないFormの場合、outにはnullを設定します。</remarks> | |
| 256 | + public bool TryGetDockForm<T>( out T dockForm ) | |
| 257 | + where T : class, IDockContent | |
| 258 | + { | |
| 259 | + try | |
| 260 | + { | |
| 261 | + dockForm = GetDockFormIfExists<T>(); | |
| 262 | + //dockForm = (T)GetDockFormIfExists( typeof( T ) ); | |
| 263 | + if ( dockForm != null ) | |
| 264 | + { | |
| 265 | + return true; | |
| 266 | + } | |
| 267 | + else | |
| 268 | + { | |
| 269 | + return false; | |
| 270 | + } | |
| 271 | + } | |
| 272 | + catch ( Exception ) | |
| 273 | + { | |
| 274 | + dockForm = default( T ); | |
| 275 | + return false; | |
| 276 | + } | |
| 277 | + } | |
| 278 | + | |
| 279 | + /// <summary> | |
| 280 | + /// IDockContentを継承するFormの実装インスタンスを取得 | |
| 281 | + /// </summary> | |
| 282 | + /// <typeparam name="T"></typeparam> | |
| 283 | + /// <param name="dockForm"></param> | |
| 284 | + /// <returns>true:取得成功<br/>false:取得失敗</returns> | |
| 285 | + /// <remarks>DockPanelに存在しないFormの場合、outにはdockFormの新しいインスタンスを設定します。</remarks> | |
| 286 | + public bool GetDockFormImpl<T>( out T dockForm ) | |
| 287 | + where T : class, IDockContent, new() | |
| 288 | + { | |
| 289 | + try | |
| 290 | + { | |
| 291 | + if ( TryGetDockForm( out dockForm ) ) | |
| 292 | + { | |
| 293 | + return true; | |
| 294 | + } | |
| 295 | + else | |
| 296 | + { | |
| 297 | + dockForm = new T(); | |
| 298 | + return true; | |
| 299 | + } | |
| 300 | + } | |
| 301 | + catch ( Exception ) | |
| 302 | + { | |
| 303 | + dockForm = default( T ); | |
| 304 | + return false; | |
| 305 | + } | |
| 306 | + } | |
| 307 | + | |
| 229 | 308 | } |
| 230 | 309 | } |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | using System; |
| 2 | 2 | using Somali.Base; |
| 3 | +using Somali.Models; | |
| 3 | 4 | |
| 4 | 5 | namespace Somali.EnvControl |
| 5 | 6 | { |
| @@ -12,15 +13,25 @@ | ||
| 12 | 13 | |
| 13 | 14 | private void OpenDirectory( SomaliActionArgs e ) |
| 14 | 15 | { |
| 15 | - // TODO:UtilでFileIOをおこなってよいのか?MVCに沿っていない | |
| 16 | - InitializeExplorer( Util.GetDirectoryTree( e.Path ) ); | |
| 16 | + ExplorerModel model = new ExplorerModel(); | |
| 17 | + model.ExplorerTree = resSec.GetExplorerTree( e.Path ); | |
| 18 | + ShowColleague<ExplorerForm>( model ); | |
| 17 | 19 | } |
| 18 | 20 | |
| 19 | 21 | private void ShowExplorer( SomaliActionArgs e ) |
| 20 | 22 | { |
| 21 | - InitializeExplorer( null ); | |
| 23 | + ShowColleague<ExplorerForm>( new ExplorerModel() ); | |
| 22 | 24 | } |
| 23 | 25 | |
| 26 | + private void ShowOutline( SomaliActionArgs e ) | |
| 27 | + { | |
| 28 | + this._mainDockPanel.DefaultFloatWindowSize = new System.Drawing.Size( 580, 300 ); | |
| 29 | + ShowColleague<OutlineForm>( new OutlineModel() ); | |
| 30 | + } | |
| 24 | 31 | |
| 32 | + private void ExpandExplorerNode( SomaliActionArgs e ) | |
| 33 | + { | |
| 34 | + resSec.ExpandExplorerNode( (System.Windows.Forms.TreeNode)e.Arg ); | |
| 35 | + } | |
| 25 | 36 | } |
| 26 | 37 | } |
| @@ -0,0 +1,102 @@ | ||
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | +using System.Windows.Forms; | |
| 6 | +using System.IO; | |
| 7 | + | |
| 8 | +namespace Somali.EnvControl | |
| 9 | +{ | |
| 10 | + class ResourceSecretary : Somali.Base.BaseSecretary | |
| 11 | + { | |
| 12 | + private string _explrDirPath = String.Empty; | |
| 13 | + private TreeNode _explrTree = null; | |
| 14 | + | |
| 15 | + public ResourceSecretary() | |
| 16 | + { | |
| 17 | + } | |
| 18 | + | |
| 19 | + public TreeNode GetExplorerTree( string dirPath ) | |
| 20 | + { | |
| 21 | + | |
| 22 | + //try | |
| 23 | + //{ | |
| 24 | + // Directory.GetFiles( dirPath, "*", SearchOption.AllDirectories ); | |
| 25 | + //} | |
| 26 | + //catch ( UnauthorizedAccessException e ) | |
| 27 | + //{ | |
| 28 | + // MessageBox.Show( "参照権限がありません。\n" + e.Message ); | |
| 29 | + // return null; | |
| 30 | + //} | |
| 31 | + | |
| 32 | + DirectoryInfo dirInfo = new DirectoryInfo( dirPath ); | |
| 33 | + TreeNode root = new TreeNode( dirInfo.Name ); | |
| 34 | + root.ImageIndex = (int)ExplorerForm.NodeIcon.FolderClose; | |
| 35 | + root.SelectedImageIndex = (int)ExplorerForm.NodeIcon.FolderOpen; | |
| 36 | + root.Nodes.Add( "dummy" ); | |
| 37 | + | |
| 38 | + this._explrDirPath = dirInfo.Parent != null ? dirInfo.Parent.FullName : String.Empty; | |
| 39 | + this._explrTree = root; | |
| 40 | + return root; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void ExpandExplorerNode( TreeNode treeNode ) | |
| 44 | + { | |
| 45 | + if ( treeNode == null ) | |
| 46 | + { | |
| 47 | + throw new ArgumentNullException(); | |
| 48 | + } | |
| 49 | + | |
| 50 | + if ( this._explrTree.TreeView.Equals( treeNode.TreeView ) ) | |
| 51 | + { | |
| 52 | + ExpandNode( this._explrDirPath, treeNode ); | |
| 53 | + } | |
| 54 | + else | |
| 55 | + { | |
| 56 | + throw new ArgumentException(); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void ExpandNode( string dirPath, TreeNode treeNode ) | |
| 61 | + { | |
| 62 | + treeNode.Nodes.Clear(); | |
| 63 | + | |
| 64 | + string path = dirPath + (dirPath.Equals( String.Empty ) ? String.Empty : @"\") + treeNode.FullPath; | |
| 65 | + DirectoryInfo dirInfo = new DirectoryInfo( path ); | |
| 66 | + if ( dirInfo.Exists ) | |
| 67 | + { | |
| 68 | + try | |
| 69 | + { | |
| 70 | + DirectoryInfo[] subDir = dirInfo.GetDirectories(); | |
| 71 | + foreach ( DirectoryInfo di in subDir ) | |
| 72 | + { | |
| 73 | + if ( (di.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden ) | |
| 74 | + { | |
| 75 | + TreeNode node = treeNode.Nodes.Add( di.Name ); | |
| 76 | + node.ImageIndex = (int)ExplorerForm.NodeIcon.FolderClose; | |
| 77 | + node.SelectedImageIndex = (int)ExplorerForm.NodeIcon.FolderOpen; | |
| 78 | + | |
| 79 | + node.Nodes.Add( "dummy" ); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + FileInfo[] files = dirInfo.GetFiles(); | |
| 84 | + foreach ( FileInfo fi in files ) | |
| 85 | + { | |
| 86 | + if ( (fi.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden ) | |
| 87 | + { | |
| 88 | + TreeNode node = treeNode.Nodes.Add( fi.Name ); | |
| 89 | + // TODO:拡張子によるアイコンの変更 | |
| 90 | + node.ImageIndex = node.SelectedImageIndex = (int)ExplorerForm.NodeIcon.FilePlain; | |
| 91 | + } | |
| 92 | + } | |
| 93 | + } | |
| 94 | + catch ( UnauthorizedAccessException e ) | |
| 95 | + { | |
| 96 | + MessageBox.Show( "参照権限がありません。\n" + e.Message ); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + } | |
| 102 | +} |
| @@ -4,6 +4,8 @@ | ||
| 4 | 4 | { |
| 5 | 5 | interface IActionColleague |
| 6 | 6 | { |
| 7 | + WeifenLuo.WinFormsUI.Docking.DockState DefaultDockState { get; } | |
| 8 | + | |
| 7 | 9 | void SetMediator( IActionMediator mediator ); |
| 8 | 10 | //void UpdateUI(); |
| 9 | 11 | void Reflesh(); |
| @@ -75,32 +75,6 @@ | ||
| 75 | 75 | } |
| 76 | 76 | #endregion |
| 77 | 77 | |
| 78 | - public static TreeNode GetDirectoryTree( string dirPath ) | |
| 79 | - { | |
| 80 | - // TODO:権限のないフォルダが含まれているとエラーとなる | |
| 81 | - IEnumerable<FileInfo> fileList = Directory.GetFiles( dirPath, "*.*", | |
| 82 | - SearchOption.AllDirectories ).Select( x => new FileInfo( x ) ); | |
| 83 | 78 | |
| 84 | - var query = from f in fileList | |
| 85 | - orderby f.FullName | |
| 86 | - group f by f.DirectoryName; | |
| 87 | - | |
| 88 | - List<TreeNode> dir = new List<TreeNode>(); | |
| 89 | - foreach ( var item in query ) | |
| 90 | - { | |
| 91 | - //Console.WriteLine( "フォルダ名:{0}", item.Key ); | |
| 92 | - List<TreeNode> files = new List<TreeNode>(); | |
| 93 | - foreach ( var f in item ) | |
| 94 | - { | |
| 95 | - //Console.WriteLine( "{0}:{1}", f.CreationTime, f.Name ); | |
| 96 | - files.Add( new TreeNode( f.Name ) ); | |
| 97 | - } | |
| 98 | - dir.Add( new TreeNode( item.Key, files.ToArray() ) ); | |
| 99 | - } | |
| 100 | - | |
| 101 | - TreeNode root = new TreeNode( Directory.GetParent( dirPath ).Name, dir.ToArray() ); | |
| 102 | - return root; | |
| 103 | - } | |
| 104 | - | |
| 105 | 79 | } |
| 106 | 80 | } |