@@ -63,81 +63,86 @@ public override void OnDrop(DragItem source)
6363 }
6464 else panel = DockViewParent as LayoutGroupPanel ;
6565
66- int index = panel . Children . IndexOf ( this ) ;
67- switch ( DropMode )
68- {
69- case DropMode . Left :
70- if ( panel . Direction == Direction . UpToDown )
66+ AttachTo ( panel , child , DropMode ) ;
67+ }
68+ else base . OnDrop ( source ) ;
69+ ( source . RelativeObj as BaseFloatWindow ) . Close ( ) ;
70+ }
71+
72+ public void AttachTo ( LayoutGroupPanel panel , IDockView source , DropMode mode )
73+ {
74+ int index = panel . Children . IndexOf ( this ) ;
75+ switch ( mode )
76+ {
77+ case DropMode . Left :
78+ if ( panel . Direction == Direction . UpToDown )
79+ {
80+ var _subpanel = new LayoutGroupPanel ( Model . Side )
7181 {
72- var _subpanel = new LayoutGroupPanel ( Model . Side )
73- {
74- Direction = Direction . LeftToRight ,
75- DesiredWidth = ActualWidth ,
76- DesiredHeight = ActualHeight ,
77- IsAnchorPanel = true
78- } ;
79- panel . _DetachChild ( this ) ;
80- panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
81- _subpanel . _AttachChild ( this , 0 ) ;
82- _subpanel . AttachChild ( child , AttachMode . Left , 0 ) ;
83- }
84- else panel . _AttachChild ( child , index ) ;
85- break ;
86- case DropMode . Top :
87- if ( panel . Direction == Direction . LeftToRight )
82+ Direction = Direction . LeftToRight ,
83+ DesiredWidth = ActualWidth ,
84+ DesiredHeight = ActualHeight ,
85+ IsAnchorPanel = true
86+ } ;
87+ panel . _DetachChild ( this ) ;
88+ panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
89+ _subpanel . _AttachChild ( this , 0 ) ;
90+ _subpanel . AttachChild ( source , AttachMode . Left , 0 ) ;
91+ }
92+ else panel . _AttachChild ( source , index ) ;
93+ break ;
94+ case DropMode . Top :
95+ if ( panel . Direction == Direction . LeftToRight )
96+ {
97+ var _subpanel = new LayoutGroupPanel ( Model . Side )
8898 {
89- var _subpanel = new LayoutGroupPanel ( Model . Side )
90- {
91- Direction = Direction . UpToDown ,
92- DesiredWidth = ActualWidth ,
93- DesiredHeight = ActualHeight ,
94- IsAnchorPanel = true
95- } ;
96- panel . _DetachChild ( this ) ;
97- panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
98- _subpanel . _AttachChild ( this , 0 ) ;
99- _subpanel . AttachChild ( child , AttachMode . Top , 0 ) ;
100- }
101- else panel . _AttachChild ( child , index ) ;
102- break ;
103- case DropMode . Right :
104- if ( panel . Direction == Direction . UpToDown )
99+ Direction = Direction . UpToDown ,
100+ DesiredWidth = ActualWidth ,
101+ DesiredHeight = ActualHeight ,
102+ IsAnchorPanel = true
103+ } ;
104+ panel . _DetachChild ( this ) ;
105+ panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
106+ _subpanel . _AttachChild ( this , 0 ) ;
107+ _subpanel . AttachChild ( source , AttachMode . Top , 0 ) ;
108+ }
109+ else panel . _AttachChild ( source , index ) ;
110+ break ;
111+ case DropMode . Right :
112+ if ( panel . Direction == Direction . UpToDown )
113+ {
114+ var _subpanel = new LayoutGroupPanel ( Model . Side )
105115 {
106- var _subpanel = new LayoutGroupPanel ( Model . Side )
107- {
108- Direction = Direction . LeftToRight ,
109- DesiredWidth = ActualWidth ,
110- DesiredHeight = ActualHeight ,
111- IsAnchorPanel = true
112- } ;
113- panel . _DetachChild ( this ) ;
114- _subpanel . _AttachChild ( this , 0 ) ;
115- _subpanel . AttachChild ( child , AttachMode . Right , 1 ) ;
116- panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
117- }
118- else panel . _AttachChild ( child , index + 1 ) ;
119- break ;
120- case DropMode . Bottom :
121- if ( panel . Direction == Direction . LeftToRight )
116+ Direction = Direction . LeftToRight ,
117+ DesiredWidth = ActualWidth ,
118+ DesiredHeight = ActualHeight ,
119+ IsAnchorPanel = true
120+ } ;
121+ panel . _DetachChild ( this ) ;
122+ _subpanel . _AttachChild ( this , 0 ) ;
123+ _subpanel . AttachChild ( source , AttachMode . Right , 1 ) ;
124+ panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
125+ }
126+ else panel . _AttachChild ( source , index + 1 ) ;
127+ break ;
128+ case DropMode . Bottom :
129+ if ( panel . Direction == Direction . LeftToRight )
130+ {
131+ var _subpanel = new LayoutGroupPanel ( Model . Side )
122132 {
123- var _subpanel = new LayoutGroupPanel ( Model . Side )
124- {
125- Direction = Direction . UpToDown ,
126- DesiredWidth = ActualWidth ,
127- DesiredHeight = ActualHeight ,
128- IsAnchorPanel = true
129- } ;
130- panel . _DetachChild ( this ) ;
131- _subpanel . _AttachChild ( this , 0 ) ;
132- _subpanel . AttachChild ( child , AttachMode . Bottom , 1 ) ;
133- panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
134- }
135- else panel . _AttachChild ( child , index + 1 ) ;
136- break ;
137- }
133+ Direction = Direction . UpToDown ,
134+ DesiredWidth = ActualWidth ,
135+ DesiredHeight = ActualHeight ,
136+ IsAnchorPanel = true
137+ } ;
138+ panel . _DetachChild ( this ) ;
139+ _subpanel . _AttachChild ( this , 0 ) ;
140+ _subpanel . AttachChild ( source , AttachMode . Bottom , 1 ) ;
141+ panel . _AttachChild ( _subpanel , Math . Min ( index , panel . Count ) ) ;
142+ }
143+ else panel . _AttachChild ( source , index + 1 ) ;
144+ break ;
138145 }
139- else base . OnDrop ( source ) ;
140- ( source . RelativeObj as BaseFloatWindow ) . Close ( ) ;
141146 }
142147 }
143148}
0 commit comments