Skip to content

Commit 5a8bbe7

Browse files
committed
V4.2.0 Released
1 parent 024d905 commit 5a8bbe7

File tree

62 files changed

+1450
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1450
-625
lines changed

ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTabPanel.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,6 @@ protected override Size ArrangeOverride( Size finalSize )
9393
return finalSize;
9494
}
9595

96-
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
97-
{
98-
if( e.LeftButton == System.Windows.Input.MouseButtonState.Pressed &&
99-
LayoutAnchorableTabItem.IsDraggingItem() )
100-
{
101-
var contentModel = LayoutAnchorableTabItem.GetDraggingItem().Model as LayoutAnchorable;
102-
var manager = contentModel.Root.Manager;
103-
LayoutAnchorableTabItem.ResetDraggingItem();
104-
105-
manager.StartDraggingFloatingWindowForContent( contentModel );
106-
}
107-
108-
base.OnMouseLeave( e );
109-
}
110-
11196
#endregion
11297
}
11398
}

ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public void Drop( LayoutFloatingWindow floatingWindow )
119119
currentActiveContent.IsSelected = false;
120120
currentActiveContent.IsActive = false;
121121
currentActiveContent.IsActive = true;
122+
currentActiveContent.IsFloating = false;
122123
} ), DispatcherPriority.Background );
123124
}
124125
}

ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ protected override void SetDefaultBindings()
352352
if( DockCommand == null )
353353
this.SetCurrentValue( LayoutAnchorableItem.DockCommandProperty, _defaultDockCommand );
354354

355-
Visibility = _anchorable.IsVisible ? Visibility.Visible : System.Windows.Visibility.Hidden;
355+
this.SetCurrentValue( LayoutAnchorableItem.VisibilityProperty, _anchorable.IsVisible ? Visibility.Visible : System.Windows.Visibility.Hidden );
356356
base.SetDefaultBindings();
357357
}
358358

ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs

Lines changed: 98 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
1515
1616
***********************************************************************************/
1717

18+
using System;
19+
using System.Collections.Generic;
1820
using System.Linq;
1921
using System.Windows;
2022
using System.Windows.Controls;
@@ -27,9 +29,17 @@ public class LayoutAnchorableTabItem : Control
2729
{
2830
#region Members
2931

32+
private static double MinDragBuffer = 5d;
33+
private static double MaxDragBuffer = 50d;
34+
3035
private bool _isMouseDown = false;
31-
private static LayoutAnchorableTabItem _draggingItem = null;
32-
private static bool _cancelMouseLeave = false;
36+
private Point _mouseDownPoint;
37+
private double _mouseLastChangePositionX;
38+
private Rect _parentAnchorableTabPanelScreenArea;
39+
private List<Rect> _otherTabsScreenArea = null;
40+
private List<TabItem> _otherTabs = null;
41+
private AnchorablePaneTabPanel _parentAnchorableTabPanel;
42+
private double _dragBuffer = MinDragBuffer;
3343

3444
#endregion
3545

@@ -136,98 +146,127 @@ protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonE
136146
base.OnMouseLeftButtonDown( e );
137147

138148
_isMouseDown = true;
139-
_draggingItem = this;
149+
_mouseDownPoint = e.GetPosition( this );
140150
}
141151

142152
protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
143153
{
144154
base.OnMouseMove( e );
145155

146-
if( e.LeftButton != MouseButtonState.Pressed )
156+
var ptMouseMove = e.GetPosition( this );
157+
158+
if( _isMouseDown )
147159
{
148-
_isMouseDown = false;
149-
_draggingItem = null;
160+
if( Math.Abs( ptMouseMove.X - _mouseDownPoint.X ) > SystemParameters.MinimumHorizontalDragDistance ||
161+
Math.Abs( ptMouseMove.Y - _mouseDownPoint.Y ) > SystemParameters.MinimumVerticalDragDistance )
162+
{
163+
this.UpdateDragDetails();
164+
this.CaptureMouse();
165+
_isMouseDown = false;
166+
}
150167
}
151-
else
168+
169+
if( this.IsMouseCaptured )
152170
{
153-
_cancelMouseLeave = false;
171+
var mousePosInScreenCoord = this.PointToScreenDPI( ptMouseMove );
172+
173+
if( !_parentAnchorableTabPanelScreenArea.Contains( mousePosInScreenCoord ) )
174+
{
175+
var contentModel = this.Model as LayoutAnchorable;
176+
var manager = contentModel.Root.Manager;
177+
this.ReleaseMouseCapture();
178+
manager.StartDraggingFloatingWindowForContent( contentModel );
179+
}
180+
else
181+
{
182+
int indexOfTabItemWithMouseOver = _otherTabsScreenArea.FindIndex( r => r.Contains( mousePosInScreenCoord ) );
183+
if( indexOfTabItemWithMouseOver >= 0 )
184+
{
185+
var targetModel = _otherTabs[ indexOfTabItemWithMouseOver ].Content as LayoutContent;
186+
var container = this.Model.Parent as ILayoutContainer;
187+
var containerPane = this.Model.Parent as ILayoutPane;
188+
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
189+
190+
// Inside current TabItem, do not care about _mouseLastChangePosition for next change position.
191+
if( targetModel == this.Model )
192+
{
193+
_mouseLastChangePositionX = currentTabScreenArea.Left + ( currentTabScreenArea.Width / 2 );
194+
}
195+
196+
if( ( containerPane is LayoutAnchorablePane ) && !( (LayoutAnchorablePane)containerPane ).CanRepositionItems )
197+
return;
198+
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutAnchorablePaneGroup ) && !( (LayoutAnchorablePaneGroup)containerPane.Parent ).CanRepositionItems )
199+
return;
200+
201+
var childrenList = container.Children.ToList();
202+
var currentIndex = childrenList.IndexOf( this.Model );
203+
var newIndex = childrenList.IndexOf( targetModel );
204+
205+
if( currentIndex != newIndex )
206+
{
207+
// Moving left when cursor leave tabItem or moving left past last change position.
208+
// Or, moving right cursor leave tabItem or moving right past last change position.
209+
if( ( ( mousePosInScreenCoord.X < currentTabScreenArea.Left ) && ( mousePosInScreenCoord.X < _mouseLastChangePositionX ) )
210+
|| ( ( mousePosInScreenCoord.X > ( currentTabScreenArea.Left + currentTabScreenArea.Width ) ) && ( mousePosInScreenCoord.X > _mouseLastChangePositionX ) ) )
211+
{
212+
containerPane.MoveChild( currentIndex, newIndex );
213+
_dragBuffer = MaxDragBuffer;
214+
_parentAnchorableTabPanel.UpdateLayout();
215+
this.UpdateDragDetails();
216+
_mouseLastChangePositionX = mousePosInScreenCoord.X;
217+
}
218+
}
219+
}
220+
}
154221
}
155222
}
156223

157224
protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
158225
{
226+
if( this.IsMouseCaptured )
227+
{
228+
this.ReleaseMouseCapture();
229+
}
159230
_isMouseDown = false;
231+
_dragBuffer = MinDragBuffer;
160232

161233
base.OnMouseLeftButtonUp( e );
162234

163-
Model.IsActive = true;
235+
this.Model.IsActive = true;
164236
}
165237

166238
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
167239
{
168240
base.OnMouseLeave( e );
169-
170-
if( _isMouseDown && e.LeftButton == MouseButtonState.Pressed )
171-
{
172-
// drag the item if the mouse leave is not canceled.
173-
// Mouse leave should be canceled when selecting a new tab to prevent automatic undock when Panel size is Auto.
174-
_draggingItem = !_cancelMouseLeave ? this : null;
175-
}
176-
177241
_isMouseDown = false;
178-
_cancelMouseLeave = false;
179242
}
180243

181244
protected override void OnMouseEnter( MouseEventArgs e )
182245
{
183246
base.OnMouseEnter( e );
184-
185-
if( _draggingItem != null
186-
&& _draggingItem != this
187-
&& e.LeftButton == MouseButtonState.Pressed )
188-
{
189-
var model = Model;
190-
var container = model.Parent as ILayoutContainer;
191-
var containerPane = model.Parent as ILayoutPane;
192-
193-
if( ( containerPane is LayoutAnchorablePane ) && !( ( LayoutAnchorablePane )containerPane ).CanRepositionItems )
194-
return;
195-
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutAnchorablePaneGroup ) && !( ( LayoutAnchorablePaneGroup )containerPane.Parent ).CanRepositionItems )
196-
return;
197-
198-
var childrenList = container.Children.ToList();
199-
containerPane.MoveChild( childrenList.IndexOf( _draggingItem.Model ), childrenList.IndexOf( model ) );
200-
}
201-
}
202-
203-
protected override void OnPreviewGotKeyboardFocus( KeyboardFocusChangedEventArgs e )
204-
{
205-
base.OnPreviewGotKeyboardFocus( e );
206-
247+
_isMouseDown = false;
207248
}
208249

209250
#endregion
210251

211-
#region Internal Methods
212-
213-
internal static bool IsDraggingItem()
214-
{
215-
return _draggingItem != null;
216-
}
252+
#region Private Methods
217253

218-
internal static LayoutAnchorableTabItem GetDraggingItem()
254+
private void UpdateDragDetails()
219255
{
220-
return _draggingItem;
221-
}
222-
internal static void ResetDraggingItem()
223-
{
224-
_draggingItem = null;
225-
}
226-
internal static void CancelMouseLeave()
227-
{
228-
_cancelMouseLeave = true;
256+
_parentAnchorableTabPanel = this.FindLogicalAncestor<AnchorablePaneTabPanel>();
257+
_parentAnchorableTabPanelScreenArea = _parentAnchorableTabPanel.GetScreenArea();
258+
_parentAnchorableTabPanelScreenArea.Inflate( 0, _dragBuffer );
259+
_otherTabs = _parentAnchorableTabPanel.Children.Cast<TabItem>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
260+
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
261+
_otherTabsScreenArea = _otherTabs.Select( ti =>
262+
{
263+
var screenArea = ti.GetScreenArea();
264+
var rect = new Rect( screenArea.Left, screenArea.Top, screenArea.Width, screenArea.Height );
265+
rect.Inflate( 0, _dragBuffer );
266+
return rect;
267+
} ).ToList();
229268
}
230269

231-
#endregion
232-
}
270+
#endregion
271+
}
233272
}

ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentTabItem.cs

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ public class LayoutDocumentTabItem : Control
2929
{
3030
#region Members
3131

32+
private static double MinDragBuffer = 5d;
33+
private static double MaxDragBuffer = 50d;
34+
3235
private List<Rect> _otherTabsScreenArea = null;
3336
private List<TabItem> _otherTabs = null;
3437
private Rect _parentDocumentTabPanelScreenArea;
3538
private DocumentPaneTabPanel _parentDocumentTabPanel;
3639
private bool _isMouseDown = false;
3740
private Point _mouseDownPoint;
41+
private double _mouseLastChangePositionX;
42+
private double _dragBuffer = MinDragBuffer;
3843

3944
#endregion
4045

@@ -159,10 +164,10 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
159164
{
160165
base.OnMouseMove( e );
161166

167+
var ptMouseMove = e.GetPosition( this );
168+
162169
if( _isMouseDown )
163170
{
164-
Point ptMouseMove = e.GetPosition( this );
165-
166171
if( Math.Abs( ptMouseMove.X - _mouseDownPoint.X ) > SystemParameters.MinimumHorizontalDragDistance ||
167172
Math.Abs( ptMouseMove.Y - _mouseDownPoint.Y ) > SystemParameters.MinimumVerticalDragDistance )
168173
{
@@ -174,7 +179,8 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
174179

175180
if( this.IsMouseCaptured )
176181
{
177-
var mousePosInScreenCoord = this.PointToScreenDPI( e.GetPosition( this ) );
182+
var mousePosInScreenCoord = this.PointToScreenDPI( ptMouseMove );
183+
178184
if( !_parentDocumentTabPanelScreenArea.Contains( mousePosInScreenCoord ) )
179185
{
180186
this.StartDraggingFloatingWindowForContent();
@@ -187,17 +193,38 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
187193
var targetModel = _otherTabs[ indexOfTabItemWithMouseOver ].Content as LayoutContent;
188194
var container = this.Model.Parent as ILayoutContainer;
189195
var containerPane = this.Model.Parent as ILayoutPane;
196+
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
190197

191-
if( ( containerPane is LayoutDocumentPane ) && !( ( LayoutDocumentPane )containerPane ).CanRepositionItems )
198+
// Inside current TabItem, do not care about _mouseLastChangePosition for next change position.
199+
if( targetModel == this.Model )
200+
{
201+
_mouseLastChangePositionX = currentTabScreenArea.Left + ( currentTabScreenArea.Width / 2 );
202+
}
203+
204+
if( ( containerPane is LayoutDocumentPane ) && !( (LayoutDocumentPane)containerPane ).CanRepositionItems )
192205
return;
193-
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutDocumentPaneGroup ) && !( ( LayoutDocumentPaneGroup )containerPane.Parent ).CanRepositionItems )
206+
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutDocumentPaneGroup ) && !( (LayoutDocumentPaneGroup)containerPane.Parent ).CanRepositionItems )
194207
return;
195208

196209
var childrenList = container.Children.ToList();
197-
containerPane.MoveChild( childrenList.IndexOf( Model ), childrenList.IndexOf( targetModel ) );
198-
this.Model.IsActive = true;
199-
_parentDocumentTabPanel.UpdateLayout();
200-
this.UpdateDragDetails();
210+
var currentIndex = childrenList.IndexOf( this.Model );
211+
var newIndex = childrenList.IndexOf( targetModel );
212+
213+
if( currentIndex != newIndex )
214+
{
215+
// Moving left when cursor leave tabItem or moving left past last change position.
216+
// Or, moving right cursor leave tabItem or moving right past last change position.
217+
if( ( ( mousePosInScreenCoord.X < currentTabScreenArea.Left ) && ( mousePosInScreenCoord.X < _mouseLastChangePositionX ) )
218+
|| ( ( mousePosInScreenCoord.X > ( currentTabScreenArea.Left + currentTabScreenArea.Width ) ) && ( mousePosInScreenCoord.X > _mouseLastChangePositionX ) ) )
219+
{
220+
containerPane.MoveChild( currentIndex, newIndex );
221+
_dragBuffer = MaxDragBuffer;
222+
this.Model.IsActive = true;
223+
_parentDocumentTabPanel.UpdateLayout();
224+
this.UpdateDragDetails();
225+
_mouseLastChangePositionX = mousePosInScreenCoord.X;
226+
}
227+
}
201228
}
202229
}
203230
}
@@ -206,8 +233,11 @@ protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
206233
protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
207234
{
208235
if( IsMouseCaptured )
209-
ReleaseMouseCapture();
236+
{
237+
this.ReleaseMouseCapture();
238+
}
210239
_isMouseDown = false;
240+
_dragBuffer = MinDragBuffer;
211241

212242
base.OnMouseLeftButtonUp( e );
213243
}
@@ -243,13 +273,15 @@ private void UpdateDragDetails()
243273
{
244274
_parentDocumentTabPanel = this.FindLogicalAncestor<DocumentPaneTabPanel>();
245275
_parentDocumentTabPanelScreenArea = _parentDocumentTabPanel.GetScreenArea();
246-
_otherTabs = _parentDocumentTabPanel.Children.Cast<TabItem>().Where( ch =>
247-
ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
248-
Rect currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
276+
_parentDocumentTabPanelScreenArea.Inflate( 0, _dragBuffer );
277+
_otherTabs = _parentDocumentTabPanel.Children.Cast<TabItem>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
278+
var currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
249279
_otherTabsScreenArea = _otherTabs.Select( ti =>
250280
{
251281
var screenArea = ti.GetScreenArea();
252-
return new Rect( screenArea.Left, screenArea.Top, currentTabScreenArea.Width, screenArea.Height );
282+
var rect = new Rect( screenArea.Left, screenArea.Top, screenArea.Width, screenArea.Height );
283+
rect.Inflate( 0, _dragBuffer );
284+
return rect;
253285
} ).ToList();
254286
}
255287

ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,9 @@ protected virtual void SetDefaultBindings()
11811181
this.SetCurrentValue( LayoutItem.MoveToPreviousTabGroupCommandProperty, _defaultMoveToPreviousTabGroupCommand );
11821182

11831183

1184-
IsSelected = LayoutElement.IsSelected;
1185-
IsActive = LayoutElement.IsActive;
1186-
CanClose = LayoutElement.CanClose;
1184+
this.SetCurrentValue( LayoutItem.IsSelectedProperty, LayoutElement.IsSelected );
1185+
this.SetCurrentValue( LayoutItem.IsActiveProperty, LayoutElement.IsActive );
1186+
this.SetCurrentValue( LayoutItem.CanCloseProperty, LayoutElement.CanClose );
11871187
}
11881188

11891189
protected virtual void OnVisibilityChanged()

0 commit comments

Comments
 (0)