Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/Somali/EnvControl/CentralMediator.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 95 - (show annotations) (download)
Sun Nov 28 06:24:47 2010 UTC (13 years, 5 months ago) by juan
File size: 3475 byte(s)
mod ExplorerForm with able to open dirTree
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Drawing;
6 using System.Windows.Forms;
7 using WeifenLuo.WinFormsUI.Docking;
8 using Somali.Base;
9 using Somali.Models;
10
11 namespace Somali.EnvControl
12 {
13 partial class CentralMediator : IActionMediator, IDisposable
14 {
15 private Dictionary<SomaliAction, Action<SomaliActionArgs>> _actionMap;
16
17 private PreferencesSecretary prefSec;
18 private LayoutSecretary layoutSec;
19 private ResourceSecretary resSec;
20 private DockPanel _mainDockPanel;
21
22 private SomaliForm _mainForm;
23 /// <summary>
24 /// 実行フォーム
25 /// </summary>
26 public Form RunForm
27 {
28 get { return this._mainForm; }
29 }
30
31 public CentralMediator()
32 {
33 this._mainForm = new SomaliForm();
34 this._mainDockPanel = this._mainForm.MainDockPanel;
35
36 prefSec = new PreferencesSecretary();
37 layoutSec = new LayoutSecretary( this._mainForm, this._mainDockPanel );
38 resSec = new ResourceSecretary();
39
40 InitializeActionMap();
41
42 InitializeColleagues();
43 }
44
45 ~CentralMediator()
46 {
47 Dispose();
48 }
49
50 public void Dispose()
51 {
52 }
53
54 private void InitializeActionMap()
55 {
56 this._actionMap = new Dictionary<SomaliAction, Action<SomaliActionArgs>>();
57 this._actionMap.Add( SomaliAction.Exit, ExitApplication );
58 this._actionMap.Add( SomaliAction.OpenDir, OpenDirectory );
59 this._actionMap.Add( SomaliAction.ShowExplorer, ShowExplorer );
60 this._actionMap.Add( SomaliAction.ShowOutlineAnalizer, ShowOutline );
61 this._actionMap.Add( SomaliAction.ExpandExplorerNode, ExpandExplorerNode );
62 }
63
64 private void InitializeColleagues()
65 {
66 // 設定情報読み込み
67 prefSec.InitPreferences();
68
69 // Layout復元
70 layoutSec.InitializeLayout();
71
72 this._mainForm.SetMediator( this );
73 }
74
75 /// <summary>
76 /// ユーザアクションによる処理振り分け
77 /// </summary>
78 /// <param name="e"></param>
79 public void DispatchAction( SomaliActionArgs e )
80 {
81 Action<SomaliActionArgs> doAction;
82 if ( this._actionMap.TryGetValue( e.ActionID, out doAction ) )
83 {
84 // カーソルを待機状態に
85 Cursor.Current = Cursors.WaitCursor;
86
87 doAction( e );
88
89 // カーソルをデフォルトに戻す
90 Cursor.Current = Cursors.Default;
91 }
92 }
93
94 private void ShowColleague<T>( Model model )
95 where T : DockContent, IDockContent, IActionColleague, new()
96 {
97 T colleague;
98 if ( layoutSec.GetDockFormImpl( out colleague ) )
99 {
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 );
105 }
106 }
107
108
109 }
110 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26