Browse Source

Isolated the grid and made it depend on the DotNetProjects fork of the toolkit.

pull/1653/head
Patrick Kursawe 5 years ago
parent
commit
08e1f835ac
  1. 25
      ExtendedWPFToolkitSolution/DotNetProjects.Xceed.Wpf.DataGrid.sln
  2. 6
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Xceed.Wpf.AvalonDock.Themes.Aero.csproj
  3. 6
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Metro/Xceed.Wpf.AvalonDock.Themes.Metro.csproj
  4. 6
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.VS2010/Xceed.Wpf.AvalonDock.Themes.VS2010.csproj
  5. 32
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/AssemblyVersionInfo.cs
  6. 22
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/AssemblyVersionInfoCommon.cs
  7. 74
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Commands/RelayCommand.cs
  8. 46
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneControlOverlayArea.cs
  9. 343
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneDropTarget.cs
  10. 112
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTabPanel.cs
  11. 212
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs
  12. 96
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs
  13. 56
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/BindingHelper.cs
  14. 52
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs
  15. 259
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DockingManagerDropTarget.cs
  16. 43
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DockingManagerOverlayArea.cs
  17. 42
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneControlOverlayArea.cs
  18. 285
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneDropAsAnchorableTarget.cs
  19. 513
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneDropTarget.cs
  20. 114
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneGroupDropTarget.cs
  21. 111
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneTabPanel.cs
  22. 201
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DragService.cs
  23. 91
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropArea.cs
  24. 149
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropDownButton.cs
  25. 129
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropDownControlArea.cs
  26. 140
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropTarget.cs
  27. 55
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropTargetBase.cs
  28. 45
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropTargetType.cs
  29. 116
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Extentions.cs
  30. 272
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs
  31. 116
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/FullWeakDictionary.cs
  32. 48
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IDropTarget.cs
  33. 35
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindow.cs
  34. 28
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindowArea.cs
  35. 33
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindowDropTarget.cs
  36. 45
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindowHost.cs
  37. 204
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorControl.cs
  38. 116
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorGroupControl.cs
  39. 287
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorSideControl.cs
  40. 162
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableControl.cs
  41. 441
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs
  42. 392
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs
  43. 113
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneControl.cs
  44. 73
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneGroupControl.cs
  45. 231
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs
  46. 583
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAutoHideWindowControl.cs
  47. 183
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentControl.cs
  48. 162
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentFloatingWindowControl.cs
  49. 143
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentItem.cs
  50. 117
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentPaneControl.cs
  51. 73
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentPaneGroupControl.cs
  52. 265
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentTabItem.cs
  53. 587
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs
  54. 579
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs
  55. 96
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridResizerControl.cs
  56. 1252
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutItem.cs
  57. 139
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutPanelControl.cs
  58. 159
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/MenuItemEx.cs
  59. 491
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs
  60. 60
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayArea.cs
  61. 729
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs
  62. 64
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindowDropTarget.cs
  63. 39
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindowDropTargetType.cs
  64. 71
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/ReentrantFlag.cs
  65. 111
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/ComGuids.cs
  66. 389
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/Debug.cs
  67. 148
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/DoubleUtil.cs
  68. 101
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/DpiHelper.cs
  69. 530
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/ErrorCodes.cs
  70. 188
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/MessageWindow.cs
  71. 3545
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/NativeMethods.cs
  72. 995
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/ShellProvider.cs
  73. 357
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/StreamHelper.cs
  74. 1071
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/Utilities.cs
  75. 328
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/Verify.cs
  76. 122
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/SystemCommands.cs
  77. 606
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/SystemParameters2.cs
  78. 303
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/WindowChrome.cs
  79. 1228
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/WindowChromeWorker.cs
  80. 120
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/TransformExtentions.cs
  81. 108
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/WeakDictionary.cs
  82. 42
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/WindowActivateEventArgs.cs
  83. 116
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/WindowHookHandler.cs
  84. 48
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/ActivateCommandLayoutItemFromLayoutModelConverter.cs
  85. 41
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AnchorSideToAngleConverter.cs
  86. 42
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AnchorSideToOrientationConverter.cs
  87. 49
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AnchorableContextMenuHideVisibilityConverter.cs
  88. 49
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AutoHideCommandLayoutItemFromLayoutModelConverter.cs
  89. 87
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/BoolToVisibilityConverter.cs
  90. 49
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/HideCommandLayoutItemFromLayoutModelConverter.cs
  91. 78
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/InverseBoolToVisibilityConverter.cs
  92. 47
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/LayoutItemFromLayoutModelConverter.cs
  93. 37
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/NullToDoNothingConverter.cs
  94. 39
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/UriSourceToBitmapImageConverter.cs
  95. 3324
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DockingManager.cs
  96. 35
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DocumentClosedEventArgs.cs
  97. 35
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DocumentClosingEventArgs.cs
  98. 58
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Extentions.cs
  99. 26
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/AnchorSide.cs
  100. 30
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/AnchorableShowStrategy.cs

25
ExtendedWPFToolkitSolution/DotNetProjects.Xceed.Wpf.DataGrid.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31019.35
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xceed.Wpf.DataGrid", "Src\Xceed.Wpf.DataGrid\Xceed.Wpf.DataGrid.csproj", "{63648392-6CE9-4A60-96D4-F9FD718D29B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Mixed Platforms = Debug|Mixed Platforms
Release|Mixed Platforms = Release|Mixed Platforms
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63648392-6CE9-4A60-96D4-F9FD718D29B0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{63648392-6CE9-4A60-96D4-F9FD718D29B0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{63648392-6CE9-4A60-96D4-F9FD718D29B0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{63648392-6CE9-4A60-96D4-F9FD718D29B0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {10BA5F90-D450-4394-AAC4-225D67CA0E65}
EndGlobalSection
EndGlobal

6
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Xceed.Wpf.AvalonDock.Themes.Aero.csproj

@ -59,12 +59,6 @@
<Compile Include="AeroTheme.cs" />
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xceed.Wpf.AvalonDock\Xceed.Wpf.AvalonDock.csproj">
<Project>{DB81988F-E0F2-45A0-A1FD-8C37F3D35244}</Project>
<Name>Xceed.Wpf.AvalonDock</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Brushes.xaml">
<Generator>MSBuild:Compile</Generator>

6
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Metro/Xceed.Wpf.AvalonDock.Themes.Metro.csproj

@ -104,12 +104,6 @@
<Resource Include="Images\PinRestore_Dark.png" />
<Resource Include="Images\VTabGroup.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xceed.Wpf.AvalonDock\Xceed.Wpf.AvalonDock.csproj">
<Project>{DB81988F-E0F2-45A0-A1FD-8C37F3D35244}</Project>
<Name>Xceed.Wpf.AvalonDock</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

6
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.VS2010/Xceed.Wpf.AvalonDock.Themes.VS2010.csproj

@ -112,12 +112,6 @@
<Resource Include="Images\PinMaximize_Dark.png" />
<Resource Include="Images\PinRestore_Dark.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xceed.Wpf.AvalonDock\Xceed.Wpf.AvalonDock.csproj">
<Project>{DB81988F-E0F2-45A0-A1FD-8C37F3D35244}</Project>
<Name>Xceed.Wpf.AvalonDock</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\PinDocMenu_Black.png" />
</ItemGroup>

32
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/AssemblyVersionInfo.cs

@ -1,32 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
#pragma warning disable 0436
[assembly: System.Reflection.AssemblyVersion( _XceedVersionInfo.Version )]
#pragma warning restore 0436
internal static class _XceedVersionInfo
{
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string BaseVersion = "3.4";
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string Version = BaseVersion +
".0.0";
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string PublicKeyToken = "ba83ff368b7563c6";
}

22
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/AssemblyVersionInfoCommon.cs

@ -1,22 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
internal static class _XceedVersionInfoCommon
{
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string Build = ".*";
}

74
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Commands/RelayCommand.cs

@ -1,74 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Input;
namespace Xceed.Wpf.AvalonDock.Commands
{
internal class RelayCommand : ICommand
{
#region Fields
private readonly Action<object> _execute;
private readonly Predicate<object> _canExecute;
#endregion // Fields
#region Constructors
public RelayCommand( Action<object> execute )
: this( execute, null )
{
}
public RelayCommand( Action<object> execute, Predicate<object> canExecute )
{
if( execute == null )
throw new ArgumentNullException( "execute" );
_execute = execute;
_canExecute = canExecute;
}
#endregion // Constructors
#region ICommand Members
public bool CanExecute( object parameter )
{
return _canExecute == null ? true : _canExecute( parameter );
}
public event EventHandler CanExecuteChanged
{
add
{
CommandManager.RequerySuggested += value;
}
remove
{
CommandManager.RequerySuggested -= value;
}
}
public void Execute( object parameter )
{
_execute( parameter );
}
#endregion // ICommand Members
}
}

46
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneControlOverlayArea.cs

@ -1,46 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class AnchorablePaneControlOverlayArea : OverlayArea
{
#region Members
private LayoutAnchorablePaneControl _anchorablePaneControl;
#endregion
#region constructors
internal AnchorablePaneControlOverlayArea(
IOverlayWindow overlayWindow,
LayoutAnchorablePaneControl anchorablePaneControl )
: base( overlayWindow )
{
_anchorablePaneControl = anchorablePaneControl;
base.SetScreenDetectionArea( new Rect(
_anchorablePaneControl.PointToScreenDPI( new Point() ),
_anchorablePaneControl.TransformActualSizeToAncestor() ) );
}
#endregion
}
}

343
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneDropTarget.cs

@ -1,343 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class AnchorablePaneDropTarget : DropTarget<LayoutAnchorablePaneControl>
{
#region Members
private LayoutAnchorablePaneControl _targetPane;
int _tabIndex = -1;
#endregion
#region Constructors
internal AnchorablePaneDropTarget( LayoutAnchorablePaneControl paneControl, Rect detectionRect, DropTargetType type )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
}
internal AnchorablePaneDropTarget( LayoutAnchorablePaneControl paneControl, Rect detectionRect, DropTargetType type, int tabIndex )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
_tabIndex = tabIndex;
}
#endregion
#region Overrides
protected override void Drop( LayoutAnchorableFloatingWindow floatingWindow )
{
ILayoutAnchorablePane targetModel = _targetPane.Model as ILayoutAnchorablePane;
LayoutAnchorable anchorableActive = floatingWindow.Descendents().OfType<LayoutAnchorable>().FirstOrDefault();
switch( Type )
{
case DropTargetType.AnchorablePaneDockBottom:
#region DropTargetType.AnchorablePaneDockBottom
{
var parentModel = targetModel.Parent as ILayoutGroup;
var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
int insertToIndex = parentModel.IndexOfChild( targetModel );
if( parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Vertical &&
parentModel.ChildrenCount == 1 )
parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Vertical;
if( parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Vertical )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
( layoutAnchorablePaneGroup.Children.Count == 1 ||
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical ) )
{
var anchorablesToMove = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < anchorablesToMove.Length; i++ )
parentModel.InsertChildAt( insertToIndex + 1 + i, anchorablesToMove[ i ] );
}
else
parentModel.InsertChildAt( insertToIndex + 1, floatingWindow.RootPanel );
}
else
{
var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
var newOrientedPanel = new LayoutAnchorablePaneGroup()
{
Orientation = System.Windows.Controls.Orientation.Vertical,
DockWidth = targetModelAsPositionableElement.DockWidth,
DockHeight = targetModelAsPositionableElement.DockHeight,
};
parentModel.InsertChildAt( insertToIndex, newOrientedPanel );
newOrientedPanel.Children.Add( targetModel );
newOrientedPanel.Children.Add( floatingWindow.RootPanel );
}
}
break;
#endregion
case DropTargetType.AnchorablePaneDockTop:
#region DropTargetType.AnchorablePaneDockTop
{
var parentModel = targetModel.Parent as ILayoutGroup;
var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
int insertToIndex = parentModel.IndexOfChild( targetModel );
if( parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Vertical &&
parentModel.ChildrenCount == 1 )
parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Vertical;
if( parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Vertical )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
( layoutAnchorablePaneGroup.Children.Count == 1 ||
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical ) )
{
var anchorablesToMove = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < anchorablesToMove.Length; i++ )
parentModel.InsertChildAt( insertToIndex + i, anchorablesToMove[ i ] );
}
else
parentModel.InsertChildAt( insertToIndex, floatingWindow.RootPanel );
}
else
{
var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
var newOrientedPanel = new LayoutAnchorablePaneGroup()
{
Orientation = System.Windows.Controls.Orientation.Vertical,
DockWidth = targetModelAsPositionableElement.DockWidth,
DockHeight = targetModelAsPositionableElement.DockHeight,
};
parentModel.InsertChildAt( insertToIndex, newOrientedPanel );
//the floating window must be added after the target modal as it could be raise a CollectGarbage call
newOrientedPanel.Children.Add( targetModel );
newOrientedPanel.Children.Insert( 0, floatingWindow.RootPanel );
}
}
break;
#endregion
case DropTargetType.AnchorablePaneDockLeft:
#region DropTargetType.AnchorablePaneDockLeft
{
var parentModel = targetModel.Parent as ILayoutGroup;
var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
int insertToIndex = parentModel.IndexOfChild( targetModel );
if( parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Horizontal &&
parentModel.ChildrenCount == 1 )
parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Horizontal;
if( parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
( layoutAnchorablePaneGroup.Children.Count == 1 ||
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal ) )
{
var anchorablesToMove = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < anchorablesToMove.Length; i++ )
parentModel.InsertChildAt( insertToIndex + i, anchorablesToMove[ i ] );
}
else
parentModel.InsertChildAt( insertToIndex, floatingWindow.RootPanel );
}
else
{
var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
var newOrientedPanel = new LayoutAnchorablePaneGroup()
{
Orientation = System.Windows.Controls.Orientation.Horizontal,
DockWidth = targetModelAsPositionableElement.DockWidth,
DockHeight = targetModelAsPositionableElement.DockHeight,
};
parentModel.InsertChildAt( insertToIndex, newOrientedPanel );
//the floating window must be added after the target modal as it could be raise a CollectGarbage call
newOrientedPanel.Children.Add( targetModel );
newOrientedPanel.Children.Insert( 0, floatingWindow.RootPanel );
}
}
break;
#endregion
case DropTargetType.AnchorablePaneDockRight:
#region DropTargetType.AnchorablePaneDockRight
{
var parentModel = targetModel.Parent as ILayoutGroup;
var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
int insertToIndex = parentModel.IndexOfChild( targetModel );
if( parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Horizontal &&
parentModel.ChildrenCount == 1 )
parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Horizontal;
if( parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
( layoutAnchorablePaneGroup.Children.Count == 1 ||
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal ) )
{
var anchorablesToMove = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < anchorablesToMove.Length; i++ )
parentModel.InsertChildAt( insertToIndex + 1 + i, anchorablesToMove[ i ] );
}
else
parentModel.InsertChildAt( insertToIndex + 1, floatingWindow.RootPanel );
}
else
{
var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
var newOrientedPanel = new LayoutAnchorablePaneGroup()
{
Orientation = System.Windows.Controls.Orientation.Horizontal,
DockWidth = targetModelAsPositionableElement.DockWidth,
DockHeight = targetModelAsPositionableElement.DockHeight,
};
parentModel.InsertChildAt( insertToIndex, newOrientedPanel );
newOrientedPanel.Children.Add( targetModel );
newOrientedPanel.Children.Add( floatingWindow.RootPanel );
}
}
break;
#endregion
case DropTargetType.AnchorablePaneDockInside:
#region DropTargetType.AnchorablePaneDockInside
{
var paneModel = targetModel as LayoutAnchorablePane;
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
int i = _tabIndex == -1 ? 0 : _tabIndex;
foreach( var anchorableToImport in
layoutAnchorablePaneGroup.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
paneModel.Children.Insert( i, anchorableToImport );
i++;
}
}
break;
#endregion
}
anchorableActive.IsActive = true;
base.Drop( floatingWindow );
}
public override System.Windows.Media.Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel )
{
//var anchorablePaneDropTarget = target as AnchorablePaneDropTarget;
var anchorableFloatingWindowModel = floatingWindowModel as LayoutAnchorableFloatingWindow;
var layoutAnchorablePane = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElement;
var layoutAnchorablePaneWithActualSize = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElementWithActualSize;
switch( Type )
{
case DropTargetType.AnchorablePaneDockBottom:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Offset( 0.0, targetScreenRect.Height / 2.0 );
targetScreenRect.Height /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.AnchorablePaneDockTop:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Height /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.AnchorablePaneDockLeft:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Width /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.AnchorablePaneDockRight:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Offset( targetScreenRect.Width / 2.0, 0.0 );
targetScreenRect.Width /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.AnchorablePaneDockInside:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
if( _tabIndex == -1 )
{
return new RectangleGeometry( targetScreenRect );
}
else
{
var translatedDetectionRect = new Rect( DetectionRects[ 0 ].TopLeft, DetectionRects[ 0 ].BottomRight );
translatedDetectionRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
var pathFigure = new PathFigure();
pathFigure.StartPoint = targetScreenRect.TopLeft;
pathFigure.Segments.Add( new LineSegment() { Point = new Point( targetScreenRect.Left, translatedDetectionRect.Top ) } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.TopLeft } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.BottomLeft } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.BottomRight } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.TopRight } );
pathFigure.Segments.Add( new LineSegment() { Point = new Point( targetScreenRect.Right, translatedDetectionRect.Top ) } );
pathFigure.Segments.Add( new LineSegment() { Point = targetScreenRect.TopRight } );
pathFigure.IsClosed = true;
pathFigure.IsFilled = true;
pathFigure.Freeze();
return new PathGeometry( new PathFigure[] { pathFigure } );
}
}
}
return null;
}
#endregion
}
}

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

@ -1,112 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class AnchorablePaneTabPanel : Panel
{
#region Constructors
public AnchorablePaneTabPanel()
{
this.FlowDirection = System.Windows.FlowDirection.LeftToRight;
}
#endregion
#region Overrides
protected override Size MeasureOverride( Size availableSize )
{
double totWidth = 0;
double maxHeight = 0;
var visibleChildren = Children.Cast<UIElement>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed );
foreach( FrameworkElement child in visibleChildren )
{
child.Measure( new Size( double.PositiveInfinity, availableSize.Height ) );
totWidth += child.DesiredSize.Width;
maxHeight = Math.Max( maxHeight, child.DesiredSize.Height );
}
if( totWidth > availableSize.Width )
{
double childFinalDesideredWidth = availableSize.Width / visibleChildren.Count();
foreach( FrameworkElement child in visibleChildren )
{
child.Measure( new Size( childFinalDesideredWidth, availableSize.Height ) );
}
}
return new Size( Math.Min( availableSize.Width, totWidth ), maxHeight );
}
protected override Size ArrangeOverride( Size finalSize )
{
var visibleChildren = Children.Cast<UIElement>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed );
double finalWidth = finalSize.Width;
double desideredWidth = visibleChildren.Sum( ch => ch.DesiredSize.Width );
double offsetX = 0.0;
if( finalWidth > desideredWidth )
{
foreach( FrameworkElement child in visibleChildren )
{
double childFinalWidth = child.DesiredSize.Width;
child.Arrange( new Rect( offsetX, 0, childFinalWidth, finalSize.Height ) );
offsetX += childFinalWidth;
}
}
else
{
double childFinalWidth = finalWidth / visibleChildren.Count();
foreach( FrameworkElement child in visibleChildren )
{
child.Arrange( new Rect( offsetX, 0, childFinalWidth, finalSize.Height ) );
offsetX += childFinalWidth;
}
}
return finalSize;
}
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
if( e.LeftButton == System.Windows.Input.MouseButtonState.Pressed &&
LayoutAnchorableTabItem.IsDraggingItem() )
{
var contentModel = LayoutAnchorableTabItem.GetDraggingItem().Model as LayoutAnchorable;
var manager = contentModel.Root.Manager;
LayoutAnchorableTabItem.ResetDraggingItem();
manager.StartDraggingFloatingWindowForContent( contentModel );
}
base.OnMouseLeave( e );
}
#endregion
}
}

212
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs

@ -1,212 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Linq;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class AnchorablePaneTitle : Control
{
#region Members
private bool _isMouseDown = false;
#endregion
#region Constructors
static AnchorablePaneTitle()
{
IsHitTestVisibleProperty.OverrideMetadata( typeof( AnchorablePaneTitle ), new FrameworkPropertyMetadata( true ) );
FocusableProperty.OverrideMetadata( typeof( AnchorablePaneTitle ), new FrameworkPropertyMetadata( false ) );
DefaultStyleKeyProperty.OverrideMetadata( typeof( AnchorablePaneTitle ), new FrameworkPropertyMetadata( typeof( AnchorablePaneTitle ) ) );
}
public AnchorablePaneTitle()
{
}
#endregion
#region Properties
#region Model
/// <summary>
/// Model Dependency Property
/// </summary>
public static readonly DependencyProperty ModelProperty = DependencyProperty.Register( "Model", typeof( LayoutAnchorable ), typeof( AnchorablePaneTitle ),
new FrameworkPropertyMetadata( ( LayoutAnchorable )null, new PropertyChangedCallback( _OnModelChanged ) ) );
/// <summary>
/// Gets or sets the Model property. This dependency property
/// indicates model attached to this view.
/// </summary>
public LayoutAnchorable Model
{
get
{
return ( LayoutAnchorable )GetValue( ModelProperty );
}
set
{
SetValue( ModelProperty, value );
}
}
private static void _OnModelChanged( DependencyObject sender, DependencyPropertyChangedEventArgs e )
{
( ( AnchorablePaneTitle )sender ).OnModelChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Model property.
/// </summary>
protected virtual void OnModelChanged( DependencyPropertyChangedEventArgs e )
{
if( Model != null )
{
this.SetLayoutItem( Model.Root.Manager.GetLayoutItemFromModel( Model ) );
}
else
{
this.SetLayoutItem( null );
}
}
#endregion
#region LayoutItem
/// <summary>
/// LayoutItem Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly( "LayoutItem", typeof( LayoutItem ), typeof( AnchorablePaneTitle ),
new FrameworkPropertyMetadata( ( LayoutItem )null ) );
public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty;
/// <summary>
/// Gets the LayoutItem property. This dependency property
/// indicates the LayoutItem attached to this tag item.
/// </summary>
public LayoutItem LayoutItem
{
get
{
return ( LayoutItem )GetValue( LayoutItemProperty );
}
}
/// <summary>
/// Provides a secure method for setting the LayoutItem property.
/// This dependency property indicates the LayoutItem attached to this tag item.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetLayoutItem( LayoutItem value )
{
this.SetValue( LayoutItemPropertyKey, value );
}
#endregion
#endregion
#region Overrides
protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
{
if( e.LeftButton != MouseButtonState.Pressed )
{
_isMouseDown = false;
}
base.OnMouseMove( e );
}
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseLeave( e );
if( _isMouseDown && e.LeftButton == MouseButtonState.Pressed )
{
var pane = this.FindVisualAncestor<LayoutAnchorablePaneControl>();
if( pane != null )
{
var paneModel = pane.Model as LayoutAnchorablePane;
var manager = paneModel.Root.Manager;
manager.StartDraggingFloatingWindowForPane( paneModel );
}
}
_isMouseDown = false;
}
protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseLeftButtonDown( e );
if( !e.Handled )
{
bool attachFloatingWindow = false;
var parentFloatingWindow = Model.FindParent<LayoutAnchorableFloatingWindow>();
if( parentFloatingWindow != null )
{
attachFloatingWindow = parentFloatingWindow.Descendents().OfType<LayoutAnchorablePane>().Count() == 1;
}
if( attachFloatingWindow )
{
//the pane is hosted inside a floating window that contains only an anchorable pane so drag the floating window itself
var floatingWndControl = Model.Root.Manager.FloatingWindows.Single( fwc => fwc.Model == parentFloatingWindow );
floatingWndControl.AttachDrag( false );
}
else
_isMouseDown = true;//normal drag
}
}
protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
_isMouseDown = false;
base.OnMouseLeftButtonUp( e );
if( Model != null )
Model.IsActive = true;//FocusElementManager.SetFocusOnLastElement(Model);
}
#endregion
#region Private Methods
private void OnHide()
{
this.Model.Hide();
}
private void OnToggleAutoHide()
{
this.Model.ToggleAutoHide();
}
#endregion
}
}

96
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs

@ -1,96 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Threading;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class AutoHideWindowManager
{
#region Members
private DockingManager _manager;
private WeakReference _currentAutohiddenAnchor = null;
private DispatcherTimer _closeTimer = null;
#endregion
#region Constructors
internal AutoHideWindowManager( DockingManager manager )
{
_manager = manager;
this.SetupCloseTimer();
}
#endregion
#region Private Methods
public void ShowAutoHideWindow( LayoutAnchorControl anchor )
{
if( _currentAutohiddenAnchor.GetValueOrDefault<LayoutAnchorControl>() != anchor )
{
StopCloseTimer();
_currentAutohiddenAnchor = new WeakReference( anchor );
_manager.AutoHideWindow.Show( anchor );
StartCloseTimer();
}
}
public void HideAutoWindow( LayoutAnchorControl anchor = null )
{
if( anchor == null ||
anchor == _currentAutohiddenAnchor.GetValueOrDefault<LayoutAnchorControl>() )
{
StopCloseTimer();
}
else
System.Diagnostics.Debug.Assert( false );
}
private void SetupCloseTimer()
{
_closeTimer = new DispatcherTimer( DispatcherPriority.Background );
_closeTimer.Interval = TimeSpan.FromMilliseconds( 1500 );
_closeTimer.Tick += ( s, e ) =>
{
if( _manager.AutoHideWindow.IsWin32MouseOver ||
( ( LayoutAnchorable )_manager.AutoHideWindow.Model ).IsActive ||
_manager.AutoHideWindow.IsResizing )
return;
StopCloseTimer();
};
}
private void StartCloseTimer()
{
_closeTimer.Start();
}
private void StopCloseTimer()
{
_closeTimer.Stop();
_manager.AutoHideWindow.Hide();
_currentAutohiddenAnchor = null;
}
#endregion
}
}

56
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/BindingHelper.cs

@ -1,56 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows;
using System.ComponentModel;
using System.Windows.Data;
using System.Windows.Threading;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class BindingHelper
{
#region Methods
public static void RebindInactiveBindings( DependencyObject dependencyObject )
{
foreach( PropertyDescriptor property in TypeDescriptor.GetProperties( dependencyObject.GetType() ) )
{
var dpd = DependencyPropertyDescriptor.FromProperty( property );
if( dpd != null )
{
BindingExpressionBase binding = BindingOperations.GetBindingExpressionBase( dependencyObject, dpd.DependencyProperty );
if( binding != null )
{
//if (property.Name == "DataContext" || binding.HasError || binding.Status != BindingStatus.Active)
{
// Ensure that no pending calls are in the dispatcher queue
Dispatcher.CurrentDispatcher.BeginInvoke( DispatcherPriority.SystemIdle, ( Action )delegate
{
// Remove and add the binding to re-trigger the binding error
dependencyObject.ClearValue( dpd.DependencyProperty );
BindingOperations.SetBinding( dependencyObject, dpd.DependencyProperty, binding.ParentBindingBase );
} );
}
}
}
}
}
#endregion
}
}

52
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs

@ -1,52 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows.Controls;
using System.Windows.Data;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class ContextMenuEx : ContextMenu
{
#region Constructors
static ContextMenuEx()
{
}
public ContextMenuEx()
{
}
#endregion
#region Overrides
protected override System.Windows.DependencyObject GetContainerForItemOverride()
{
return new MenuItemEx();
}
protected override void OnOpened( System.Windows.RoutedEventArgs e )
{
BindingOperations.GetBindingExpression( this, ItemsSourceProperty ).UpdateTarget();
base.OnOpened( e );
}
#endregion
}
}

259
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DockingManagerDropTarget.cs

@ -1,259 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class DockingManagerDropTarget : DropTarget<DockingManager>
{
#region Members
private DockingManager _manager;
#endregion
#region Constructors
internal DockingManagerDropTarget( DockingManager manager, Rect detectionRect, DropTargetType type )
: base( manager, detectionRect, type )
{
_manager = manager;
}
#endregion
#region Overrides
protected override void Drop( LayoutAnchorableFloatingWindow floatingWindow )
{
switch( Type )
{
case DropTargetType.DockingManagerDockLeft:
#region DropTargetType.DockingManagerDockLeft
{
if( _manager.Layout.RootPanel.Orientation != System.Windows.Controls.Orientation.Horizontal &&
_manager.Layout.RootPanel.Children.Count == 1 )
_manager.Layout.RootPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
if( _manager.Layout.RootPanel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
var childrenToTransfer = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < childrenToTransfer.Length; i++ )
_manager.Layout.RootPanel.Children.Insert( i, childrenToTransfer[ i ] );
}
else
_manager.Layout.RootPanel.Children.Insert( 0, floatingWindow.RootPanel );
}
else
{
var newOrientedPanel = new LayoutPanel()
{
Orientation = System.Windows.Controls.Orientation.Horizontal
};
newOrientedPanel.Children.Add( floatingWindow.RootPanel );
newOrientedPanel.Children.Add( _manager.Layout.RootPanel );
_manager.Layout.RootPanel = newOrientedPanel;
}
}
break;
#endregion
case DropTargetType.DockingManagerDockRight:
#region DropTargetType.DockingManagerDockRight
{
if( _manager.Layout.RootPanel.Orientation != System.Windows.Controls.Orientation.Horizontal &&
_manager.Layout.RootPanel.Children.Count == 1 )
_manager.Layout.RootPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
if( _manager.Layout.RootPanel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
var childrenToTransfer = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < childrenToTransfer.Length; i++ )
_manager.Layout.RootPanel.Children.Add( childrenToTransfer[ i ] );
}
else
_manager.Layout.RootPanel.Children.Add( floatingWindow.RootPanel );
}
else
{
var newOrientedPanel = new LayoutPanel()
{
Orientation = System.Windows.Controls.Orientation.Horizontal
};
newOrientedPanel.Children.Add( floatingWindow.RootPanel );
newOrientedPanel.Children.Insert( 0, _manager.Layout.RootPanel );
_manager.Layout.RootPanel = newOrientedPanel;
}
}
break;
#endregion
case DropTargetType.DockingManagerDockTop:
#region DropTargetType.DockingManagerDockTop
{
if( _manager.Layout.RootPanel.Orientation != System.Windows.Controls.Orientation.Vertical &&
_manager.Layout.RootPanel.Children.Count == 1 )
_manager.Layout.RootPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
if( _manager.Layout.RootPanel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical )
{
var childrenToTransfer = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < childrenToTransfer.Length; i++ )
_manager.Layout.RootPanel.Children.Insert( i, childrenToTransfer[ i ] );
}
else
_manager.Layout.RootPanel.Children.Insert( 0, floatingWindow.RootPanel );
}
else
{
var newOrientedPanel = new LayoutPanel()
{
Orientation = System.Windows.Controls.Orientation.Vertical
};
newOrientedPanel.Children.Add( floatingWindow.RootPanel );
newOrientedPanel.Children.Add( _manager.Layout.RootPanel );
_manager.Layout.RootPanel = newOrientedPanel;
}
}
break;
#endregion
case DropTargetType.DockingManagerDockBottom:
#region DropTargetType.DockingManagerDockBottom
{
if( _manager.Layout.RootPanel.Orientation != System.Windows.Controls.Orientation.Vertical &&
_manager.Layout.RootPanel.Children.Count == 1 )
_manager.Layout.RootPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
if( _manager.Layout.RootPanel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
if( layoutAnchorablePaneGroup != null &&
layoutAnchorablePaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical )
{
var childrenToTransfer = layoutAnchorablePaneGroup.Children.ToArray();
for( int i = 0; i < childrenToTransfer.Length; i++ )
_manager.Layout.RootPanel.Children.Add( childrenToTransfer[ i ] );
}
else
_manager.Layout.RootPanel.Children.Add( floatingWindow.RootPanel );
}
else
{
var newOrientedPanel = new LayoutPanel()
{
Orientation = System.Windows.Controls.Orientation.Vertical
};
newOrientedPanel.Children.Add( floatingWindow.RootPanel );
newOrientedPanel.Children.Insert( 0, _manager.Layout.RootPanel );
_manager.Layout.RootPanel = newOrientedPanel;
}
}
break;
#endregion
}
base.Drop( floatingWindow );
}
public override System.Windows.Media.Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel )
{
var anchorableFloatingWindowModel = floatingWindowModel as LayoutAnchorableFloatingWindow;
var layoutAnchorablePane = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElement;
var layoutAnchorablePaneWithActualSize = anchorableFloatingWindowModel.RootPanel as ILayoutPositionableElementWithActualSize;
var targetScreenRect = TargetElement.GetScreenArea();
switch( Type )
{
case DropTargetType.DockingManagerDockLeft:
{
var desideredWidth = layoutAnchorablePane.DockWidth.IsAbsolute ? layoutAnchorablePane.DockWidth.Value : layoutAnchorablePaneWithActualSize.ActualWidth;
var previewBoxRect = new Rect(
targetScreenRect.Left - overlayWindow.Left,
targetScreenRect.Top - overlayWindow.Top,
Math.Min( desideredWidth, targetScreenRect.Width / 2.0 ),
targetScreenRect.Height );
return new RectangleGeometry( previewBoxRect );
}
case DropTargetType.DockingManagerDockTop:
{
var desideredHeight = layoutAnchorablePane.DockHeight.IsAbsolute ? layoutAnchorablePane.DockHeight.Value : layoutAnchorablePaneWithActualSize.ActualHeight;
var previewBoxRect = new Rect(
targetScreenRect.Left - overlayWindow.Left,
targetScreenRect.Top - overlayWindow.Top,
targetScreenRect.Width,
Math.Min( desideredHeight, targetScreenRect.Height / 2.0 ) );
return new RectangleGeometry( previewBoxRect );
}
case DropTargetType.DockingManagerDockRight:
{
var desideredWidth = layoutAnchorablePane.DockWidth.IsAbsolute ? layoutAnchorablePane.DockWidth.Value : layoutAnchorablePaneWithActualSize.ActualWidth;
var previewBoxRect = new Rect(
targetScreenRect.Right - overlayWindow.Left - Math.Min( desideredWidth, targetScreenRect.Width / 2.0 ),
targetScreenRect.Top - overlayWindow.Top,
Math.Min( desideredWidth, targetScreenRect.Width / 2.0 ),
targetScreenRect.Height );
return new RectangleGeometry( previewBoxRect );
}
case DropTargetType.DockingManagerDockBottom:
{
var desideredHeight = layoutAnchorablePane.DockHeight.IsAbsolute ? layoutAnchorablePane.DockHeight.Value : layoutAnchorablePaneWithActualSize.ActualHeight;
var previewBoxRect = new Rect(
targetScreenRect.Left - overlayWindow.Left,
targetScreenRect.Bottom - overlayWindow.Top - Math.Min( desideredHeight, targetScreenRect.Height / 2.0 ),
targetScreenRect.Width,
Math.Min( desideredHeight, targetScreenRect.Height / 2.0 ) );
return new RectangleGeometry( previewBoxRect );
}
}
throw new InvalidOperationException();
}
#endregion
}
}

43
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DockingManagerOverlayArea.cs

@ -1,43 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class DockingManagerOverlayArea : OverlayArea
{
#region Members
private DockingManager _manager;
#endregion
#region Constructors
internal DockingManagerOverlayArea( IOverlayWindow overlayWindow, DockingManager manager )
: base( overlayWindow )
{
_manager = manager;
base.SetScreenDetectionArea( new Rect(
_manager.PointToScreenDPI( new Point() ),
_manager.TransformActualSizeToAncestor() ) );
}
#endregion
}
}

42
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneControlOverlayArea.cs

@ -1,42 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class DocumentPaneControlOverlayArea : OverlayArea
{
#region Members
private LayoutDocumentPaneControl _documentPaneControl;
#endregion
#region Constructors
internal DocumentPaneControlOverlayArea(
IOverlayWindow overlayWindow,
LayoutDocumentPaneControl documentPaneControl )
: base( overlayWindow )
{
_documentPaneControl = documentPaneControl;
base.SetScreenDetectionArea( new Rect( _documentPaneControl.PointToScreenDPI( new Point() ), _documentPaneControl.TransformActualSizeToAncestor() ) );
}
#endregion
}
}

285
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneDropAsAnchorableTarget.cs

@ -1,285 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class DocumentPaneDropAsAnchorableTarget : DropTarget<LayoutDocumentPaneControl>
{
#region Members
private LayoutDocumentPaneControl _targetPane;
int _tabIndex = -1;
#endregion
#region Constructors
internal DocumentPaneDropAsAnchorableTarget( LayoutDocumentPaneControl paneControl, Rect detectionRect, DropTargetType type )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
}
internal DocumentPaneDropAsAnchorableTarget( LayoutDocumentPaneControl paneControl, Rect detectionRect, DropTargetType type, int tabIndex )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
_tabIndex = tabIndex;
}
#endregion
#region Overrides
protected override void Drop( LayoutAnchorableFloatingWindow floatingWindow )
{
ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
LayoutDocumentPaneGroup parentGroup;
LayoutPanel parentGroupPanel;
FindParentLayoutDocumentPane( targetModel, out parentGroup, out parentGroupPanel );
switch( Type )
{
case DropTargetType.DocumentPaneDockAsAnchorableBottom:
#region DropTargetType.DocumentPaneDockAsAnchorableBottom
{
if( parentGroupPanel != null &&
parentGroupPanel.ChildrenCount == 1 )
parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
if( parentGroupPanel != null &&
parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
parentGroupPanel.Children.Insert(
parentGroupPanel.IndexOfChild( parentGroup != null ? parentGroup : targetModel ) + 1,
floatingWindow.RootPanel );
}
else if( parentGroupPanel != null )
{
var newParentPanel = new LayoutPanel() { Orientation = System.Windows.Controls.Orientation.Vertical };
parentGroupPanel.ReplaceChild( parentGroup != null ? parentGroup : targetModel, newParentPanel );
newParentPanel.Children.Add( parentGroup != null ? parentGroup : targetModel );
newParentPanel.Children.Add( floatingWindow.RootPanel );
}
else
{
throw new NotImplementedException();
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockAsAnchorableTop:
#region DropTargetType.DocumentPaneDockAsAnchorableTop
{
if( parentGroupPanel != null &&
parentGroupPanel.ChildrenCount == 1 )
parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
if( parentGroupPanel != null &&
parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
parentGroupPanel.Children.Insert(
parentGroupPanel.IndexOfChild( parentGroup != null ? parentGroup : targetModel ),
floatingWindow.RootPanel );
}
else if( parentGroupPanel != null )
{
var newParentPanel = new LayoutPanel() { Orientation = System.Windows.Controls.Orientation.Vertical };
parentGroupPanel.ReplaceChild( parentGroup != null ? parentGroup : targetModel, newParentPanel );
newParentPanel.Children.Add( parentGroup != null ? parentGroup : targetModel );
newParentPanel.Children.Insert( 0, floatingWindow.RootPanel );
}
else
{
throw new NotImplementedException();
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockAsAnchorableLeft:
#region DropTargetType.DocumentPaneDockAsAnchorableLeft
{
if( parentGroupPanel != null &&
parentGroupPanel.ChildrenCount == 1 )
parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
if( parentGroupPanel != null &&
parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
parentGroupPanel.Children.Insert(
parentGroupPanel.IndexOfChild( parentGroup != null ? parentGroup : targetModel ),
floatingWindow.RootPanel );
}
else if( parentGroupPanel != null )
{
var newParentPanel = new LayoutPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };
parentGroupPanel.ReplaceChild( parentGroup != null ? parentGroup : targetModel, newParentPanel );
newParentPanel.Children.Add( parentGroup != null ? parentGroup : targetModel );
newParentPanel.Children.Insert( 0, floatingWindow.RootPanel );
}
else
{
throw new NotImplementedException();
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockAsAnchorableRight:
#region DropTargetType.DocumentPaneDockAsAnchorableRight
{
if( parentGroupPanel != null &&
parentGroupPanel.ChildrenCount == 1 )
parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
if( parentGroupPanel != null &&
parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
parentGroupPanel.Children.Insert(
parentGroupPanel.IndexOfChild( parentGroup != null ? parentGroup : targetModel ) + 1,
floatingWindow.RootPanel );
}
else if( parentGroupPanel != null )
{
var newParentPanel = new LayoutPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };
parentGroupPanel.ReplaceChild( parentGroup != null ? parentGroup : targetModel, newParentPanel );
newParentPanel.Children.Add( parentGroup != null ? parentGroup : targetModel );
newParentPanel.Children.Add( floatingWindow.RootPanel );
}
else
{
throw new NotImplementedException();
}
}
break;
#endregion
}
base.Drop( floatingWindow );
}
public override System.Windows.Media.Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel )
{
Rect targetScreenRect;
ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
var manager = targetModel.Root.Manager;
//ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
LayoutDocumentPaneGroup parentGroup;
LayoutPanel parentGroupPanel;
if( !FindParentLayoutDocumentPane( targetModel, out parentGroup, out parentGroupPanel ) )
return null;
//if (targetModel.Parent is LayoutDocumentPaneGroup)
//{
// var parentGroup = targetModel.Parent as LayoutDocumentPaneGroup;
// var documentPaneGroupControl = manager.FindLogicalChildren<LayoutDocumentPaneGroupControl>().First(d => d.Model == parentGroup);
// targetScreenRect = documentPaneGroupControl.GetScreenArea();
//}
//else
//{
// var documentPaneControl = manager.FindLogicalChildren<LayoutDocumentPaneControl>().First(d => d.Model == targetModel);
// targetScreenRect = documentPaneControl.GetScreenArea();
//}
//var parentPanel = targetModel.FindParent<LayoutPanel>();
var documentPaneControl = manager.FindLogicalChildren<FrameworkElement>().OfType<ILayoutControl>().First( d => parentGroup != null ? d.Model == parentGroup : d.Model == parentGroupPanel ) as FrameworkElement;
targetScreenRect = documentPaneControl.GetScreenArea();
switch( Type )
{
case DropTargetType.DocumentPaneDockAsAnchorableBottom:
{
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Offset( 0.0, targetScreenRect.Height - targetScreenRect.Height / 3.0 );
targetScreenRect.Height /= 3.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.DocumentPaneDockAsAnchorableTop:
{
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Height /= 3.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.DocumentPaneDockAsAnchorableRight:
{
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Offset( targetScreenRect.Width - targetScreenRect.Width / 3.0, 0.0 );
targetScreenRect.Width /= 3.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.DocumentPaneDockAsAnchorableLeft:
{
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Width /= 3.0;
return new RectangleGeometry( targetScreenRect );
}
}
return null;
}
#endregion
#region Private Methods
private bool FindParentLayoutDocumentPane( ILayoutDocumentPane documentPane, out LayoutDocumentPaneGroup containerPaneGroup, out LayoutPanel containerPanel )
{
containerPaneGroup = null;
containerPanel = null;
if( documentPane.Parent is LayoutPanel )
{
containerPaneGroup = null;
containerPanel = documentPane.Parent as LayoutPanel;
return true;
}
else if( documentPane.Parent is LayoutDocumentPaneGroup )
{
var currentDocumentPaneGroup = documentPane.Parent as LayoutDocumentPaneGroup;
while( !( currentDocumentPaneGroup.Parent is LayoutPanel ) )
{
currentDocumentPaneGroup = currentDocumentPaneGroup.Parent as LayoutDocumentPaneGroup;
if( currentDocumentPaneGroup == null )
break;
}
if( currentDocumentPaneGroup == null )
return false;
containerPaneGroup = currentDocumentPaneGroup;
containerPanel = currentDocumentPaneGroup.Parent as LayoutPanel;
return true;
}
return false;
}
#endregion
}
}

513
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneDropTarget.cs

@ -1,513 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class DocumentPaneDropTarget : DropTarget<LayoutDocumentPaneControl>
{
#region Members
private LayoutDocumentPaneControl _targetPane;
private int _tabIndex = -1;
#endregion
#region Constructors
internal DocumentPaneDropTarget( LayoutDocumentPaneControl paneControl, Rect detectionRect, DropTargetType type )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
}
internal DocumentPaneDropTarget( LayoutDocumentPaneControl paneControl, Rect detectionRect, DropTargetType type, int tabIndex )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
_tabIndex = tabIndex;
}
#endregion
#region Overrides
protected override void Drop( LayoutDocumentFloatingWindow floatingWindow )
{
ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
switch( Type )
{
case DropTargetType.DocumentPaneDockBottom:
#region DropTargetType.DocumentPaneDockBottom
{
var newLayoutDocumentPane = new LayoutDocumentPane( floatingWindow.RootDocument );
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
newParentModel.Children.Add( newLayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex + 1, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( targetModel );
newChildGroup.Children.Add( newLayoutDocumentPane );
}
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockTop:
#region DropTargetType.DocumentPaneDockTop
{
var newLayoutDocumentPane = new LayoutDocumentPane( floatingWindow.RootDocument );
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
newParentModel.Children.Insert( 0, newLayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( newLayoutDocumentPane );
newChildGroup.Children.Add( targetModel );
}
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockLeft:
#region DropTargetType.DocumentPaneDockLeft
{
var newLayoutDocumentPane = new LayoutDocumentPane( floatingWindow.RootDocument );
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Horizontal };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( targetModel );
newParentModel.Children.Insert( 0, newLayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( newLayoutDocumentPane );
newChildGroup.Children.Add( targetModel );
}
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockRight:
#region DropTargetType.DocumentPaneDockRight
{
var newLayoutDocumentPane = new LayoutDocumentPane( floatingWindow.RootDocument );
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Horizontal };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
newParentModel.Children.Add( newLayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex + 1, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( targetModel );
newChildGroup.Children.Add( newLayoutDocumentPane );
}
}
}
break;
#endregion
case DropTargetType.DocumentPaneDockInside:
#region DropTargetType.DocumentPaneDockInside
{
var paneModel = targetModel as LayoutDocumentPane;
var sourceModel = floatingWindow.RootDocument;
int i = 0;
if( _tabIndex != -1 )
{
i = _tabIndex;
}
else
{
var previousIndex = 0;
var previousContainer = ( ( ILayoutPreviousContainer )sourceModel ).PreviousContainer;
if( object.ReferenceEquals( previousContainer, targetModel ) && ( sourceModel.PreviousContainerIndex != -1 ) )
{
previousIndex = sourceModel.PreviousContainerIndex;
}
i = previousIndex;
}
sourceModel.IsActive = false;
paneModel.Children.Insert( i, sourceModel );
sourceModel.IsActive = true;
}
break;
#endregion
}
base.Drop( floatingWindow );
}
protected override void Drop( LayoutAnchorableFloatingWindow floatingWindow )
{
ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
switch( Type )
{
case DropTargetType.DocumentPaneDockBottom:
#region DropTargetType.DocumentPaneDockBottom
{
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
var newLayoutDocumentPane = new LayoutDocumentPane();
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
newParentModel.Children.Add( newLayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex + 1, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( targetModel );
newChildGroup.Children.Add( newLayoutDocumentPane );
}
}
foreach( var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType<LayoutAnchorable>().ToArray() )
newLayoutDocumentPane.Children.Add( cntToTransfer );
}
break;
#endregion
case DropTargetType.DocumentPaneDockTop:
#region DropTargetType.DocumentPaneDockTop
{
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
var newLayoutDocumentPane = new LayoutDocumentPane();
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( newLayoutDocumentPane );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( newLayoutDocumentPane );
newChildGroup.Children.Add( targetModel );
}
}
foreach( var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType<LayoutAnchorable>().ToArray() )
newLayoutDocumentPane.Children.Add( cntToTransfer );
}
break;
#endregion
case DropTargetType.DocumentPaneDockLeft:
#region DropTargetType.DocumentPaneDockLeft
{
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
var newLayoutDocumentPane = new LayoutDocumentPane();
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Horizontal };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( newLayoutDocumentPane );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( newLayoutDocumentPane );
newChildGroup.Children.Add( targetModel );
}
}
foreach( var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType<LayoutAnchorable>().ToArray() )
newLayoutDocumentPane.Children.Add( cntToTransfer );
}
break;
#endregion
case DropTargetType.DocumentPaneDockRight:
#region DropTargetType.DocumentPaneDockRight
{
var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;
var newLayoutDocumentPane = new LayoutDocumentPane();
if( parentModel == null )
{
var parentContainer = targetModel.Parent as ILayoutContainer;
var newParentModel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Horizontal };
parentContainer.ReplaceChild( targetModel, newParentModel );
newParentModel.Children.Add( targetModel as LayoutDocumentPane );
newParentModel.Children.Add( newLayoutDocumentPane );
}
else
{
var manager = parentModel.Root.Manager;
if( !manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal )
{
parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
int targetPaneIndex = parentModel.IndexOfChild( targetModel );
parentModel.Children.Insert( targetPaneIndex + 1, newLayoutDocumentPane );
}
else
{
LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
parentModel.ReplaceChild( targetModel, newChildGroup );
newChildGroup.Children.Add( targetModel );
newChildGroup.Children.Add( newLayoutDocumentPane );
}
}
foreach( var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType<LayoutAnchorable>().ToArray() )
newLayoutDocumentPane.Children.Add( cntToTransfer );
}
break;
#endregion
case DropTargetType.DocumentPaneDockInside:
#region DropTargetType.DocumentPaneDockInside
{
var paneModel = targetModel as LayoutDocumentPane;
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
bool checkPreviousContainer = true;
int i = 0;
if( _tabIndex != -1 )
{
i = _tabIndex;
checkPreviousContainer = false;
}
LayoutAnchorable anchorableToActivate = null;
foreach( var anchorableToImport in layoutAnchorablePaneGroup.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
if( checkPreviousContainer )
{
var previousContainer = ( ( ILayoutPreviousContainer )anchorableToImport ).PreviousContainer;
if( object.ReferenceEquals( previousContainer, targetModel ) && ( anchorableToImport.PreviousContainerIndex != -1 ) )
{
i = anchorableToImport.PreviousContainerIndex;
}
checkPreviousContainer = false;
}
anchorableToImport.SetCanCloseInternal( true );
paneModel.Children.Insert( i, anchorableToImport );
i++;
anchorableToActivate = anchorableToImport;
}
anchorableToActivate.IsActive = true;
}
break;
#endregion
}
base.Drop( floatingWindow );
}
public override System.Windows.Media.Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel )
{
switch( Type )
{
case DropTargetType.DocumentPaneDockInside:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
if( _tabIndex == -1 )
{
return new RectangleGeometry( targetScreenRect );
}
else
{
var translatedDetectionRect = new Rect( DetectionRects[ 0 ].TopLeft, DetectionRects[ 0 ].BottomRight );
translatedDetectionRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
var pathFigure = new PathFigure();
pathFigure.StartPoint = targetScreenRect.BottomRight;
pathFigure.Segments.Add( new LineSegment() { Point = new Point( targetScreenRect.Right, translatedDetectionRect.Bottom ) } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.BottomRight } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.TopRight } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.TopLeft } );
pathFigure.Segments.Add( new LineSegment() { Point = translatedDetectionRect.BottomLeft } );
pathFigure.Segments.Add( new LineSegment() { Point = new Point( targetScreenRect.Left, translatedDetectionRect.Bottom ) } );
pathFigure.Segments.Add( new LineSegment() { Point = targetScreenRect.BottomLeft } );
pathFigure.IsClosed = true;
pathFigure.IsFilled = true;
pathFigure.Freeze();
return new PathGeometry( new PathFigure[] { pathFigure } );
}
}
case DropTargetType.DocumentPaneDockBottom:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Offset( 0.0, targetScreenRect.Height / 2.0 );
targetScreenRect.Height /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.DocumentPaneDockTop:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Height /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.DocumentPaneDockLeft:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Width /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
case DropTargetType.DocumentPaneDockRight:
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
targetScreenRect.Offset( targetScreenRect.Width / 2.0, 0.0 );
targetScreenRect.Width /= 2.0;
return new RectangleGeometry( targetScreenRect );
}
}
return null;
}
#endregion
}
}

114
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneGroupDropTarget.cs

@ -1,114 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class DocumentPaneGroupDropTarget : DropTarget<LayoutDocumentPaneGroupControl>
{
#region Constructors
internal DocumentPaneGroupDropTarget( LayoutDocumentPaneGroupControl paneControl, Rect detectionRect, DropTargetType type )
: base( paneControl, detectionRect, type )
{
_targetPane = paneControl;
}
#endregion
#region Members
private LayoutDocumentPaneGroupControl _targetPane;
#endregion
#region Overrides
protected override void Drop( LayoutDocumentFloatingWindow floatingWindow )
{
ILayoutPane targetModel = _targetPane.Model as ILayoutPane;
switch( Type )
{
case DropTargetType.DocumentPaneGroupDockInside:
#region DropTargetType.DocumentPaneGroupDockInside
{
var paneGroupModel = targetModel as LayoutDocumentPaneGroup;
var paneModel = paneGroupModel.Children[ 0 ] as LayoutDocumentPane;
var sourceModel = floatingWindow.RootDocument;
paneModel.Children.Insert( 0, sourceModel );
}
break;
#endregion
}
base.Drop( floatingWindow );
}
protected override void Drop( LayoutAnchorableFloatingWindow floatingWindow )
{
ILayoutPane targetModel = _targetPane.Model as ILayoutPane;
switch( Type )
{
case DropTargetType.DocumentPaneGroupDockInside:
#region DropTargetType.DocumentPaneGroupDockInside
{
var paneGroupModel = targetModel as LayoutDocumentPaneGroup;
var paneModel = paneGroupModel.Children[ 0 ] as LayoutDocumentPane;
var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;
int i = 0;
foreach( var anchorableToImport in layoutAnchorablePaneGroup.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
anchorableToImport.SetCanCloseInternal( true );
paneModel.Children.Insert( i, anchorableToImport );
i++;
}
}
break;
#endregion
}
base.Drop( floatingWindow );
}
public override System.Windows.Media.Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel )
{
switch( Type )
{
case DropTargetType.DocumentPaneGroupDockInside:
#region DropTargetType.DocumentPaneGroupDockInside
{
var targetScreenRect = TargetElement.GetScreenArea();
targetScreenRect.Offset( -overlayWindow.Left, -overlayWindow.Top );
return new RectangleGeometry( targetScreenRect );
}
#endregion
}
return null;
}
#endregion
}
}

111
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneTabPanel.cs

@ -1,111 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class DocumentPaneTabPanel : Panel
{
#region Constructors
public DocumentPaneTabPanel()
{
this.FlowDirection = System.Windows.FlowDirection.LeftToRight;
}
#endregion
#region Overrides
protected override Size MeasureOverride( Size availableSize )
{
var visibleChildren = Children.Cast<UIElement>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed );
Size desideredSize = new Size();
foreach( FrameworkElement child in Children )
{
child.Measure( new Size( double.PositiveInfinity, double.PositiveInfinity ) );
desideredSize.Width += child.DesiredSize.Width;
desideredSize.Height = Math.Max( desideredSize.Height, child.DesiredSize.Height );
}
return new Size( Math.Min( desideredSize.Width, availableSize.Width ), desideredSize.Height );
}
protected override Size ArrangeOverride( Size finalSize )
{
var visibleChildren = Children.Cast<UIElement>().Where( ch => ch.Visibility != System.Windows.Visibility.Collapsed );
var offset = 0.0;
var skipAllOthers = false;
foreach( TabItem doc in visibleChildren )
{
var layoutContent = doc.Content as LayoutContent;
if( skipAllOthers || offset + doc.DesiredSize.Width > finalSize.Width )
{
if( layoutContent.IsSelected && !doc.IsVisible )
{
var parentContainer = layoutContent.Parent as ILayoutContainer;
var parentSelector = layoutContent.Parent as ILayoutContentSelector;
var parentPane = layoutContent.Parent as ILayoutPane;
int contentIndex = parentSelector.IndexOf( layoutContent );
if( contentIndex > 0 &&
parentContainer.ChildrenCount > 1 )
{
parentPane.MoveChild( contentIndex, 0 );
parentSelector.SelectedContentIndex = 0;
return ArrangeOverride( finalSize );
}
}
doc.Visibility = System.Windows.Visibility.Hidden;
skipAllOthers = true;
}
else
{
doc.Visibility = System.Windows.Visibility.Visible;
doc.Arrange( new Rect( offset, 0.0, doc.DesiredSize.Width, finalSize.Height ) );
offset += doc.ActualWidth + doc.Margin.Left + doc.Margin.Right;
}
}
return finalSize;
}
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
//if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed &&
// LayoutDocumentTabItem.IsDraggingItem())
//{
// var contentModel = LayoutDocumentTabItem.GetDraggingItem().Model;
// var manager = contentModel.Root.Manager;
// LayoutDocumentTabItem.ResetDraggingItem();
// System.Diagnostics.Trace.WriteLine("OnMouseLeave()");
// manager.StartDraggingFloatingWindowForContent(contentModel);
//}
base.OnMouseLeave( e );
}
#endregion
}
}

201
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DragService.cs

@ -1,201 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class DragService
{
#region Members
private DockingManager _manager;
private LayoutFloatingWindowControl _floatingWindow;
private List<IOverlayWindowHost> _overlayWindowHosts = new List<IOverlayWindowHost>();
private IOverlayWindowHost _currentHost;
private IOverlayWindow _currentWindow;
private List<IDropArea> _currentWindowAreas = new List<IDropArea>();
private IDropTarget _currentDropTarget;
#endregion
#region Public Methods
public DragService( LayoutFloatingWindowControl floatingWindow )
{
_floatingWindow = floatingWindow;
_manager = floatingWindow.Model.Root.Manager;
GetOverlayWindowHosts();
}
public void UpdateMouseLocation( Point dragPosition )
{
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
var newHost = _overlayWindowHosts.FirstOrDefault( oh => oh.HitTest( dragPosition ) );
if( _currentHost != null || _currentHost != newHost )
{
//is mouse still inside current overlay window host?
if( ( _currentHost != null && !_currentHost.HitTest( dragPosition ) ) ||
_currentHost != newHost )
{
//esit drop target
if( _currentDropTarget != null )
_currentWindow.DragLeave( _currentDropTarget );
_currentDropTarget = null;
//exit area
_currentWindowAreas.ForEach( a =>
_currentWindow.DragLeave( a ) );
_currentWindowAreas.Clear();
//hide current overlay window
if( _currentWindow != null )
_currentWindow.DragLeave( _floatingWindow );
if( _currentHost != null )
_currentHost.HideOverlayWindow();
_currentHost = null;
}
if( _currentHost != newHost )
{
_currentHost = newHost;
_currentWindow = _currentHost.ShowOverlayWindow( _floatingWindow );
_currentWindow.DragEnter( _floatingWindow );
}
}
if( _currentHost == null )
return;
if( _currentDropTarget != null &&
!_currentDropTarget.HitTest( dragPosition ) )
{
_currentWindow.DragLeave( _currentDropTarget );
_currentDropTarget = null;
}
List<IDropArea> areasToRemove = new List<IDropArea>();
_currentWindowAreas.ForEach( a =>
{
//is mouse still inside this area?
if( !a.DetectionRect.Contains( dragPosition ) )
{
_currentWindow.DragLeave( a );
areasToRemove.Add( a );
}
} );
areasToRemove.ForEach( a =>
_currentWindowAreas.Remove( a ) );
var areasToAdd =
_currentHost.GetDropAreas( _floatingWindow ).Where( cw => !_currentWindowAreas.Contains( cw ) && cw.DetectionRect.Contains( dragPosition ) ).ToList();
_currentWindowAreas.AddRange( areasToAdd );
areasToAdd.ForEach( a =>
_currentWindow.DragEnter( a ) );
if( _currentDropTarget == null )
{
_currentWindowAreas.ForEach( wa =>
{
if( _currentDropTarget != null )
return;
_currentDropTarget = _currentWindow.GetTargets().FirstOrDefault( dt => dt.HitTest( dragPosition ) );
if( _currentDropTarget != null )
{
_currentWindow.DragEnter( _currentDropTarget );
return;
}
} );
}
}
public void Drop( Point dropLocation, out bool dropHandled )
{
dropHandled = false;
UpdateMouseLocation( dropLocation );
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
var root = floatingWindowModel.Root;
if( _currentHost != null )
_currentHost.HideOverlayWindow();
if( _currentDropTarget != null )
{
_currentWindow.DragDrop( _currentDropTarget );
root.CollectGarbage();
dropHandled = true;
}
_currentWindowAreas.ForEach( a => _currentWindow.DragLeave( a ) );
if( _currentDropTarget != null )
_currentWindow.DragLeave( _currentDropTarget );
if( _currentWindow != null )
_currentWindow.DragLeave( _floatingWindow );
_currentWindow = null;
_currentHost = null;
}
#endregion
#region Internal Methods
internal void Abort()
{
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
_currentWindowAreas.ForEach( a => _currentWindow.DragLeave( a ) );
if( _currentDropTarget != null )
_currentWindow.DragLeave( _currentDropTarget );
if( _currentWindow != null )
_currentWindow.DragLeave( _floatingWindow );
_currentWindow = null;
if( _currentHost != null )
_currentHost.HideOverlayWindow();
_currentHost = null;
}
#endregion
#region Private Methods
private void GetOverlayWindowHosts()
{
_overlayWindowHosts.AddRange( _manager.GetFloatingWindowsByZOrder().OfType<LayoutAnchorableFloatingWindowControl>().Where( fw => fw != _floatingWindow && fw.IsVisible ) );
_overlayWindowHosts.Add( _manager );
}
#endregion
}
}

91
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropArea.cs

@ -1,91 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public enum DropAreaType
{
DockingManager,
DocumentPane,
DocumentPaneGroup,
AnchorablePane,
}
public interface IDropArea
{
Rect DetectionRect
{
get;
}
DropAreaType Type
{
get;
}
}
public class DropArea<T> : IDropArea where T : FrameworkElement
{
#region Members
private Rect _detectionRect;
private DropAreaType _type;
private T _element;
#endregion
#region Constructors
internal DropArea( T areaElement, DropAreaType type )
{
_element = areaElement;
_detectionRect = areaElement.GetScreenArea();
_type = type;
}
#endregion
#region Properties
public Rect DetectionRect
{
get
{
return _detectionRect;
}
}
public DropAreaType Type
{
get
{
return _type;
}
}
public T AreaElement
{
get
{
return _element;
}
}
#endregion
}
}

149
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropDownButton.cs

@ -1,149 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows.Controls.Primitives;
using System.Windows;
using System.Windows.Controls;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class DropDownButton : ToggleButton
{
#region Constructors
public DropDownButton()
{
this.Unloaded += new RoutedEventHandler( DropDownButton_Unloaded );
}
#endregion
#region Properties
#region DropDownContextMenu
/// <summary>
/// DropDownContextMenu Dependency Property
/// </summary>
public static readonly DependencyProperty DropDownContextMenuProperty = DependencyProperty.Register( "DropDownContextMenu", typeof( ContextMenu ), typeof( DropDownButton ),
new FrameworkPropertyMetadata( ( ContextMenu )null, new PropertyChangedCallback( OnDropDownContextMenuChanged ) ) );
/// <summary>
/// Gets or sets the DropDownContextMenu property. This dependency property
/// indicates drop down menu to show up when user click on an anchorable menu pin.
/// </summary>
public ContextMenu DropDownContextMenu
{
get
{
return ( ContextMenu )GetValue( DropDownContextMenuProperty );
}
set
{
SetValue( DropDownContextMenuProperty, value );
}
}
/// <summary>
/// Handles changes to the DropDownContextMenu property.
/// </summary>
private static void OnDropDownContextMenuChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( DropDownButton )d ).OnDropDownContextMenuChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the DropDownContextMenu property.
/// </summary>
protected virtual void OnDropDownContextMenuChanged( DependencyPropertyChangedEventArgs e )
{
var oldContextMenu = e.OldValue as ContextMenu;
if( oldContextMenu != null && IsChecked.GetValueOrDefault() )
oldContextMenu.Closed -= new RoutedEventHandler( OnContextMenuClosed );
}
#endregion
#region DropDownContextMenuDataContext
/// <summary>
/// DropDownContextMenuDataContext Dependency Property
/// </summary>
public static readonly DependencyProperty DropDownContextMenuDataContextProperty = DependencyProperty.Register( "DropDownContextMenuDataContext", typeof( object ), typeof( DropDownButton ),
new FrameworkPropertyMetadata( ( object )null ) );
/// <summary>
/// Gets or sets the DropDownContextMenuDataContext property. This dependency property
/// indicates data context to set for drop down context menu.
/// </summary>
public object DropDownContextMenuDataContext
{
get
{
return ( object )GetValue( DropDownContextMenuDataContextProperty );
}
set
{
SetValue( DropDownContextMenuDataContextProperty, value );
}
}
#endregion
#endregion
#region Overrides
protected override void OnClick()
{
if( DropDownContextMenu != null )
{
//IsChecked = true;
DropDownContextMenu.PlacementTarget = this;
DropDownContextMenu.Placement = PlacementMode.Bottom;
DropDownContextMenu.DataContext = DropDownContextMenuDataContext;
DropDownContextMenu.Closed += new RoutedEventHandler( OnContextMenuClosed );
DropDownContextMenu.IsOpen = true;
}
base.OnClick();
}
#endregion
#region Private Methods
private void OnContextMenuClosed( object sender, RoutedEventArgs e )
{
//Debug.Assert(IsChecked.GetValueOrDefault());
var ctxMenu = sender as ContextMenu;
ctxMenu.Closed -= new RoutedEventHandler( OnContextMenuClosed );
IsChecked = false;
}
private void DropDownButton_Unloaded( object sender, RoutedEventArgs e )
{
// When changing theme, Unloaded event is called, erasing the DropDownContextMenu.
// Prevent this on theme changes.
if( this.IsLoaded )
{
DropDownContextMenu = null;
}
}
#endregion
}
}

129
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropDownControlArea.cs

@ -1,129 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class DropDownControlArea : UserControl
{
#region Constructors
//static DropDownControlArea()
//{
// //IsHitTestVisibleProperty.OverrideMetadata(typeof(DropDownControlArea), new FrameworkPropertyMetadata(true));
//}
public DropDownControlArea()
{
}
#endregion
#region Properties
#region DropDownContextMenu
/// <summary>
/// DropDownContextMenu Dependency Property
/// </summary>
public static readonly DependencyProperty DropDownContextMenuProperty = DependencyProperty.Register( "DropDownContextMenu", typeof( ContextMenu ), typeof( DropDownControlArea ),
new FrameworkPropertyMetadata( ( ContextMenu )null ) );
/// <summary>
/// Gets or sets the DropDownContextMenu property. This dependency property
/// indicates context menu to show when a right click is detected over the area occpied by the control.
/// </summary>
public ContextMenu DropDownContextMenu
{
get
{
return ( ContextMenu )GetValue( DropDownContextMenuProperty );
}
set
{
SetValue( DropDownContextMenuProperty, value );
}
}
#endregion
#region DropDownContextMenuDataContext
/// <summary>
/// DropDownContextMenuDataContext Dependency Property
/// </summary>
public static readonly DependencyProperty DropDownContextMenuDataContextProperty = DependencyProperty.Register( "DropDownContextMenuDataContext", typeof( object ), typeof( DropDownControlArea ),
new FrameworkPropertyMetadata( ( object )null ) );
/// <summary>
/// Gets or sets the DropDownContextMenuDataContext property. This dependency property
/// indicates data context to attach when context menu is shown.
/// </summary>
public object DropDownContextMenuDataContext
{
get
{
return ( object )GetValue( DropDownContextMenuDataContextProperty );
}
set
{
SetValue( DropDownContextMenuDataContextProperty, value );
}
}
#endregion
#endregion
#region Overrides
protected override void OnMouseRightButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseRightButtonDown( e );
}
protected override void OnPreviewMouseRightButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnPreviewMouseRightButtonUp( e );
if( !e.Handled )
{
if( DropDownContextMenu != null )
{
DropDownContextMenu.PlacementTarget = null;
DropDownContextMenu.Placement = PlacementMode.MousePoint;
DropDownContextMenu.DataContext = DropDownContextMenuDataContext;
DropDownContextMenu.IsOpen = true;
// e.Handled = true;
}
}
}
//protected override System.Windows.Media.HitTestResult HitTestCore(System.Windows.Media.PointHitTestParameters hitTestParameters)
//{
// var hitResult = base.HitTestCore(hitTestParameters);
// if (hitResult == null)
// return new PointHitTestResult(this, hitTestParameters.HitPoint);
// return hitResult;
//}
#endregion
}
}

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

@ -1,140 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows.Threading;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal abstract class DropTarget<T> : DropTargetBase, IDropTarget where T : FrameworkElement
{
#region Members
private Rect[] _detectionRect;
private T _targetElement;
private DropTargetType _type;
#endregion
#region Constructors
protected DropTarget( T targetElement, Rect detectionRect, DropTargetType type )
{
_targetElement = targetElement;
_detectionRect = new Rect[] { detectionRect };
_type = type;
}
protected DropTarget( T targetElement, IEnumerable<Rect> detectionRects, DropTargetType type )
{
_targetElement = targetElement;
_detectionRect = detectionRects.ToArray();
_type = type;
}
#endregion
#region Properties
public Rect[] DetectionRects
{
get
{
return _detectionRect;
}
}
public T TargetElement
{
get
{
return _targetElement;
}
}
public DropTargetType Type
{
get
{
return _type;
}
}
#endregion
#region Overrides
protected virtual void Drop( LayoutAnchorableFloatingWindow floatingWindow )
{
}
protected virtual void Drop( LayoutDocumentFloatingWindow floatingWindow )
{
}
#endregion
#region Public Methods
public void Drop( LayoutFloatingWindow floatingWindow )
{
var root = floatingWindow.Root;
var currentActiveContent = floatingWindow.Root.ActiveContent;
var fwAsAnchorable = floatingWindow as LayoutAnchorableFloatingWindow;
if( fwAsAnchorable != null )
{
this.Drop( fwAsAnchorable );
}
else
{
var fwAsDocument = floatingWindow as LayoutDocumentFloatingWindow;
this.Drop( fwAsDocument );
}
Dispatcher.BeginInvoke( new Action( () =>
{
currentActiveContent.IsSelected = false;
currentActiveContent.IsActive = false;
currentActiveContent.IsActive = true;
} ), DispatcherPriority.Background );
}
public virtual bool HitTest( Point dragPoint )
{
return _detectionRect.Any( dr => dr.Contains( dragPoint ) );
}
public abstract Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindow );
public void DragEnter()
{
SetIsDraggingOver( TargetElement, true );
}
public void DragLeave()
{
SetIsDraggingOver( TargetElement, false );
}
#endregion
}
}

55
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropTargetBase.cs

@ -1,55 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
abstract class DropTargetBase : DependencyObject
{
#region Properties
#region IsDraggingOver
/// <summary>
/// IsDraggingOver Attached Dependency Property
/// </summary>
public static readonly DependencyProperty IsDraggingOverProperty = DependencyProperty.RegisterAttached( "IsDraggingOver", typeof( bool ), typeof( DropTargetBase ),
new FrameworkPropertyMetadata( ( bool )false ) );
/// <summary>
/// Gets the IsDraggingOver property. This dependency property
/// indicates if user is dragging a window over the target element.
/// </summary>
public static bool GetIsDraggingOver( DependencyObject d )
{
return ( bool )d.GetValue( IsDraggingOverProperty );
}
/// <summary>
/// Sets the IsDraggingOver property. This dependency property
/// indicates if user is dragging away a window from the target element.
/// </summary>
public static void SetIsDraggingOver( DependencyObject d, bool value )
{
d.SetValue( IsDraggingOverProperty, value );
}
#endregion
#endregion
}
}

45
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DropTargetType.cs

@ -1,45 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
namespace Xceed.Wpf.AvalonDock.Controls
{
public enum DropTargetType
{
DockingManagerDockLeft,
DockingManagerDockTop,
DockingManagerDockRight,
DockingManagerDockBottom,
DocumentPaneDockLeft,
DocumentPaneDockTop,
DocumentPaneDockRight,
DocumentPaneDockBottom,
DocumentPaneDockInside,
DocumentPaneGroupDockInside,
AnchorablePaneDockLeft,
AnchorablePaneDockTop,
AnchorablePaneDockRight,
AnchorablePaneDockBottom,
AnchorablePaneDockInside,
DocumentPaneDockAsAnchorableLeft,
DocumentPaneDockAsAnchorableTop,
DocumentPaneDockAsAnchorableRight,
DocumentPaneDockAsAnchorableBottom,
}
}

116
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Extentions.cs

@ -1,116 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Media3D;
namespace Xceed.Wpf.AvalonDock.Controls
{
public static class Extentions
{
public static IEnumerable<T> FindVisualChildren<T>( this DependencyObject depObj ) where T : DependencyObject
{
if( depObj != null )
{
for( int i = 0; i < VisualTreeHelper.GetChildrenCount( depObj ); i++ )
{
DependencyObject child = VisualTreeHelper.GetChild( depObj, i );
if( child != null && child is T )
{
yield return ( T )child;
}
foreach( T childOfChild in FindVisualChildren<T>( child ) )
{
yield return childOfChild;
}
}
}
}
public static IEnumerable<T> FindLogicalChildren<T>( this DependencyObject depObj ) where T : DependencyObject
{
if( depObj != null )
{
foreach( DependencyObject child in LogicalTreeHelper.GetChildren( depObj ).OfType<DependencyObject>() )
{
if( child != null && child is T )
{
yield return ( T )child;
}
foreach( T childOfChild in FindLogicalChildren<T>( child ) )
{
yield return childOfChild;
}
}
}
}
public static DependencyObject FindVisualTreeRoot( this DependencyObject initial )
{
DependencyObject current = initial;
DependencyObject result = initial;
while( current != null )
{
result = current;
if( current is Visual || current is Visual3D )
{
current = VisualTreeHelper.GetParent( current );
}
else
{
// If we're in Logical Land then we must walk
// up the logical tree until we find a
// Visual/Visual3D to get us back to Visual Land.
current = LogicalTreeHelper.GetParent( current );
}
}
return result;
}
public static T FindVisualAncestor<T>( this DependencyObject dependencyObject ) where T : class
{
DependencyObject target = dependencyObject;
do
{
target = VisualTreeHelper.GetParent( target );
}
while( target != null && !( target is T ) );
return target as T;
}
public static T FindLogicalAncestor<T>( this DependencyObject dependencyObject ) where T : class
{
DependencyObject target = dependencyObject;
do
{
var current = target;
target = LogicalTreeHelper.GetParent( target );
if( target == null )
target = VisualTreeHelper.GetParent( current );
}
while( target != null && !( target is T ) );
return target as T;
}
}
}

272
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs

@ -1,272 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows;
using System.Diagnostics;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows.Media;
using System.Windows.Threading;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal static class FocusElementManager
{
#region Member
private static List<DockingManager> _managers = new List<DockingManager>();
private static FullWeakDictionary<ILayoutElement, IInputElement> _modelFocusedElement = new FullWeakDictionary<ILayoutElement, IInputElement>();
private static WeakDictionary<ILayoutElement, IntPtr> _modelFocusedWindowHandle = new WeakDictionary<ILayoutElement, IntPtr>();
private static WeakReference _lastFocusedElement;
private static WindowHookHandler _windowHandler = null;
private static DispatcherOperation _setFocusAsyncOperation;
private static WeakReference _lastFocusedElementBeforeEnterMenuMode = null;
#endregion
#region Internal Methods
internal static void SetupFocusManagement( DockingManager manager )
{
if( _managers.Count == 0 )
{
//InputManager.Current.EnterMenuMode += new EventHandler(InputManager_EnterMenuMode);
//InputManager.Current.LeaveMenuMode += new EventHandler(InputManager_LeaveMenuMode);
_windowHandler = new WindowHookHandler();
_windowHandler.FocusChanged += new EventHandler<FocusChangeEventArgs>( WindowFocusChanging );
//_windowHandler.Activate += new EventHandler<WindowActivateEventArgs>(WindowActivating);
_windowHandler.Attach();
if( Application.Current != null )
Application.Current.Exit += new ExitEventHandler( Current_Exit );
}
manager.PreviewGotKeyboardFocus += new KeyboardFocusChangedEventHandler( manager_PreviewGotKeyboardFocus );
_managers.Add( manager );
}
internal static void FinalizeFocusManagement( DockingManager manager )
{
manager.PreviewGotKeyboardFocus -= new KeyboardFocusChangedEventHandler( manager_PreviewGotKeyboardFocus );
_managers.Remove( manager );
if( _managers.Count == 0 )
{
//InputManager.Current.EnterMenuMode -= new EventHandler(InputManager_EnterMenuMode);
//InputManager.Current.LeaveMenuMode -= new EventHandler(InputManager_LeaveMenuMode);
if( _windowHandler != null )
{
_windowHandler.FocusChanged -= new EventHandler<FocusChangeEventArgs>( WindowFocusChanging );
//_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
_windowHandler.Detach();
_windowHandler = null;
}
}
}
/// <summary>
/// Get the input element that was focused before user left the layout element
/// </summary>
/// <param name="model">Element to look for</param>
/// <returns>Input element </returns>
internal static IInputElement GetLastFocusedElement( ILayoutElement model )
{
IInputElement objectWithFocus;
if( _modelFocusedElement.GetValue( model, out objectWithFocus ) )
return objectWithFocus;
return null;
}
/// <summary>
/// Get the last window handle focused before user left the element passed as argument
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
internal static IntPtr GetLastWindowHandle( ILayoutElement model )
{
IntPtr handleWithFocus;
if( _modelFocusedWindowHandle.GetValue( model, out handleWithFocus ) )
return handleWithFocus;
return IntPtr.Zero;
}
/// <summary>
/// Given a layout element tries to set the focus of the keyword where it was before user moved to another element
/// </summary>
/// <param name="model"></param>
internal static void SetFocusOnLastElement( ILayoutElement model )
{
bool focused = false;
IInputElement objectToFocus;
if( _modelFocusedElement.GetValue( model, out objectToFocus ) )
{
focused = objectToFocus == Keyboard.Focus( objectToFocus );
}
IntPtr handleToFocus;
if( _modelFocusedWindowHandle.GetValue( model, out handleToFocus ) )
focused = IntPtr.Zero != Win32Helper.SetFocus( handleToFocus );
if( focused )
{
_lastFocusedElement = new WeakReference( model );
}
}
#endregion
#region Private Methods
private static void Current_Exit( object sender, ExitEventArgs e )
{
Application.Current.Exit -= new ExitEventHandler( Current_Exit );
if( _windowHandler != null )
{
_windowHandler.FocusChanged -= new EventHandler<FocusChangeEventArgs>( WindowFocusChanging );
//_windowHandler.Activate -= new EventHandler<WindowActivateEventArgs>(WindowActivating);
_windowHandler.Detach();
_windowHandler = null;
}
}
private static void manager_PreviewGotKeyboardFocus( object sender, KeyboardFocusChangedEventArgs e )
{
var focusedElement = e.NewFocus as Visual;
if( focusedElement != null &&
!( focusedElement is LayoutAnchorableTabItem || focusedElement is LayoutDocumentTabItem ) )
//Avoid tracking focus for elements like this
{
var parentAnchorable = focusedElement.FindVisualAncestor<LayoutAnchorableControl>();
if( parentAnchorable != null )
{
_modelFocusedElement[ parentAnchorable.Model ] = e.NewFocus;
}
else
{
var parentDocument = focusedElement.FindVisualAncestor<LayoutDocumentControl>();
if( parentDocument != null )
{
_modelFocusedElement[ parentDocument.Model ] = e.NewFocus;
}
}
}
}
private static void WindowFocusChanging( object sender, FocusChangeEventArgs e )
{
foreach( var manager in _managers )
{
var hostContainingFocusedHandle = manager.FindLogicalChildren<HwndHost>().FirstOrDefault( hw => Win32Helper.IsChild( hw.Handle, e.GotFocusWinHandle ) );
if( hostContainingFocusedHandle != null )
{
var parentAnchorable = hostContainingFocusedHandle.FindVisualAncestor<LayoutAnchorableControl>();
if( parentAnchorable != null )
{
_modelFocusedWindowHandle[ parentAnchorable.Model ] = e.GotFocusWinHandle;
if( parentAnchorable.Model != null )
parentAnchorable.Model.IsActive = true;
}
else
{
var parentDocument = hostContainingFocusedHandle.FindVisualAncestor<LayoutDocumentControl>();
if( parentDocument != null )
{
_modelFocusedWindowHandle[ parentDocument.Model ] = e.GotFocusWinHandle;
if( parentDocument.Model != null )
parentDocument.Model.IsActive = true;
}
}
}
}
}
private static void WindowActivating( object sender, WindowActivateEventArgs e )
{
if( Keyboard.FocusedElement == null &&
_lastFocusedElement != null &&
_lastFocusedElement.IsAlive )
{
var elementToSetFocus = _lastFocusedElement.Target as ILayoutElement;
if( elementToSetFocus != null )
{
var manager = elementToSetFocus.Root.Manager;
if( manager == null )
return;
IntPtr parentHwnd;
if( !manager.GetParentWindowHandle( out parentHwnd ) )
return;
if( e.HwndActivating != parentHwnd )
return;
_setFocusAsyncOperation = Dispatcher.CurrentDispatcher.BeginInvoke( new Action( () =>
{
try
{
SetFocusOnLastElement( elementToSetFocus );
}
finally
{
_setFocusAsyncOperation = null;
}
} ), DispatcherPriority.Input );
}
}
}
private static void InputManager_EnterMenuMode( object sender, EventArgs e )
{
if( Keyboard.FocusedElement == null )
return;
var lastfocusDepObj = Keyboard.FocusedElement as DependencyObject;
if( lastfocusDepObj.FindLogicalAncestor<DockingManager>() == null )
{
_lastFocusedElementBeforeEnterMenuMode = null;
return;
}
_lastFocusedElementBeforeEnterMenuMode = new WeakReference( Keyboard.FocusedElement );
}
private static void InputManager_LeaveMenuMode( object sender, EventArgs e )
{
if( _lastFocusedElementBeforeEnterMenuMode != null &&
_lastFocusedElementBeforeEnterMenuMode.IsAlive )
{
var lastFocusedInputElement = _lastFocusedElementBeforeEnterMenuMode.GetValueOrDefault<UIElement>();
if( lastFocusedInputElement != null )
{
if( lastFocusedInputElement != Keyboard.Focus( lastFocusedInputElement ) )
Debug.WriteLine( "Unable to activate the element" );
}
}
}
#endregion
}
}

116
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/FullWeakDictionary.cs

@ -1,116 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class FullWeakDictionary<K, V> where K : class
{
#region Members
private List<WeakReference> _keys = new List<WeakReference>();
private List<WeakReference> _values = new List<WeakReference>();
#endregion
#region Constructors
public FullWeakDictionary()
{
}
#endregion
#region Public Methods
public V this[ K key ]
{
get
{
V valueToReturn;
if( !GetValue( key, out valueToReturn ) )
throw new ArgumentException();
return valueToReturn;
}
set
{
SetValue( key, value );
}
}
public bool ContainsKey( K key )
{
CollectGarbage();
return -1 != _keys.FindIndex( k => k.GetValueOrDefault<K>() == key );
}
public void SetValue( K key, V value )
{
CollectGarbage();
int vIndex = _keys.FindIndex( k => k.GetValueOrDefault<K>() == key );
if( vIndex > -1 )
_values[ vIndex ] = new WeakReference( value );
else
{
_values.Add( new WeakReference( value ) );
_keys.Add( new WeakReference( key ) );
}
}
public bool GetValue( K key, out V value )
{
CollectGarbage();
int vIndex = _keys.FindIndex( k => k.GetValueOrDefault<K>() == key );
value = default( V );
if( vIndex == -1 )
return false;
value = _values[ vIndex ].GetValueOrDefault<V>();
return true;
}
void CollectGarbage()
{
int vIndex = 0;
do
{
vIndex = _keys.FindIndex( vIndex, k => !k.IsAlive );
if( vIndex >= 0 )
{
_keys.RemoveAt( vIndex );
_values.RemoveAt( vIndex );
}
}
while( vIndex >= 0 );
vIndex = 0;
do
{
vIndex = _values.FindIndex( vIndex, v => !v.IsAlive );
if( vIndex >= 0 )
{
_values.RemoveAt( vIndex );
_keys.RemoveAt( vIndex );
}
}
while( vIndex >= 0 );
}
#endregion
}
}

48
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IDropTarget.cs

@ -1,48 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal interface IDropTarget
{
#region Properties
DropTargetType Type
{
get;
}
#endregion
#region Methods
Geometry GetPreviewPath( OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindow );
bool HitTest( Point dragPoint );
void Drop( LayoutFloatingWindow floatingWindow );
void DragEnter();
void DragLeave();
#endregion
}
}

35
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindow.cs

@ -1,35 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Collections.Generic;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal interface IOverlayWindow
{
IEnumerable<IDropTarget> GetTargets();
void DragEnter( LayoutFloatingWindowControl floatingWindow );
void DragLeave( LayoutFloatingWindowControl floatingWindow );
void DragEnter( IDropArea area );
void DragLeave( IDropArea area );
void DragEnter( IDropTarget target );
void DragLeave( IDropTarget target );
void DragDrop( IDropTarget target );
}
}

28
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindowArea.cs

@ -1,28 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal interface IOverlayWindowArea
{
Rect ScreenDetectionArea
{
get;
}
}
}

33
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindowDropTarget.cs

@ -1,33 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
interface IOverlayWindowDropTarget
{
Rect ScreenDetectionArea
{
get;
}
OverlayWindowDropTargetType Type
{
get;
}
}
}

45
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/IOverlayWindowHost.cs

@ -1,45 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Collections.Generic;
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal interface IOverlayWindowHost
{
#region Properties
DockingManager Manager
{
get;
}
#endregion
#region Methods
bool HitTest( Point dragPoint );
IOverlayWindow ShowOverlayWindow( LayoutFloatingWindowControl draggingWindow );
void HideOverlayWindow();
IEnumerable<IDropArea> GetDropAreas( LayoutFloatingWindowControl draggingWindow );
#endregion
}
}

204
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorControl.cs

@ -1,204 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows;
using System.Windows.Controls;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows.Threading;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorControl : Control, ILayoutControl
{
#region Members
private LayoutAnchorable _model;
private DispatcherTimer _openUpTimer = null;
#endregion
#region Constructors
static LayoutAnchorControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAnchorControl ), new FrameworkPropertyMetadata( typeof( LayoutAnchorControl ) ) );
Control.IsHitTestVisibleProperty.AddOwner( typeof( LayoutAnchorControl ), new FrameworkPropertyMetadata( true ) );
}
internal LayoutAnchorControl( LayoutAnchorable model )
{
_model = model;
_model.IsActiveChanged += new EventHandler( _model_IsActiveChanged );
_model.IsSelectedChanged += new EventHandler( _model_IsSelectedChanged );
SetSide( _model.FindParent<LayoutAnchorSide>().Side );
}
#endregion
#region Properties
#region Model
public ILayoutElement Model
{
get
{
return _model;
}
}
#endregion
#region Side
/// <summary>
/// Side Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey SidePropertyKey = DependencyProperty.RegisterReadOnly( "Side", typeof( AnchorSide ), typeof( LayoutAnchorControl ),
new FrameworkPropertyMetadata( ( AnchorSide )AnchorSide.Left ) );
public static readonly DependencyProperty SideProperty = SidePropertyKey.DependencyProperty;
/// <summary>
/// Gets the Side property. This dependency property
/// indicates the anchor side of the control.
/// </summary>
public AnchorSide Side
{
get
{
return ( AnchorSide )GetValue( SideProperty );
}
}
/// <summary>
/// Provides a secure method for setting the Side property.
/// This dependency property indicates the anchor side of the control.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetSide( AnchorSide value )
{
SetValue( SidePropertyKey, value );
}
#endregion
#endregion
#region Private Methods
private void _model_IsSelectedChanged( object sender, EventArgs e )
{
if( !_model.IsAutoHidden )
_model.IsSelectedChanged -= new EventHandler( _model_IsSelectedChanged );
else if( _model.IsSelected )
{
_model.Root.Manager.ShowAutoHideWindow( this );
_model.IsSelected = false;
}
}
private void _model_IsActiveChanged( object sender, EventArgs e )
{
if( !_model.IsAutoHidden )
_model.IsActiveChanged -= new EventHandler( _model_IsActiveChanged );
else if( _model.IsActive )
_model.Root.Manager.ShowAutoHideWindow( this );
}
private void _openUpTimer_Tick( object sender, EventArgs e )
{
_openUpTimer.Tick -= new EventHandler( _openUpTimer_Tick );
_openUpTimer.Stop();
_openUpTimer = null;
_model.Root.Manager.ShowAutoHideWindow( this );
}
#endregion
#region Overrides
//protected override void OnVisualParentChanged(DependencyObject oldParent)
//{
// base.OnVisualParentChanged(oldParent);
// var contentModel = _model;
// if (oldParent != null && contentModel != null && contentModel.Content is UIElement)
// {
// var oldParentPaneControl = oldParent.FindVisualAncestor<LayoutAnchorablePaneControl>();
// if (oldParentPaneControl != null)
// {
// ((ILogicalChildrenContainer)oldParentPaneControl).InternalRemoveLogicalChild(contentModel.Content);
// }
// }
// if (contentModel.Content != null && contentModel.Content is UIElement)
// {
// var oldLogicalParentPaneControl = LogicalTreeHelper.GetParent(contentModel.Content as UIElement)
// as ILogicalChildrenContainer;
// if (oldLogicalParentPaneControl != null)
// oldLogicalParentPaneControl.InternalRemoveLogicalChild(contentModel.Content);
// }
// if (contentModel != null && contentModel.Content != null && contentModel.Root != null && contentModel.Content is UIElement)
// {
// ((ILogicalChildrenContainer)contentModel.Root.Manager).InternalAddLogicalChild(contentModel.Content);
// }
//}
protected override void OnMouseDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseDown( e );
if( !e.Handled )
{
_model.Root.Manager.ShowAutoHideWindow( this );
_model.IsActive = true;
}
}
protected override void OnMouseEnter( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseEnter( e );
if( !e.Handled )
{
_openUpTimer = new DispatcherTimer( DispatcherPriority.ApplicationIdle );
_openUpTimer.Interval = TimeSpan.FromMilliseconds( 400 );
_openUpTimer.Tick += new EventHandler( _openUpTimer_Tick );
_openUpTimer.Start();
}
}
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
if( _openUpTimer != null )
{
_openUpTimer.Tick -= new EventHandler( _openUpTimer_Tick );
_openUpTimer.Stop();
_openUpTimer = null;
}
base.OnMouseLeave( e );
}
#endregion
}
}

116
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorGroupControl.cs

@ -1,116 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Linq;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorGroupControl : Control, ILayoutControl
{
#region Members
private ObservableCollection<LayoutAnchorControl> _childViews = new ObservableCollection<LayoutAnchorControl>();
private LayoutAnchorGroup _model;
#endregion
#region Constructors
static LayoutAnchorGroupControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAnchorGroupControl ), new FrameworkPropertyMetadata( typeof( LayoutAnchorGroupControl ) ) );
}
internal LayoutAnchorGroupControl( LayoutAnchorGroup model )
{
_model = model;
CreateChildrenViews();
_model.Children.CollectionChanged += ( s, e ) => OnModelChildrenCollectionChanged( e );
}
#endregion
#region Properties
public ObservableCollection<LayoutAnchorControl> Children
{
get
{
return _childViews;
}
}
public ILayoutElement Model
{
get
{
return _model;
}
}
#endregion
#region Private Methods
private void CreateChildrenViews()
{
var manager = _model.Root.Manager;
foreach( var childModel in _model.Children )
{
_childViews.Add( new LayoutAnchorControl( childModel ) { Template = manager.AnchorTemplate } );
}
}
private void OnModelChildrenCollectionChanged( System.Collections.Specialized.NotifyCollectionChangedEventArgs e )
{
if( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace )
{
if( e.OldItems != null )
{
{
foreach( var childModel in e.OldItems )
_childViews.Remove( _childViews.First( cv => cv.Model == childModel ) );
}
}
}
if( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset )
_childViews.Clear();
if( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace )
{
if( e.NewItems != null )
{
var manager = _model.Root.Manager;
int insertIndex = e.NewStartingIndex;
foreach( LayoutAnchorable childModel in e.NewItems )
{
_childViews.Insert( insertIndex++, new LayoutAnchorControl( childModel ) { Template = manager.AnchorTemplate } );
}
}
}
}
#endregion
}
}

287
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorSideControl.cs

@ -1,287 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows;
using System.Collections.ObjectModel;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorSideControl : Control, ILayoutControl
{
#region Members
private LayoutAnchorSide _model = null;
private ObservableCollection<LayoutAnchorGroupControl> _childViews = new ObservableCollection<LayoutAnchorGroupControl>();
#endregion
#region Constructors
static LayoutAnchorSideControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAnchorSideControl ), new FrameworkPropertyMetadata( typeof( LayoutAnchorSideControl ) ) );
}
internal LayoutAnchorSideControl( LayoutAnchorSide model )
{
if( model == null )
throw new ArgumentNullException( "model" );
_model = model;
CreateChildrenViews();
_model.Children.CollectionChanged += ( s, e ) => OnModelChildrenCollectionChanged( e );
UpdateSide();
}
#endregion
#region Properties
#region Model
public ILayoutElement Model
{
get
{
return _model;
}
}
#endregion
#region Children
public ObservableCollection<LayoutAnchorGroupControl> Children
{
get
{
return _childViews;
}
}
#endregion
#region IsLeftSide
/// <summary>
/// IsLeftSide Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsLeftSidePropertyKey = DependencyProperty.RegisterReadOnly( "IsLeftSide", typeof( bool ), typeof( LayoutAnchorSideControl ),
new FrameworkPropertyMetadata( ( bool )false ) );
public static readonly DependencyProperty IsLeftSideProperty = IsLeftSidePropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsLeftSide property. This dependency property
/// indicates this control is anchored to left side.
/// </summary>
public bool IsLeftSide
{
get
{
return ( bool )GetValue( IsLeftSideProperty );
}
}
/// <summary>
/// Provides a secure method for setting the IsLeftSide property.
/// This dependency property indicates this control is anchored to left side.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsLeftSide( bool value )
{
SetValue( IsLeftSidePropertyKey, value );
}
#endregion
#region IsTopSide
/// <summary>
/// IsTopSide Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsTopSidePropertyKey = DependencyProperty.RegisterReadOnly( "IsTopSide", typeof( bool ), typeof( LayoutAnchorSideControl ),
new FrameworkPropertyMetadata( ( bool )false ) );
public static readonly DependencyProperty IsTopSideProperty = IsTopSidePropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsTopSide property. This dependency property
/// indicates this control is anchored to top side.
/// </summary>
public bool IsTopSide
{
get
{
return ( bool )GetValue( IsTopSideProperty );
}
}
/// <summary>
/// Provides a secure method for setting the IsTopSide property.
/// This dependency property indicates this control is anchored to top side.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsTopSide( bool value )
{
SetValue( IsTopSidePropertyKey, value );
}
#endregion
#region IsRightSide
/// <summary>
/// IsRightSide Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsRightSidePropertyKey = DependencyProperty.RegisterReadOnly( "IsRightSide", typeof( bool ), typeof( LayoutAnchorSideControl ),
new FrameworkPropertyMetadata( ( bool )false ) );
public static readonly DependencyProperty IsRightSideProperty = IsRightSidePropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsRightSide property. This dependency property
/// indicates this control is anchored to right side.
/// </summary>
public bool IsRightSide
{
get
{
return ( bool )GetValue( IsRightSideProperty );
}
}
/// <summary>
/// Provides a secure method for setting the IsRightSide property.
/// This dependency property indicates this control is anchored to right side.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsRightSide( bool value )
{
SetValue( IsRightSidePropertyKey, value );
}
#endregion
#region IsBottomSide
/// <summary>
/// IsBottomSide Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsBottomSidePropertyKey = DependencyProperty.RegisterReadOnly( "IsBottomSide", typeof( bool ), typeof( LayoutAnchorSideControl ),
new FrameworkPropertyMetadata( ( bool )false ) );
public static readonly DependencyProperty IsBottomSideProperty = IsBottomSidePropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsBottomSide property. This dependency property
/// indicates if this panel is anchored to bottom side.
/// </summary>
public bool IsBottomSide
{
get
{
return ( bool )GetValue( IsBottomSideProperty );
}
}
/// <summary>
/// Provides a secure method for setting the IsBottomSide property.
/// This dependency property indicates if this panel is anchored to bottom side.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsBottomSide( bool value )
{
SetValue( IsBottomSidePropertyKey, value );
}
#endregion
#endregion
#region Overrides
#endregion
#region Private Methods
private void CreateChildrenViews()
{
var manager = _model.Root.Manager;
foreach( var childModel in _model.Children )
{
_childViews.Add( manager.CreateUIElementForModel( childModel ) as LayoutAnchorGroupControl );
}
}
private void OnModelChildrenCollectionChanged( System.Collections.Specialized.NotifyCollectionChangedEventArgs e )
{
if( e.OldItems != null &&
( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace ) )
{
foreach( var childModel in e.OldItems )
_childViews.Remove( _childViews.First( cv => cv.Model == childModel ) );
}
if( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset )
_childViews.Clear();
if( e.NewItems != null &&
( e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace ) )
{
var manager = _model.Root.Manager;
int insertIndex = e.NewStartingIndex;
foreach( LayoutAnchorGroup childModel in e.NewItems )
{
_childViews.Insert( insertIndex++, manager.CreateUIElementForModel( childModel ) as LayoutAnchorGroupControl );
}
}
}
private void UpdateSide()
{
switch( _model.Side )
{
case AnchorSide.Left:
SetIsLeftSide( true );
break;
case AnchorSide.Top:
SetIsTopSide( true );
break;
case AnchorSide.Right:
SetIsRightSide( true );
break;
case AnchorSide.Bottom:
SetIsBottomSide( true );
break;
}
}
#endregion
}
}

162
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableControl.cs

@ -1,162 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
using System.Windows.Controls;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorableControl : Control
{
#region Constructors
static LayoutAnchorableControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAnchorableControl ), new FrameworkPropertyMetadata( typeof( LayoutAnchorableControl ) ) );
FocusableProperty.OverrideMetadata( typeof( LayoutAnchorableControl ), new FrameworkPropertyMetadata( false ) );
}
public LayoutAnchorableControl()
{
//SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this });
}
#endregion
#region Properties
#region Model
/// <summary>
/// Model Dependency Property
/// </summary>
public static readonly DependencyProperty ModelProperty = DependencyProperty.Register( "Model", typeof( LayoutAnchorable ), typeof( LayoutAnchorableControl ),
new FrameworkPropertyMetadata( ( LayoutAnchorable )null, new PropertyChangedCallback( OnModelChanged ) ) );
/// <summary>
/// Gets or sets the Model property. This dependency property
/// indicates the model attached to this view.
/// </summary>
public LayoutAnchorable Model
{
get
{
return ( LayoutAnchorable )GetValue( ModelProperty );
}
set
{
SetValue( ModelProperty, value );
}
}
/// <summary>
/// Handles changes to the Model property.
/// </summary>
private static void OnModelChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableControl )d ).OnModelChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Model property.
/// </summary>
protected virtual void OnModelChanged( DependencyPropertyChangedEventArgs e )
{
if( e.OldValue != null )
{
( ( LayoutContent )e.OldValue ).PropertyChanged -= Model_PropertyChanged;
}
if( Model != null )
{
Model.PropertyChanged += Model_PropertyChanged;
SetLayoutItem( Model.Root.Manager.GetLayoutItemFromModel( Model ) );
}
else
SetLayoutItem( null );
}
private void Model_PropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
{
if( e.PropertyName == "IsEnabled" )
{
if( Model != null )
{
IsEnabled = Model.IsEnabled;
if( !IsEnabled && Model.IsActive )
{
if( ( Model.Parent != null ) && ( Model.Parent is LayoutAnchorablePane ) )
{
( ( LayoutAnchorablePane )Model.Parent ).SetNextSelectedIndex();
}
}
}
}
}
#endregion
#region LayoutItem
/// <summary>
/// LayoutItem Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly( "LayoutItem", typeof( LayoutItem ), typeof( LayoutAnchorableControl ),
new FrameworkPropertyMetadata( ( LayoutItem )null ) );
public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty;
/// <summary>
/// Gets the LayoutItem property. This dependency property
/// indicates the LayoutItem attached to this tag item.
/// </summary>
public LayoutItem LayoutItem
{
get
{
return ( LayoutItem )GetValue( LayoutItemProperty );
}
}
/// <summary>
/// Provides a secure method for setting the LayoutItem property.
/// This dependency property indicates the LayoutItem attached to this tag item.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetLayoutItem( LayoutItem value )
{
SetValue( LayoutItemPropertyKey, value );
}
#endregion
#endregion
#region Overrides
protected override void OnGotKeyboardFocus( System.Windows.Input.KeyboardFocusChangedEventArgs e )
{
if( Model != null )
Model.IsActive = true;
base.OnGotKeyboardFocus( e );
}
#endregion
}
}

441
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs

@ -1,441 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using Xceed.Wpf.AvalonDock.Layout;
using Xceed.Wpf.AvalonDock.Converters;
using System.Windows.Controls.Primitives;
using Xceed.Wpf.AvalonDock.Commands;
using Microsoft.Windows.Shell;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorableFloatingWindowControl : LayoutFloatingWindowControl, IOverlayWindowHost
{
#region Members
private LayoutAnchorableFloatingWindow _model;
private OverlayWindow _overlayWindow = null;
private List<IDropArea> _dropAreas = null;
#endregion
#region Constructors
static LayoutAnchorableFloatingWindowControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAnchorableFloatingWindowControl ), new FrameworkPropertyMetadata( typeof( LayoutAnchorableFloatingWindowControl ) ) );
}
internal LayoutAnchorableFloatingWindowControl( LayoutAnchorableFloatingWindow model )
: base( model )
{
_model = model;
HideWindowCommand = new RelayCommand( ( p ) => OnExecuteHideWindowCommand( p ), ( p ) => CanExecuteHideWindowCommand( p ) );
CloseWindowCommand = new RelayCommand( ( p ) => OnExecuteCloseWindowCommand( p ), ( p ) => CanExecuteCloseWindowCommand( p ) );
UpdateThemeResources();
}
#endregion
#region Properties
#region SingleContentLayoutItem
/// <summary>
/// SingleContentLayoutItem Dependency Property
/// </summary>
public static readonly DependencyProperty SingleContentLayoutItemProperty = DependencyProperty.Register( "SingleContentLayoutItem", typeof( LayoutItem ), typeof( LayoutAnchorableFloatingWindowControl ),
new FrameworkPropertyMetadata( ( LayoutItem )null, new PropertyChangedCallback( OnSingleContentLayoutItemChanged ) ) );
/// <summary>
/// Gets or sets the SingleContentLayoutItem property. This dependency property
/// indicates the layout item of the selected content when is shown a single anchorable pane.
/// </summary>
public LayoutItem SingleContentLayoutItem
{
get
{
return ( LayoutItem )GetValue( SingleContentLayoutItemProperty );
}
set
{
SetValue( SingleContentLayoutItemProperty, value );
}
}
/// <summary>
/// Handles changes to the SingleContentLayoutItem property.
/// </summary>
private static void OnSingleContentLayoutItemChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableFloatingWindowControl )d ).OnSingleContentLayoutItemChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the SingleContentLayoutItem property.
/// </summary>
protected virtual void OnSingleContentLayoutItemChanged( DependencyPropertyChangedEventArgs e )
{
}
#endregion
#endregion
#region Overrides
public override ILayoutElement Model
{
get
{
return _model;
}
}
protected override void OnInitialized( EventArgs e )
{
base.OnInitialized( e );
var manager = _model.Root.Manager;
Content = manager.CreateUIElementForModel( _model.RootPanel );
//SetBinding(VisibilityProperty, new Binding("IsVisible") { Source = _model, Converter = new BoolToVisibilityConverter(), Mode = BindingMode.OneWay, ConverterParameter = Visibility.Hidden });
//Issue: http://avalondock.codeplex.com/workitem/15036
IsVisibleChanged += ( s, args ) =>
{
var visibilityBinding = GetBindingExpression( VisibilityProperty );
if( IsVisible && ( visibilityBinding == null ) )
{
SetBinding( VisibilityProperty, new Binding( "IsVisible" ) { Source = _model, Converter = new BoolToVisibilityConverter(), Mode = BindingMode.OneWay, ConverterParameter = Visibility.Hidden } );
}
};
SetBinding( SingleContentLayoutItemProperty, new Binding( "Model.SinglePane.SelectedContent" ) { Source = this, Converter = new LayoutItemFromLayoutModelConverter() } );
_model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler( _model_PropertyChanged );
}
protected override void OnClosed( EventArgs e )
{
var root = Model.Root;
root.Manager.RemoveFloatingWindow( this );
root.CollectGarbage();
if( _overlayWindow != null )
{
_overlayWindow.Close();
_overlayWindow = null;
}
base.OnClosed( e );
if( !CloseInitiatedByUser )
{
root.FloatingWindows.Remove( _model );
}
_model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler( _model_PropertyChanged );
}
protected override void OnClosing( System.ComponentModel.CancelEventArgs e )
{
if( CloseInitiatedByUser && !KeepContentVisibleOnClose )
{
e.Cancel = true;
_model.Descendents().OfType<LayoutAnchorable>().ToArray().ForEach<LayoutAnchorable>( ( a ) => a.Hide() );
}
base.OnClosing( e );
}
protected override IntPtr FilterMessage( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled )
{
switch( msg )
{
case Win32Helper.WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager
if( wParam.ToInt32() == Win32Helper.HT_CAPTION )
{
_model.Descendents().OfType<LayoutAnchorablePane>().First( p => p.ChildrenCount > 0 && p.SelectedContent != null ).SelectedContent.IsActive = true;
handled = true;
}
break;
case Win32Helper.WM_NCRBUTTONUP:
if( wParam.ToInt32() == Win32Helper.HT_CAPTION )
{
if( OpenContextMenu() )
handled = true;
if( _model.Root.Manager.ShowSystemMenu )
WindowChrome.GetWindowChrome( this ).ShowSystemMenu = !handled;
else
WindowChrome.GetWindowChrome( this ).ShowSystemMenu = false;
}
break;
}
return base.FilterMessage( hwnd, msg, wParam, lParam, ref handled );
}
internal override void UpdateThemeResources( Xceed.Wpf.AvalonDock.Themes.Theme oldTheme = null )
{
base.UpdateThemeResources( oldTheme );
if( _overlayWindow != null )
{
_overlayWindow.UpdateThemeResources( oldTheme );
}
}
#endregion
#region Private Methods
private void _model_PropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
{
if( e.PropertyName == "RootPanel" &&
_model.RootPanel == null )
{
InternalClose();
}
}
private void CreateOverlayWindow()
{
if( _overlayWindow == null )
_overlayWindow = new OverlayWindow( this );
Rect rectWindow = new Rect( this.PointToScreenDPIWithoutFlowDirection( new Point() ), this.TransformActualSizeToAncestor() );
_overlayWindow.Left = rectWindow.Left;
_overlayWindow.Top = rectWindow.Top;
_overlayWindow.Width = rectWindow.Width;
_overlayWindow.Height = rectWindow.Height;
}
private bool OpenContextMenu()
{
var ctxMenu = _model.Root.Manager.AnchorableContextMenu;
if( ctxMenu != null && SingleContentLayoutItem != null )
{
ctxMenu.PlacementTarget = null;
ctxMenu.Placement = PlacementMode.MousePoint;
ctxMenu.DataContext = SingleContentLayoutItem;
ctxMenu.IsOpen = true;
return true;
}
return false;
}
private bool IsContextMenuOpen()
{
var ctxMenu = _model.Root.Manager.AnchorableContextMenu;
if( ctxMenu != null && SingleContentLayoutItem != null )
{
return ctxMenu.IsOpen;
}
return false;
}
#endregion
#region Commands
#region HideWindowCommand
public ICommand HideWindowCommand
{
get;
private set;
}
private bool CanExecuteHideWindowCommand( object parameter )
{
if( Model == null )
return false;
var root = Model.Root;
if( root == null )
return false;
var manager = root.Manager;
if( manager == null )
return false;
bool canExecute = false;
foreach( var anchorable in this.Model.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
if( !anchorable.CanHide )
{
canExecute = false;
break;
}
var anchorableLayoutItem = manager.GetLayoutItemFromModel( anchorable ) as LayoutAnchorableItem;
if( anchorableLayoutItem == null ||
anchorableLayoutItem.HideCommand == null ||
!anchorableLayoutItem.HideCommand.CanExecute( parameter ) )
{
canExecute = false;
break;
}
canExecute = true;
}
return canExecute;
}
private void OnExecuteHideWindowCommand( object parameter )
{
var manager = Model.Root.Manager;
foreach( var anchorable in this.Model.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
var anchorableLayoutItem = manager.GetLayoutItemFromModel( anchorable ) as LayoutAnchorableItem;
anchorableLayoutItem.HideCommand.Execute( parameter );
}
}
#endregion
#region CloseWindowCommand
public ICommand CloseWindowCommand
{
get;
private set;
}
private bool CanExecuteCloseWindowCommand( object parameter )
{
if( Model == null )
return false;
var root = Model.Root;
if( root == null )
return false;
var manager = root.Manager;
if( manager == null )
return false;
bool canExecute = false;
foreach( var anchorable in this.Model.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
if( !anchorable.CanClose )
{
canExecute = false;
break;
}
var anchorableLayoutItem = manager.GetLayoutItemFromModel( anchorable ) as LayoutAnchorableItem;
if( anchorableLayoutItem == null ||
anchorableLayoutItem.CloseCommand == null ||
!anchorableLayoutItem.CloseCommand.CanExecute( parameter ) )
{
canExecute = false;
break;
}
canExecute = true;
}
return canExecute;
}
private void OnExecuteCloseWindowCommand( object parameter )
{
var manager = Model.Root.Manager;
foreach( var anchorable in this.Model.Descendents().OfType<LayoutAnchorable>().ToArray() )
{
var anchorableLayoutItem = manager.GetLayoutItemFromModel( anchorable ) as LayoutAnchorableItem;
anchorableLayoutItem.CloseCommand.Execute( parameter );
}
}
#endregion
#endregion
#region IOverlayWindowHost
bool IOverlayWindowHost.HitTest( Point dragPoint )
{
Rect detectionRect = new Rect( this.PointToScreenDPIWithoutFlowDirection( new Point() ), this.TransformActualSizeToAncestor() );
return detectionRect.Contains( dragPoint );
}
DockingManager IOverlayWindowHost.Manager
{
get
{
return _model.Root.Manager;
}
}
IOverlayWindow IOverlayWindowHost.ShowOverlayWindow( LayoutFloatingWindowControl draggingWindow )
{
CreateOverlayWindow();
_overlayWindow.Owner = draggingWindow;
_overlayWindow.EnableDropTargets();
_overlayWindow.Show();
return _overlayWindow;
}
void IOverlayWindowHost.HideOverlayWindow()
{
_dropAreas = null;
_overlayWindow.Owner = null;
_overlayWindow.HideDropTargets();
}
IEnumerable<IDropArea> IOverlayWindowHost.GetDropAreas( LayoutFloatingWindowControl draggingWindow )
{
if( _dropAreas != null )
return _dropAreas;
_dropAreas = new List<IDropArea>();
if( draggingWindow.Model is LayoutDocumentFloatingWindow )
return _dropAreas;
var rootVisual = ( Content as FloatingWindowContentHost ).RootVisual;
foreach( var areaHost in rootVisual.FindVisualChildren<LayoutAnchorablePaneControl>() )
{
_dropAreas.Add( new DropArea<LayoutAnchorablePaneControl>(
areaHost,
DropAreaType.AnchorablePane ) );
}
foreach( var areaHost in rootVisual.FindVisualChildren<LayoutDocumentPaneControl>() )
{
_dropAreas.Add( new DropArea<LayoutDocumentPaneControl>(
areaHost,
DropAreaType.DocumentPane ) );
}
return _dropAreas;
}
#endregion
}
}

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

@ -1,392 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows.Input;
using System.Windows;
using Xceed.Wpf.AvalonDock.Commands;
using System.Windows.Data;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorableItem : LayoutItem
{
#region Members
private LayoutAnchorable _anchorable;
private ICommand _defaultHideCommand;
private ICommand _defaultAutoHideCommand;
private ICommand _defaultDockCommand;
private ReentrantFlag _visibilityReentrantFlag = new ReentrantFlag();
#endregion
#region Constructors
internal LayoutAnchorableItem()
{
}
#endregion
#region Properties
#region HideCommand
/// <summary>
/// HideCommand Dependency Property
/// </summary>
public static readonly DependencyProperty HideCommandProperty = DependencyProperty.Register( "HideCommand", typeof( ICommand ), typeof( LayoutAnchorableItem ),
new FrameworkPropertyMetadata( null, new PropertyChangedCallback( OnHideCommandChanged ), new CoerceValueCallback( CoerceHideCommandValue ) ) );
/// <summary>
/// Gets or sets the HideCommand property. This dependency property
/// indicates the command to execute when an anchorable is hidden.
/// </summary>
public ICommand HideCommand
{
get
{
return ( ICommand )GetValue( HideCommandProperty );
}
set
{
SetValue( HideCommandProperty, value );
}
}
/// <summary>
/// Handles changes to the HideCommand property.
/// </summary>
private static void OnHideCommandChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableItem )d ).OnHideCommandChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the HideCommand property.
/// </summary>
protected virtual void OnHideCommandChanged( DependencyPropertyChangedEventArgs e )
{
}
/// <summary>
/// Coerces the HideCommand value.
/// </summary>
private static object CoerceHideCommandValue( DependencyObject d, object value )
{
return value;
}
private bool CanExecuteHideCommand( object parameter )
{
if( LayoutElement == null )
return false;
return _anchorable.CanHide;
}
private void ExecuteHideCommand( object parameter )
{
if( _anchorable != null && _anchorable.Root != null && _anchorable.Root.Manager != null )
_anchorable.Root.Manager._ExecuteHideCommand( _anchorable );
}
#endregion
#region AutoHideCommand
/// <summary>
/// AutoHideCommand Dependency Property
/// </summary>
public static readonly DependencyProperty AutoHideCommandProperty = DependencyProperty.Register( "AutoHideCommand", typeof( ICommand ), typeof( LayoutAnchorableItem ),
new FrameworkPropertyMetadata( null, new PropertyChangedCallback( OnAutoHideCommandChanged ), new CoerceValueCallback( CoerceAutoHideCommandValue ) ) );
/// <summary>
/// Gets or sets the AutoHideCommand property. This dependency property
/// indicates the command to execute when user click the auto hide button.
/// </summary>
/// <remarks>By default this command toggles auto hide state for an anchorable.</remarks>
public ICommand AutoHideCommand
{
get
{
return ( ICommand )GetValue( AutoHideCommandProperty );
}
set
{
SetValue( AutoHideCommandProperty, value );
}
}
/// <summary>
/// Handles changes to the AutoHideCommand property.
/// </summary>
private static void OnAutoHideCommandChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableItem )d ).OnAutoHideCommandChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the AutoHideCommand property.
/// </summary>
protected virtual void OnAutoHideCommandChanged( DependencyPropertyChangedEventArgs e )
{
}
/// <summary>
/// Coerces the AutoHideCommand value.
/// </summary>
private static object CoerceAutoHideCommandValue( DependencyObject d, object value )
{
return value;
}
private bool CanExecuteAutoHideCommand( object parameter )
{
if( LayoutElement == null )
return false;
if( LayoutElement.FindParent<LayoutAnchorableFloatingWindow>() != null )
return false;//is floating
return _anchorable.CanAutoHide;
}
private void ExecuteAutoHideCommand( object parameter )
{
if( _anchorable != null && _anchorable.Root != null && _anchorable.Root.Manager != null )
_anchorable.Root.Manager._ExecuteAutoHideCommand( _anchorable );
}
#endregion
#region DockCommand
/// <summary>
/// DockCommand Dependency Property
/// </summary>
public static readonly DependencyProperty DockCommandProperty = DependencyProperty.Register( "DockCommand", typeof( ICommand ), typeof( LayoutAnchorableItem ),
new FrameworkPropertyMetadata( null, new PropertyChangedCallback( OnDockCommandChanged ), new CoerceValueCallback( CoerceDockCommandValue ) ) );
/// <summary>
/// Gets or sets the DockCommand property. This dependency property
/// indicates the command to execute when user click the Dock button.
/// </summary>
/// <remarks>By default this command moves the anchorable inside the container pane which previously hosted the object.</remarks>
public ICommand DockCommand
{
get
{
return ( ICommand )GetValue( DockCommandProperty );
}
set
{
SetValue( DockCommandProperty, value );
}
}
/// <summary>
/// Handles changes to the DockCommand property.
/// </summary>
private static void OnDockCommandChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableItem )d ).OnDockCommandChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the DockCommand property.
/// </summary>
protected virtual void OnDockCommandChanged( DependencyPropertyChangedEventArgs e )
{
}
/// <summary>
/// Coerces the DockCommand value.
/// </summary>
private static object CoerceDockCommandValue( DependencyObject d, object value )
{
return value;
}
private bool CanExecuteDockCommand( object parameter )
{
if( LayoutElement == null )
return false;
return LayoutElement.FindParent<LayoutAnchorableFloatingWindow>() != null;
}
private void ExecuteDockCommand( object parameter )
{
LayoutElement.Root.Manager._ExecuteDockCommand( _anchorable );
}
#endregion
#region CanHide
/// <summary>
/// CanHide Dependency Property
/// </summary>
public static readonly DependencyProperty CanHideProperty = DependencyProperty.Register( "CanHide", typeof( bool ), typeof( LayoutAnchorableItem ), new FrameworkPropertyMetadata( ( bool )true,
new PropertyChangedCallback( OnCanHideChanged ) ) );
/// <summary>
/// Gets or sets the CanHide property. This dependency property
/// indicates if user can hide the anchorable item.
/// </summary>
public bool CanHide
{
get
{
return ( bool )GetValue( CanHideProperty );
}
set
{
SetValue( CanHideProperty, value );
}
}
/// <summary>
/// Handles changes to the CanHide property.
/// </summary>
private static void OnCanHideChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableItem )d ).OnCanHideChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the CanHide property.
/// </summary>
protected virtual void OnCanHideChanged( DependencyPropertyChangedEventArgs e )
{
if( _anchorable != null )
_anchorable.CanHide = ( bool )e.NewValue;
}
#endregion
#endregion
#region Overrides
internal override void Attach( LayoutContent model )
{
_anchorable = model as LayoutAnchorable;
_anchorable.IsVisibleChanged += new EventHandler( _anchorable_IsVisibleChanged );
base.Attach( model );
}
internal override void Detach()
{
_anchorable.IsVisibleChanged -= new EventHandler( _anchorable_IsVisibleChanged );
_anchorable = null;
base.Detach();
}
protected override void Close()
{
if( ( _anchorable.Root != null ) && ( _anchorable.Root.Manager != null ) )
{
var dockingManager = _anchorable.Root.Manager;
dockingManager._ExecuteCloseCommand( _anchorable );
}
}
protected override void InitDefaultCommands()
{
_defaultHideCommand = new RelayCommand( ( p ) => ExecuteHideCommand( p ), ( p ) => CanExecuteHideCommand( p ) );
_defaultAutoHideCommand = new RelayCommand( ( p ) => ExecuteAutoHideCommand( p ), ( p ) => CanExecuteAutoHideCommand( p ) );
_defaultDockCommand = new RelayCommand( ( p ) => ExecuteDockCommand( p ), ( p ) => CanExecuteDockCommand( p ) );
base.InitDefaultCommands();
}
protected override void ClearDefaultBindings()
{
if( HideCommand == _defaultHideCommand )
BindingOperations.ClearBinding( this, HideCommandProperty );
if( AutoHideCommand == _defaultAutoHideCommand )
BindingOperations.ClearBinding( this, AutoHideCommandProperty );
if( DockCommand == _defaultDockCommand )
BindingOperations.ClearBinding( this, DockCommandProperty );
base.ClearDefaultBindings();
}
protected override void SetDefaultBindings()
{
if( HideCommand == null )
HideCommand = _defaultHideCommand;
if( AutoHideCommand == null )
AutoHideCommand = _defaultAutoHideCommand;
if( DockCommand == null )
DockCommand = _defaultDockCommand;
Visibility = _anchorable.IsVisible ? Visibility.Visible : System.Windows.Visibility.Hidden;
base.SetDefaultBindings();
}
protected override void OnVisibilityChanged()
{
if( _anchorable != null && _anchorable.Root != null )
{
if( _visibilityReentrantFlag.CanEnter )
{
using( _visibilityReentrantFlag.Enter() )
{
if( Visibility == System.Windows.Visibility.Hidden )
_anchorable.Hide( false );
else if( Visibility == System.Windows.Visibility.Visible )
_anchorable.Show();
}
}
}
base.OnVisibilityChanged();
}
#endregion
#region Private Methods
private void _anchorable_IsVisibleChanged( object sender, EventArgs e )
{
if( _anchorable != null && _anchorable.Root != null )
{
if( _visibilityReentrantFlag.CanEnter )
{
using( _visibilityReentrantFlag.Enter() )
{
if( _anchorable.IsVisible )
Visibility = Visibility.Visible;
else
Visibility = Visibility.Hidden;
}
}
}
}
#endregion
}
}

113
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneControl.cs

@ -1,113 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorablePaneControl : TabControl, ILayoutControl//, ILogicalChildrenContainer
{
#region Members
private LayoutAnchorablePane _model;
#endregion
#region Constructors
static LayoutAnchorablePaneControl()
{
FocusableProperty.OverrideMetadata( typeof( LayoutAnchorablePaneControl ), new FrameworkPropertyMetadata( false ) );
}
public LayoutAnchorablePaneControl( LayoutAnchorablePane model )
{
if( model == null )
throw new ArgumentNullException( "model" );
_model = model;
SetBinding( ItemsSourceProperty, new Binding( "Model.Children" ) { Source = this } );
SetBinding( FlowDirectionProperty, new Binding( "Model.Root.Manager.FlowDirection" ) { Source = this } );
this.LayoutUpdated += new EventHandler( OnLayoutUpdated );
}
#endregion
#region Properties
public ILayoutElement Model
{
get
{
return _model;
}
}
#endregion
#region Overrides
protected override void OnGotKeyboardFocus( System.Windows.Input.KeyboardFocusChangedEventArgs e )
{
if( ( _model != null ) && ( _model.SelectedContent != null ) )
{
_model.SelectedContent.IsActive = true;
}
base.OnGotKeyboardFocus( e );
}
protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseLeftButtonDown( e );
if( !e.Handled && ( _model != null ) && ( _model.SelectedContent != null ) )
{
_model.SelectedContent.IsActive = true;
}
}
protected override void OnMouseRightButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseRightButtonDown( e );
if( !e.Handled && ( _model != null ) && ( _model.SelectedContent != null ) )
{
_model.SelectedContent.IsActive = true;
}
}
#endregion
#region Private Methods
private void OnLayoutUpdated( object sender, EventArgs e )
{
var modelWithAtcualSize = _model as ILayoutPositionableElementWithActualSize;
modelWithAtcualSize.ActualWidth = ActualWidth;
modelWithAtcualSize.ActualHeight = ActualHeight;
}
#endregion
}
}

73
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneGroupControl.cs

@ -1,73 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows.Controls;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorablePaneGroupControl : LayoutGridControl<ILayoutAnchorablePane>, ILayoutControl
{
#region Members
private LayoutAnchorablePaneGroup _model;
#endregion
#region Constructors
internal LayoutAnchorablePaneGroupControl( LayoutAnchorablePaneGroup model )
: base( model, model.Orientation )
{
_model = model;
}
#endregion
#region Overrides
protected override void OnFixChildrenDockLengths()
{
#region Setup DockWidth/Height for children
if( _model.Orientation == Orientation.Horizontal )
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockWidth.IsStar )
{
childModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
}
}
else
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockHeight.IsStar )
{
childModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
}
}
#endregion
}
#endregion
}
}

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

@ -1,231 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAnchorableTabItem : Control
{
#region Members
private bool _isMouseDown = false;
private static LayoutAnchorableTabItem _draggingItem = null;
private static bool _cancelMouseLeave = false;
#endregion
#region Constructors
static LayoutAnchorableTabItem()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAnchorableTabItem ), new FrameworkPropertyMetadata( typeof( LayoutAnchorableTabItem ) ) );
}
public LayoutAnchorableTabItem()
{
}
#endregion
#region Properties
#region Model
/// <summary>
/// Model Dependency Property
/// </summary>
public static readonly DependencyProperty ModelProperty = DependencyProperty.Register( "Model", typeof( LayoutContent ), typeof( LayoutAnchorableTabItem ),
new FrameworkPropertyMetadata( ( LayoutContent )null, new PropertyChangedCallback( OnModelChanged ) ) );
/// <summary>
/// Gets or sets the Model property. This dependency property
/// indicates model attached to the anchorable tab item.
/// </summary>
public LayoutContent Model
{
get
{
return ( LayoutContent )GetValue( ModelProperty );
}
set
{
SetValue( ModelProperty, value );
}
}
/// <summary>
/// Handles changes to the Model property.
/// </summary>
private static void OnModelChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutAnchorableTabItem )d ).OnModelChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Model property.
/// </summary>
protected virtual void OnModelChanged( DependencyPropertyChangedEventArgs e )
{
if( Model != null )
SetLayoutItem( Model.Root.Manager.GetLayoutItemFromModel( Model ) );
else
SetLayoutItem( null );
//UpdateLogicalParent();
}
#endregion
#region LayoutItem
/// <summary>
/// LayoutItem Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly( "LayoutItem", typeof( LayoutItem ), typeof( LayoutAnchorableTabItem ),
new FrameworkPropertyMetadata( ( LayoutItem )null ) );
public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty;
/// <summary>
/// Gets the LayoutItem property. This dependency property
/// indicates the LayoutItem attached to this tag item.
/// </summary>
public LayoutItem LayoutItem
{
get
{
return ( LayoutItem )GetValue( LayoutItemProperty );
}
}
/// <summary>
/// Provides a secure method for setting the LayoutItem property.
/// This dependency property indicates the LayoutItem attached to this tag item.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetLayoutItem( LayoutItem value )
{
SetValue( LayoutItemPropertyKey, value );
}
#endregion
#endregion
#region Overrides
protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseLeftButtonDown( e );
_isMouseDown = true;
_draggingItem = this;
}
protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseMove( e );
if( e.LeftButton != MouseButtonState.Pressed )
{
_isMouseDown = false;
_draggingItem = null;
}
else
{
_cancelMouseLeave = false;
}
}
protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
_isMouseDown = false;
base.OnMouseLeftButtonUp( e );
Model.IsActive = true;
}
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseLeave( e );
if( _isMouseDown && e.LeftButton == MouseButtonState.Pressed )
{
// drag the item if the mouse leave is not canceled.
// Mouse leave should be canceled when selecting a new tab to prevent automatic undock when Panel size is Auto.
_draggingItem = !_cancelMouseLeave ? this : null;
}
_isMouseDown = false;
_cancelMouseLeave = false;
}
protected override void OnMouseEnter( MouseEventArgs e )
{
base.OnMouseEnter( e );
if( _draggingItem != this &&
e.LeftButton == MouseButtonState.Pressed )
{
var model = Model;
var container = model.Parent as ILayoutContainer;
var containerPane = model.Parent as ILayoutPane;
if( ( containerPane is LayoutAnchorablePane ) && !( ( LayoutAnchorablePane )containerPane ).CanRepositionItems )
return;
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutAnchorablePaneGroup ) && !( ( LayoutAnchorablePaneGroup )containerPane.Parent ).CanRepositionItems )
return;
var childrenList = container.Children.ToList();
containerPane.MoveChild( childrenList.IndexOf( _draggingItem.Model ), childrenList.IndexOf( model ) );
}
}
protected override void OnPreviewGotKeyboardFocus( KeyboardFocusChangedEventArgs e )
{
base.OnPreviewGotKeyboardFocus( e );
}
#endregion
#region Internal Methods
internal static bool IsDraggingItem()
{
return _draggingItem != null;
}
internal static LayoutAnchorableTabItem GetDraggingItem()
{
return _draggingItem;
}
internal static void ResetDraggingItem()
{
_draggingItem = null;
}
internal static void CancelMouseLeave()
{
_cancelMouseLeave = true;
}
#endregion
}
}

583
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAutoHideWindowControl.cs

@ -1,583 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows.Interop;
using System.Windows.Controls;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Data;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutAutoHideWindowControl : HwndHost, ILayoutControl
{
#region Members
internal LayoutAnchorableControl _internalHost = null;
private LayoutAnchorControl _anchor;
private LayoutAnchorable _model;
private HwndSource _internalHwndSource = null;
private IntPtr parentWindowHandle;
private bool _internalHost_ContentRendered = false;
private ContentPresenter _internalHostPresenter = new ContentPresenter();
private Grid _internalGrid = null;
private AnchorSide _side;
private LayoutGridResizerControl _resizer = null;
private DockingManager _manager;
private Border _resizerGhost = null;
private Window _resizerWindowHost = null;
private Vector _initialStartPoint;
#endregion
#region Constructors
static LayoutAutoHideWindowControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutAutoHideWindowControl ), new FrameworkPropertyMetadata( typeof( LayoutAutoHideWindowControl ) ) );
UIElement.FocusableProperty.OverrideMetadata( typeof( LayoutAutoHideWindowControl ), new FrameworkPropertyMetadata( true ) );
Control.IsTabStopProperty.OverrideMetadata( typeof( LayoutAutoHideWindowControl ), new FrameworkPropertyMetadata( true ) );
VisibilityProperty.OverrideMetadata( typeof( LayoutAutoHideWindowControl ), new FrameworkPropertyMetadata( Visibility.Hidden ) );
}
internal LayoutAutoHideWindowControl()
{
}
#endregion
#region Properties
#region AnchorableStyle
/// <summary>
/// AnchorableStyle Dependency Property
/// </summary>
public static readonly DependencyProperty AnchorableStyleProperty = DependencyProperty.Register( "AnchorableStyle", typeof( Style ), typeof( LayoutAutoHideWindowControl ),
new FrameworkPropertyMetadata( ( Style )null ) );
/// <summary>
/// Gets or sets the AnchorableStyle property. This dependency property
/// indicates the style to apply to the LayoutAnchorableControl hosted in this auto hide window.
/// </summary>
public Style AnchorableStyle
{
get
{
return ( Style )GetValue( AnchorableStyleProperty );
}
set
{
SetValue( AnchorableStyleProperty, value );
}
}
#endregion
#region Background
/// <summary>
/// Background Dependency Property
/// </summary>
public static readonly DependencyProperty BackgroundProperty = DependencyProperty.Register( "Background", typeof( Brush ), typeof( LayoutAutoHideWindowControl ),
new FrameworkPropertyMetadata( ( Brush )null ) );
/// <summary>
/// Gets or sets the Background property. This dependency property
/// indicates background of the autohide childwindow.
/// </summary>
public Brush Background
{
get
{
return ( Brush )GetValue( BackgroundProperty );
}
set
{
SetValue( BackgroundProperty, value );
}
}
#endregion
#region Model
public ILayoutElement Model
{
get
{
return _model;
}
}
#endregion
#region Resizer
internal bool IsResizing
{
get;
private set;
}
#endregion
#endregion
#region Overrides
protected override System.Runtime.InteropServices.HandleRef BuildWindowCore( System.Runtime.InteropServices.HandleRef hwndParent )
{
parentWindowHandle = hwndParent.Handle;
_internalHwndSource = new HwndSource( new HwndSourceParameters()
{
ParentWindow = hwndParent.Handle,
WindowStyle = Win32Helper.WS_CHILD | Win32Helper.WS_VISIBLE | Win32Helper.WS_CLIPSIBLINGS | Win32Helper.WS_CLIPCHILDREN,
Width = 0,
Height = 0,
} );
_internalHost_ContentRendered = false;
_internalHwndSource.ContentRendered += _internalHwndSource_ContentRendered;
_internalHwndSource.RootVisual = _internalHostPresenter;
AddLogicalChild( _internalHostPresenter );
Win32Helper.BringWindowToTop( _internalHwndSource.Handle );
return new HandleRef( this, _internalHwndSource.Handle );
}
protected override IntPtr WndProc( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled )
{
if( msg == Win32Helper.WM_WINDOWPOSCHANGING )
{
if( _internalHost_ContentRendered )
Win32Helper.SetWindowPos( _internalHwndSource.Handle, Win32Helper.HWND_TOP, 0, 0, 0, 0, Win32Helper.SetWindowPosFlags.IgnoreMove | Win32Helper.SetWindowPosFlags.IgnoreResize );
}
return base.WndProc( hwnd, msg, wParam, lParam, ref handled );
}
protected override void DestroyWindowCore( System.Runtime.InteropServices.HandleRef hwnd )
{
if( _internalHwndSource != null )
{
_internalHwndSource.ContentRendered -= _internalHwndSource_ContentRendered;
_internalHwndSource.Dispose();
_internalHwndSource = null;
}
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}
protected override bool HasFocusWithinCore()
{
return false;
}
protected override System.Collections.IEnumerator LogicalChildren
{
get
{
if( _internalHostPresenter == null )
return new UIElement[] { }.GetEnumerator();
return new UIElement[] { _internalHostPresenter }.GetEnumerator();
}
}
protected override Size MeasureOverride( Size constraint )
{
if( _internalHostPresenter == null )
return base.MeasureOverride( constraint );
_internalHostPresenter.Measure( constraint );
//return base.MeasureOverride(constraint);
return _internalHostPresenter.DesiredSize;
}
protected override Size ArrangeOverride( Size finalSize )
{
if( _internalHostPresenter == null )
return base.ArrangeOverride( finalSize );
_internalHostPresenter.Arrange( new Rect( finalSize ) );
return base.ArrangeOverride( finalSize );// new Size(_internalHostPresenter.ActualWidth, _internalHostPresenter.ActualHeight);
}
#endregion
#region Internal Methods
internal void Show( LayoutAnchorControl anchor )
{
if( _model != null )
throw new InvalidOperationException();
_anchor = anchor;
_model = anchor.Model as LayoutAnchorable;
_side = ( anchor.Model.Parent.Parent as LayoutAnchorSide ).Side;
_manager = _model.Root.Manager;
CreateInternalGrid();
_model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler( _model_PropertyChanged );
Visibility = System.Windows.Visibility.Visible;
InvalidateMeasure();
UpdateWindowPos();
}
internal void Hide()
{
if( _model == null )
return;
_model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler( _model_PropertyChanged );
RemoveInternalGrid();
_anchor = null;
_model = null;
_manager = null;
Visibility = System.Windows.Visibility.Hidden;
}
internal bool IsWin32MouseOver
{
get
{
var ptMouse = new Win32Helper.Win32Point();
if( !Win32Helper.GetCursorPos( ref ptMouse ) )
return false;
Point location = this.PointToScreenDPI( new Point() );
Rect rectWindow = this.GetScreenArea();
if( rectWindow.Contains( new Point( ptMouse.X, ptMouse.Y ) ) )
return true;
var manager = Model.Root.Manager;
var anchor = manager.FindVisualChildren<LayoutAnchorControl>().Where( c => c.Model == Model ).FirstOrDefault();
if( anchor == null )
return false;
location = anchor.PointToScreenDPI( new Point() );
if( anchor.IsMouseOver )
return true;
return false;
}
}
#endregion
#region Private Methods
private void _internalHwndSource_ContentRendered( object sender, EventArgs e )
{
_internalHost_ContentRendered = true;
}
private void _model_PropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
{
if( e.PropertyName == "IsAutoHidden" )
{
if( !_model.IsAutoHidden )
{
_manager.HideAutoHideWindow( _anchor );
}
}
}
private void CreateInternalGrid()
{
_internalGrid = new Grid() { FlowDirection = System.Windows.FlowDirection.LeftToRight };
_internalGrid.SetBinding( Grid.BackgroundProperty, new Binding( "Background" ) { Source = this } );
_internalHost = new LayoutAnchorableControl() { Model = _model, Style = AnchorableStyle };
_internalHost.SetBinding( FlowDirectionProperty, new Binding( "Model.Root.Manager.FlowDirection" ) { Source = this } );
KeyboardNavigation.SetTabNavigation( _internalGrid, KeyboardNavigationMode.Cycle );
_resizer = new LayoutGridResizerControl();
_resizer.DragStarted += new System.Windows.Controls.Primitives.DragStartedEventHandler( OnResizerDragStarted );
_resizer.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler( OnResizerDragDelta );
_resizer.DragCompleted += new System.Windows.Controls.Primitives.DragCompletedEventHandler( OnResizerDragCompleted );
if( _side == AnchorSide.Right )
{
_internalGrid.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength( _manager.GridSplitterWidth ) } );
_internalGrid.ColumnDefinitions.Add( new ColumnDefinition()
{
Width = _model.AutoHideWidth == 0.0 ? new GridLength( _model.AutoHideMinWidth ) : new GridLength( _model.AutoHideWidth, GridUnitType.Pixel )
} );
Grid.SetColumn( _resizer, 0 );
Grid.SetColumn( _internalHost, 1 );
_resizer.Cursor = Cursors.SizeWE;
HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
}
else if( _side == AnchorSide.Left )
{
_internalGrid.ColumnDefinitions.Add( new ColumnDefinition()
{
Width = _model.AutoHideWidth == 0.0 ? new GridLength( _model.AutoHideMinWidth ) : new GridLength( _model.AutoHideWidth, GridUnitType.Pixel ),
} );
_internalGrid.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength( _manager.GridSplitterWidth ) } );
Grid.SetColumn( _internalHost, 0 );
Grid.SetColumn( _resizer, 1 );
_resizer.Cursor = Cursors.SizeWE;
HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
}
else if( _side == AnchorSide.Top )
{
_internalGrid.RowDefinitions.Add( new RowDefinition()
{
Height = _model.AutoHideHeight == 0.0 ? new GridLength( _model.AutoHideMinHeight ) : new GridLength( _model.AutoHideHeight, GridUnitType.Pixel ),
} );
_internalGrid.RowDefinitions.Add( new RowDefinition() { Height = new GridLength( _manager.GridSplitterHeight ) } );
Grid.SetRow( _internalHost, 0 );
Grid.SetRow( _resizer, 1 );
_resizer.Cursor = Cursors.SizeNS;
VerticalAlignment = System.Windows.VerticalAlignment.Top;
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
}
else if( _side == AnchorSide.Bottom )
{
_internalGrid.RowDefinitions.Add( new RowDefinition() { Height = new GridLength( _manager.GridSplitterHeight ) } );
_internalGrid.RowDefinitions.Add( new RowDefinition()
{
Height = _model.AutoHideHeight == 0.0 ? new GridLength( _model.AutoHideMinHeight ) : new GridLength( _model.AutoHideHeight, GridUnitType.Pixel ),
} );
Grid.SetRow( _resizer, 0 );
Grid.SetRow( _internalHost, 1 );
_resizer.Cursor = Cursors.SizeNS;
VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
}
_internalGrid.Children.Add( _resizer );
_internalGrid.Children.Add( _internalHost );
_internalHostPresenter.Content = _internalGrid;
}
private void RemoveInternalGrid()
{
_resizer.DragStarted -= new System.Windows.Controls.Primitives.DragStartedEventHandler( OnResizerDragStarted );
_resizer.DragDelta -= new System.Windows.Controls.Primitives.DragDeltaEventHandler( OnResizerDragDelta );
_resizer.DragCompleted -= new System.Windows.Controls.Primitives.DragCompletedEventHandler( OnResizerDragCompleted );
_internalHostPresenter.Content = null;
}
private void ShowResizerOverlayWindow( LayoutGridResizerControl splitter )
{
_resizerGhost = new Border()
{
Background = splitter.BackgroundWhileDragging,
Opacity = splitter.OpacityWhileDragging
};
var areaElement = _manager.GetAutoHideAreaElement();
var modelControlActualSize = this._internalHost.TransformActualSizeToAncestor();
Point ptTopLeftScreen = areaElement.PointToScreenDPIWithoutFlowDirection( new Point() );
var managerSize = areaElement.TransformActualSizeToAncestor();
Size windowSize;
if( _side == AnchorSide.Right || _side == AnchorSide.Left )
{
windowSize = new Size(
managerSize.Width - 25.0 + splitter.ActualWidth,
managerSize.Height );
_resizerGhost.Width = splitter.ActualWidth;
_resizerGhost.Height = windowSize.Height;
ptTopLeftScreen.Offset( 25, 0.0 );
}
else
{
windowSize = new Size(
managerSize.Width,
managerSize.Height - _model.AutoHideMinHeight - 25.0 + splitter.ActualHeight );
_resizerGhost.Height = splitter.ActualHeight;
_resizerGhost.Width = windowSize.Width;
ptTopLeftScreen.Offset( 0.0, 25.0 );
}
_initialStartPoint = splitter.PointToScreenDPIWithoutFlowDirection( new Point() ) - ptTopLeftScreen;
if( _side == AnchorSide.Right || _side == AnchorSide.Left )
{
Canvas.SetLeft( _resizerGhost, _initialStartPoint.X );
}
else
{
Canvas.SetTop( _resizerGhost, _initialStartPoint.Y );
}
Canvas panelHostResizer = new Canvas()
{
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
VerticalAlignment = System.Windows.VerticalAlignment.Stretch
};
panelHostResizer.Children.Add( _resizerGhost );
_resizerWindowHost = new Window()
{
ResizeMode = ResizeMode.NoResize,
WindowStyle = System.Windows.WindowStyle.None,
ShowInTaskbar = false,
AllowsTransparency = true,
Background = null,
Width = windowSize.Width,
Height = windowSize.Height,
Left = ptTopLeftScreen.X,
Top = ptTopLeftScreen.Y,
ShowActivated = false,
Owner = Window.GetWindow( this ),
Content = panelHostResizer
};
_resizerWindowHost.Show();
}
private void HideResizerOverlayWindow()
{
if( _resizerWindowHost != null )
{
_resizerWindowHost.Close();
_resizerWindowHost = null;
}
}
private void OnResizerDragCompleted( object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e )
{
LayoutGridResizerControl splitter = sender as LayoutGridResizerControl;
var rootVisual = this.FindVisualTreeRoot() as Visual;
var trToWnd = TransformToAncestor( rootVisual );
Vector transformedDelta = trToWnd.Transform( new Point( e.HorizontalChange, e.VerticalChange ) ) -
trToWnd.Transform( new Point() );
double delta;
if( _side == AnchorSide.Right || _side == AnchorSide.Left )
delta = Canvas.GetLeft( _resizerGhost ) - _initialStartPoint.X;
else
delta = Canvas.GetTop( _resizerGhost ) - _initialStartPoint.Y;
if( _side == AnchorSide.Right )
{
if( _model.AutoHideWidth == 0.0 )
_model.AutoHideWidth = _internalHost.ActualWidth - delta;
else
_model.AutoHideWidth -= delta;
_internalGrid.ColumnDefinitions[ 1 ].Width = new GridLength( _model.AutoHideWidth, GridUnitType.Pixel );
}
else if( _side == AnchorSide.Left )
{
if( _model.AutoHideWidth == 0.0 )
_model.AutoHideWidth = _internalHost.ActualWidth + delta;
else
_model.AutoHideWidth += delta;
_internalGrid.ColumnDefinitions[ 0 ].Width = new GridLength( _model.AutoHideWidth, GridUnitType.Pixel );
}
else if( _side == AnchorSide.Top )
{
if( _model.AutoHideHeight == 0.0 )
_model.AutoHideHeight = _internalHost.ActualHeight + delta;
else
_model.AutoHideHeight += delta;
_internalGrid.RowDefinitions[ 0 ].Height = new GridLength( _model.AutoHideHeight, GridUnitType.Pixel );
}
else if( _side == AnchorSide.Bottom )
{
if( _model.AutoHideHeight == 0.0 )
_model.AutoHideHeight = _internalHost.ActualHeight - delta;
else
_model.AutoHideHeight -= delta;
_internalGrid.RowDefinitions[ 1 ].Height = new GridLength( _model.AutoHideHeight, GridUnitType.Pixel );
}
HideResizerOverlayWindow();
IsResizing = false;
InvalidateMeasure();
}
private void OnResizerDragDelta( object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e )
{
LayoutGridResizerControl splitter = sender as LayoutGridResizerControl;
var rootVisual = this.FindVisualTreeRoot() as Visual;
var trToWnd = TransformToAncestor( rootVisual );
Vector transformedDelta = trToWnd.Transform( new Point( e.HorizontalChange, e.VerticalChange ) ) -
trToWnd.Transform( new Point() );
if( _side == AnchorSide.Right || _side == AnchorSide.Left )
{
if( FrameworkElement.GetFlowDirection( _internalHost ) == System.Windows.FlowDirection.RightToLeft )
transformedDelta.X = -transformedDelta.X;
Canvas.SetLeft( _resizerGhost, MathHelper.MinMax( _initialStartPoint.X + transformedDelta.X, 0.0, _resizerWindowHost.Width - _resizerGhost.Width ) );
}
else
{
Canvas.SetTop( _resizerGhost, MathHelper.MinMax( _initialStartPoint.Y + transformedDelta.Y, 0.0, _resizerWindowHost.Height - _resizerGhost.Height ) );
}
}
private void OnResizerDragStarted( object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e )
{
var resizer = sender as LayoutGridResizerControl;
ShowResizerOverlayWindow( resizer );
IsResizing = true;
}
#endregion
}
}

183
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentControl.cs

@ -1,183 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutDocumentControl : Control
{
#region Constructors
static LayoutDocumentControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutDocumentControl ), new FrameworkPropertyMetadata( typeof( LayoutDocumentControl ) ) );
FocusableProperty.OverrideMetadata( typeof( LayoutDocumentControl ), new FrameworkPropertyMetadata( true ) );
}
#endregion
#region Properties
#region Model
/// <summary>
/// Model Dependency Property
/// </summary>
public static readonly DependencyProperty ModelProperty = DependencyProperty.Register( "Model", typeof( LayoutContent ), typeof( LayoutDocumentControl ),
new FrameworkPropertyMetadata( null, OnModelChanged ) );
/// <summary>
/// Gets or sets the Model property. This dependency property
/// indicates the model attached to this view.
/// </summary>
public LayoutContent Model
{
get
{
return ( LayoutContent )GetValue( ModelProperty );
}
set
{
SetValue( ModelProperty, value );
}
}
/// <summary>
/// Handles changes to the Model property.
/// </summary>
private static void OnModelChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutDocumentControl )d ).OnModelChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Model property.
/// </summary>
protected virtual void OnModelChanged( DependencyPropertyChangedEventArgs e )
{
if( e.OldValue != null )
{
( ( LayoutContent )e.OldValue ).PropertyChanged -= Model_PropertyChanged;
}
if( Model != null )
{
Model.PropertyChanged += Model_PropertyChanged;
SetLayoutItem( Model.Root.Manager.GetLayoutItemFromModel( Model ) );
}
else
{
SetLayoutItem( null );
}
}
private void Model_PropertyChanged( object sender, PropertyChangedEventArgs e )
{
if( e.PropertyName == "IsEnabled" )
{
if( Model != null )
{
IsEnabled = Model.IsEnabled;
if( !IsEnabled && Model.IsActive )
{
if( ( Model.Parent != null ) && ( Model.Parent is LayoutDocumentPane ) )
{
( ( LayoutDocumentPane )Model.Parent ).SetNextSelectedIndex();
}
}
}
}
}
#endregion
#region LayoutItem
/// <summary>
/// LayoutItem Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly( "LayoutItem", typeof( LayoutItem ), typeof( LayoutDocumentControl ),
new FrameworkPropertyMetadata(( LayoutItem )null ) );
public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty;
/// <summary>
/// Gets the LayoutItem property. This dependency property
/// indicates the LayoutItem attached to this tag item.
/// </summary>
public LayoutItem LayoutItem
{
get
{
return ( LayoutItem )GetValue( LayoutItemProperty );
}
}
/// <summary>
/// Provides a secure method for setting the LayoutItem property.
/// This dependency property indicates the LayoutItem attached to this tag item.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetLayoutItem( LayoutItem value )
{
SetValue( LayoutItemPropertyKey, value );
}
#endregion
#endregion
#region Overrides
protected override void OnPreviewGotKeyboardFocus( KeyboardFocusChangedEventArgs e )
{
this.SetIsActive();
base.OnPreviewGotKeyboardFocus( e );
}
protected override void OnMouseLeftButtonDown( MouseButtonEventArgs e )
{
this.SetIsActive();
base.OnMouseLeftButtonDown( e );
}
protected override void OnMouseRightButtonDown( MouseButtonEventArgs e )
{
this.SetIsActive();
base.OnMouseLeftButtonDown( e );
}
#endregion
#region Private Methods
private void SetIsActive()
{
if( this.Model != null )
{
this.Model.IsActive = true;
}
}
#endregion
}
}

162
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentFloatingWindowControl.cs

@ -1,162 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows;
using System.Windows.Controls.Primitives;
using Microsoft.Windows.Shell;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutDocumentFloatingWindowControl : LayoutFloatingWindowControl
{
#region Members
private LayoutDocumentFloatingWindow _model;
#endregion
#region Constructors
static LayoutDocumentFloatingWindowControl()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutDocumentFloatingWindowControl ), new FrameworkPropertyMetadata( typeof( LayoutDocumentFloatingWindowControl ) ) );
}
internal LayoutDocumentFloatingWindowControl( LayoutDocumentFloatingWindow model )
: base( model )
{
_model = model;
UpdateThemeResources();
}
#endregion
#region Properties
public LayoutItem RootDocumentLayoutItem
{
get
{
return _model.Root.Manager.GetLayoutItemFromModel( _model.RootDocument );
}
}
#endregion
#region Overrides
public override ILayoutElement Model
{
get
{
return _model;
}
}
protected override void OnInitialized( EventArgs e )
{
base.OnInitialized( e );
if( _model.RootDocument == null )
{
InternalClose();
}
else
{
var manager = _model.Root.Manager;
Content = manager.CreateUIElementForModel( _model.RootDocument );
_model.RootDocumentChanged += new EventHandler( _model_RootDocumentChanged );
}
}
protected override IntPtr FilterMessage( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled )
{
switch( msg )
{
case Win32Helper.WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager
if( wParam.ToInt32() == Win32Helper.HT_CAPTION )
{
if( _model.RootDocument != null )
_model.RootDocument.IsActive = true;
}
break;
case Win32Helper.WM_NCRBUTTONUP:
if( wParam.ToInt32() == Win32Helper.HT_CAPTION )
{
if( OpenContextMenu() )
handled = true;
if( _model.Root.Manager.ShowSystemMenu )
WindowChrome.GetWindowChrome( this ).ShowSystemMenu = !handled;
else
WindowChrome.GetWindowChrome( this ).ShowSystemMenu = false;
}
break;
}
return base.FilterMessage( hwnd, msg, wParam, lParam, ref handled );
}
protected override void OnClosed( EventArgs e )
{
var root = Model.Root;
root.Manager.RemoveFloatingWindow( this );
root.CollectGarbage();
base.OnClosed( e );
if( !CloseInitiatedByUser )
{
root.FloatingWindows.Remove( _model );
}
_model.RootDocumentChanged -= new EventHandler( _model_RootDocumentChanged );
}
#endregion
#region Private Methods
private void _model_RootDocumentChanged( object sender, EventArgs e )
{
if( _model.RootDocument == null )
{
InternalClose();
}
}
private bool OpenContextMenu()
{
var ctxMenu = _model.Root.Manager.DocumentContextMenu;
if( ctxMenu != null && RootDocumentLayoutItem != null )
{
ctxMenu.PlacementTarget = null;
ctxMenu.Placement = PlacementMode.MousePoint;
ctxMenu.DataContext = RootDocumentLayoutItem;
ctxMenu.IsOpen = true;
return true;
}
return false;
}
#endregion
}
}

143
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentItem.cs

@ -1,143 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows;
using Xceed.Wpf.AvalonDock.Commands;
using System.Windows.Input;
using System.Windows.Data;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutDocumentItem : LayoutItem
{
#region Members
private LayoutDocument _document;
#endregion
#region Constructors
internal LayoutDocumentItem()
{
}
#endregion
#region Properties
#region Description
/// <summary>
/// Description Dependency Property
/// </summary>
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register( "Description", typeof( string ), typeof( LayoutDocumentItem ),
new FrameworkPropertyMetadata( ( string )null, new PropertyChangedCallback( OnDescriptionChanged ) ) );
/// <summary>
/// Gets or sets the Description property. This dependency property
/// indicates the description to display for the document item.
/// </summary>
public string Description
{
get
{
return ( string )GetValue( DescriptionProperty );
}
set
{
SetValue( DescriptionProperty, value );
}
}
/// <summary>
/// Handles changes to the Description property.
/// </summary>
private static void OnDescriptionChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutDocumentItem )d ).OnDescriptionChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Description property.
/// </summary>
protected virtual void OnDescriptionChanged( DependencyPropertyChangedEventArgs e )
{
_document.Description = ( string )e.NewValue;
}
#endregion
#endregion
#region Overrides
protected override void Close()
{
if( ( _document.Root != null ) && ( _document.Root.Manager != null ) )
{
var dockingManager = _document.Root.Manager;
dockingManager._ExecuteCloseCommand( _document );
}
}
protected override void OnVisibilityChanged()
{
if( (_document != null) && (_document.Root != null) )
{
_document.IsVisible = ( this.Visibility == Visibility.Visible );
if( _document.Parent is LayoutDocumentPane )
{
( ( LayoutDocumentPane )_document.Parent ).ComputeVisibility();
}
}
base.OnVisibilityChanged();
}
internal override void Attach( LayoutContent model )
{
_document = model as LayoutDocument;
base.Attach( model );
}
internal override void Detach()
{
_document = null;
base.Detach();
}
#endregion
#region Private Methods
#endregion
}
}

117
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentPaneControl.cs

@ -1,117 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutDocumentPaneControl : TabControl, ILayoutControl//, ILogicalChildrenContainer
{
#region Members
private List<object> _logicalChildren = new List<object>();
private LayoutDocumentPane _model;
#endregion
#region Constructors
static LayoutDocumentPaneControl()
{
FocusableProperty.OverrideMetadata( typeof( LayoutDocumentPaneControl ), new FrameworkPropertyMetadata( false ) );
}
internal LayoutDocumentPaneControl( LayoutDocumentPane model )
{
if( model == null )
throw new ArgumentNullException( "model" );
_model = model;
SetBinding( ItemsSourceProperty, new Binding( "Model.Children" ) { Source = this } );
SetBinding( FlowDirectionProperty, new Binding( "Model.Root.Manager.FlowDirection" ) { Source = this } );
this.LayoutUpdated += new EventHandler( OnLayoutUpdated );
}
#endregion
#region Properties
public ILayoutElement Model
{
get
{
return _model;
}
}
#endregion
#region Overrides
protected override System.Collections.IEnumerator LogicalChildren
{
get
{
return _logicalChildren.GetEnumerator();
}
}
protected override void OnSelectionChanged( SelectionChangedEventArgs e )
{
base.OnSelectionChanged( e );
if( _model.SelectedContent != null )
_model.SelectedContent.IsActive = true;
}
protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseLeftButtonDown( e );
if( !e.Handled && _model.SelectedContent != null )
_model.SelectedContent.IsActive = true;
}
protected override void OnMouseRightButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseRightButtonDown( e );
if( !e.Handled && _model.SelectedContent != null )
_model.SelectedContent.IsActive = true;
}
#endregion
#region Private Methods
private void OnLayoutUpdated( object sender, EventArgs e )
{
var modelWithAtcualSize = _model as ILayoutPositionableElementWithActualSize;
modelWithAtcualSize.ActualWidth = ActualWidth;
modelWithAtcualSize.ActualHeight = ActualHeight;
}
#endregion
}
}

73
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentPaneGroupControl.cs

@ -1,73 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows.Controls;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutDocumentPaneGroupControl : LayoutGridControl<ILayoutDocumentPane>, ILayoutControl
{
#region Members
private LayoutDocumentPaneGroup _model;
#endregion
#region Constructors
internal LayoutDocumentPaneGroupControl( LayoutDocumentPaneGroup model )
: base( model, model.Orientation )
{
_model = model;
}
#endregion
#region Overrides
protected override void OnFixChildrenDockLengths()
{
#region Setup DockWidth/Height for children
if( _model.Orientation == Orientation.Horizontal )
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockWidth.IsStar )
{
childModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
}
}
else
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childModel.DockHeight.IsStar )
{
childModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
}
}
#endregion
}
#endregion
}
}

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

@ -1,265 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutDocumentTabItem : Control
{
#region Members
private List<Rect> _otherTabsScreenArea = null;
private List<TabItem> _otherTabs = null;
private Rect _parentDocumentTabPanelScreenArea;
private DocumentPaneTabPanel _parentDocumentTabPanel;
private bool _isMouseDown = false;
private Point _mouseDownPoint;
#endregion
#region Contructors
static LayoutDocumentTabItem()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutDocumentTabItem ), new FrameworkPropertyMetadata( typeof( LayoutDocumentTabItem ) ) );
}
public LayoutDocumentTabItem()
{
}
#endregion
#region Properties
#region Model
/// <summary>
/// Model Dependency Property
/// </summary>
public static readonly DependencyProperty ModelProperty = DependencyProperty.Register( "Model", typeof( LayoutContent ), typeof( LayoutDocumentTabItem ),
new FrameworkPropertyMetadata( ( LayoutContent )null, new PropertyChangedCallback( OnModelChanged ) ) );
/// <summary>
/// Gets or sets the Model property. This dependency property
/// indicates the layout content model attached to the tab item.
/// </summary>
public LayoutContent Model
{
get
{
return ( LayoutContent )GetValue( ModelProperty );
}
set
{
SetValue( ModelProperty, value );
}
}
/// <summary>
/// Handles changes to the Model property.
/// </summary>
private static void OnModelChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutDocumentTabItem )d ).OnModelChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Model property.
/// </summary>
protected virtual void OnModelChanged( DependencyPropertyChangedEventArgs e )
{
if( Model != null )
SetLayoutItem( Model.Root.Manager.GetLayoutItemFromModel( Model ) );
else
SetLayoutItem( null );
//UpdateLogicalParent();
}
#endregion
#region LayoutItem
/// <summary>
/// LayoutItem Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly( "LayoutItem", typeof( LayoutItem ), typeof( LayoutDocumentTabItem ),
new FrameworkPropertyMetadata( ( LayoutItem )null ) );
public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty;
/// <summary>
/// Gets the LayoutItem property. This dependency property
/// indicates the LayoutItem attached to this tag item.
/// </summary>
public LayoutItem LayoutItem
{
get
{
return ( LayoutItem )GetValue( LayoutItemProperty );
}
}
/// <summary>
/// Provides a secure method for setting the LayoutItem property.
/// This dependency property indicates the LayoutItem attached to this tag item.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetLayoutItem( LayoutItem value )
{
SetValue( LayoutItemPropertyKey, value );
}
#endregion
#endregion
#region Overrides
protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonEventArgs e )
{
base.OnMouseLeftButtonDown( e );
Model.IsActive = true;
if( e.ClickCount == 1 )
{
_mouseDownPoint = e.GetPosition( this );
_isMouseDown = true;
}
}
protected override void OnMouseMove( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseMove( e );
if( _isMouseDown )
{
Point ptMouseMove = e.GetPosition( this );
if( Math.Abs( ptMouseMove.X - _mouseDownPoint.X ) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs( ptMouseMove.Y - _mouseDownPoint.Y ) > SystemParameters.MinimumVerticalDragDistance )
{
this.UpdateDragDetails();
this.CaptureMouse();
_isMouseDown = false;
}
}
if( this.IsMouseCaptured )
{
var mousePosInScreenCoord = this.PointToScreenDPI( e.GetPosition( this ) );
if( !_parentDocumentTabPanelScreenArea.Contains( mousePosInScreenCoord ) )
{
this.StartDraggingFloatingWindowForContent();
}
else
{
int indexOfTabItemWithMouseOver = _otherTabsScreenArea.FindIndex( r => r.Contains( mousePosInScreenCoord ) );
if( indexOfTabItemWithMouseOver >= 0 )
{
var targetModel = _otherTabs[ indexOfTabItemWithMouseOver ].Content as LayoutContent;
var container = this.Model.Parent as ILayoutContainer;
var containerPane = this.Model.Parent as ILayoutPane;
if( ( containerPane is LayoutDocumentPane ) && !( ( LayoutDocumentPane )containerPane ).CanRepositionItems )
return;
if( ( containerPane.Parent != null ) && ( containerPane.Parent is LayoutDocumentPaneGroup ) && !( ( LayoutDocumentPaneGroup )containerPane.Parent ).CanRepositionItems )
return;
var childrenList = container.Children.ToList();
containerPane.MoveChild( childrenList.IndexOf( Model ), childrenList.IndexOf( targetModel ) );
this.Model.IsActive = true;
_parentDocumentTabPanel.UpdateLayout();
this.UpdateDragDetails();
}
}
}
}
protected override void OnMouseLeftButtonUp( System.Windows.Input.MouseButtonEventArgs e )
{
if( IsMouseCaptured )
ReleaseMouseCapture();
_isMouseDown = false;
base.OnMouseLeftButtonUp( e );
}
protected override void OnMouseLeave( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseLeave( e );
_isMouseDown = false;
}
protected override void OnMouseEnter( MouseEventArgs e )
{
base.OnMouseEnter( e );
_isMouseDown = false;
}
protected override void OnMouseDown( MouseButtonEventArgs e )
{
if( e.ChangedButton == MouseButton.Middle )
{
if( LayoutItem.CloseCommand.CanExecute( null ) )
LayoutItem.CloseCommand.Execute( null );
}
base.OnMouseDown( e );
}
#endregion
#region Private Methods
private void UpdateDragDetails()
{
_parentDocumentTabPanel = this.FindLogicalAncestor<DocumentPaneTabPanel>();
_parentDocumentTabPanelScreenArea = _parentDocumentTabPanel.GetScreenArea();
_otherTabs = _parentDocumentTabPanel.Children.Cast<TabItem>().Where( ch =>
ch.Visibility != System.Windows.Visibility.Collapsed ).ToList();
Rect currentTabScreenArea = this.FindLogicalAncestor<TabItem>().GetScreenArea();
_otherTabsScreenArea = _otherTabs.Select( ti =>
{
var screenArea = ti.GetScreenArea();
return new Rect( screenArea.Left, screenArea.Top, currentTabScreenArea.Width, screenArea.Height );
} ).ToList();
}
private void StartDraggingFloatingWindowForContent()
{
this.ReleaseMouseCapture();
if( this.Model is LayoutAnchorable )
{
( ( LayoutAnchorable )this.Model ).ResetCanCloseInternal();
}
var manager = this.Model.Root.Manager;
manager.StartDraggingFloatingWindowForContent( this.Model );
}
#endregion
}
}

587
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs

@ -1,587 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows.Documents;
using Xceed.Wpf.AvalonDock.Themes;
namespace Xceed.Wpf.AvalonDock.Controls
{
public abstract class LayoutFloatingWindowControl : Window, ILayoutControl
{
#region Members
private ResourceDictionary currentThemeResourceDictionary; // = null
private bool _isInternalChange; //false
private ILayoutElement _model;
private bool _attachDrag = false;
private HwndSource _hwndSrc;
private HwndSourceHook _hwndSrcHook;
private DragService _dragService = null;
private bool _internalCloseFlag = false;
#endregion
#region Constructors
static LayoutFloatingWindowControl()
{
LayoutFloatingWindowControl.ContentProperty.OverrideMetadata( typeof( LayoutFloatingWindowControl ), new FrameworkPropertyMetadata( null, null, new CoerceValueCallback( CoerceContentValue ) ) );
AllowsTransparencyProperty.OverrideMetadata( typeof( LayoutFloatingWindowControl ), new FrameworkPropertyMetadata( false ) );
ShowInTaskbarProperty.OverrideMetadata( typeof( LayoutFloatingWindowControl ), new FrameworkPropertyMetadata( false ) );
}
protected LayoutFloatingWindowControl( ILayoutElement model )
{
this.Loaded += new RoutedEventHandler( OnLoaded );
this.Unloaded += new RoutedEventHandler( OnUnloaded );
_model = model;
}
#endregion
#region Properties
#region Model
public abstract ILayoutElement Model
{
get;
}
#endregion
#region IsDragging
/// <summary>
/// IsDragging Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsDraggingPropertyKey = DependencyProperty.RegisterReadOnly( "IsDragging", typeof( bool ), typeof( LayoutFloatingWindowControl ),
new FrameworkPropertyMetadata( ( bool )false, new PropertyChangedCallback( OnIsDraggingChanged ) ) );
public static readonly DependencyProperty IsDraggingProperty = IsDraggingPropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsDragging property. This dependency property
/// indicates that this floating window is being dragged.
/// </summary>
public bool IsDragging
{
get
{
return ( bool )GetValue( IsDraggingProperty );
}
}
/// <summary>
/// Provides a secure method for setting the IsDragging property.
/// This dependency property indicates that this floating window is being dragged.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsDragging( bool value )
{
SetValue( IsDraggingPropertyKey, value );
}
/// <summary>
/// Handles changes to the IsDragging property.
/// </summary>
private static void OnIsDraggingChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( LayoutFloatingWindowControl )d ).OnIsDraggingChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the IsDragging property.
/// </summary>
protected virtual void OnIsDraggingChanged( DependencyPropertyChangedEventArgs e )
{
if( ( bool )e.NewValue )
{
CaptureMouse();
}
else
{
ReleaseMouseCapture();
}
}
#endregion
#region CloseInitiatedByUser
protected bool CloseInitiatedByUser
{
get
{
return !_internalCloseFlag;
}
}
#endregion
#region KeepContentVisibleOnClose
internal bool KeepContentVisibleOnClose
{
get;
set;
}
#endregion
#region IsMaximized
/// <summary>
/// IsMaximized Dependency Property
/// </summary>
public static readonly DependencyProperty IsMaximizedProperty = DependencyProperty.Register( "IsMaximized", typeof( bool ), typeof( LayoutFloatingWindowControl ),
new FrameworkPropertyMetadata( ( bool )false ) );
/// <summary>
/// Gets/sets the IsMaximized property. This dependency property
/// indicates if the window is maximized.
/// </summary>
public bool IsMaximized
{
get
{
return ( bool )GetValue( IsMaximizedProperty );
}
private set
{
SetValue( IsMaximizedProperty, value );
UpdatePositionAndSizeOfPanes();
}
}
/// <summary>
/// Provides a secure method for setting the IsMaximized property.
/// This dependency property indicates if the window is maximized.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected override void OnStateChanged( EventArgs e )
{
if( !_isInternalChange )
{
if( WindowState == WindowState.Maximized )
{
UpdateMaximizedState( true );
}
else
{
WindowState = IsMaximized ? WindowState.Maximized : WindowState.Normal;
}
}
base.OnStateChanged( e );
}
#endregion
#endregion
#region Overrides
protected override void OnClosed( EventArgs e )
{
if( Content != null )
{
var host = Content as FloatingWindowContentHost;
host.Dispose();
if( _hwndSrc != null )
{
_hwndSrc.RemoveHook( _hwndSrcHook );
_hwndSrc.Dispose();
_hwndSrc = null;
}
}
base.OnClosed( e );
}
protected override void OnInitialized( EventArgs e )
{
CommandBindings.Add( new CommandBinding( Microsoft.Windows.Shell.SystemCommands.CloseWindowCommand,
new ExecutedRoutedEventHandler( ( s, args ) => Microsoft.Windows.Shell.SystemCommands.CloseWindow( ( Window )args.Parameter ) ) ) );
CommandBindings.Add( new CommandBinding( Microsoft.Windows.Shell.SystemCommands.MaximizeWindowCommand,
new ExecutedRoutedEventHandler( ( s, args ) => Microsoft.Windows.Shell.SystemCommands.MaximizeWindow( ( Window )args.Parameter ) ) ) );
CommandBindings.Add( new CommandBinding( Microsoft.Windows.Shell.SystemCommands.MinimizeWindowCommand,
new ExecutedRoutedEventHandler( ( s, args ) => Microsoft.Windows.Shell.SystemCommands.MinimizeWindow( ( Window )args.Parameter ) ) ) );
CommandBindings.Add( new CommandBinding( Microsoft.Windows.Shell.SystemCommands.RestoreWindowCommand,
new ExecutedRoutedEventHandler( ( s, args ) => Microsoft.Windows.Shell.SystemCommands.RestoreWindow( ( Window )args.Parameter ) ) ) );
//Debug.Assert(this.Owner != null);
base.OnInitialized( e );
}
#endregion
#region Internal Methods
internal virtual void UpdateThemeResources( Theme oldTheme = null )
{
if( oldTheme != null )
{
if( oldTheme is DictionaryTheme )
{
if( currentThemeResourceDictionary != null )
{
Resources.MergedDictionaries.Remove( currentThemeResourceDictionary );
currentThemeResourceDictionary = null;
}
}
else
{
var resourceDictionaryToRemove =
Resources.MergedDictionaries.FirstOrDefault( r => r.Source == oldTheme.GetResourceUri() );
if( resourceDictionaryToRemove != null )
Resources.MergedDictionaries.Remove(
resourceDictionaryToRemove );
}
}
var manager = _model.Root.Manager;
if( manager.Theme != null )
{
if( manager.Theme is DictionaryTheme )
{
currentThemeResourceDictionary = ( ( DictionaryTheme )manager.Theme ).ThemeResourceDictionary;
Resources.MergedDictionaries.Add( currentThemeResourceDictionary );
}
else
{
Resources.MergedDictionaries.Add( new ResourceDictionary() { Source = manager.Theme.GetResourceUri() } );
}
}
}
internal void AttachDrag( bool onActivated = true )
{
if( onActivated )
{
_attachDrag = true;
this.Activated += new EventHandler( OnActivated );
}
else
{
IntPtr windowHandle = new WindowInteropHelper( this ).Handle;
IntPtr lParam = new IntPtr( ( ( int )Left & ( int )0xFFFF ) | ( ( ( int )Top ) << 16 ) );
Win32Helper.SendMessage( windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr( Win32Helper.HT_CAPTION ), lParam );
}
}
protected virtual IntPtr FilterMessage( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled )
{
handled = false;
switch( msg )
{
case Win32Helper.WM_ACTIVATE:
if( ( ( int )wParam & 0xFFFF ) == Win32Helper.WA_INACTIVE )
{
if( lParam == this.GetParentWindowHandle() )
{
Win32Helper.SetActiveWindow( _hwndSrc.Handle );
handled = true;
}
}
break;
case Win32Helper.WM_EXITSIZEMOVE:
UpdatePositionAndSizeOfPanes();
if( _dragService != null )
{
bool dropFlag;
var mousePosition = this.TransformToDeviceDPI( Win32Helper.GetMousePosition() );
_dragService.Drop( mousePosition, out dropFlag );
_dragService = null;
SetIsDragging( false );
if( dropFlag )
InternalClose();
}
break;
case Win32Helper.WM_MOVING:
{
UpdateDragPosition();
if( this.IsMaximized )
{
this.UpdateMaximizedState( false );
}
}
break;
case Win32Helper.WM_LBUTTONUP: //set as handled right button click on title area (after showing context menu)
if( _dragService != null && Mouse.LeftButton == MouseButtonState.Released )
{
_dragService.Abort();
_dragService = null;
SetIsDragging( false );
}
break;
case Win32Helper.WM_SYSCOMMAND:
int command = ( int )wParam & 0xFFF0;
if( command == Win32Helper.SC_MAXIMIZE || command == Win32Helper.SC_RESTORE )
{
UpdateMaximizedState( command == Win32Helper.SC_MAXIMIZE );
}
break;
}
return IntPtr.Zero;
}
internal void InternalClose()
{
_internalCloseFlag = true;
Close();
}
#endregion
#region Private Methods
private static object CoerceContentValue( DependencyObject sender, object content )
{
return new FloatingWindowContentHost( sender as LayoutFloatingWindowControl ) { Content = content as UIElement };
}
private void OnLoaded( object sender, RoutedEventArgs e )
{
this.Loaded -= new RoutedEventHandler( OnLoaded );
this.SetParentToMainWindowOf( Model.Root.Manager );
_hwndSrc = HwndSource.FromDependencyObject( this ) as HwndSource;
_hwndSrcHook = new HwndSourceHook( FilterMessage );
_hwndSrc.AddHook( _hwndSrcHook );
// Restore maximize state
var maximized = Model.Descendents().OfType<ILayoutElementForFloatingWindow>().Any( l => l.IsMaximized );
UpdateMaximizedState( maximized );
}
private void OnUnloaded( object sender, RoutedEventArgs e )
{
this.Unloaded -= new RoutedEventHandler( OnUnloaded );
if( _hwndSrc != null )
{
_hwndSrc.RemoveHook( _hwndSrcHook );
InternalClose();
}
}
private void OnActivated( object sender, EventArgs e )
{
this.Activated -= new EventHandler( OnActivated );
if( _attachDrag && Mouse.LeftButton == MouseButtonState.Pressed )
{
IntPtr windowHandle = new WindowInteropHelper( this ).Handle;
var mousePosition = this.PointToScreenDPI( Mouse.GetPosition( this ) );
var clientArea = Win32Helper.GetClientRect( windowHandle );
var windowArea = Win32Helper.GetWindowRect( windowHandle );
Left = mousePosition.X - windowArea.Width / 2.0;
Top = mousePosition.Y - ( windowArea.Height - clientArea.Height ) / 2.0;
_attachDrag = false;
IntPtr lParam = new IntPtr( ( ( int )mousePosition.X & ( int )0xFFFF ) | ( ( ( int )mousePosition.Y ) << 16 ) );
Win32Helper.SendMessage( windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr( Win32Helper.HT_CAPTION ), lParam );
}
}
private void UpdatePositionAndSizeOfPanes()
{
foreach( var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>() )
{
posElement.FloatingLeft = Left;
posElement.FloatingTop = Top;
posElement.FloatingWidth = Width;
posElement.FloatingHeight = Height;
}
}
private void UpdateMaximizedState( bool isMaximized )
{
foreach( var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>() )
{
posElement.IsMaximized = isMaximized;
}
IsMaximized = isMaximized;
_isInternalChange = true;
WindowState = isMaximized ? WindowState.Maximized : WindowState.Normal;
_isInternalChange = false;
}
private void UpdateDragPosition()
{
if( _dragService == null )
{
_dragService = new DragService( this );
SetIsDragging( true );
}
var mousePosition = this.TransformToDeviceDPI( Win32Helper.GetMousePosition() );
_dragService.UpdateMouseLocation( mousePosition );
}
#endregion
#region Internal Classes
protected internal class FloatingWindowContentHost : HwndHost
{
#region Members
private LayoutFloatingWindowControl _owner;
private HwndSource _wpfContentHost = null;
private Border _rootPresenter = null;
private DockingManager _manager = null;
#endregion
#region Constructors
public FloatingWindowContentHost( LayoutFloatingWindowControl owner )
{
_owner = owner;
var manager = _owner.Model.Root.Manager;
}
#endregion
#region Properties
#region RootVisual
public Visual RootVisual
{
get
{
return _rootPresenter;
}
}
#endregion
#region Content
/// <summary>
/// Content Dependency Property
/// </summary>
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( "Content", typeof( UIElement ), typeof( FloatingWindowContentHost ),
new FrameworkPropertyMetadata( ( UIElement )null, new PropertyChangedCallback( OnContentChanged ) ) );
/// <summary>
/// Gets or sets the Content property. This dependency property
/// indicates ....
/// </summary>
public UIElement Content
{
get
{
return ( UIElement )GetValue( ContentProperty );
}
set
{
SetValue( ContentProperty, value );
}
}
/// <summary>
/// Handles changes to the Content property.
/// </summary>
private static void OnContentChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( FloatingWindowContentHost )d ).OnContentChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Content property.
/// </summary>
protected virtual void OnContentChanged( DependencyPropertyChangedEventArgs e )
{
if( _rootPresenter != null )
_rootPresenter.Child = Content;
}
#endregion
#endregion
#region Overrides
protected override System.Runtime.InteropServices.HandleRef BuildWindowCore( System.Runtime.InteropServices.HandleRef hwndParent )
{
_wpfContentHost = new HwndSource( new HwndSourceParameters()
{
ParentWindow = hwndParent.Handle,
WindowStyle = Win32Helper.WS_CHILD | Win32Helper.WS_VISIBLE | Win32Helper.WS_CLIPSIBLINGS | Win32Helper.WS_CLIPCHILDREN,
Width = 1,
Height = 1
} );
_rootPresenter = new Border() { Child = new AdornerDecorator() { Child = Content }, Focusable = true };
_rootPresenter.SetBinding( Border.BackgroundProperty, new Binding( "Background" ) { Source = _owner } );
_wpfContentHost.RootVisual = _rootPresenter;
_wpfContentHost.SizeToContent = SizeToContent.Manual;
_manager = _owner.Model.Root.Manager;
_manager.InternalAddLogicalChild( _rootPresenter );
return new HandleRef( this, _wpfContentHost.Handle );
}
protected override void DestroyWindowCore( HandleRef hwnd )
{
_manager.InternalRemoveLogicalChild( _rootPresenter );
if( _wpfContentHost != null )
{
_wpfContentHost.Dispose();
_wpfContentHost = null;
}
}
protected override Size MeasureOverride( Size constraint )
{
if( Content == null )
return base.MeasureOverride( constraint );
Content.Measure( constraint );
return Content.DesiredSize;
}
#endregion
}
#endregion
}
}

579
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs

@ -1,579 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout;
using System.Windows.Threading;
namespace Xceed.Wpf.AvalonDock.Controls
{
public abstract class LayoutGridControl<T> : Grid, ILayoutControl where T : class, ILayoutPanelElement
{
#region Members
private LayoutPositionableGroup<T> _model;
private Orientation _orientation;
private bool _initialized;
private ChildrenTreeChange? _asyncRefreshCalled;
private ReentrantFlag _fixingChildrenDockLengths = new ReentrantFlag();
private Border _resizerGhost = null;
private Window _resizerWindowHost = null;
private Vector _initialStartPoint;
#endregion
#region Constructors
static LayoutGridControl()
{
}
internal LayoutGridControl( LayoutPositionableGroup<T> model, Orientation orientation )
{
if( model == null )
throw new ArgumentNullException( "model" );
_model = model;
_orientation = orientation;
FlowDirection = System.Windows.FlowDirection.LeftToRight;
}
#endregion
#region Properties
public ILayoutElement Model
{
get
{
return _model;
}
}
public Orientation Orientation
{
get
{
return ( _model as ILayoutOrientableGroup ).Orientation;
}
}
private bool AsyncRefreshCalled
{
get
{
return _asyncRefreshCalled != null;
}
}
#endregion
#region Overrides
protected override void OnInitialized( EventArgs e )
{
base.OnInitialized( e );
_model.ChildrenTreeChanged += ( s, args ) =>
{
if( _asyncRefreshCalled.HasValue &&
_asyncRefreshCalled.Value == args.Change )
return;
_asyncRefreshCalled = args.Change;
Dispatcher.BeginInvoke( new Action( () =>
{
_asyncRefreshCalled = null;
UpdateChildren();
} ), DispatcherPriority.Normal, null );
};
this.LayoutUpdated += new EventHandler( OnLayoutUpdated );
}
#endregion
#region Internal Methods
protected void FixChildrenDockLengths()
{
using( _fixingChildrenDockLengths.Enter() )
OnFixChildrenDockLengths();
}
protected abstract void OnFixChildrenDockLengths();
#endregion
#region Private Methods
private void OnLayoutUpdated( object sender, EventArgs e )
{
var modelWithAtcualSize = _model as ILayoutPositionableElementWithActualSize;
modelWithAtcualSize.ActualWidth = ActualWidth;
modelWithAtcualSize.ActualHeight = ActualHeight;
if( !_initialized )
{
_initialized = true;
UpdateChildren();
}
}
private void UpdateChildren()
{
var alreadyContainedChildren = Children.OfType<ILayoutControl>().ToArray();
DetachOldSplitters();
DetachPropertChangeHandler();
Children.Clear();
ColumnDefinitions.Clear();
RowDefinitions.Clear();
if( _model == null ||
_model.Root == null )
return;
var manager = _model.Root.Manager;
if( manager == null )
return;
foreach( ILayoutElement child in _model.Children )
{
var foundContainedChild = alreadyContainedChildren.FirstOrDefault( chVM => chVM.Model == child );
if( foundContainedChild != null )
Children.Add( foundContainedChild as UIElement );
else
Children.Add( manager.CreateUIElementForModel( child ) );
}
CreateSplitters();
UpdateRowColDefinitions();
AttachNewSplitters();
AttachPropertyChangeHandler();
}
private void AttachPropertyChangeHandler()
{
foreach( var child in InternalChildren.OfType<ILayoutControl>() )
{
child.Model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler( this.OnChildModelPropertyChanged );
}
}
private void DetachPropertChangeHandler()
{
foreach( var child in InternalChildren.OfType<ILayoutControl>() )
{
child.Model.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler( this.OnChildModelPropertyChanged );
}
}
private void OnChildModelPropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
{
if( AsyncRefreshCalled )
return;
if( _fixingChildrenDockLengths.CanEnter && e.PropertyName == "DockWidth" && Orientation == System.Windows.Controls.Orientation.Horizontal )
{
if( ColumnDefinitions.Count == InternalChildren.Count )
{
var changedElement = sender as ILayoutPositionableElement;
var childFromModel = InternalChildren.OfType<ILayoutControl>().First( ch => ch.Model == changedElement ) as UIElement;
int indexOfChild = InternalChildren.IndexOf( childFromModel );
ColumnDefinitions[ indexOfChild ].Width = changedElement.DockWidth;
}
}
else if( _fixingChildrenDockLengths.CanEnter && e.PropertyName == "DockHeight" && Orientation == System.Windows.Controls.Orientation.Vertical )
{
if( RowDefinitions.Count == InternalChildren.Count )
{
var changedElement = sender as ILayoutPositionableElement;
var childFromModel = InternalChildren.OfType<ILayoutControl>().First( ch => ch.Model == changedElement ) as UIElement;
int indexOfChild = InternalChildren.IndexOf( childFromModel );
RowDefinitions[ indexOfChild ].Height = changedElement.DockHeight;
}
}
else if( e.PropertyName == "IsVisible" )
{
UpdateRowColDefinitions();
}
}
private void UpdateRowColDefinitions()
{
var root = _model.Root;
if( root == null )
return;
var manager = root.Manager;
if( manager == null )
return;
FixChildrenDockLengths();
//Debug.Assert(InternalChildren.Count == _model.ChildrenCount + (_model.ChildrenCount - 1));
#region Setup GridRows/Cols
RowDefinitions.Clear();
ColumnDefinitions.Clear();
if( Orientation == Orientation.Horizontal )
{
int iColumn = 0;
int iChild = 0;
for( int iChildModel = 0; iChildModel < _model.Children.Count; iChildModel++, iColumn++, iChild++ )
{
var childModel = _model.Children[ iChildModel ] as ILayoutPositionableElement;
ColumnDefinitions.Add( new ColumnDefinition()
{
Width = childModel.IsVisible ? childModel.DockWidth : new GridLength( 0.0, GridUnitType.Pixel ),
MinWidth = childModel.IsVisible ? childModel.DockMinWidth : 0.0
} );
Grid.SetColumn( InternalChildren[ iChild ], iColumn );
//append column for splitter
if( iChild < InternalChildren.Count - 1 )
{
iChild++;
iColumn++;
bool nextChildModelVisibleExist = false;
for( int i = iChildModel + 1; i < _model.Children.Count; i++ )
{
var nextChildModel = _model.Children[ i ] as ILayoutPositionableElement;
if( nextChildModel.IsVisible )
{
nextChildModelVisibleExist = true;
break;
}
}
ColumnDefinitions.Add( new ColumnDefinition()
{
Width = childModel.IsVisible && nextChildModelVisibleExist ? new GridLength( manager.GridSplitterWidth ) : new GridLength( 0.0, GridUnitType.Pixel )
} );
Grid.SetColumn( InternalChildren[ iChild ], iColumn );
}
}
}
else //if (_model.Orientation == Orientation.Vertical)
{
int iRow = 0;
int iChild = 0;
for( int iChildModel = 0; iChildModel < _model.Children.Count; iChildModel++, iRow++, iChild++ )
{
var childModel = _model.Children[ iChildModel ] as ILayoutPositionableElement;
RowDefinitions.Add( new RowDefinition()
{
Height = childModel.IsVisible ? childModel.DockHeight : new GridLength( 0.0, GridUnitType.Pixel ),
MinHeight = childModel.IsVisible ? childModel.DockMinHeight : 0.0
} );
Grid.SetRow( InternalChildren[ iChild ], iRow );
//if (RowDefinitions.Last().Height.Value == 0.0)
// System.Diagnostics.Debugger.Break();
//append row for splitter (if necessary)
if( iChild < InternalChildren.Count - 1 )
{
iChild++;
iRow++;
bool nextChildModelVisibleExist = false;
for( int i = iChildModel + 1; i < _model.Children.Count; i++ )
{
var nextChildModel = _model.Children[ i ] as ILayoutPositionableElement;
if( nextChildModel.IsVisible )
{
nextChildModelVisibleExist = true;
break;
}
}
RowDefinitions.Add( new RowDefinition()
{
Height = childModel.IsVisible && nextChildModelVisibleExist ? new GridLength( manager.GridSplitterHeight ) : new GridLength( 0.0, GridUnitType.Pixel )
} );
//if (RowDefinitions.Last().Height.Value == 0.0)
// System.Diagnostics.Debugger.Break();
Grid.SetRow( InternalChildren[ iChild ], iRow );
}
}
}
#endregion
}
private void CreateSplitters()
{
for( int iChild = 1; iChild < Children.Count; iChild++ )
{
var splitter = new LayoutGridResizerControl();
splitter.Cursor = this.Orientation == Orientation.Horizontal ? Cursors.SizeWE : Cursors.SizeNS;
Children.Insert( iChild, splitter );
iChild++;
}
}
private void DetachOldSplitters()
{
foreach( var splitter in Children.OfType<LayoutGridResizerControl>() )
{
splitter.DragStarted -= new System.Windows.Controls.Primitives.DragStartedEventHandler( OnSplitterDragStarted );
splitter.DragDelta -= new System.Windows.Controls.Primitives.DragDeltaEventHandler( OnSplitterDragDelta );
splitter.DragCompleted -= new System.Windows.Controls.Primitives.DragCompletedEventHandler( OnSplitterDragCompleted );
}
}
private void AttachNewSplitters()
{
foreach( var splitter in Children.OfType<LayoutGridResizerControl>() )
{
splitter.DragStarted += new System.Windows.Controls.Primitives.DragStartedEventHandler( OnSplitterDragStarted );
splitter.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler( OnSplitterDragDelta );
splitter.DragCompleted += new System.Windows.Controls.Primitives.DragCompletedEventHandler( OnSplitterDragCompleted );
}
}
private void OnSplitterDragStarted( object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e )
{
var resizer = sender as LayoutGridResizerControl;
ShowResizerOverlayWindow( resizer );
}
private void OnSplitterDragDelta( object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e )
{
LayoutGridResizerControl splitter = sender as LayoutGridResizerControl;
var rootVisual = this.FindVisualTreeRoot() as Visual;
var trToWnd = TransformToAncestor( rootVisual );
Vector transformedDelta = trToWnd.Transform( new Point( e.HorizontalChange, e.VerticalChange ) ) -
trToWnd.Transform( new Point() );
if( Orientation == System.Windows.Controls.Orientation.Horizontal )
{
Canvas.SetLeft( _resizerGhost, MathHelper.MinMax( _initialStartPoint.X + transformedDelta.X, 0.0, _resizerWindowHost.Width - _resizerGhost.Width ) );
}
else
{
Canvas.SetTop( _resizerGhost, MathHelper.MinMax( _initialStartPoint.Y + transformedDelta.Y, 0.0, _resizerWindowHost.Height - _resizerGhost.Height ) );
}
}
private void OnSplitterDragCompleted( object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e )
{
LayoutGridResizerControl splitter = sender as LayoutGridResizerControl;
var rootVisual = this.FindVisualTreeRoot() as Visual;
var trToWnd = TransformToAncestor( rootVisual );
Vector transformedDelta = trToWnd.Transform( new Point( e.HorizontalChange, e.VerticalChange ) ) -
trToWnd.Transform( new Point() );
double delta;
if( Orientation == System.Windows.Controls.Orientation.Horizontal )
delta = Canvas.GetLeft( _resizerGhost ) - _initialStartPoint.X;
else
delta = Canvas.GetTop( _resizerGhost ) - _initialStartPoint.Y;
int indexOfResizer = InternalChildren.IndexOf( splitter );
var prevChild = InternalChildren[ indexOfResizer - 1 ] as FrameworkElement;
var nextChild = GetNextVisibleChild( indexOfResizer );
var prevChildActualSize = prevChild.TransformActualSizeToAncestor();
var nextChildActualSize = nextChild.TransformActualSizeToAncestor();
var prevChildModel = ( ILayoutPositionableElement )( prevChild as ILayoutControl ).Model;
var nextChildModel = ( ILayoutPositionableElement )( nextChild as ILayoutControl ).Model;
if( Orientation == System.Windows.Controls.Orientation.Horizontal )
{
if( prevChildModel.DockWidth.IsStar )
{
prevChildModel.DockWidth = new GridLength( prevChildModel.DockWidth.Value * ( prevChildActualSize.Width + delta ) / prevChildActualSize.Width, GridUnitType.Star );
}
else
{
var width = ( prevChildModel.DockWidth.IsAuto ) ? prevChildActualSize.Width : prevChildModel.DockWidth.Value;
prevChildModel.DockWidth = new GridLength( width + delta, GridUnitType.Pixel );
}
if( nextChildModel.DockWidth.IsStar )
{
nextChildModel.DockWidth = new GridLength( nextChildModel.DockWidth.Value * ( nextChildActualSize.Width - delta ) / nextChildActualSize.Width, GridUnitType.Star );
}
else
{
var width = ( nextChildModel.DockWidth.IsAuto ) ? nextChildActualSize.Width : nextChildModel.DockWidth.Value;
nextChildModel.DockWidth = new GridLength( width - delta, GridUnitType.Pixel );
}
}
else
{
if( prevChildModel.DockHeight.IsStar )
{
prevChildModel.DockHeight = new GridLength( prevChildModel.DockHeight.Value * ( prevChildActualSize.Height + delta ) / prevChildActualSize.Height, GridUnitType.Star );
}
else
{
var height = ( prevChildModel.DockHeight.IsAuto ) ? prevChildActualSize.Height : prevChildModel.DockHeight.Value;
prevChildModel.DockHeight = new GridLength( height + delta, GridUnitType.Pixel );
}
if( nextChildModel.DockHeight.IsStar )
{
nextChildModel.DockHeight = new GridLength( nextChildModel.DockHeight.Value * ( nextChildActualSize.Height - delta ) / nextChildActualSize.Height, GridUnitType.Star );
}
else
{
var height = ( nextChildModel.DockHeight.IsAuto ) ? nextChildActualSize.Height : nextChildModel.DockHeight.Value;
nextChildModel.DockHeight = new GridLength( height - delta, GridUnitType.Pixel );
}
}
HideResizerOverlayWindow();
}
private FrameworkElement GetNextVisibleChild( int index )
{
for( int i = index + 1; i < InternalChildren.Count; i++ )
{
if( InternalChildren[ i ] is LayoutGridResizerControl )
continue;
if( Orientation == System.Windows.Controls.Orientation.Horizontal )
{
if( ColumnDefinitions[ i ].Width.IsStar || ColumnDefinitions[ i ].Width.Value > 0 )
return InternalChildren[ i ] as FrameworkElement;
}
else
{
if( RowDefinitions[ i ].Height.IsStar || RowDefinitions[ i ].Height.Value > 0 )
return InternalChildren[ i ] as FrameworkElement;
}
}
return null;
}
private void ShowResizerOverlayWindow( LayoutGridResizerControl splitter )
{
_resizerGhost = new Border()
{
Background = splitter.BackgroundWhileDragging,
Opacity = splitter.OpacityWhileDragging
};
int indexOfResizer = InternalChildren.IndexOf( splitter );
var prevChild = InternalChildren[ indexOfResizer - 1 ] as FrameworkElement;
var nextChild = GetNextVisibleChild( indexOfResizer );
var prevChildActualSize = prevChild.TransformActualSizeToAncestor();
var nextChildActualSize = nextChild.TransformActualSizeToAncestor();
var prevChildModel = ( ILayoutPositionableElement )( prevChild as ILayoutControl ).Model;
var nextChildModel = ( ILayoutPositionableElement )( nextChild as ILayoutControl ).Model;
Point ptTopLeftScreen = prevChild.PointToScreenDPIWithoutFlowDirection( new Point() );
Size actualSize;
if( Orientation == System.Windows.Controls.Orientation.Horizontal )
{
actualSize = new Size(
prevChildActualSize.Width - prevChildModel.DockMinWidth + splitter.ActualWidth + nextChildActualSize.Width - nextChildModel.DockMinWidth,
nextChildActualSize.Height );
_resizerGhost.Width = splitter.ActualWidth;
_resizerGhost.Height = actualSize.Height;
ptTopLeftScreen.Offset( prevChildModel.DockMinWidth, 0.0 );
}
else
{
actualSize = new Size(
prevChildActualSize.Width,
prevChildActualSize.Height - prevChildModel.DockMinHeight + splitter.ActualHeight + nextChildActualSize.Height - nextChildModel.DockMinHeight );
_resizerGhost.Height = splitter.ActualHeight;
_resizerGhost.Width = actualSize.Width;
ptTopLeftScreen.Offset( 0.0, prevChildModel.DockMinHeight );
}
_initialStartPoint = splitter.PointToScreenDPIWithoutFlowDirection( new Point() ) - ptTopLeftScreen;
if( Orientation == System.Windows.Controls.Orientation.Horizontal )
{
Canvas.SetLeft( _resizerGhost, _initialStartPoint.X );
}
else
{
Canvas.SetTop( _resizerGhost, _initialStartPoint.Y );
}
Canvas panelHostResizer = new Canvas()
{
HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
VerticalAlignment = System.Windows.VerticalAlignment.Stretch
};
panelHostResizer.Children.Add( _resizerGhost );
_resizerWindowHost = new Window()
{
SizeToContent = System.Windows.SizeToContent.Manual,
ResizeMode = ResizeMode.NoResize,
WindowStyle = System.Windows.WindowStyle.None,
ShowInTaskbar = false,
AllowsTransparency = true,
Background = null,
Width = actualSize.Width,
Height = actualSize.Height,
Left = ptTopLeftScreen.X,
Top = ptTopLeftScreen.Y,
ShowActivated = false,
//Owner = Window.GetWindow(this),
Content = panelHostResizer
};
_resizerWindowHost.Loaded += ( s, e ) =>
{
_resizerWindowHost.SetParentToMainWindowOf( this );
};
_resizerWindowHost.Show();
}
private void HideResizerOverlayWindow()
{
if( _resizerWindowHost != null )
{
_resizerWindowHost.Close();
_resizerWindowHost = null;
}
}
#endregion
}
}

96
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridResizerControl.cs

@ -1,96 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows.Controls.Primitives;
using System.Windows;
using System.Windows.Media;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutGridResizerControl : Thumb
{
#region Constructors
static LayoutGridResizerControl()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata( typeof( LayoutGridResizerControl ), new FrameworkPropertyMetadata( typeof( LayoutGridResizerControl ) ) );
HorizontalAlignmentProperty.OverrideMetadata( typeof( LayoutGridResizerControl ), new FrameworkPropertyMetadata( HorizontalAlignment.Stretch, FrameworkPropertyMetadataOptions.AffectsParentMeasure ) );
VerticalAlignmentProperty.OverrideMetadata( typeof( LayoutGridResizerControl ), new FrameworkPropertyMetadata( VerticalAlignment.Stretch, FrameworkPropertyMetadataOptions.AffectsParentMeasure ) );
BackgroundProperty.OverrideMetadata( typeof( LayoutGridResizerControl ), new FrameworkPropertyMetadata( Brushes.Transparent ) );
IsHitTestVisibleProperty.OverrideMetadata( typeof( LayoutGridResizerControl ), new FrameworkPropertyMetadata( true, null ) );
}
#endregion
#region Properties
#region BackgroundWhileDragging
/// <summary>
/// BackgroundWhileDragging Dependency Property
/// </summary>
public static readonly DependencyProperty BackgroundWhileDraggingProperty = DependencyProperty.Register( "BackgroundWhileDragging", typeof( Brush ), typeof( LayoutGridResizerControl ),
new FrameworkPropertyMetadata( ( Brush )Brushes.Black ) );
/// <summary>
/// Gets or sets the BackgroundWhileDragging property. This dependency property
/// indicates ....
/// </summary>
public Brush BackgroundWhileDragging
{
get
{
return ( Brush )GetValue( BackgroundWhileDraggingProperty );
}
set
{
SetValue( BackgroundWhileDraggingProperty, value );
}
}
#endregion
#region OpacityWhileDragging
/// <summary>
/// OpacityWhileDragging Dependency Property
/// </summary>
public static readonly DependencyProperty OpacityWhileDraggingProperty = DependencyProperty.Register( "OpacityWhileDragging", typeof( double ), typeof( LayoutGridResizerControl ),
new FrameworkPropertyMetadata( ( double )0.5 ) );
/// <summary>
/// Gets or sets the OpacityWhileDragging property. This dependency property
/// indicates ....
/// </summary>
public double OpacityWhileDragging
{
get
{
return ( double )GetValue( OpacityWhileDraggingProperty );
}
set
{
SetValue( OpacityWhileDraggingProperty, value );
}
}
#endregion
#endregion
}
}

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

File diff suppressed because it is too large

139
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutPanelControl.cs

@ -1,139 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Controls;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class LayoutPanelControl : LayoutGridControl<ILayoutPanelElement>, ILayoutControl
{
#region Members
private LayoutPanel _model;
#endregion
#region Constructors
internal LayoutPanelControl( LayoutPanel model )
: base( model, model.Orientation )
{
_model = model;
}
#endregion
#region Overrides
protected override void OnFixChildrenDockLengths()
{
if( ActualWidth == 0.0 ||
ActualHeight == 0.0 )
return;
var modelAsPositionableElement = _model as ILayoutPositionableElementWithActualSize;
#region Setup DockWidth/Height for children
if( _model.Orientation == Orientation.Horizontal )
{
if( _model.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() )
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childContainerModel = _model.Children[ i ] as ILayoutContainer;
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;
if( childContainerModel != null &&
( childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ) )
{
childPositionableModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
else if( childPositionableModel != null && childPositionableModel.DockWidth.IsStar )
{
var childPositionableModelWidthActualSize = childPositionableModel as ILayoutPositionableElementWithActualSize;
var widthToSet = Math.Max( childPositionableModelWidthActualSize.ActualWidth, childPositionableModel.DockMinWidth );
widthToSet = Math.Min( widthToSet, ActualWidth / 2.0 );
widthToSet = Math.Max( widthToSet, childPositionableModel.DockMinWidth );
childPositionableModel.DockWidth = new GridLength(
widthToSet,
GridUnitType.Pixel );
}
}
}
else
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childPositionableModel.DockWidth.IsStar )
{
childPositionableModel.DockWidth = new GridLength( 1.0, GridUnitType.Star );
}
}
}
}
else
{
if( _model.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() )
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childContainerModel = _model.Children[ i ] as ILayoutContainer;
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;
if( childContainerModel != null &&
( childContainerModel.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childContainerModel.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ) )
{
childPositionableModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
else if( childPositionableModel != null && childPositionableModel.DockHeight.IsStar )
{
var childPositionableModelWidthActualSize = childPositionableModel as ILayoutPositionableElementWithActualSize;
var heightToSet = Math.Max( childPositionableModelWidthActualSize.ActualHeight, childPositionableModel.DockMinHeight );
heightToSet = Math.Min( heightToSet, ActualHeight / 2.0 );
heightToSet = Math.Max( heightToSet, childPositionableModel.DockMinHeight );
childPositionableModel.DockHeight = new GridLength( heightToSet, GridUnitType.Pixel );
}
}
}
else
{
for( int i = 0; i < _model.Children.Count; i++ )
{
var childPositionableModel = _model.Children[ i ] as ILayoutPositionableElement;
if( !childPositionableModel.DockHeight.IsStar )
{
childPositionableModel.DockHeight = new GridLength( 1.0, GridUnitType.Star );
}
}
}
}
#endregion
}
#endregion
}
}

159
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/MenuItemEx.cs

@ -1,159 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows.Controls;
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class MenuItemEx : MenuItem
{
#region Members
private bool _reentrantFlag = false;
#endregion
#region Constructors
static MenuItemEx()
{
IconProperty.OverrideMetadata( typeof( MenuItemEx ), new FrameworkPropertyMetadata( new PropertyChangedCallback( OnIconPropertyChanged ) ) );
}
public MenuItemEx()
{
}
#endregion
#region Properties
#region IconTemplate
/// <summary>
/// IconTemplate Dependency Property
/// </summary>
public static readonly DependencyProperty IconTemplateProperty = DependencyProperty.Register( "IconTemplate", typeof( DataTemplate ), typeof( MenuItemEx ),
new FrameworkPropertyMetadata( ( DataTemplate )null, new PropertyChangedCallback( OnIconTemplateChanged ) ) );
/// <summary>
/// Gets or sets the IconTemplate property. This dependency property
/// indicates the data template for the icon.
/// </summary>
public DataTemplate IconTemplate
{
get
{
return ( DataTemplate )GetValue( IconTemplateProperty );
}
set
{
SetValue( IconTemplateProperty, value );
}
}
/// <summary>
/// Handles changes to the IconTemplate property.
/// </summary>
private static void OnIconTemplateChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( MenuItemEx )d ).OnIconTemplateChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the IconTemplate property.
/// </summary>
protected virtual void OnIconTemplateChanged( DependencyPropertyChangedEventArgs e )
{
UpdateIcon();
}
#endregion
#region IconTemplateSelector
/// <summary>
/// IconTemplateSelector Dependency Property
/// </summary>
public static readonly DependencyProperty IconTemplateSelectorProperty = DependencyProperty.Register( "IconTemplateSelector", typeof( DataTemplateSelector ), typeof( MenuItemEx ),
new FrameworkPropertyMetadata( ( DataTemplateSelector )null, new PropertyChangedCallback( OnIconTemplateSelectorChanged ) ) );
/// <summary>
/// Gets or sets the IconTemplateSelector property. This dependency property
/// indicates the DataTemplateSelector for the Icon.
/// </summary>
public DataTemplateSelector IconTemplateSelector
{
get
{
return ( DataTemplateSelector )GetValue( IconTemplateSelectorProperty );
}
set
{
SetValue( IconTemplateSelectorProperty, value );
}
}
/// <summary>
/// Handles changes to the IconTemplateSelector property.
/// </summary>
private static void OnIconTemplateSelectorChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( MenuItemEx )d ).OnIconTemplateSelectorChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the IconTemplateSelector property.
/// </summary>
protected virtual void OnIconTemplateSelectorChanged( DependencyPropertyChangedEventArgs e )
{
UpdateIcon();
}
#endregion
#endregion
#region Private Mehods
private static void OnIconPropertyChanged( DependencyObject sender, DependencyPropertyChangedEventArgs e )
{
if( e.NewValue != null )
{
( ( MenuItemEx )sender ).UpdateIcon();
}
}
private void UpdateIcon()
{
if( _reentrantFlag )
return;
_reentrantFlag = true;
if( IconTemplateSelector != null )
{
var dataTemplateToUse = IconTemplateSelector.SelectTemplate( Icon, this );
if( dataTemplateToUse != null )
Icon = dataTemplateToUse.LoadContent();
}
else if( IconTemplate != null )
Icon = IconTemplate.LoadContent();
_reentrantFlag = false;
}
#endregion
}
}

491
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs

@ -1,491 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Xceed.Wpf.AvalonDock.Layout;
using Xceed.Wpf.AvalonDock.Themes;
using System.Windows.Controls;
namespace Xceed.Wpf.AvalonDock.Controls
{
[TemplatePart( Name = PART_AnchorableListBox, Type = typeof( ListBox ) )]
[TemplatePart( Name = PART_DocumentListBox, Type = typeof( ListBox ) )]
public class NavigatorWindow : Window
{
#region Members
private const string PART_AnchorableListBox = "PART_AnchorableListBox";
private const string PART_DocumentListBox = "PART_DocumentListBox";
private ResourceDictionary currentThemeResourceDictionary; // = null
private DockingManager _manager;
private bool _isSelectingDocument;
private ListBox _anchorableListBox;
private ListBox _documentListBox;
private bool _internalSetSelectedDocument = false;
private bool _internalSetSelectedAnchorable = false;
#endregion
#region Constructors
static NavigatorWindow()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( NavigatorWindow ), new FrameworkPropertyMetadata( typeof( NavigatorWindow ) ) );
ShowActivatedProperty.OverrideMetadata( typeof( NavigatorWindow ), new FrameworkPropertyMetadata( false ) );
ShowInTaskbarProperty.OverrideMetadata( typeof( NavigatorWindow ), new FrameworkPropertyMetadata( false ) );
}
internal NavigatorWindow( DockingManager manager )
{
_manager = manager;
_internalSetSelectedDocument = true;
this.SetAnchorables( _manager.Layout.Descendents().OfType<LayoutAnchorable>().Where( a => a.IsVisible ).Select( d => ( LayoutAnchorableItem )_manager.GetLayoutItemFromModel( d ) ).ToArray() );
this.SetDocuments( _manager.Layout.Descendents().OfType<LayoutDocument>().OrderByDescending( d => d.LastActivationTimeStamp.GetValueOrDefault() ).Select( d => ( LayoutDocumentItem )_manager.GetLayoutItemFromModel( d ) ).ToArray() );
_internalSetSelectedDocument = false;
if( this.Documents.Length > 1 )
{
this.InternalSetSelectedDocument( this.Documents[ 1 ] );
_isSelectingDocument = true;
}
else if( this.Anchorables.Count() > 1 )
{
this.InternalSetSelectedAnchorable( this.Anchorables.ToArray()[ 1 ] );
_isSelectingDocument = false;
}
this.DataContext = this;
this.Loaded += new RoutedEventHandler( OnLoaded );
this.Unloaded += new RoutedEventHandler( OnUnloaded );
this.UpdateThemeResources();
}
#endregion
#region Properties
#region Documents
/// <summary>
/// Documents Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey DocumentsPropertyKey = DependencyProperty.RegisterReadOnly( "Documents", typeof( IEnumerable<LayoutDocumentItem> ), typeof( NavigatorWindow ),
new FrameworkPropertyMetadata( null ) );
public static readonly DependencyProperty DocumentsProperty = DocumentsPropertyKey.DependencyProperty;
/// <summary>
/// Gets the Documents property. This dependency property
/// indicates the list of documents.
/// </summary>
public LayoutDocumentItem[] Documents
{
get
{
return ( LayoutDocumentItem[] )GetValue( DocumentsProperty );
}
}
#endregion
#region Anchorables
/// <summary>
/// Anchorables Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey AnchorablesPropertyKey = DependencyProperty.RegisterReadOnly( "Anchorables", typeof( IEnumerable<LayoutAnchorableItem> ), typeof( NavigatorWindow ),
new FrameworkPropertyMetadata( ( IEnumerable<LayoutAnchorableItem> )null ) );
public static readonly DependencyProperty AnchorablesProperty = AnchorablesPropertyKey.DependencyProperty;
/// <summary>
/// Gets the Anchorables property. This dependency property
/// indicates the list of anchorables.
/// </summary>
public IEnumerable<LayoutAnchorableItem> Anchorables
{
get
{
return ( IEnumerable<LayoutAnchorableItem> )GetValue( AnchorablesProperty );
}
}
#endregion
#region SelectedDocument
/// <summary>
/// SelectedDocument Dependency Property
/// </summary>
public static readonly DependencyProperty SelectedDocumentProperty = DependencyProperty.Register( "SelectedDocument", typeof( LayoutDocumentItem ), typeof( NavigatorWindow ),
new FrameworkPropertyMetadata( ( LayoutDocumentItem )null, new PropertyChangedCallback( OnSelectedDocumentChanged ) ) );
/// <summary>
/// Gets or sets the SelectedDocument property. This dependency property
/// indicates the selected document.
/// </summary>
public LayoutDocumentItem SelectedDocument
{
get
{
return ( LayoutDocumentItem )GetValue( SelectedDocumentProperty );
}
set
{
SetValue( SelectedDocumentProperty, value );
}
}
/// <summary>
/// Handles changes to the SelectedDocument property.
/// </summary>
private static void OnSelectedDocumentChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( NavigatorWindow )d ).OnSelectedDocumentChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the SelectedDocument property.
/// </summary>
protected virtual void OnSelectedDocumentChanged( DependencyPropertyChangedEventArgs e )
{
if( _internalSetSelectedDocument )
return;
if( this.SelectedDocument != null &&
this.SelectedDocument.ActivateCommand.CanExecute( null ) )
{
this.Hide();
this.SelectedDocument.ActivateCommand.Execute( null );
}
}
#endregion
#region SelectedAnchorable
/// <summary>
/// SelectedAnchorable Dependency Property
/// </summary>
public static readonly DependencyProperty SelectedAnchorableProperty = DependencyProperty.Register( "SelectedAnchorable", typeof( LayoutAnchorableItem ), typeof( NavigatorWindow ),
new FrameworkPropertyMetadata( ( LayoutAnchorableItem )null, new PropertyChangedCallback( OnSelectedAnchorableChanged ) ) );
/// <summary>
/// Gets or sets the SelectedAnchorable property. This dependency property
/// indicates the selected anchorable.
/// </summary>
public LayoutAnchorableItem SelectedAnchorable
{
get
{
return ( LayoutAnchorableItem )GetValue( SelectedAnchorableProperty );
}
set
{
SetValue( SelectedAnchorableProperty, value );
}
}
/// <summary>
/// Handles changes to the SelectedAnchorable property.
/// </summary>
private static void OnSelectedAnchorableChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
( ( NavigatorWindow )d ).OnSelectedAnchorableChanged( e );
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the SelectedAnchorable property.
/// </summary>
protected virtual void OnSelectedAnchorableChanged( DependencyPropertyChangedEventArgs e )
{
if( _internalSetSelectedAnchorable )
return;
var selectedAnchorable = e.NewValue as LayoutAnchorableItem;
if( this.SelectedAnchorable != null &&
this.SelectedAnchorable.ActivateCommand.CanExecute( null ) )
{
this.Close();
this.SelectedAnchorable.ActivateCommand.Execute( null );
}
}
#endregion
#endregion
#region Overrides
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_anchorableListBox = this.GetTemplateChild( PART_AnchorableListBox ) as ListBox;
_documentListBox = this.GetTemplateChild( PART_DocumentListBox ) as ListBox;
}
protected override void OnPreviewKeyDown( System.Windows.Input.KeyEventArgs e )
{
bool shouldHandle = false;
// Press Tab to switch Selected LayoutContent.
if( e.Key == System.Windows.Input.Key.Tab)
{
// Selecting LayoutDocuments
if( _isSelectingDocument )
{
if( this.SelectedDocument != null )
{
// Jump to next LayoutDocument
var docIndex = this.Documents.IndexOf<LayoutDocumentItem>( this.SelectedDocument );
if( docIndex < (this.Documents.Length - 1) )
{
this.SelectNextDocument();
shouldHandle = true;
}
// Jump to first LayoutAnchorable
else if( this.Anchorables.Count() > 0 )
{
_isSelectingDocument = false;
this.InternalSetSelectedDocument( null );
this.InternalSetSelectedAnchorable( this.Anchorables.First() );
shouldHandle = true;
}
}
// There is no SelectedDocument, select the first one.
else
{
if( this.Documents.Length > 0 )
{
this.InternalSetSelectedDocument( this.Documents[ 0 ] );
shouldHandle = true;
}
}
}
// Selecting LayoutAnchorables
else
{
if( this.SelectedAnchorable != null )
{
// Jump to next LayoutAnchorable
var anchorableIndex = this.Anchorables.ToArray().IndexOf<LayoutAnchorableItem>( this.SelectedAnchorable );
if( anchorableIndex < (this.Anchorables.Count() - 1) )
{
this.SelectNextAnchorable();
shouldHandle = true;
}
// Jump to first LayoutDocument
else if( this.Documents.Length > 0 )
{
_isSelectingDocument = true;
this.InternalSetSelectedAnchorable( null );
this.InternalSetSelectedDocument( this.Documents[ 0 ] );
shouldHandle = true;
}
}
// There is no SelectedAnchorable, select the first one.
else
{
if( this.Anchorables.Count() > 0 )
{
this.InternalSetSelectedAnchorable( this.Anchorables.ToArray()[ 0 ] );
shouldHandle = true;
}
}
}
}
if( shouldHandle )
{
e.Handled = true;
}
base.OnPreviewKeyDown( e );
}
protected override void OnPreviewKeyUp( System.Windows.Input.KeyEventArgs e )
{
if( e.Key != System.Windows.Input.Key.Tab )
{
this.Close();
if( this.SelectedDocument != null &&
this.SelectedDocument.ActivateCommand.CanExecute( null ) )
{
this.SelectedDocument.ActivateCommand.Execute( null );
}
if( this.SelectedDocument == null &&
this.SelectedAnchorable != null &&
this.SelectedAnchorable.ActivateCommand.CanExecute( null ) )
{
this.SelectedAnchorable.ActivateCommand.Execute( null );
}
e.Handled = true;
}
base.OnPreviewKeyUp( e );
}
#endregion
#region Internal Methods
/// <summary>
/// Provides a secure method for setting the Anchorables property.
/// This dependency property indicates the list of anchorables.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetAnchorables( IEnumerable<LayoutAnchorableItem> value )
{
this.SetValue( AnchorablesPropertyKey, value );
}
/// <summary>
/// Provides a secure method for setting the Documents property.
/// This dependency property indicates the list of documents.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetDocuments( LayoutDocumentItem[] value )
{
this.SetValue( DocumentsPropertyKey, value );
}
internal void UpdateThemeResources( Theme oldTheme = null )
{
if( oldTheme != null )
{
if( oldTheme is DictionaryTheme )
{
if( currentThemeResourceDictionary != null )
{
this.Resources.MergedDictionaries.Remove( currentThemeResourceDictionary );
currentThemeResourceDictionary = null;
}
}
else
{
var resourceDictionaryToRemove = this.Resources.MergedDictionaries.FirstOrDefault( r => r.Source == oldTheme.GetResourceUri() );
if( resourceDictionaryToRemove != null )
{
this.Resources.MergedDictionaries.Remove( resourceDictionaryToRemove );
}
}
}
if( _manager.Theme != null )
{
if( _manager.Theme is DictionaryTheme )
{
currentThemeResourceDictionary = ( ( DictionaryTheme )_manager.Theme ).ThemeResourceDictionary;
this.Resources.MergedDictionaries.Add( currentThemeResourceDictionary );
}
else
{
this.Resources.MergedDictionaries.Add( new ResourceDictionary() { Source = _manager.Theme.GetResourceUri() } );
}
}
}
internal void SelectNextDocument()
{
if( this.SelectedDocument != null )
{
int docIndex = this.Documents.IndexOf<LayoutDocumentItem>( this.SelectedDocument );
docIndex++;
if( docIndex == this.Documents.Length )
{
docIndex = 0;
}
this.InternalSetSelectedDocument( this.Documents[ docIndex ] );
}
}
internal void SelectNextAnchorable()
{
if( this.SelectedAnchorable != null )
{
var anchorablesArray = this.Anchorables.ToArray();
int anchorableIndex = anchorablesArray.IndexOf<LayoutAnchorableItem>( this.SelectedAnchorable );
anchorableIndex++;
if( anchorableIndex == this.Anchorables.Count() )
{
anchorableIndex = 0;
}
this.InternalSetSelectedAnchorable( anchorablesArray[ anchorableIndex ] );
}
}
#endregion
#region Private Methods
private void InternalSetSelectedAnchorable( LayoutAnchorableItem anchorableToSelect )
{
_internalSetSelectedAnchorable = true;
this.SelectedAnchorable = anchorableToSelect;
_internalSetSelectedAnchorable = false;
if( _anchorableListBox != null )
{
_anchorableListBox.Focus();
}
}
private void InternalSetSelectedDocument( LayoutDocumentItem documentToSelect )
{
_internalSetSelectedDocument = true;
this.SelectedDocument = documentToSelect;
_internalSetSelectedDocument = false;
if( ( _documentListBox != null ) && ( documentToSelect != null ) )
{
_documentListBox.Focus();
}
}
private void OnLoaded( object sender, RoutedEventArgs e )
{
this.Loaded -= new RoutedEventHandler( OnLoaded );
if( ( _documentListBox != null ) && (this.SelectedDocument != null) )
{
_documentListBox.Focus();
}
else if( ( _anchorableListBox != null ) && (this.SelectedAnchorable != null) )
{
_anchorableListBox.Focus();
}
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}
private void OnUnloaded( object sender, RoutedEventArgs e )
{
this.Unloaded -= new RoutedEventHandler( OnUnloaded );
}
#endregion
}
}

60
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayArea.cs

@ -1,60 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public abstract class OverlayArea : IOverlayWindowArea
{
#region Members
private IOverlayWindow _overlayWindow;
private Rect? _screenDetectionArea;
#endregion
#region Constructors
internal OverlayArea( IOverlayWindow overlayWindow )
{
_overlayWindow = overlayWindow;
}
#endregion
#region Internal Methods
protected void SetScreenDetectionArea( Rect rect )
{
_screenDetectionArea = rect;
}
#endregion
#region IOverlayWindowArea
Rect IOverlayWindowArea.ScreenDetectionArea
{
get
{
return _screenDetectionArea.Value;
}
}
#endregion
}
}

729
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs

@ -1,729 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
using Xceed.Wpf.AvalonDock.Layout;
using Xceed.Wpf.AvalonDock.Themes;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class OverlayWindow : Window, IOverlayWindow
{
#region Members
private ResourceDictionary currentThemeResourceDictionary; // = null
private Canvas _mainCanvasPanel;
private Grid _gridDockingManagerDropTargets;
private Grid _gridAnchorablePaneDropTargets;
private Grid _gridDocumentPaneDropTargets;
private Grid _gridDocumentPaneFullDropTargets;
private FrameworkElement _dockingManagerDropTargetBottom;
private FrameworkElement _dockingManagerDropTargetTop;
private FrameworkElement _dockingManagerDropTargetLeft;
private FrameworkElement _dockingManagerDropTargetRight;
private FrameworkElement _anchorablePaneDropTargetBottom;
private FrameworkElement _anchorablePaneDropTargetTop;
private FrameworkElement _anchorablePaneDropTargetLeft;
private FrameworkElement _anchorablePaneDropTargetRight;
private FrameworkElement _anchorablePaneDropTargetInto;
private FrameworkElement _documentPaneDropTargetBottom;
private FrameworkElement _documentPaneDropTargetTop;
private FrameworkElement _documentPaneDropTargetLeft;
private FrameworkElement _documentPaneDropTargetRight;
private FrameworkElement _documentPaneDropTargetInto;
private FrameworkElement _documentPaneDropTargetBottomAsAnchorablePane;
private FrameworkElement _documentPaneDropTargetTopAsAnchorablePane;
private FrameworkElement _documentPaneDropTargetLeftAsAnchorablePane;
private FrameworkElement _documentPaneDropTargetRightAsAnchorablePane;
private FrameworkElement _documentPaneFullDropTargetBottom;
private FrameworkElement _documentPaneFullDropTargetTop;
private FrameworkElement _documentPaneFullDropTargetLeft;
private FrameworkElement _documentPaneFullDropTargetRight;
private FrameworkElement _documentPaneFullDropTargetInto;
private Path _previewBox;
private IOverlayWindowHost _host;
private LayoutFloatingWindowControl _floatingWindow = null;
private List<IDropArea> _visibleAreas = new List<IDropArea>();
#endregion
#region Constructors
static OverlayWindow()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( OverlayWindow ), new FrameworkPropertyMetadata( typeof( OverlayWindow ) ) );
OverlayWindow.AllowsTransparencyProperty.OverrideMetadata( typeof( OverlayWindow ), new FrameworkPropertyMetadata( true ) );
OverlayWindow.WindowStyleProperty.OverrideMetadata( typeof( OverlayWindow ), new FrameworkPropertyMetadata( WindowStyle.None ) );
OverlayWindow.ShowInTaskbarProperty.OverrideMetadata( typeof( OverlayWindow ), new FrameworkPropertyMetadata( false ) );
OverlayWindow.ShowActivatedProperty.OverrideMetadata( typeof( OverlayWindow ), new FrameworkPropertyMetadata( false ) );
OverlayWindow.VisibilityProperty.OverrideMetadata( typeof( OverlayWindow ), new FrameworkPropertyMetadata( Visibility.Hidden ) );
}
internal OverlayWindow( IOverlayWindowHost host )
{
_host = host;
UpdateThemeResources();
}
#endregion
#region Overrides
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_mainCanvasPanel = GetTemplateChild( "PART_DropTargetsContainer" ) as Canvas;
_gridDockingManagerDropTargets = GetTemplateChild( "PART_DockingManagerDropTargets" ) as Grid;
_gridAnchorablePaneDropTargets = GetTemplateChild( "PART_AnchorablePaneDropTargets" ) as Grid;
_gridDocumentPaneDropTargets = GetTemplateChild( "PART_DocumentPaneDropTargets" ) as Grid;
_gridDocumentPaneFullDropTargets = GetTemplateChild( "PART_DocumentPaneFullDropTargets" ) as Grid;
_gridDockingManagerDropTargets.Visibility = System.Windows.Visibility.Hidden;
_gridAnchorablePaneDropTargets.Visibility = System.Windows.Visibility.Hidden;
_gridDocumentPaneDropTargets.Visibility = System.Windows.Visibility.Hidden;
if( _gridDocumentPaneFullDropTargets != null )
_gridDocumentPaneFullDropTargets.Visibility = System.Windows.Visibility.Hidden;
_dockingManagerDropTargetBottom = GetTemplateChild( "PART_DockingManagerDropTargetBottom" ) as FrameworkElement;
_dockingManagerDropTargetTop = GetTemplateChild( "PART_DockingManagerDropTargetTop" ) as FrameworkElement;
_dockingManagerDropTargetLeft = GetTemplateChild( "PART_DockingManagerDropTargetLeft" ) as FrameworkElement;
_dockingManagerDropTargetRight = GetTemplateChild( "PART_DockingManagerDropTargetRight" ) as FrameworkElement;
_anchorablePaneDropTargetBottom = GetTemplateChild( "PART_AnchorablePaneDropTargetBottom" ) as FrameworkElement;
_anchorablePaneDropTargetTop = GetTemplateChild( "PART_AnchorablePaneDropTargetTop" ) as FrameworkElement;
_anchorablePaneDropTargetLeft = GetTemplateChild( "PART_AnchorablePaneDropTargetLeft" ) as FrameworkElement;
_anchorablePaneDropTargetRight = GetTemplateChild( "PART_AnchorablePaneDropTargetRight" ) as FrameworkElement;
_anchorablePaneDropTargetInto = GetTemplateChild( "PART_AnchorablePaneDropTargetInto" ) as FrameworkElement;
_documentPaneDropTargetBottom = GetTemplateChild( "PART_DocumentPaneDropTargetBottom" ) as FrameworkElement;
_documentPaneDropTargetTop = GetTemplateChild( "PART_DocumentPaneDropTargetTop" ) as FrameworkElement;
_documentPaneDropTargetLeft = GetTemplateChild( "PART_DocumentPaneDropTargetLeft" ) as FrameworkElement;
_documentPaneDropTargetRight = GetTemplateChild( "PART_DocumentPaneDropTargetRight" ) as FrameworkElement;
_documentPaneDropTargetInto = GetTemplateChild( "PART_DocumentPaneDropTargetInto" ) as FrameworkElement;
_documentPaneDropTargetBottomAsAnchorablePane = GetTemplateChild( "PART_DocumentPaneDropTargetBottomAsAnchorablePane" ) as FrameworkElement;
_documentPaneDropTargetTopAsAnchorablePane = GetTemplateChild( "PART_DocumentPaneDropTargetTopAsAnchorablePane" ) as FrameworkElement;
_documentPaneDropTargetLeftAsAnchorablePane = GetTemplateChild( "PART_DocumentPaneDropTargetLeftAsAnchorablePane" ) as FrameworkElement;
_documentPaneDropTargetRightAsAnchorablePane = GetTemplateChild( "PART_DocumentPaneDropTargetRightAsAnchorablePane" ) as FrameworkElement;
_documentPaneFullDropTargetBottom = GetTemplateChild( "PART_DocumentPaneFullDropTargetBottom" ) as FrameworkElement;
_documentPaneFullDropTargetTop = GetTemplateChild( "PART_DocumentPaneFullDropTargetTop" ) as FrameworkElement;
_documentPaneFullDropTargetLeft = GetTemplateChild( "PART_DocumentPaneFullDropTargetLeft" ) as FrameworkElement;
_documentPaneFullDropTargetRight = GetTemplateChild( "PART_DocumentPaneFullDropTargetRight" ) as FrameworkElement;
_documentPaneFullDropTargetInto = GetTemplateChild( "PART_DocumentPaneFullDropTargetInto" ) as FrameworkElement;
_previewBox = GetTemplateChild( "PART_PreviewBox" ) as Path;
}
protected override void OnClosing( System.ComponentModel.CancelEventArgs e )
{
base.OnClosing( e );
}
#endregion
#region Internal Methods
internal void UpdateThemeResources( Theme oldTheme = null )
{
if( oldTheme != null )
{
if( oldTheme is DictionaryTheme )
{
if( currentThemeResourceDictionary != null )
{
Resources.MergedDictionaries.Remove( currentThemeResourceDictionary );
currentThemeResourceDictionary = null;
}
}
else
{
var resourceDictionaryToRemove =
Resources.MergedDictionaries.FirstOrDefault( r => r.Source == oldTheme.GetResourceUri() );
if( resourceDictionaryToRemove != null )
Resources.MergedDictionaries.Remove(
resourceDictionaryToRemove );
}
}
if( _host.Manager.Theme != null )
{
if( _host.Manager.Theme is DictionaryTheme )
{
currentThemeResourceDictionary = ( ( DictionaryTheme )_host.Manager.Theme ).ThemeResourceDictionary;
Resources.MergedDictionaries.Add( currentThemeResourceDictionary );
}
else
{
Resources.MergedDictionaries.Add( new ResourceDictionary() { Source = _host.Manager.Theme.GetResourceUri() } );
}
}
}
internal void EnableDropTargets()
{
if( _mainCanvasPanel != null )
_mainCanvasPanel.Visibility = System.Windows.Visibility.Visible;
}
internal void HideDropTargets()
{
if( _mainCanvasPanel != null )
_mainCanvasPanel.Visibility = System.Windows.Visibility.Hidden;
}
#endregion
#region Private Methods
/// <summary>
/// This method controls the DropTargetInto button of the overlay window.
/// It checks that only 1 of the defined ContentLayouts can be present on the LayoutDocumentPane or LayoutAnchorablePane.
/// The combination between the ContentLayout Title and the ContentId is the search key, and has to be unique.
/// If a floating window is dropped on a LayoutDocumentPane or LayoutAnchorablePane, it checks if one of the containing LayoutContents
/// is already present on the LayoutDocumentPane or LayoutAnchorablePane. If so, then it will disable the DropTargetInto button.
/// </summary>
/// <param name="positionableElement">The given LayoutDocumentPane or LayoutAnchorablePane</param>
private void SetDropTargetIntoVisibility( ILayoutPositionableElement positionableElement )
{
if( positionableElement is LayoutAnchorablePane )
{
_anchorablePaneDropTargetInto.Visibility = Visibility.Visible;
}
else if( positionableElement is LayoutDocumentPane )
{
_documentPaneDropTargetInto.Visibility = Visibility.Visible;
}
if( positionableElement == null || _floatingWindow.Model == null || positionableElement.AllowDuplicateContent )
{
return;
}
// Find all content layouts in the anchorable pane (object to drop on)
var contentLayoutsOnPositionableElementPane = GetAllLayoutContents( positionableElement );
// Find all content layouts in the floating window (object to drop)
var contentLayoutsOnFloatingWindow = GetAllLayoutContents( _floatingWindow.Model );
// If any of the content layouts is present in the drop area, then disable the DropTargetInto button.
foreach( var content in contentLayoutsOnFloatingWindow )
{
if( !contentLayoutsOnPositionableElementPane.Any( item =>
item.Title == content.Title &&
item.ContentId == content.ContentId ) )
{
continue;
}
if( positionableElement is LayoutAnchorablePane )
{
_anchorablePaneDropTargetInto.Visibility = Visibility.Hidden;
}
else if( positionableElement is LayoutDocumentPane )
{
_documentPaneDropTargetInto.Visibility = Visibility.Hidden;
}
break;
}
}
/// <summary>
/// Find any LayoutDocument or LayoutAnchorable from a given source (e.g. LayoutDocumentPane, LayoutAnchorableFloatingWindow, etc.)
/// </summary>
/// <param name="source">The given source to search in</param>
/// <returns>A list of all LayoutContent's</returns>
private List<LayoutContent> GetAllLayoutContents( object source )
{
var result = new List<LayoutContent>();
var documentFloatingWindow = source as LayoutDocumentFloatingWindow;
if( documentFloatingWindow != null )
{
foreach( var layoutElement in documentFloatingWindow.Children )
{
result.AddRange( GetAllLayoutContents( layoutElement ) );
}
}
var anchorableFloatingWindow = source as LayoutAnchorableFloatingWindow;
if( anchorableFloatingWindow != null )
{
foreach( var layoutElement in anchorableFloatingWindow.Children )
{
result.AddRange( GetAllLayoutContents( layoutElement ) );
}
}
var documentPaneGroup = source as LayoutDocumentPaneGroup;
if( documentPaneGroup != null )
{
foreach( var layoutDocumentPane in documentPaneGroup.Children )
{
result.AddRange( GetAllLayoutContents( layoutDocumentPane ) );
}
}
var anchorablePaneGroup = source as LayoutAnchorablePaneGroup;
if( anchorablePaneGroup != null )
{
foreach( var layoutDocumentPane in anchorablePaneGroup.Children )
{
result.AddRange( GetAllLayoutContents( layoutDocumentPane ) );
}
}
var documentPane = source as LayoutDocumentPane;
if( documentPane != null )
{
foreach( var layoutContent in documentPane.Children )
{
result.Add( layoutContent );
}
}
var anchorablePane = source as LayoutAnchorablePane;
if( anchorablePane != null )
{
foreach( var layoutContent in anchorablePane.Children )
{
result.Add( layoutContent );
}
}
var document = source as LayoutDocument;
if( document != null )
{
result.Add( document );
}
var anchorable = source as LayoutAnchorable;
if( anchorable != null )
{
result.Add( anchorable );
}
return result;
}
#endregion
#region IOverlayWindow
IEnumerable<IDropTarget> IOverlayWindow.GetTargets()
{
foreach( var visibleArea in _visibleAreas )
{
switch( visibleArea.Type )
{
case DropAreaType.DockingManager:
{
var dropAreaDockingManager = visibleArea as DropArea<DockingManager>;
yield return new DockingManagerDropTarget( dropAreaDockingManager.AreaElement, _dockingManagerDropTargetLeft.GetScreenArea(), DropTargetType.DockingManagerDockLeft );
yield return new DockingManagerDropTarget( dropAreaDockingManager.AreaElement, _dockingManagerDropTargetTop.GetScreenArea(), DropTargetType.DockingManagerDockTop );
yield return new DockingManagerDropTarget( dropAreaDockingManager.AreaElement, _dockingManagerDropTargetBottom.GetScreenArea(), DropTargetType.DockingManagerDockBottom );
yield return new DockingManagerDropTarget( dropAreaDockingManager.AreaElement, _dockingManagerDropTargetRight.GetScreenArea(), DropTargetType.DockingManagerDockRight );
}
break;
case DropAreaType.AnchorablePane:
{
var dropAreaAnchorablePane = visibleArea as DropArea<LayoutAnchorablePaneControl>;
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetLeft.GetScreenArea(), DropTargetType.AnchorablePaneDockLeft );
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetTop.GetScreenArea(), DropTargetType.AnchorablePaneDockTop );
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetRight.GetScreenArea(), DropTargetType.AnchorablePaneDockRight );
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetBottom.GetScreenArea(), DropTargetType.AnchorablePaneDockBottom );
if( _anchorablePaneDropTargetInto.IsVisible )
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, _anchorablePaneDropTargetInto.GetScreenArea(), DropTargetType.AnchorablePaneDockInside );
var parentPaneModel = dropAreaAnchorablePane.AreaElement.Model as LayoutAnchorablePane;
LayoutAnchorableTabItem lastAreaTabItem = null;
foreach( var dropAreaTabItem in dropAreaAnchorablePane.AreaElement.FindVisualChildren<LayoutAnchorableTabItem>() )
{
var tabItemModel = dropAreaTabItem.Model as LayoutAnchorable;
lastAreaTabItem = lastAreaTabItem == null || lastAreaTabItem.GetScreenArea().Right < dropAreaTabItem.GetScreenArea().Right ?
dropAreaTabItem : lastAreaTabItem;
int tabIndex = parentPaneModel.Children.IndexOf( tabItemModel );
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, dropAreaTabItem.GetScreenArea(), DropTargetType.AnchorablePaneDockInside, tabIndex );
}
if( lastAreaTabItem != null )
{
var lastAreaTabItemScreenArea = lastAreaTabItem.GetScreenArea();
var newAreaTabItemScreenArea = new Rect( lastAreaTabItemScreenArea.TopRight, new Point( lastAreaTabItemScreenArea.Right + lastAreaTabItemScreenArea.Width, lastAreaTabItemScreenArea.Bottom ) );
if( newAreaTabItemScreenArea.Right < dropAreaAnchorablePane.AreaElement.GetScreenArea().Right )
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, newAreaTabItemScreenArea, DropTargetType.AnchorablePaneDockInside, parentPaneModel.Children.Count );
}
var dropAreaTitle = dropAreaAnchorablePane.AreaElement.FindVisualChildren<AnchorablePaneTitle>().FirstOrDefault();
if( dropAreaTitle != null )
yield return new AnchorablePaneDropTarget( dropAreaAnchorablePane.AreaElement, dropAreaTitle.GetScreenArea(), DropTargetType.AnchorablePaneDockInside );
}
break;
case DropAreaType.DocumentPane:
{
bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow;
if( isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null )
{
var dropAreaDocumentPane = visibleArea as DropArea<LayoutDocumentPaneControl>;
if( _documentPaneFullDropTargetLeft.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetLeft.GetScreenArea(), DropTargetType.DocumentPaneDockLeft );
if( _documentPaneFullDropTargetTop.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetTop.GetScreenArea(), DropTargetType.DocumentPaneDockTop );
if( _documentPaneFullDropTargetRight.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetRight.GetScreenArea(), DropTargetType.DocumentPaneDockRight );
if( _documentPaneFullDropTargetBottom.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetBottom.GetScreenArea(), DropTargetType.DocumentPaneDockBottom );
if( _documentPaneFullDropTargetInto.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneFullDropTargetInto.GetScreenArea(), DropTargetType.DocumentPaneDockInside );
var parentPaneModel = dropAreaDocumentPane.AreaElement.Model as LayoutDocumentPane;
LayoutDocumentTabItem lastAreaTabItem = null;
foreach( var dropAreaTabItem in dropAreaDocumentPane.AreaElement.FindVisualChildren<LayoutDocumentTabItem>() )
{
var tabItemModel = dropAreaTabItem.Model;
lastAreaTabItem = lastAreaTabItem == null || lastAreaTabItem.GetScreenArea().Right < dropAreaTabItem.GetScreenArea().Right ?
dropAreaTabItem : lastAreaTabItem;
int tabIndex = parentPaneModel.Children.IndexOf( tabItemModel );
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, dropAreaTabItem.GetScreenArea(), DropTargetType.DocumentPaneDockInside, tabIndex );
}
if( lastAreaTabItem != null )
{
var lastAreaTabItemScreenArea = lastAreaTabItem.GetScreenArea();
var newAreaTabItemScreenArea = new Rect( lastAreaTabItemScreenArea.TopRight, new Point( lastAreaTabItemScreenArea.Right + lastAreaTabItemScreenArea.Width, lastAreaTabItemScreenArea.Bottom ) );
if( newAreaTabItemScreenArea.Right < dropAreaDocumentPane.AreaElement.GetScreenArea().Right )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, newAreaTabItemScreenArea, DropTargetType.DocumentPaneDockInside, parentPaneModel.Children.Count );
}
if( _documentPaneDropTargetLeftAsAnchorablePane.IsVisible )
yield return new DocumentPaneDropAsAnchorableTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetLeftAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableLeft );
if( _documentPaneDropTargetTopAsAnchorablePane.IsVisible )
yield return new DocumentPaneDropAsAnchorableTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetTopAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableTop );
if( _documentPaneDropTargetRightAsAnchorablePane.IsVisible )
yield return new DocumentPaneDropAsAnchorableTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetRightAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableRight );
if( _documentPaneDropTargetBottomAsAnchorablePane.IsVisible )
yield return new DocumentPaneDropAsAnchorableTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetBottomAsAnchorablePane.GetScreenArea(), DropTargetType.DocumentPaneDockAsAnchorableBottom );
}
else
{
var dropAreaDocumentPane = visibleArea as DropArea<LayoutDocumentPaneControl>;
if( _documentPaneDropTargetLeft.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetLeft.GetScreenArea(), DropTargetType.DocumentPaneDockLeft );
if( _documentPaneDropTargetTop.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetTop.GetScreenArea(), DropTargetType.DocumentPaneDockTop );
if( _documentPaneDropTargetRight.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetRight.GetScreenArea(), DropTargetType.DocumentPaneDockRight );
if( _documentPaneDropTargetBottom.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetBottom.GetScreenArea(), DropTargetType.DocumentPaneDockBottom );
if( _documentPaneDropTargetInto.IsVisible )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetInto.GetScreenArea(), DropTargetType.DocumentPaneDockInside );
var parentPaneModel = dropAreaDocumentPane.AreaElement.Model as LayoutDocumentPane;
LayoutDocumentTabItem lastAreaTabItem = null;
foreach( var dropAreaTabItem in dropAreaDocumentPane.AreaElement.FindVisualChildren<LayoutDocumentTabItem>() )
{
var tabItemModel = dropAreaTabItem.Model;
lastAreaTabItem = lastAreaTabItem == null || lastAreaTabItem.GetScreenArea().Right < dropAreaTabItem.GetScreenArea().Right ?
dropAreaTabItem : lastAreaTabItem;
int tabIndex = parentPaneModel.Children.IndexOf( tabItemModel );
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, dropAreaTabItem.GetScreenArea(), DropTargetType.DocumentPaneDockInside, tabIndex );
}
if( lastAreaTabItem != null )
{
var lastAreaTabItemScreenArea = lastAreaTabItem.GetScreenArea();
var newAreaTabItemScreenArea = new Rect( lastAreaTabItemScreenArea.TopRight, new Point( lastAreaTabItemScreenArea.Right + lastAreaTabItemScreenArea.Width, lastAreaTabItemScreenArea.Bottom ) );
if( newAreaTabItemScreenArea.Right < dropAreaDocumentPane.AreaElement.GetScreenArea().Right )
yield return new DocumentPaneDropTarget( dropAreaDocumentPane.AreaElement, newAreaTabItemScreenArea, DropTargetType.DocumentPaneDockInside, parentPaneModel.Children.Count );
}
}
}
break;
case DropAreaType.DocumentPaneGroup:
{
var dropAreaDocumentPane = visibleArea as DropArea<LayoutDocumentPaneGroupControl>;
if( _documentPaneDropTargetInto.IsVisible )
yield return new DocumentPaneGroupDropTarget( dropAreaDocumentPane.AreaElement, _documentPaneDropTargetInto.GetScreenArea(), DropTargetType.DocumentPaneGroupDockInside );
}
break;
}
}
yield break;
}
void IOverlayWindow.DragEnter( LayoutFloatingWindowControl floatingWindow )
{
_floatingWindow = floatingWindow;
EnableDropTargets();
}
void IOverlayWindow.DragLeave( LayoutFloatingWindowControl floatingWindow )
{
Visibility = System.Windows.Visibility.Hidden;
_floatingWindow = null;
}
void IOverlayWindow.DragEnter( IDropArea area )
{
_visibleAreas.Add( area );
FrameworkElement areaElement;
switch( area.Type )
{
case DropAreaType.DockingManager:
areaElement = _gridDockingManagerDropTargets;
break;
case DropAreaType.AnchorablePane:
areaElement = _gridAnchorablePaneDropTargets;
var dropAreaAnchorablePaneGroup = area as DropArea<LayoutAnchorablePaneControl>;
var layoutAnchorablePane = dropAreaAnchorablePaneGroup.AreaElement.Model as LayoutAnchorablePane;
SetDropTargetIntoVisibility( layoutAnchorablePane );
break;
case DropAreaType.DocumentPaneGroup:
{
areaElement = _gridDocumentPaneDropTargets;
var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneGroupControl>;
var layoutDocumentPane = ( dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPaneGroup ).Children.First() as LayoutDocumentPane;
var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup;
_documentPaneDropTargetLeft.Visibility = Visibility.Hidden;
_documentPaneDropTargetRight.Visibility = Visibility.Hidden;
_documentPaneDropTargetTop.Visibility = Visibility.Hidden;
_documentPaneDropTargetBottom.Visibility = Visibility.Hidden;
}
break;
case DropAreaType.DocumentPane:
default:
{
bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow;
if( isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null )
{
areaElement = _gridDocumentPaneFullDropTargets;
var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneControl>;
var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane;
var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup;
SetDropTargetIntoVisibility( layoutDocumentPane );
if( parentDocumentPaneGroup != null &&
parentDocumentPaneGroup.Children.Where( c => c.IsVisible ).Count() > 1 )
{
var manager = parentDocumentPaneGroup.Root.Manager;
if( !manager.AllowMixedOrientation )
{
_documentPaneFullDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden;
_documentPaneFullDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden;
_documentPaneFullDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden;
_documentPaneFullDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden;
}
else
{
_documentPaneFullDropTargetLeft.Visibility = Visibility.Visible;
_documentPaneFullDropTargetRight.Visibility = Visibility.Visible;
_documentPaneFullDropTargetTop.Visibility = Visibility.Visible;
_documentPaneFullDropTargetBottom.Visibility = Visibility.Visible;
}
}
else if( parentDocumentPaneGroup == null &&
layoutDocumentPane != null &&
layoutDocumentPane.ChildrenCount == 0 )
{
_documentPaneFullDropTargetLeft.Visibility = Visibility.Hidden;
_documentPaneFullDropTargetRight.Visibility = Visibility.Hidden;
_documentPaneFullDropTargetTop.Visibility = Visibility.Hidden;
_documentPaneFullDropTargetBottom.Visibility = Visibility.Hidden;
}
else
{
_documentPaneFullDropTargetLeft.Visibility = Visibility.Visible;
_documentPaneFullDropTargetRight.Visibility = Visibility.Visible;
_documentPaneFullDropTargetTop.Visibility = Visibility.Visible;
_documentPaneFullDropTargetBottom.Visibility = Visibility.Visible;
}
if( parentDocumentPaneGroup != null &&
parentDocumentPaneGroup.Children.Where( c => c.IsVisible ).Count() > 1 )
{
int indexOfDocumentPane = parentDocumentPaneGroup.Children.Where( ch => ch.IsVisible ).ToList().IndexOf( layoutDocumentPane );
bool isFirstChild = indexOfDocumentPane == 0;
bool isLastChild = indexOfDocumentPane == parentDocumentPaneGroup.ChildrenCount - 1;
var manager = parentDocumentPaneGroup.Root.Manager;
if( !manager.AllowMixedOrientation )
{
_documentPaneDropTargetBottomAsAnchorablePane.Visibility =
parentDocumentPaneGroup.Orientation == Orientation.Vertical ?
( isLastChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden ) :
System.Windows.Visibility.Hidden;
_documentPaneDropTargetTopAsAnchorablePane.Visibility =
parentDocumentPaneGroup.Orientation == Orientation.Vertical ?
( isFirstChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden ) :
System.Windows.Visibility.Hidden;
_documentPaneDropTargetLeftAsAnchorablePane.Visibility =
parentDocumentPaneGroup.Orientation == Orientation.Horizontal ?
( isFirstChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden ) :
System.Windows.Visibility.Hidden;
_documentPaneDropTargetRightAsAnchorablePane.Visibility =
parentDocumentPaneGroup.Orientation == Orientation.Horizontal ?
( isLastChild ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden ) :
System.Windows.Visibility.Hidden;
}
else
{
_documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
_documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
_documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
_documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
}
}
else
{
_documentPaneDropTargetBottomAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
_documentPaneDropTargetLeftAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
_documentPaneDropTargetRightAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
_documentPaneDropTargetTopAsAnchorablePane.Visibility = System.Windows.Visibility.Visible;
}
}
else
{
areaElement = _gridDocumentPaneDropTargets;
var dropAreaDocumentPaneGroup = area as DropArea<LayoutDocumentPaneControl>;
var layoutDocumentPane = dropAreaDocumentPaneGroup.AreaElement.Model as LayoutDocumentPane;
var parentDocumentPaneGroup = layoutDocumentPane.Parent as LayoutDocumentPaneGroup;
SetDropTargetIntoVisibility( layoutDocumentPane );
if( parentDocumentPaneGroup != null &&
parentDocumentPaneGroup.Children.Where( c => c.IsVisible ).Count() > 1 )
{
var manager = parentDocumentPaneGroup.Root.Manager;
if( !manager.AllowMixedOrientation )
{
_documentPaneDropTargetLeft.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden;
_documentPaneDropTargetRight.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Hidden;
_documentPaneDropTargetTop.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden;
_documentPaneDropTargetBottom.Visibility = parentDocumentPaneGroup.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Hidden;
}
else
{
_documentPaneDropTargetLeft.Visibility = Visibility.Visible;
_documentPaneDropTargetRight.Visibility = Visibility.Visible;
_documentPaneDropTargetTop.Visibility = Visibility.Visible;
_documentPaneDropTargetBottom.Visibility = Visibility.Visible;
}
}
else if( parentDocumentPaneGroup == null &&
layoutDocumentPane != null &&
layoutDocumentPane.ChildrenCount == 0 )
{
_documentPaneDropTargetLeft.Visibility = Visibility.Hidden;
_documentPaneDropTargetRight.Visibility = Visibility.Hidden;
_documentPaneDropTargetTop.Visibility = Visibility.Hidden;
_documentPaneDropTargetBottom.Visibility = Visibility.Hidden;
}
else
{
_documentPaneDropTargetLeft.Visibility = Visibility.Visible;
_documentPaneDropTargetRight.Visibility = Visibility.Visible;
_documentPaneDropTargetTop.Visibility = Visibility.Visible;
_documentPaneDropTargetBottom.Visibility = Visibility.Visible;
}
}
}
break;
}
Canvas.SetLeft( areaElement, area.DetectionRect.Left - Left );
Canvas.SetTop( areaElement, area.DetectionRect.Top - Top );
areaElement.Width = area.DetectionRect.Width;
areaElement.Height = area.DetectionRect.Height;
areaElement.Visibility = System.Windows.Visibility.Visible;
}
void IOverlayWindow.DragLeave( IDropArea area )
{
_visibleAreas.Remove( area );
FrameworkElement areaElement;
switch( area.Type )
{
case DropAreaType.DockingManager:
areaElement = _gridDockingManagerDropTargets;
break;
case DropAreaType.AnchorablePane:
areaElement = _gridAnchorablePaneDropTargets;
break;
case DropAreaType.DocumentPaneGroup:
areaElement = _gridDocumentPaneDropTargets;
break;
case DropAreaType.DocumentPane:
default:
{
bool isDraggingAnchorables = _floatingWindow.Model is LayoutAnchorableFloatingWindow;
if( isDraggingAnchorables && _gridDocumentPaneFullDropTargets != null )
areaElement = _gridDocumentPaneFullDropTargets;
else
areaElement = _gridDocumentPaneDropTargets;
}
break;
}
areaElement.Visibility = System.Windows.Visibility.Hidden;
}
void IOverlayWindow.DragEnter( IDropTarget target )
{
var previewBoxPath = target.GetPreviewPath( this, _floatingWindow.Model as LayoutFloatingWindow );
if( previewBoxPath != null )
{
_previewBox.Data = previewBoxPath;
_previewBox.Visibility = System.Windows.Visibility.Visible;
}
}
void IOverlayWindow.DragLeave( IDropTarget target )
{
_previewBox.Visibility = System.Windows.Visibility.Hidden;
}
void IOverlayWindow.DragDrop( IDropTarget target )
{
target.Drop( _floatingWindow.Model as LayoutFloatingWindow );
}
#endregion
}
}

64
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindowDropTarget.cs

@ -1,64 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Controls
{
public class OverlayWindowDropTarget : IOverlayWindowDropTarget
{
#region Members
private IOverlayWindowArea _overlayArea;
private Rect _screenDetectionArea;
private OverlayWindowDropTargetType _type;
#endregion
#region Constructors
internal OverlayWindowDropTarget( IOverlayWindowArea overlayArea, OverlayWindowDropTargetType targetType, FrameworkElement element )
{
_overlayArea = overlayArea;
_type = targetType;
_screenDetectionArea = new Rect( element.TransformToDeviceDPI( new Point() ), element.TransformActualSizeToAncestor() );
}
#endregion
#region IOverlayWindowDropTarget
Rect IOverlayWindowDropTarget.ScreenDetectionArea
{
get
{
return _screenDetectionArea;
}
}
OverlayWindowDropTargetType IOverlayWindowDropTarget.Type
{
get
{
return _type;
}
}
#endregion
}
}

39
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindowDropTargetType.cs

@ -1,39 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
namespace Xceed.Wpf.AvalonDock.Controls
{
public enum OverlayWindowDropTargetType
{
DockingManagerDockLeft,
DockingManagerDockTop,
DockingManagerDockRight,
DockingManagerDockBottom,
DocumentPaneDockLeft,
DocumentPaneDockTop,
DocumentPaneDockRight,
DocumentPaneDockBottom,
DocumentPaneDockInside,
AnchorablePaneDockLeft,
AnchorablePaneDockTop,
AnchorablePaneDockRight,
AnchorablePaneDockBottom,
AnchorablePaneDockInside,
}
}

71
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/ReentrantFlag.cs

@ -1,71 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class ReentrantFlag
{
#region Members
private bool _flag = false;
#endregion
#region Properties
public bool CanEnter
{
get
{
return !_flag;
}
}
#endregion
#region Public Methods
public _ReentrantFlagHandler Enter()
{
if( _flag )
throw new InvalidOperationException();
return new _ReentrantFlagHandler( this );
}
#endregion
#region Internal Classes
public class _ReentrantFlagHandler : IDisposable
{
private ReentrantFlag _owner;
public _ReentrantFlagHandler( ReentrantFlag owner )
{
_owner = owner;
_owner._flag = true;
}
public void Dispose()
{
_owner._flag = false;
}
}
#endregion
}
}

111
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/ComGuids.cs

@ -1,111 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Standard
{
internal static partial class IID
{
/// <summary>IID_IEnumIDList</summary>
public const string EnumIdList = "000214F2-0000-0000-C000-000000000046";
/// <summary>IID_IEnumObjects</summary>
public const string EnumObjects = "2c1c7e2e-2d0e-4059-831e-1e6f82335c2e";
/// <summary>IID_IHTMLDocument2</summary>
public const string HtmlDocument2 = "332C4425-26CB-11D0-B483-00C04FD90119";
/// <summary>IID_IModalWindow</summary>
public const string ModalWindow = "b4db1657-70d7-485e-8e3e-6fcb5a5c1802";
/// <summary>IID_IObjectArray</summary>
public const string ObjectArray = "92CA9DCD-5622-4bba-A805-5E9F541BD8C9";
/// <summary>IID_IObjectCollection</summary>
public const string ObjectCollection = "5632b1a4-e38a-400a-928a-d4cd63230295";
/// <summary>IID_IPropertyNotifySink</summary>
public const string PropertyNotifySink = "9BFBBC02-EFF1-101A-84ED-00AA00341D07";
/// <summary>IID_IPropertyStore</summary>
public const string PropertyStore = "886d8eeb-8cf2-4446-8d02-cdba1dbdcf99";
/// <summary>IID_IServiceProvider</summary>
public const string ServiceProvider = "6d5140c1-7436-11ce-8034-00aa006009fa";
/// <summary>IID_IShellFolder</summary>
public const string ShellFolder = "000214E6-0000-0000-C000-000000000046";
/// <summary>IID_IShellLink</summary>
public const string ShellLink = "000214F9-0000-0000-C000-000000000046";
/// <summary>IID_IShellItem</summary>
public const string ShellItem = "43826d1e-e718-42ee-bc55-a1e261c37bfe";
/// <summary>IID_IShellItem2</summary>
public const string ShellItem2 = "7e9fb0d3-919f-4307-ab2e-9b1860310c93";
/// <summary>IID_IShellItemArray</summary>
public const string ShellItemArray = "B63EA76D-1F85-456F-A19C-48159EFA858B";
/// <summary>IID_ITaskbarList</summary>
public const string TaskbarList = "56FDF342-FD6D-11d0-958A-006097C9A090";
/// <summary>IID_ITaskbarList2</summary>
public const string TaskbarList2 = "602D4995-B13A-429b-A66E-1935E44F4317";
/// <summary>IID_IUnknown</summary>
public const string Unknown = "00000000-0000-0000-C000-000000000046";
#region Win7 IIDs
/// <summary>IID_IApplicationDestinations</summary>
public const string ApplicationDestinations = "12337d35-94c6-48a0-bce7-6a9c69d4d600";
/// <summary>IID_IApplicationDocumentLists</summary>
public const string ApplicationDocumentLists = "3c594f9f-9f30-47a1-979a-c9e83d3d0a06";
/// <summary>IID_ICustomDestinationList</summary>
public const string CustomDestinationList = "6332debf-87b5-4670-90c0-5e57b408a49e";
/// <summary>IID_IObjectWithAppUserModelID</summary>
public const string ObjectWithAppUserModelId = "36db0196-9665-46d1-9ba7-d3709eecf9ed";
/// <summary>IID_IObjectWithProgID</summary>
public const string ObjectWithProgId = "71e806fb-8dee-46fc-bf8c-7748a8a1ae13";
/// <summary>IID_ITaskbarList3</summary>
public const string TaskbarList3 = "ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf";
/// <summary>IID_ITaskbarList4</summary>
public const string TaskbarList4 = "c43dc798-95d1-4bea-9030-bb99e2983a1a";
#endregion
}
internal static partial class CLSID
{
public static T CoCreateInstance<T>( string clsid )
{
return ( T )System.Activator.CreateInstance( System.Type.GetTypeFromCLSID( new System.Guid( clsid ) ) );
}
/// <summary>CLSID_TaskbarList</summary>
/// <remarks>IID_ITaskbarList</remarks>
public const string TaskbarList = "56FDF344-FD6D-11d0-958A-006097C9A090";
/// <summary>CLSID_EnumerableObjectCollection</summary>
/// <remarks>IID_IEnumObjects.</remarks>
public const string EnumerableObjectCollection = "2d3468c1-36a7-43b6-ac24-d3f02fd9607a";
/// <summary>CLSID_ShellLink</summary>
/// <remarks>IID_IShellLink</remarks>
public const string ShellLink = "00021401-0000-0000-C000-000000000046";
#region Win7 CLSIDs
/// <summary>CLSID_DestinationList</summary>
/// <remarks>IID_ICustomDestinationList</remarks>
public const string DestinationList = "77f10cf0-3db5-4966-b520-b7c54fd35ed6";
/// <summary>CLSID_ApplicationDestinations</summary>
/// <remarks>IID_IApplicationDestinations</remarks>
public const string ApplicationDestinations = "86c14003-4d6b-4ef3-a7b4-0506663b2e68";
/// <summary>CLSID_ApplicationDocumentLists</summary>
/// <remarks>IID_IApplicationDocumentLists</remarks>
public const string ApplicationDocumentLists = "86bec222-30f2-47e0-9f25-60d11cd75c28";
#endregion
}
}

389
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/Debug.cs

@ -1,389 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
// Conditional to use more aggressive fail-fast behaviors when debugging.
#define DEV_DEBUG
// This file contains general utilities to aid in development.
// It is distinct from unit test Assert classes.
// Classes here generally shouldn't be exposed publicly since
// they're not particular to any library functionality.
// Because the classes here are internal, it's likely this file
// might be included in multiple assemblies.
namespace Standard
{
using System;
using System.Diagnostics;
using System.Threading;
/// <summary>A static class for verifying assumptions.</summary>
internal static class Assert
{
private static void _Break()
{
#if DEV_DEBUG
Debugger.Break();
#else
Debug.Assert(false);
#endif
}
/// <summary>A function signature for Assert.Evaluate.</summary>
public delegate void EvaluateFunction();
/// <summary>A function signature for Assert.Implies.</summary>
/// <returns>Returns the truth of a predicate.</returns>
public delegate bool ImplicationFunction();
/// <summary>
/// Executes the specified argument.
/// </summary>
/// <param name="argument">The function to execute.</param>
[Conditional( "DEBUG" )]
public static void Evaluate( EvaluateFunction argument )
{
IsNotNull( argument );
argument();
}
/// <summary>Obsolete: Use Standard.Assert.AreEqual instead of Assert.Equals</summary>
/// <typeparam name="T">The generic type to compare for equality.</typeparam>
/// <param name="expected">The first generic type data to compare. This is is the expected value.</param>
/// <param name="actual">The second generic type data to compare. This is the actual value.</param>
[
Obsolete( "Use Assert.AreEqual instead of Assert.Equals", false ),
Conditional( "DEBUG" )
]
public static void Equals<T>( T expected, T actual )
{
AreEqual( expected, actual );
}
/// <summary>
/// Verifies that two generic type data are equal. The assertion fails if they are not.
/// </summary>
/// <typeparam name="T">The generic type to compare for equality.</typeparam>
/// <param name="expected">The first generic type data to compare. This is is the expected value.</param>
/// <param name="actual">The second generic type data to compare. This is the actual value.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void AreEqual<T>( T expected, T actual )
{
if( null == expected )
{
// Two nulls are considered equal, regardless of type semantics.
if( null != actual && !actual.Equals( expected ) )
{
_Break();
}
}
else if( !expected.Equals( actual ) )
{
_Break();
}
}
/// <summary>
/// Verifies that two generic type data are not equal. The assertion fails if they are.
/// </summary>
/// <typeparam name="T">The generic type to compare for inequality.</typeparam>
/// <param name="notExpected">The first generic type data to compare. This is is the value that's not expected.</param>
/// <param name="actual">The second generic type data to compare. This is the actual value.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void AreNotEqual<T>( T notExpected, T actual )
{
if( null == notExpected )
{
// Two nulls are considered equal, regardless of type semantics.
if( null == actual || actual.Equals( notExpected ) )
{
_Break();
}
}
else if( notExpected.Equals( actual ) )
{
_Break();
}
}
/// <summary>
/// Verifies that if the specified condition is true, then so is the result.
/// The assertion fails if the condition is true but the result is false.
/// </summary>
/// <param name="condition">if set to <c>true</c> [condition].</param>
/// <param name="result">
/// A second Boolean statement. If the first was true then so must this be.
/// If the first statement was false then the value of this is ignored.
/// </param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void Implies( bool condition, bool result )
{
if( condition && !result )
{
_Break();
}
}
/// <summary>
/// Lazy evaluation overload. Verifies that if a condition is true, then so is a secondary value.
/// </summary>
/// <param name="condition">The conditional value.</param>
/// <param name="result">A function to be evaluated for truth if the condition argument is true.</param>
/// <remarks>
/// This overload only evaluates the result if the first condition is true.
/// </remarks>
[Conditional( "DEBUG" )]
public static void Implies( bool condition, ImplicationFunction result )
{
if( condition && !result() )
{
_Break();
}
}
/// <summary>
/// Verifies that a string has content. I.e. it is not null and it is not empty.
/// </summary>
/// <param name="value">The string to verify.</param>
[Conditional( "DEBUG" )]
public static void IsNeitherNullNorEmpty( string value )
{
IsFalse( string.IsNullOrEmpty( value ) );
}
/// <summary>
/// Verifies that a string has content. I.e. it is not null and it is not purely whitespace.
/// </summary>
/// <param name="value">The string to verify.</param>
[Conditional( "DEBUG" )]
public static void IsNeitherNullNorWhitespace( string value )
{
if( string.IsNullOrEmpty( value ) )
{
_Break();
}
if( value.Trim().Length == 0 )
{
_Break();
}
}
/// <summary>
/// Verifies the specified value is not null. The assertion fails if it is.
/// </summary>
/// <typeparam name="T">The generic reference type.</typeparam>
/// <param name="value">The value to check for nullness.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void IsNotNull<T>( T value ) where T : class
{
if( null == value )
{
_Break();
}
}
[Conditional( "DEBUG" )]
public static void IsDefault<T>( T value ) where T : struct
{
if( !value.Equals( default( T ) ) )
{
Assert.Fail();
}
}
[Conditional( "DEBUG" )]
public static void IsNotDefault<T>( T value ) where T : struct
{
if( value.Equals( default( T ) ) )
{
Assert.Fail();
}
}
/// <summary>
/// Verifies that the specified condition is false. The assertion fails if it is true.
/// </summary>
/// <param name="condition">The expression that should be <c>false</c>.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void IsFalse( bool condition )
{
if( condition )
{
_Break();
}
}
/// <summary>
/// Verifies that the specified condition is false. The assertion fails if it is true.
/// </summary>
/// <param name="condition">The expression that should be <c>false</c>.</param>
/// <param name="message">The message to display if the condition is <c>true</c>.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void IsFalse( bool condition, string message )
{
if( condition )
{
_Break();
}
}
/// <summary>
/// Verifies that the specified condition is true. The assertion fails if it is not.
/// </summary>
/// <param name="condition">A condition that is expected to be <c>true</c>.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void IsTrue( bool condition )
{
if( !condition )
{
_Break();
}
}
/// <summary>
/// Verifies that the specified condition is true. The assertion fails if it is not.
/// </summary>
/// <param name="condition">A condition that is expected to be <c>true</c>.</param>
/// <param name="message">The message to write in case the condition is <c>false</c>.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void IsTrue( bool condition, string message )
{
if( !condition )
{
_Break();
}
}
/// <summary>
/// This line should never be executed. The assertion always fails.
/// </summary>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void Fail()
{
_Break();
}
/// <summary>
/// This line should never be executed. The assertion always fails.
/// </summary>
/// <param name="message">The message to display if this function is executed.</param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void Fail( string message )
{
_Break();
}
/// <summary>
/// Verifies that the specified object is null. The assertion fails if it is not.
/// </summary>
/// <param name="item">The item to verify is null.</param>
[Conditional( "DEBUG" )]
public static void IsNull<T>( T item ) where T : class
{
if( null != item )
{
_Break();
}
}
/// <summary>
/// Verifies that the specified value is within the expected range. The assertion fails if it isn't.
/// </summary>
/// <param name="lowerBoundInclusive">The lower bound inclusive value.</param>
/// <param name="value">The value to verify.</param>
/// <param name="upperBoundInclusive">The upper bound inclusive value.</param>
[Conditional( "DEBUG" )]
public static void BoundedDoubleInc( double lowerBoundInclusive, double value, double upperBoundInclusive )
{
if( value < lowerBoundInclusive || value > upperBoundInclusive )
{
_Break();
}
}
/// <summary>
/// Verifies that the specified value is within the expected range. The assertion fails if it isn't.
/// </summary>
/// <param name="lowerBoundInclusive">The lower bound inclusive value.</param>
/// <param name="value">The value to verify.</param>
/// <param name="upperBoundExclusive">The upper bound exclusive value.</param>
[Conditional( "DEBUG" )]
public static void BoundedInteger( int lowerBoundInclusive, int value, int upperBoundExclusive )
{
if( value < lowerBoundInclusive || value >= upperBoundExclusive )
{
_Break();
}
}
/// <summary>
/// Verify the current thread's apartment state is what's expected. The assertion fails if it isn't
/// </summary>
/// <param name="expectedState">
/// The expected apartment state for the current thread.
/// </param>
/// <remarks>This breaks into the debugger in the case of a failed assertion.</remarks>
[Conditional( "DEBUG" )]
public static void IsApartmentState( ApartmentState expectedState )
{
if( Thread.CurrentThread.GetApartmentState() != expectedState )
{
_Break();
}
}
[Conditional( "DEBUG" )]
public static void NullableIsNotNull<T>( T? value ) where T : struct
{
if( null == value )
{
_Break();
}
}
[Conditional( "DEBUG" )]
public static void NullableIsNull<T>( T? value ) where T : struct
{
if( null != value )
{
_Break();
}
}
[Conditional( "DEBUG" )]
public static void IsNotOnMainThread()
{
if( System.Windows.Application.Current.Dispatcher.CheckAccess() )
{
_Break();
}
}
}
}

148
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/DoubleUtil.cs

@ -1,148 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
namespace Standard
{
using System;
using System.Diagnostics.CodeAnalysis;
/// <summary>
/// DoubleUtil uses fixed eps to provide fuzzy comparison functionality for doubles.
/// Note that FP noise is a big problem and using any of these compare
/// methods is not a complete solution, but rather the way to reduce
/// the probability of repeating unnecessary work.
/// </summary>
internal static class DoubleUtilities
{
/// <summary>
/// Epsilon - more or less random, more or less small number.
/// </summary>
private const double Epsilon = 0.00000153;
/// <summary>
/// AreClose returns whether or not two doubles are "close". That is, whether or
/// not they are within epsilon of each other.
/// There are plenty of ways for this to return false even for numbers which
/// are theoretically identical, so no code calling this should fail to work if this
/// returns false.
/// </summary>
/// <param name="value1">The first double to compare.</param>
/// <param name="value2">The second double to compare.</param>
/// <returns>The result of the AreClose comparision.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool AreClose( double value1, double value2 )
{
if( value1 == value2 )
{
return true;
}
double delta = value1 - value2;
return ( delta < Epsilon ) && ( delta > -Epsilon );
}
/// <summary>
/// LessThan returns whether or not the first double is less than the second double.
/// That is, whether or not the first is strictly less than *and* not within epsilon of
/// the other number.
/// There are plenty of ways for this to return false even for numbers which
/// are theoretically identical, so no code calling this should fail to work if this
/// returns false.
/// </summary>
/// <param name="value1">The first double to compare.</param>
/// <param name="value2">The second double to compare.</param>
/// <returns>The result of the LessThan comparision.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool LessThan( double value1, double value2 )
{
return ( value1 < value2 ) && !AreClose( value1, value2 );
}
/// <summary>
/// GreaterThan returns whether or not the first double is greater than the second double.
/// That is, whether or not the first is strictly greater than *and* not within epsilon of
/// the other number.
/// There are plenty of ways for this to return false even for numbers which
/// are theoretically identical, so no code calling this should fail to work if this
/// returns false.
/// </summary>
/// <param name="value1">The first double to compare.</param>
/// <param name="value2">The second double to compare.</param>
/// <returns>The result of the GreaterThan comparision.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool GreaterThan( double value1, double value2 )
{
return ( value1 > value2 ) && !AreClose( value1, value2 );
}
/// <summary>
/// LessThanOrClose returns whether or not the first double is less than or close to
/// the second double. That is, whether or not the first is strictly less than or within
/// epsilon of the other number.
/// There are plenty of ways for this to return false even for numbers which
/// are theoretically identical, so no code calling this should fail to work if this
/// returns false.
/// </summary>
/// <param name="value1">The first double to compare.</param>
/// <param name="value2">The second double to compare.</param>
/// <returns>The result of the LessThanOrClose comparision.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool LessThanOrClose( double value1, double value2 )
{
return ( value1 < value2 ) || AreClose( value1, value2 );
}
/// <summary>
/// GreaterThanOrClose returns whether or not the first double is greater than or close to
/// the second double. That is, whether or not the first is strictly greater than or within
/// epsilon of the other number.
/// There are plenty of ways for this to return false even for numbers which
/// are theoretically identical, so no code calling this should fail to work if this
/// returns false.
/// </summary>
/// <param name="value1">The first double to compare.</param>
/// <param name="value2">The second double to compare.</param>
/// <returns>The result of the GreaterThanOrClose comparision.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool GreaterThanOrClose( double value1, double value2 )
{
return ( value1 > value2 ) || AreClose( value1, value2 );
}
/// <summary>
/// Test to see if a double is a finite number (is not NaN or Infinity).
/// </summary>
/// <param name='value'>The value to test.</param>
/// <returns>Whether or not the value is a finite number.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool IsFinite( double value )
{
return !double.IsNaN( value ) && !double.IsInfinity( value );
}
/// <summary>
/// Test to see if a double a valid size value (is finite and > 0).
/// </summary>
/// <param name='value'>The value to test.</param>
/// <returns>Whether or not the value is a valid size value.</returns>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static bool IsValidSize( double value )
{
return IsFinite( value ) && GreaterThanOrClose( value, 0 );
}
}
}

101
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/DpiHelper.cs

@ -1,101 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Standard
{
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Media;
internal static class DpiHelper
{
private static Matrix _transformToDevice;
private static Matrix _transformToDip;
[SuppressMessage( "Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline" )]
static DpiHelper()
{
using( SafeDC desktop = SafeDC.GetDesktop() )
{
// Can get these in the static constructor. They shouldn't vary window to window,
// and changing the system DPI requires a restart.
int pixelsPerInchX = NativeMethods.GetDeviceCaps( desktop, DeviceCap.LOGPIXELSX );
int pixelsPerInchY = NativeMethods.GetDeviceCaps( desktop, DeviceCap.LOGPIXELSY );
_transformToDip = Matrix.Identity;
_transformToDip.Scale( 96d / ( double )pixelsPerInchX, 96d / ( double )pixelsPerInchY );
_transformToDevice = Matrix.Identity;
_transformToDevice.Scale( ( double )pixelsPerInchX / 96d, ( double )pixelsPerInchY / 96d );
}
}
/// <summary>
/// Convert a point in device independent pixels (1/96") to a point in the system coordinates.
/// </summary>
/// <param name="logicalPoint">A point in the logical coordinate system.</param>
/// <returns>Returns the parameter converted to the system's coordinates.</returns>
public static Point LogicalPixelsToDevice( Point logicalPoint )
{
return _transformToDevice.Transform( logicalPoint );
}
/// <summary>
/// Convert a point in system coordinates to a point in device independent pixels (1/96").
/// </summary>
/// <param name="logicalPoint">A point in the physical coordinate system.</param>
/// <returns>Returns the parameter converted to the device independent coordinate system.</returns>
public static Point DevicePixelsToLogical( Point devicePoint )
{
return _transformToDip.Transform( devicePoint );
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static Rect LogicalRectToDevice( Rect logicalRectangle )
{
Point topLeft = LogicalPixelsToDevice( new Point( logicalRectangle.Left, logicalRectangle.Top ) );
Point bottomRight = LogicalPixelsToDevice( new Point( logicalRectangle.Right, logicalRectangle.Bottom ) );
return new Rect( topLeft, bottomRight );
}
public static Rect DeviceRectToLogical( Rect deviceRectangle )
{
Point topLeft = DevicePixelsToLogical( new Point( deviceRectangle.Left, deviceRectangle.Top ) );
Point bottomRight = DevicePixelsToLogical( new Point( deviceRectangle.Right, deviceRectangle.Bottom ) );
return new Rect( topLeft, bottomRight );
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
public static Size LogicalSizeToDevice( Size logicalSize )
{
Point pt = LogicalPixelsToDevice( new Point( logicalSize.Width, logicalSize.Height ) );
return new Size { Width = pt.X, Height = pt.Y };
}
public static Size DeviceSizeToLogical( Size deviceSize )
{
Point pt = DevicePixelsToLogical( new Point( deviceSize.Width, deviceSize.Height ) );
return new Size( pt.X, pt.Y );
}
}
}

530
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/ErrorCodes.cs

@ -1,530 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Standard
{
using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
/// <summary>
/// Wrapper for common Win32 status codes.
/// </summary>
[StructLayout( LayoutKind.Explicit )]
internal struct Win32Error
{
[FieldOffset( 0 )]
private readonly int _value;
// NOTE: These public static field declarations are automatically
// picked up by (HRESULT's) ToString through reflection.
/// <summary>The operation completed successfully.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_SUCCESS = new Win32Error( 0 );
/// <summary>Incorrect function.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_INVALID_FUNCTION = new Win32Error( 1 );
/// <summary>The system cannot find the file specified.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_FILE_NOT_FOUND = new Win32Error( 2 );
/// <summary>The system cannot find the path specified.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_PATH_NOT_FOUND = new Win32Error( 3 );
/// <summary>The system cannot open the file.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_TOO_MANY_OPEN_FILES = new Win32Error( 4 );
/// <summary>Access is denied.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_ACCESS_DENIED = new Win32Error( 5 );
/// <summary>The handle is invalid.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_INVALID_HANDLE = new Win32Error( 6 );
/// <summary>Not enough storage is available to complete this operation.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_OUTOFMEMORY = new Win32Error( 14 );
/// <summary>There are no more files.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_NO_MORE_FILES = new Win32Error( 18 );
/// <summary>The process cannot access the file because it is being used by another process.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_SHARING_VIOLATION = new Win32Error( 32 );
/// <summary>The parameter is incorrect.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_INVALID_PARAMETER = new Win32Error( 87 );
/// <summary>The data area passed to a system call is too small.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_INSUFFICIENT_BUFFER = new Win32Error( 122 );
/// <summary>Cannot nest calls to LoadModule.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_NESTING_NOT_ALLOWED = new Win32Error( 215 );
/// <summary>Illegal operation attempted on a registry key that has been marked for deletion.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_KEY_DELETED = new Win32Error( 1018 );
/// <summary>Element not found.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_NOT_FOUND = new Win32Error( 1168 );
/// <summary>There was no match for the specified key in the index.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_NO_MATCH = new Win32Error( 1169 );
/// <summary>An invalid device was specified.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_BAD_DEVICE = new Win32Error( 1200 );
/// <summary>The operation was canceled by the user.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_CANCELLED = new Win32Error( 1223 );
/// <summary>The window class was already registered.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_CLASS_ALREADY_EXISTS = new Win32Error( 1410 );
/// <summary>The specified datatype is invalid.</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly Win32Error ERROR_INVALID_DATATYPE = new Win32Error( 1804 );
/// <summary>
/// Create a new Win32 error.
/// </summary>
/// <param name="i">The integer value of the error.</param>
public Win32Error( int i )
{
_value = i;
}
/// <summary>Performs HRESULT_FROM_WIN32 conversion.</summary>
/// <param name="error">The Win32 error being converted to an HRESULT.</param>
/// <returns>The equivilent HRESULT value.</returns>
public static explicit operator HRESULT( Win32Error error )
{
// #define __HRESULT_FROM_WIN32(x)
// ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)))
if( error._value <= 0 )
{
return new HRESULT( ( uint )error._value );
}
return HRESULT.Make( true, Facility.Win32, error._value & 0x0000FFFF );
}
// Method version of the cast operation
/// <summary>Performs HRESULT_FROM_WIN32 conversion.</summary>
/// <param name="error">The Win32 error being converted to an HRESULT.</param>
/// <returns>The equivilent HRESULT value.</returns>
public HRESULT ToHRESULT()
{
return ( HRESULT )this;
}
/// <summary>Performs the equivalent of Win32's GetLastError()</summary>
/// <returns>A Win32Error instance with the result of the native GetLastError</returns>
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
public static Win32Error GetLastError()
{
return new Win32Error( Marshal.GetLastWin32Error() );
}
public override bool Equals( object obj )
{
try
{
return ( ( Win32Error )obj )._value == _value;
}
catch( InvalidCastException )
{
return false;
}
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
/// <summary>
/// Compare two Win32 error codes for equality.
/// </summary>
/// <param name="errLeft">The first error code to compare.</param>
/// <param name="errRight">The second error code to compare.</param>
/// <returns>Whether the two error codes are the same.</returns>
public static bool operator ==( Win32Error errLeft, Win32Error errRight )
{
return errLeft._value == errRight._value;
}
/// <summary>
/// Compare two Win32 error codes for inequality.
/// </summary>
/// <param name="errLeft">The first error code to compare.</param>
/// <param name="errRight">The second error code to compare.</param>
/// <returns>Whether the two error codes are not the same.</returns>
public static bool operator !=( Win32Error errLeft, Win32Error errRight )
{
return !( errLeft == errRight );
}
}
internal enum Facility
{
/// <summary>FACILITY_NULL</summary>
Null = 0,
/// <summary>FACILITY_RPC</summary>
Rpc = 1,
/// <summary>FACILITY_DISPATCH</summary>
Dispatch = 2,
/// <summary>FACILITY_STORAGE</summary>
Storage = 3,
/// <summary>FACILITY_ITF</summary>
Itf = 4,
/// <summary>FACILITY_WIN32</summary>
Win32 = 7,
/// <summary>FACILITY_WINDOWS</summary>
Windows = 8,
/// <summary>FACILITY_CONTROL</summary>
Control = 10,
/// <summary>MSDN doced facility code for ESE errors.</summary>
Ese = 0xE5E,
/// <summary>FACILITY_WINCODEC (WIC)</summary>
WinCodec = 0x898,
}
/// <summary>Wrapper for HRESULT status codes.</summary>
[StructLayout( LayoutKind.Explicit )]
internal struct HRESULT
{
[FieldOffset( 0 )]
private readonly uint _value;
// NOTE: These public static field declarations are automatically
// picked up by ToString through reflection.
/// <summary>S_OK</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT S_OK = new HRESULT( 0x00000000 );
/// <summary>S_FALSE</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT S_FALSE = new HRESULT( 0x00000001 );
/// <summary>E_PENDING</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_PENDING = new HRESULT( 0x8000000A );
/// <summary>E_NOTIMPL</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_NOTIMPL = new HRESULT( 0x80004001 );
/// <summary>E_NOINTERFACE</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_NOINTERFACE = new HRESULT( 0x80004002 );
/// <summary>E_POINTER</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_POINTER = new HRESULT( 0x80004003 );
/// <summary>E_ABORT</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_ABORT = new HRESULT( 0x80004004 );
/// <summary>E_FAIL</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_FAIL = new HRESULT( 0x80004005 );
/// <summary>E_UNEXPECTED</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_UNEXPECTED = new HRESULT( 0x8000FFFF );
/// <summary>STG_E_INVALIDFUNCTION</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT STG_E_INVALIDFUNCTION = new HRESULT( 0x80030001 );
/// <summary>REGDB_E_CLASSNOTREG</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT REGDB_E_CLASSNOTREG = new HRESULT( 0x80040154 );
/// <summary>DESTS_E_NO_MATCHING_ASSOC_HANDLER. Win7 internal error code for Jump Lists.</summary>
/// <remarks>There is no Assoc Handler for the given item registered by the specified application.</remarks>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT DESTS_E_NO_MATCHING_ASSOC_HANDLER = new HRESULT( 0x80040F03 );
/// <summary>DESTS_E_NORECDOCS. Win7 internal error code for Jump Lists.</summary>
/// <remarks>The given item is excluded from the recent docs folder by the NoRecDocs bit on its registration.</remarks>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT DESTS_E_NORECDOCS = new HRESULT( 0x80040F04 );
/// <summary>DESTS_E_NOTALLCLEARED. Win7 internal error code for Jump Lists.</summary>
/// <remarks>Not all of the items were successfully cleared</remarks>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT DESTS_E_NOTALLCLEARED = new HRESULT( 0x80040F05 );
/// <summary>E_ACCESSDENIED</summary>
/// <remarks>Win32Error ERROR_ACCESS_DENIED.</remarks>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_ACCESSDENIED = new HRESULT( 0x80070005 );
/// <summary>E_OUTOFMEMORY</summary>
/// <remarks>Win32Error ERROR_OUTOFMEMORY.</remarks>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_OUTOFMEMORY = new HRESULT( 0x8007000E );
/// <summary>E_INVALIDARG</summary>
/// <remarks>Win32Error ERROR_INVALID_PARAMETER.</remarks>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT E_INVALIDARG = new HRESULT( 0x80070057 );
/// <summary>INTSAFE_E_ARITHMETIC_OVERFLOW</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT INTSAFE_E_ARITHMETIC_OVERFLOW = new HRESULT( 0x80070216 );
/// <summary>COR_E_OBJECTDISPOSED</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT COR_E_OBJECTDISPOSED = new HRESULT( 0x80131622 );
/// <summary>WC_E_GREATERTHAN</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT WC_E_GREATERTHAN = new HRESULT( 0xC00CEE23 );
/// <summary>WC_E_SYNTAX</summary>
[SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public static readonly HRESULT WC_E_SYNTAX = new HRESULT( 0xC00CEE2D );
/// <summary>
/// Create an HRESULT from an integer value.
/// </summary>
/// <param name="i"></param>
public HRESULT( uint i )
{
_value = i;
}
public static HRESULT Make( bool severe, Facility facility, int code )
{
// #define MAKE_HRESULT(sev,fac,code) \
// ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
// Severity has 1 bit reserved.
// bitness is enforced by the boolean parameter.
// Facility has 11 bits reserved (different than SCODES, which have 4 bits reserved)
// MSDN documentation incorrectly uses 12 bits for the ESE facility (e5e), so go ahead and let that one slide.
// And WIC also ignores it the documented size...
Assert.Implies( ( int )facility != ( int )( ( int )facility & 0x1FF ), facility == Facility.Ese || facility == Facility.WinCodec );
// Code has 4 bits reserved.
Assert.AreEqual( code, code & 0xFFFF );
return new HRESULT( ( uint )( ( severe ? ( 1 << 31 ) : 0 ) | ( ( int )facility << 16 ) | code ) );
}
/// <summary>
/// retrieve HRESULT_FACILITY
/// </summary>
public Facility Facility
{
get
{
return GetFacility( ( int )_value );
}
}
public static Facility GetFacility( int errorCode )
{
// #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
return ( Facility )( ( errorCode >> 16 ) & 0x1fff );
}
/// <summary>
/// retrieve HRESULT_CODE
/// </summary>
public int Code
{
get
{
return GetCode( ( int )_value );
}
}
public static int GetCode( int error )
{
// #define HRESULT_CODE(hr) ((hr) & 0xFFFF)
return ( int )( error & 0xFFFF );
}
#region Object class override members
/// <summary>
/// Get a string representation of this HRESULT.
/// </summary>
/// <returns></returns>
public override string ToString()
{
// Use reflection to try to name this HRESULT.
// This is expensive, but if someone's ever printing HRESULT strings then
// I think it's a fair guess that they're not in a performance critical area
// (e.g. printing exception strings).
// This is less error prone than trying to keep the list in the function.
// To properly add an HRESULT's name to the ToString table, just add the HRESULT
// like all the others above.
//
// CONSIDER: This data is static. It could be cached
// after first usage for fast lookup since the keys are unique.
//
foreach( FieldInfo publicStaticField in typeof( HRESULT ).GetFields( BindingFlags.Static | BindingFlags.Public ) )
{
if( publicStaticField.FieldType == typeof( HRESULT ) )
{
var hr = ( HRESULT )publicStaticField.GetValue( null );
if( hr == this )
{
return publicStaticField.Name;
}
}
}
// Try Win32 error codes also
if( Facility == Facility.Win32 )
{
foreach( FieldInfo publicStaticField in typeof( Win32Error ).GetFields( BindingFlags.Static | BindingFlags.Public ) )
{
if( publicStaticField.FieldType == typeof( Win32Error ) )
{
var error = ( Win32Error )publicStaticField.GetValue( null );
if( ( HRESULT )error == this )
{
return "HRESULT_FROM_WIN32(" + publicStaticField.Name + ")";
}
}
}
}
// If there's no good name for this HRESULT,
// return the string as readable hex (0x########) format.
return string.Format( CultureInfo.InvariantCulture, "0x{0:X8}", _value );
}
public override bool Equals( object obj )
{
try
{
return ( ( HRESULT )obj )._value == _value;
}
catch( InvalidCastException )
{
return false;
}
}
public override int GetHashCode()
{
return _value.GetHashCode();
}
#endregion
public static bool operator ==( HRESULT hrLeft, HRESULT hrRight )
{
return hrLeft._value == hrRight._value;
}
public static bool operator !=( HRESULT hrLeft, HRESULT hrRight )
{
return !( hrLeft == hrRight );
}
public bool Succeeded
{
get
{
return ( int )_value >= 0;
}
}
public bool Failed
{
get
{
return ( int )_value < 0;
}
}
public void ThrowIfFailed()
{
ThrowIfFailed( null );
}
[
SuppressMessage(
"Microsoft.Usage",
"CA2201:DoNotRaiseReservedExceptionTypes",
Justification = "Only recreating Exceptions that were already raised." ),
SuppressMessage(
"Microsoft.Security",
"CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )
]
public void ThrowIfFailed( string message )
{
if( Failed )
{
if( string.IsNullOrEmpty( message ) )
{
message = ToString();
}
#if DEBUG
else
{
message += " (" + ToString() + ")";
}
#endif
// Wow. Reflection in a throw call. Later on this may turn out to have been a bad idea.
// If you're throwing an exception I assume it's OK for me to take some time to give it back.
// I want to convert the HRESULT to a more appropriate exception type than COMException.
// Marshal.ThrowExceptionForHR does this for me, but the general call uses GetErrorInfo
// if it's set, and then ignores the HRESULT that I've provided. This makes it so this
// call works the first time but you get burned on the second. To avoid this, I use
// the overload that explicitly ignores the IErrorInfo.
// In addition, the function doesn't allow me to set the Message unless I go through
// the process of implementing an IErrorInfo and then use that. There's no stock
// implementations of IErrorInfo available and I don't think it's worth the maintenance
// overhead of doing it, nor would it have significant value over this approach.
Exception e = Marshal.GetExceptionForHR( ( int )_value, new IntPtr( -1 ) );
Assert.IsNotNull( e );
// ArgumentNullException doesn't have the right constructor parameters,
// (nor does Win32Exception...)
// but E_POINTER gets mapped to NullReferenceException,
// so I don't think it will ever matter.
Assert.IsFalse( e is ArgumentNullException );
// If we're not getting anything better than a COMException from Marshal,
// then at least check the facility and attempt to do better ourselves.
if( e.GetType() == typeof( COMException ) )
{
switch( Facility )
{
case Facility.Win32:
e = new Win32Exception( Code, message );
break;
default:
e = new COMException( message, ( int )_value );
break;
}
}
else
{
ConstructorInfo cons = e.GetType().GetConstructor( new[] { typeof( string ) } );
if( null != cons )
{
e = cons.Invoke( new object[] { message } ) as Exception;
Assert.IsNotNull( e );
}
}
throw e;
}
}
/// <summary>
/// Convert the result of Win32 GetLastError() into a raised exception.
/// </summary>
public static void ThrowLastError()
{
( ( HRESULT )Win32Error.GetLastError() ).ThrowIfFailed();
// Only expecting to call this when we're expecting a failed GetLastError()
Assert.Fail();
}
}
}

188
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/MessageWindow.cs

@ -1,188 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Standard
{
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Threading;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
internal sealed class MessageWindow : DispatcherObject, IDisposable
{
// Alias this to a static so the wrapper doesn't get GC'd
private static readonly WndProc s_WndProc = new WndProc( _WndProc );
private static readonly Dictionary<IntPtr, MessageWindow> s_windowLookup = new Dictionary<IntPtr, MessageWindow>();
private WndProc _wndProcCallback;
private string _className;
private bool _isDisposed;
public IntPtr Handle
{
get; private set;
}
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
public MessageWindow( CS classStyle, WS style, WS_EX exStyle, Rect location, string name, WndProc callback )
{
// A null callback means just use DefWindowProc.
_wndProcCallback = callback;
_className = "MessageWindowClass+" + Guid.NewGuid().ToString();
var wc = new WNDCLASSEX
{
cbSize = Marshal.SizeOf( typeof( WNDCLASSEX ) ),
style = classStyle,
lpfnWndProc = s_WndProc,
hInstance = NativeMethods.GetModuleHandle( null ),
hbrBackground = NativeMethods.GetStockObject( StockObject.NULL_BRUSH ),
lpszMenuName = "",
lpszClassName = _className,
};
NativeMethods.RegisterClassEx( ref wc );
GCHandle gcHandle = default( GCHandle );
try
{
gcHandle = GCHandle.Alloc( this );
IntPtr pinnedThisPtr = ( IntPtr )gcHandle;
Handle = NativeMethods.CreateWindowEx(
exStyle,
_className,
name,
style,
( int )location.X,
( int )location.Y,
( int )location.Width,
( int )location.Height,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
pinnedThisPtr );
}
finally
{
gcHandle.Free();
}
}
~MessageWindow()
{
_Dispose( false, false );
}
public void Dispose()
{
_Dispose( true, false );
GC.SuppressFinalize( this );
}
// This isn't right if the Dispatcher has already started shutting down.
// It will wind up leaking the class ATOM...
[SuppressMessage( "Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "disposing" )]
private void _Dispose( bool disposing, bool isHwndBeingDestroyed )
{
if( _isDisposed )
{
// Block against reentrancy.
return;
}
_isDisposed = true;
IntPtr hwnd = Handle;
string className = _className;
if( isHwndBeingDestroyed )
{
Dispatcher.BeginInvoke( DispatcherPriority.Normal, ( DispatcherOperationCallback )( arg => _DestroyWindow( IntPtr.Zero, className ) ) );
}
else if( Handle != IntPtr.Zero )
{
if( CheckAccess() )
{
_DestroyWindow( hwnd, className );
}
else
{
Dispatcher.BeginInvoke( DispatcherPriority.Normal, ( DispatcherOperationCallback )( arg => _DestroyWindow( hwnd, className ) ) );
}
}
s_windowLookup.Remove( hwnd );
_className = null;
Handle = IntPtr.Zero;
}
[SuppressMessage( "Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly" )]
private static IntPtr _WndProc( IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam )
{
IntPtr ret = IntPtr.Zero;
MessageWindow hwndWrapper = null;
if( msg == WM.CREATE )
{
var createStruct = ( CREATESTRUCT )Marshal.PtrToStructure( lParam, typeof( CREATESTRUCT ) );
GCHandle gcHandle = GCHandle.FromIntPtr( createStruct.lpCreateParams );
hwndWrapper = ( MessageWindow )gcHandle.Target;
s_windowLookup.Add( hwnd, hwndWrapper );
}
else
{
if( !s_windowLookup.TryGetValue( hwnd, out hwndWrapper ) )
{
return NativeMethods.DefWindowProc( hwnd, msg, wParam, lParam );
}
}
Assert.IsNotNull( hwndWrapper );
WndProc callback = hwndWrapper._wndProcCallback;
if( callback != null )
{
ret = callback( hwnd, msg, wParam, lParam );
}
else
{
ret = NativeMethods.DefWindowProc( hwnd, msg, wParam, lParam );
}
if( msg == WM.NCDESTROY )
{
hwndWrapper._Dispose( true, true );
GC.SuppressFinalize( hwndWrapper );
}
return ret;
}
private static object _DestroyWindow( IntPtr hwnd, string className )
{
Utility.SafeDestroyWindow( ref hwnd );
NativeMethods.UnregisterClass( className, NativeMethods.GetModuleHandle( null ) );
return null;
}
}
}

3545
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/NativeMethods.cs

File diff suppressed because it is too large

995
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/ShellProvider.cs

@ -1,995 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Standard
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
#region Enums and Static Property Classes
/// <summary>ShellItem attribute flags. SIATTRIBFLAGS_*</summary>
internal enum SIATTRIBFLAGS
{
AND = 0x00000001,
OR = 0x00000002,
APPCOMPAT = 0x00000003,
}
internal enum APPDOCLISTTYPE
{
ADLT_RECENT = 0, // The recently used documents list
ADLT_FREQUENT, // The frequently used documents list
}
/// <summary>
/// Flags for SetTabProperties. STPF_*
/// </summary>
/// <remarks>The native enum was called STPFLAG.</remarks>
[Flags]
internal enum STPF
{
NONE = 0x00000000,
USEAPPTHUMBNAILALWAYS = 0x00000001,
USEAPPTHUMBNAILWHENACTIVE = 0x00000002,
USEAPPPEEKALWAYS = 0x00000004,
USEAPPPEEKWHENACTIVE = 0x00000008,
}
/// <summary>
/// Flags for Setting Taskbar Progress state. TBPF_*
/// </summary>
/// <remarks>
/// The native enum was called TBPFLAG.
/// </remarks>
internal enum TBPF
{
NOPROGRESS = 0x00000000,
INDETERMINATE = 0x00000001,
NORMAL = 0x00000002,
ERROR = 0x00000004,
PAUSED = 0x00000008,
}
/// <summary>
/// THUMBBUTTON mask. THB_*
/// </summary>
[Flags]
internal enum THB : uint
{
BITMAP = 0x0001,
ICON = 0x0002,
TOOLTIP = 0x0004,
FLAGS = 0x0008,
}
/// <summary>
/// THUMBBUTTON flags. THBF_*
/// </summary>
[Flags]
internal enum THBF : uint
{
ENABLED = 0x0000,
DISABLED = 0x0001,
DISMISSONCLICK = 0x0002,
NOBACKGROUND = 0x0004,
HIDDEN = 0x0008,
// Added post-beta
NONINTERACTIVE = 0x0010,
}
/// <summary>
/// GetPropertyStoreFlags. GPS_*.
/// </summary>
/// <remarks>
/// These are new for Vista, but are used in downlevel components
/// </remarks>
internal enum GPS
{
// If no flags are specified (GPS_DEFAULT), a read-only property store is returned that includes properties for the file or item.
// In the case that the shell item is a file, the property store contains:
// 1. properties about the file from the file system
// 2. properties from the file itself provided by the file's property handler, unless that file is offline,
// see GPS_OPENSLOWITEM
// 3. if requested by the file's property handler and supported by the file system, properties stored in the
// alternate property store.
//
// Non-file shell items should return a similar read-only store
//
// Specifying other GPS_ flags modifies the store that is returned
DEFAULT = 0x00000000,
HANDLERPROPERTIESONLY = 0x00000001, // only include properties directly from the file's property handler
READWRITE = 0x00000002, // Writable stores will only include handler properties
TEMPORARY = 0x00000004, // A read/write store that only holds properties for the lifetime of the IShellItem object
FASTPROPERTIESONLY = 0x00000008, // do not include any properties from the file's property handler (because the file's property handler will hit the disk)
OPENSLOWITEM = 0x00000010, // include properties from a file's property handler, even if it means retrieving the file from offline storage.
DELAYCREATION = 0x00000020, // delay the creation of the file's property handler until those properties are read, written, or enumerated
BESTEFFORT = 0x00000040, // For readonly stores, succeed and return all available properties, even if one or more sources of properties fails. Not valid with GPS_READWRITE.
NO_OPLOCK = 0x00000080, // some data sources protect the read property store with an oplock, this disables that
MASK_VALID = 0x000000FF,
}
/// <summary>
/// KNOWNDESTCATEGORY. KDC_*
/// </summary>
internal enum KDC
{
FREQUENT = 1,
RECENT,
}
// IShellFolder::GetAttributesOf flags
[Flags]
internal enum SFGAO : uint
{
/// <summary>Objects can be copied</summary>
/// <remarks>DROPEFFECT_COPY</remarks>
CANCOPY = 0x1,
/// <summary>Objects can be moved</summary>
/// <remarks>DROPEFFECT_MOVE</remarks>
CANMOVE = 0x2,
/// <summary>Objects can be linked</summary>
/// <remarks>
/// DROPEFFECT_LINK.
///
/// If this bit is set on an item in the shell folder, a
/// 'Create Shortcut' menu item will be added to the File
/// menu and context menus for the item. If the user selects
/// that command, your IContextMenu::InvokeCommand() will be called
/// with 'link'.
/// That flag will also be used to determine if 'Create Shortcut'
/// should be added when the item in your folder is dragged to another
/// folder.
/// </remarks>
CANLINK = 0x4,
/// <summary>supports BindToObject(IID_IStorage)</summary>
STORAGE = 0x00000008,
/// <summary>Objects can be renamed</summary>
CANRENAME = 0x00000010,
/// <summary>Objects can be deleted</summary>
CANDELETE = 0x00000020,
/// <summary>Objects have property sheets</summary>
HASPROPSHEET = 0x00000040,
// unused = 0x00000080,
/// <summary>Objects are drop target</summary>
DROPTARGET = 0x00000100,
CAPABILITYMASK = 0x00000177,
// unused = 0x00000200,
// unused = 0x00000400,
// unused = 0x00000800,
// unused = 0x00001000,
/// <summary>Object is encrypted (use alt color)</summary>
ENCRYPTED = 0x00002000,
/// <summary>'Slow' object</summary>
ISSLOW = 0x00004000,
/// <summary>Ghosted icon</summary>
GHOSTED = 0x00008000,
/// <summary>Shortcut (link)</summary>
LINK = 0x00010000,
/// <summary>Shared</summary>
SHARE = 0x00020000,
/// <summary>Read-only</summary>
READONLY = 0x00040000,
/// <summary> Hidden object</summary>
HIDDEN = 0x00080000,
DISPLAYATTRMASK = 0x000FC000,
/// <summary> May contain children with SFGAO_FILESYSTEM</summary>
FILESYSANCESTOR = 0x10000000,
/// <summary>Support BindToObject(IID_IShellFolder)</summary>
FOLDER = 0x20000000,
/// <summary>Is a win32 file system object (file/folder/root)</summary>
FILESYSTEM = 0x40000000,
/// <summary>May contain children with SFGAO_FOLDER (may be slow)</summary>
HASSUBFOLDER = 0x80000000,
CONTENTSMASK = 0x80000000,
/// <summary>Invalidate cached information (may be slow)</summary>
VALIDATE = 0x01000000,
/// <summary>Is this removeable media?</summary>
REMOVABLE = 0x02000000,
/// <summary> Object is compressed (use alt color)</summary>
COMPRESSED = 0x04000000,
/// <summary>Supports IShellFolder, but only implements CreateViewObject() (non-folder view)</summary>
BROWSABLE = 0x08000000,
/// <summary>Is a non-enumerated object (should be hidden)</summary>
NONENUMERATED = 0x00100000,
/// <summary>Should show bold in explorer tree</summary>
NEWCONTENT = 0x00200000,
/// <summary>Obsolete</summary>
CANMONIKER = 0x00400000,
/// <summary>Obsolete</summary>
HASSTORAGE = 0x00400000,
/// <summary>Supports BindToObject(IID_IStream)</summary>
STREAM = 0x00400000,
/// <summary>May contain children with SFGAO_STORAGE or SFGAO_STREAM</summary>
STORAGEANCESTOR = 0x00800000,
/// <summary>For determining storage capabilities, ie for open/save semantics</summary>
STORAGECAPMASK = 0x70C50008,
/// <summary>
/// Attributes that are masked out for PKEY_SFGAOFlags because they are considered
/// to cause slow calculations or lack context
/// (SFGAO_VALIDATE | SFGAO_ISSLOW | SFGAO_HASSUBFOLDER and others)
/// </summary>
PKEYSFGAOMASK = 0x81044000,
}
/// <summary>
/// IShellFolder::EnumObjects grfFlags bits. Also called SHCONT
/// </summary>
internal enum SHCONTF
{
CHECKING_FOR_CHILDREN = 0x0010, // hint that client is checking if (what) child items the folder contains - not all details (e.g. short file name) are needed
FOLDERS = 0x0020, // only want folders enumerated (SFGAO_FOLDER)
NONFOLDERS = 0x0040, // include non folders (items without SFGAO_FOLDER)
INCLUDEHIDDEN = 0x0080, // show items normally hidden (items with SFGAO_HIDDEN)
INIT_ON_FIRST_NEXT = 0x0100, // DEFUNCT - this is always assumed
NETPRINTERSRCH = 0x0200, // hint that client is looking for printers
SHAREABLE = 0x0400, // hint that client is looking sharable resources (local drives or hidden root shares)
STORAGE = 0x0800, // include all items with accessible storage and their ancestors
NAVIGATION_ENUM = 0x1000, // mark child folders to indicate that they should provide a "navigation" enumeration by default
FASTITEMS = 0x2000, // hint that client is only interested in items that can be enumerated quickly
FLATLIST = 0x4000, // enumerate items as flat list even if folder is stacked
ENABLE_ASYNC = 0x8000, // inform enumerator that client is listening for change notifications so enumerator does not need to be complete, items can be reported via change notifications
}
/// <summary>
/// IShellFolder::GetDisplayNameOf/SetNameOf uFlags. Also called SHGDNF.
/// </summary>
/// <remarks>
/// For compatibility with SIGDN, these bits must all sit in the LOW word.
/// </remarks>
[Flags]
internal enum SHGDN
{
SHGDN_NORMAL = 0x0000, // default (display purpose)
SHGDN_INFOLDER = 0x0001, // displayed under a folder (relative)
SHGDN_FOREDITING = 0x1000, // for in-place editing
SHGDN_FORADDRESSBAR = 0x4000, // UI friendly parsing name (remove ugly stuff)
SHGDN_FORPARSING = 0x8000, // parsing name for ParseDisplayName()
}
/// <summary>
/// SHELLITEMCOMPAREHINTF. SICHINT_*.
/// </summary>
internal enum SICHINT : uint
{
/// <summary>iOrder based on display in a folder view</summary>
DISPLAY = 0x00000000,
/// <summary>exact instance compare</summary>
ALLFIELDS = 0x80000000,
/// <summary>iOrder based on canonical name (better performance)</summary>
CANONICAL = 0x10000000,
TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000,
};
/// <summary>
/// ShellItem enum. SIGDN_*.
/// </summary>
internal enum SIGDN : uint
{ // lower word (& with 0xFFFF)
NORMALDISPLAY = 0x00000000, // SHGDN_NORMAL
PARENTRELATIVEPARSING = 0x80018001, // SHGDN_INFOLDER | SHGDN_FORPARSING
DESKTOPABSOLUTEPARSING = 0x80028000, // SHGDN_FORPARSING
PARENTRELATIVEEDITING = 0x80031001, // SHGDN_INFOLDER | SHGDN_FOREDITING
DESKTOPABSOLUTEEDITING = 0x8004c000, // SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
FILESYSPATH = 0x80058000, // SHGDN_FORPARSING
URL = 0x80068000, // SHGDN_FORPARSING
PARENTRELATIVEFORADDRESSBAR = 0x8007c001, // SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
PARENTRELATIVE = 0x80080001, // SHGDN_INFOLDER
}
/// <summary>
/// STR_GPS_*
/// </summary>
/// <remarks>
/// When requesting a property store through IShellFolder, you can specify the equivalent of
/// GPS_DEFAULT by passing in a null IBindCtx parameter.
///
/// You can specify the equivalent of GPS_READWRITE by passing a mode of STGM_READWRITE | STGM_EXCLUSIVE
/// in the bind context
///
/// Here are the string versions of GPS_ flags, passed to IShellFolder::BindToObject() via IBindCtx::RegisterObjectParam()
/// These flags are valid when requesting an IPropertySetStorage or IPropertyStore handler
///
/// The meaning of these flags are described above.
///
/// There is no STR_ equivalent for GPS_TEMPORARY because temporary property stores
/// are provided by IShellItem2 only -- not by the underlying IShellFolder.
/// </remarks>
internal static class STR_GPS
{
public const string HANDLERPROPERTIESONLY = "GPS_HANDLERPROPERTIESONLY";
public const string FASTPROPERTIESONLY = "GPS_FASTPROPERTIESONLY";
public const string OPENSLOWITEM = "GPS_OPENSLOWITEM";
public const string DELAYCREATION = "GPS_DELAYCREATION";
public const string BESTEFFORT = "GPS_BESTEFFORT";
public const string NO_OPLOCK = "GPS_NO_OPLOCK";
}
#endregion
#region Structs
[StructLayout( LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode )]
internal struct THUMBBUTTON
{
/// <summary>
/// WPARAM value for a THUMBBUTTON being clicked.
/// </summary>
public const int THBN_CLICKED = 0x1800;
public THB dwMask;
public uint iId;
public uint iBitmap;
public IntPtr hIcon;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string szTip;
public THBF dwFlags;
}
[StructLayout( LayoutKind.Sequential, Pack = 4 )]
internal struct PKEY
{
/// <summary>fmtid</summary>
private readonly Guid _fmtid;
/// <summary>pid</summary>
private readonly uint _pid;
public PKEY( Guid fmtid, uint pid )
{
_fmtid = fmtid;
_pid = pid;
}
/// <summary>PKEY_Title</summary>
public static readonly PKEY Title = new PKEY( new Guid( "F29F85E0-4FF9-1068-AB91-08002B27B3D9" ), 2 );
/// <summary>PKEY_AppUserModel_ID</summary>
public static readonly PKEY AppUserModel_ID = new PKEY( new Guid( "9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3" ), 5 );
/// <summary>PKEY_AppUserModel_IsDestListSeparator</summary>
public static readonly PKEY AppUserModel_IsDestListSeparator = new PKEY( new Guid( "9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3" ), 6 );
/// <summary>PKEY_AppUserModel_RelaunchCommand</summary>
public static readonly PKEY AppUserModel_RelaunchCommand = new PKEY( new Guid( "9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3" ), 2 );
/// <summary>PKEY_AppUserModel_RelaunchDisplayNameResource</summary>
public static readonly PKEY AppUserModel_RelaunchDisplayNameResource = new PKEY( new Guid( "9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3" ), 4 );
/// <summary>PKEY_AppUserModel_RelaunchIconResource</summary>
public static readonly PKEY AppUserModel_RelaunchIconResource = new PKEY( new Guid( "9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3" ), 3 );
}
#endregion
#region Interfaces
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.EnumIdList ),
]
internal interface IEnumIDList
{
[PreserveSig()]
HRESULT Next( uint celt, out IntPtr rgelt, out int pceltFetched );
[PreserveSig()]
HRESULT Skip( uint celt );
void Reset();
void Clone( [Out, MarshalAs( UnmanagedType.Interface )] out IEnumIDList ppenum );
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.EnumObjects ),
]
internal interface IEnumObjects
{
//[local]
// This signature might not work... Hopefully don't need this interface though.
void Next( uint celt, [In] ref Guid riid, [Out, MarshalAs( UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown, IidParameterIndex = 1, SizeParamIndex = 0 )] object[] rgelt, [Out] out uint pceltFetched );
/*
[call_as(Next)] HRESULT RemoteNext(
[in] ULONG celt,
[in] REFIID riid,
[out, size_is(celt), length_is(*pceltFetched), iid_is(riid)] void **rgelt,
[out] ULONG *pceltFetched);
*/
void Skip( uint celt );
void Reset();
IEnumObjects Clone();
}
/// <summary>Unknown Object Array</summary>
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ObjectArray ),
]
internal interface IObjectArray
{
uint GetCount();
[return: MarshalAs( UnmanagedType.IUnknown )]
object GetAt( [In] uint uiIndex, [In] ref Guid riid );
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ObjectArray ),
]
interface IObjectCollection : IObjectArray
{
#region IObjectArray redeclarations
new uint GetCount();
[return: MarshalAs( UnmanagedType.IUnknown )]
new object GetAt( [In] uint uiIndex, [In] ref Guid riid );
#endregion
void AddObject( [MarshalAs( UnmanagedType.IUnknown )] object punk );
void AddFromArray( IObjectArray poaSource );
void RemoveObjectAt( uint uiIndex );
void Clear();
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.PropertyStore )
]
internal interface IPropertyStore
{
uint GetCount();
PKEY GetAt( uint iProp );
void GetValue( [In] ref PKEY pkey, [In, Out] PROPVARIANT pv );
void SetValue( [In] ref PKEY pkey, PROPVARIANT pv );
void Commit();
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ShellFolder ),
]
internal interface IShellFolder
{
void ParseDisplayName(
[In] IntPtr hwnd,
[In] IBindCtx pbc,
[In, MarshalAs( UnmanagedType.LPWStr )] string pszDisplayName,
[In, Out] ref int pchEaten,
[Out] out IntPtr ppidl,
[In, Out] ref uint pdwAttributes );
IEnumIDList EnumObjects(
[In] IntPtr hwnd,
[In] SHCONTF grfFlags );
// returns an instance of a sub-folder which is specified by the IDList (pidl).
// IShellFolder or derived interfaces
[return: MarshalAs( UnmanagedType.Interface )]
object BindToObject(
[In] IntPtr pidl,
[In] IBindCtx pbc,
[In] ref Guid riid );
// produces the same result as BindToObject()
[return: MarshalAs( UnmanagedType.Interface )]
object BindToStorage( [In] IntPtr pidl, [In] IBindCtx pbc, [In] ref Guid riid );
// compares two IDLists and returns the result. The shell
// explorer always passes 0 as lParam, which indicates 'sort by name'.
// It should return 0 (as CODE of the scode), if two id indicates the
// same object; negative value if pidl1 should be placed before pidl2;
// positive value if pidl2 should be placed before pidl1.
// use the macro ResultFromShort() to extract the result comparison
// it deals with the casting and type conversion issues for you
[PreserveSig]
HRESULT CompareIDs( [In] IntPtr lParam, [In] IntPtr pidl1, [In] IntPtr pidl2 );
// creates a view object of the folder itself. The view
// object is a difference instance from the shell folder object.
// 'hwndOwner' can be used as the owner window of its dialog box or
// menu during the lifetime of the view object.
// This member function should always create a new
// instance which has only one reference count. The explorer may create
// more than one instances of view object from one shell folder object
// and treat them as separate instances.
// returns IShellView derived interface
[return: MarshalAs( UnmanagedType.Interface )]
object CreateViewObject( [In] IntPtr hwndOwner, [In] ref Guid riid );
// returns the attributes of specified objects in that
// folder. 'cidl' and 'apidl' specifies objects. 'apidl' contains only
// simple IDLists. The explorer initializes *prgfInOut with a set of
// flags to be evaluated. The shell folder may optimize the operation
// by not returning unspecified flags.
void GetAttributesOf(
[In] uint cidl,
[In] IntPtr apidl,
[In, Out] ref SFGAO rgfInOut );
// creates a UI object to be used for specified objects.
// The shell explorer passes either IID_IDataObject (for transfer operation)
// or IID_IContextMenu (for context menu operation) as riid
// and many other interfaces
[return: MarshalAs( UnmanagedType.Interface )]
object GetUIObjectOf(
[In] IntPtr hwndOwner,
[In] uint cidl,
[In, MarshalAs( UnmanagedType.LPArray, ArraySubType = UnmanagedType.SysInt, SizeParamIndex = 2 )] IntPtr apidl,
[In] ref Guid riid,
[In, Out] ref uint rgfReserved );
// returns the display name of the specified object.
// If the ID contains the display name (in the locale character set),
// it returns the offset to the name. Otherwise, it returns a pointer
// to the display name string (UNICODE), which is allocated by the
// task allocator, or fills in a buffer.
// use the helper APIS StrRetToStr() or StrRetToBuf() to deal with the different
// forms of the STRRET structure
void GetDisplayNameOf( [In] IntPtr pidl, [In] SHGDN uFlags, [Out] out IntPtr pName );
// sets the display name of the specified object.
// If it changes the ID as well, it returns the new ID which is
// alocated by the task allocator.
void SetNameOf( [In] IntPtr hwnd,
[In] IntPtr pidl,
[In, MarshalAs( UnmanagedType.LPWStr )] string pszName,
[In] SHGDN uFlags,
[Out] out IntPtr ppidlOut );
}
/// <summary>
/// Shell Namespace helper
/// </summary>
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ShellItem ),
]
internal interface IShellItem
{
[return: MarshalAs( UnmanagedType.Interface )]
object BindToHandler( IBindCtx pbc, [In] ref Guid bhid, [In] ref Guid riid );
IShellItem GetParent();
[return: MarshalAs( UnmanagedType.LPWStr )]
string GetDisplayName( SIGDN sigdnName );
SFGAO GetAttributes( SFGAO sfgaoMask );
int Compare( IShellItem psi, SICHINT hint );
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ShellItemArray ),
]
internal interface IShellItemArray
{
[return: MarshalAs( UnmanagedType.Interface )]
object BindToHandler( IBindCtx pbc, [In] ref Guid rbhid, [In] ref Guid riid );
[return: MarshalAs( UnmanagedType.Interface )]
object GetPropertyStore( int flags, [In] ref Guid riid );
[return: MarshalAs( UnmanagedType.Interface )]
object GetPropertyDescriptionList( [In] ref PKEY keyType, [In] ref Guid riid );
uint GetAttributes( SIATTRIBFLAGS dwAttribFlags, uint sfgaoMask );
uint GetCount();
IShellItem GetItemAt( uint dwIndex );
[return: MarshalAs( UnmanagedType.Interface )]
object EnumItems();
}
/// <summary>
/// Shell Namespace helper 2
/// </summary>
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ShellItem2 ),
]
interface IShellItem2 : IShellItem
{
#region IShellItem redeclarations
[return: MarshalAs( UnmanagedType.Interface )]
new object BindToHandler( [In] IBindCtx pbc, [In] ref Guid bhid, [In] ref Guid riid );
new IShellItem GetParent();
[return: MarshalAs( UnmanagedType.LPWStr )]
new string GetDisplayName( SIGDN sigdnName );
new SFGAO GetAttributes( SFGAO sfgaoMask );
new int Compare( IShellItem psi, SICHINT hint );
#endregion
[return: MarshalAs( UnmanagedType.Interface )]
object GetPropertyStore(
GPS flags,
[In] ref Guid riid );
[return: MarshalAs( UnmanagedType.Interface )]
object GetPropertyStoreWithCreateObject(
GPS flags,
[MarshalAs( UnmanagedType.IUnknown )] object punkCreateObject, // factory for low-rights creation of type ICreateObject
[In] ref Guid riid );
[return: MarshalAs( UnmanagedType.Interface )]
object GetPropertyStoreForKeys(
IntPtr rgKeys,
uint cKeys,
GPS flags,
[In] ref Guid riid );
[return: MarshalAs( UnmanagedType.Interface )]
object GetPropertyDescriptionList(
IntPtr keyType,
[In] ref Guid riid );
// Ensures any cached information in this item is up to date, or returns __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) if the item does not exist.
void Update( IBindCtx pbc );
PROPVARIANT GetProperty( IntPtr key );
Guid GetCLSID( IntPtr key );
FILETIME GetFileTime( IntPtr key );
int GetInt32( IntPtr key );
[return: MarshalAs( UnmanagedType.LPWStr )]
string GetString( IntPtr key );
uint GetUInt32( IntPtr key );
ulong GetUInt64( IntPtr key );
[return: MarshalAs( UnmanagedType.Bool )]
void GetBool( IntPtr key );
}
[
ComImport,
InterfaceTypeAttribute( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ShellLink ),
]
internal interface IShellLinkW
{
void GetPath( [Out, MarshalAs( UnmanagedType.LPWStr )] StringBuilder pszFile, int cchMaxPath, [In, Out] WIN32_FIND_DATAW pfd, SLGP fFlags );
void GetIDList( out IntPtr ppidl );
void SetIDList( IntPtr pidl );
void GetDescription( [Out, MarshalAs( UnmanagedType.LPWStr )] StringBuilder pszFile, int cchMaxName );
void SetDescription( [MarshalAs( UnmanagedType.LPWStr )] string pszName );
void GetWorkingDirectory( [Out, MarshalAs( UnmanagedType.LPWStr )] StringBuilder pszDir, int cchMaxPath );
void SetWorkingDirectory( [MarshalAs( UnmanagedType.LPWStr )] string pszDir );
void GetArguments( [Out, MarshalAs( UnmanagedType.LPWStr )] StringBuilder pszArgs, int cchMaxPath );
void SetArguments( [MarshalAs( UnmanagedType.LPWStr )] string pszArgs );
short GetHotKey();
void SetHotKey( short wHotKey );
uint GetShowCmd();
void SetShowCmd( uint iShowCmd );
void GetIconLocation( [Out, MarshalAs( UnmanagedType.LPWStr )] StringBuilder pszIconPath, int cchIconPath, out int piIcon );
void SetIconLocation( [MarshalAs( UnmanagedType.LPWStr )] string pszIconPath, int iIcon );
void SetRelativePath( [MarshalAs( UnmanagedType.LPWStr )] string pszPathRel, uint dwReserved );
void Resolve( IntPtr hwnd, uint fFlags );
void SetPath( [MarshalAs( UnmanagedType.LPWStr )] string pszFile );
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.TaskbarList ),
]
internal interface ITaskbarList
{
/// <summary>
/// This function must be called first to validate use of other members.
/// </summary>
void HrInit();
/// <summary>
/// This function adds a tab for hwnd to the taskbar.
/// </summary>
/// <param name="hwnd">The HWND for which to add the tab.</param>
void AddTab( IntPtr hwnd );
/// <summary>
/// This function deletes a tab for hwnd from the taskbar.
/// </summary>
/// <param name="hwnd">The HWND for which the tab is to be deleted.</param>
void DeleteTab( IntPtr hwnd );
/// <summary>
/// This function activates the tab associated with hwnd on the taskbar.
/// </summary>
/// <param name="hwnd">The HWND for which the tab is to be actuvated.</param>
void ActivateTab( IntPtr hwnd );
/// <summary>
/// This function marks hwnd in the taskbar as the active tab.
/// </summary>
/// <param name="hwnd">The HWND to activate.</param>
void SetActiveAlt( IntPtr hwnd );
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.TaskbarList2 ),
]
internal interface ITaskbarList2 : ITaskbarList
{
#region ITaskbarList redeclaration
new void HrInit();
new void AddTab( IntPtr hwnd );
new void DeleteTab( IntPtr hwnd );
new void ActivateTab( IntPtr hwnd );
new void SetActiveAlt( IntPtr hwnd );
#endregion
/// <summary>
/// Marks a window as full-screen.
/// </summary>
/// <param name="hwnd">The handle of the window to be marked.</param>
/// <param name="fFullscreen">A Boolean value marking the desired full-screen status of the window.</param>
/// <remarks>
/// Setting the value of fFullscreen to true, the Shell treats this window as a full-screen window, and the taskbar
/// is moved to the bottom of the z-order when this window is active. Setting the value of fFullscreen to false
/// removes the full-screen marking, but <i>does not</i> cause the Shell to treat the window as though it were
/// definitely not full-screen. With a false fFullscreen value, the Shell depends on its automatic detection facility
/// to specify how the window should be treated, possibly still flagging the window as full-screen.
/// </remarks>
void MarkFullscreenWindow( IntPtr hwnd, [MarshalAs( UnmanagedType.Bool )] bool fFullscreen );
}
// Used to remove items from the automatic destination lists created when apps or the system call SHAddToRecentDocs to report usage of a document.
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ApplicationDestinations )
]
internal interface IApplicationDestinations
{
// Set the App User Model ID for the application removing destinations from its list. If an AppID is not provided
// via this method, the system will use a heuristically determined ID. This method must be called before
// RemoveDestination or RemoveAllDestinations.
void SetAppID( [In, MarshalAs( UnmanagedType.LPWStr )] string pszAppID );
// Remove an IShellItem or an IShellLink from the automatic destination list
void RemoveDestination( [MarshalAs( UnmanagedType.IUnknown )] object punk );
// Clear the frequent and recent destination lists for this application.
void RemoveAllDestinations();
}
/// <summary>
/// Allows an application to retrieve the most recent and frequent documents opened in that app, as reported via SHAddToRecentDocs
/// </summary>
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ApplicationDocumentLists )
]
internal interface IApplicationDocumentLists
{
/// <summary>
/// Set the App User Model ID for the application retrieving this list. If an AppID is not provided via this method,
/// the system will use a heuristically determined ID. This method must be called before GetList.
/// </summary>
/// <param name="pszAppID">App Id.</param>
void SetAppID( [MarshalAs( UnmanagedType.LPWStr )] string pszAppID );
/// <summary>
/// Retrieve an IEnumObjects or IObjectArray for IShellItems and/or IShellLinks.
/// Items may appear in both the frequent and recent lists.
/// </summary>
/// <param name="?"></param>
/// <returns></returns>
[return: MarshalAs( UnmanagedType.IUnknown )]
object GetList( [In] APPDOCLISTTYPE listtype, [In] uint cItemsDesired, [In] ref Guid riid );
}
// Custom Destination List
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.CustomDestinationList )
]
internal interface ICustomDestinationList
{
void SetAppID( [In, MarshalAs( UnmanagedType.LPWStr )] string pszAppID );
// Retrieve IObjectArray of IShellItems or IShellLinks that represent removed destinations
[return: MarshalAs( UnmanagedType.Interface )]
object BeginList( out uint pcMaxSlots, [In] ref Guid riid );
// PreserveSig because this will return custom errors when attempting to add unregistered ShellItems.
// Can't readily detect that case without just trying to append it.
[PreserveSig]
HRESULT AppendCategory( [MarshalAs( UnmanagedType.LPWStr )] string pszCategory, IObjectArray poa );
void AppendKnownCategory( KDC category );
[PreserveSig]
HRESULT AddUserTasks( IObjectArray poa );
void CommitList();
// Retrieve IObjectCollection of IShellItems
[return: MarshalAs( UnmanagedType.Interface )]
object GetRemovedDestinations( [In] ref Guid riid );
void DeleteList( [MarshalAs( UnmanagedType.LPWStr )] string pszAppID );
void AbortList();
}
/// <summary>
/// Provides access to the App User Model ID on objects supporting this value.
/// </summary>
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ObjectWithAppUserModelId )
]
internal interface IObjectWithAppUserModelId
{
void SetAppID( [MarshalAs( UnmanagedType.LPWStr )] string pszAppID );
[return: MarshalAs( UnmanagedType.LPWStr )]
string GetAppID();
};
/// <summary>
/// Provides access to the ProgID associated with an object
/// </summary>
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.ObjectWithProgId )
]
internal interface IObjectWithProgId
{
void SetProgID( [MarshalAs( UnmanagedType.LPWStr )] string pszProgID );
[return: MarshalAs( UnmanagedType.LPWStr )]
string GetProgID();
};
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.TaskbarList3 ),
]
internal interface ITaskbarList3 : ITaskbarList2
{
#region ITaskbarList2 redeclaration
#region ITaskbarList redeclaration
new void HrInit();
new void AddTab( IntPtr hwnd );
new void DeleteTab( IntPtr hwnd );
new void ActivateTab( IntPtr hwnd );
new void SetActiveAlt( IntPtr hwnd );
#endregion
new void MarkFullscreenWindow( IntPtr hwnd, [MarshalAs( UnmanagedType.Bool )] bool fFullscreen );
#endregion
[PreserveSig]
HRESULT SetProgressValue( IntPtr hwnd, ulong ullCompleted, ulong ullTotal );
[PreserveSig]
HRESULT SetProgressState( IntPtr hwnd, TBPF tbpFlags );
[PreserveSig]
HRESULT RegisterTab( IntPtr hwndTab, IntPtr hwndMDI );
[PreserveSig]
HRESULT UnregisterTab( IntPtr hwndTab );
[PreserveSig]
HRESULT SetTabOrder( IntPtr hwndTab, IntPtr hwndInsertBefore );
[PreserveSig]
HRESULT SetTabActive( IntPtr hwndTab, IntPtr hwndMDI, uint dwReserved );
[PreserveSig]
HRESULT ThumbBarAddButtons( IntPtr hwnd, uint cButtons, [MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 1 )] THUMBBUTTON[] pButtons );
[PreserveSig]
HRESULT ThumbBarUpdateButtons( IntPtr hwnd, uint cButtons, [MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 1 )] THUMBBUTTON[] pButtons );
[PreserveSig]
HRESULT ThumbBarSetImageList( IntPtr hwnd, [MarshalAs( UnmanagedType.IUnknown )] object himl );
[PreserveSig]
HRESULT SetOverlayIcon( IntPtr hwnd, IntPtr hIcon, [MarshalAs( UnmanagedType.LPWStr )] string pszDescription );
[PreserveSig]
HRESULT SetThumbnailTooltip( IntPtr hwnd, [MarshalAs( UnmanagedType.LPWStr )] string pszTip );
// Using RefRECT to making passing NULL possible. Removes clipping from the HWND.
[PreserveSig]
HRESULT SetThumbnailClip( IntPtr hwnd, RefRECT prcClip );
}
[
ComImport,
InterfaceType( ComInterfaceType.InterfaceIsIUnknown ),
Guid( IID.TaskbarList3 ),
]
internal interface ITaskbarList4 : ITaskbarList3
{
#region ITaskbarList3 redeclaration
#region ITaskbarList2 redeclaration
#region ITaskbarList redeclaration
new void HrInit();
new void AddTab( IntPtr hwnd );
new void DeleteTab( IntPtr hwnd );
new void ActivateTab( IntPtr hwnd );
new void SetActiveAlt( IntPtr hwnd );
#endregion
new void MarkFullscreenWindow( IntPtr hwnd, [MarshalAs( UnmanagedType.Bool )] bool fFullscreen );
#endregion
[PreserveSig]
new HRESULT SetProgressValue( IntPtr hwnd, ulong ullCompleted, ulong ullTotal );
[PreserveSig]
new HRESULT SetProgressState( IntPtr hwnd, TBPF tbpFlags );
[PreserveSig]
new HRESULT RegisterTab( IntPtr hwndTab, IntPtr hwndMDI );
[PreserveSig]
new HRESULT UnregisterTab( IntPtr hwndTab );
[PreserveSig]
new HRESULT SetTabOrder( IntPtr hwndTab, IntPtr hwndInsertBefore );
[PreserveSig]
new HRESULT SetTabActive( IntPtr hwndTab, IntPtr hwndMDI, uint dwReserved );
[PreserveSig]
new HRESULT ThumbBarAddButtons( IntPtr hwnd, uint cButtons, [MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 1 )] THUMBBUTTON[] pButtons );
[PreserveSig]
new HRESULT ThumbBarUpdateButtons( IntPtr hwnd, uint cButtons, [MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 1 )] THUMBBUTTON[] pButtons );
[PreserveSig]
new HRESULT ThumbBarSetImageList( IntPtr hwnd, [MarshalAs( UnmanagedType.IUnknown )] object himl );
[PreserveSig]
new HRESULT SetOverlayIcon( IntPtr hwnd, IntPtr hIcon, [MarshalAs( UnmanagedType.LPWStr )] string pszDescription );
[PreserveSig]
new HRESULT SetThumbnailTooltip( IntPtr hwnd, [MarshalAs( UnmanagedType.LPWStr )] string pszTip );
// Using RefRECT to making passing NULL possible. Removes clipping from the HWND.
[PreserveSig]
new HRESULT SetThumbnailClip( IntPtr hwnd, RefRECT prcClip );
#endregion
void SetTabProperties( IntPtr hwndTab, STPF stpFlags );
}
#endregion
}

357
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/StreamHelper.cs

@ -1,357 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Standard
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
// disambiguate with System.Runtime.InteropServices.STATSTG
using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG;
// All these methods return void. Does the standard marshaller convert them to HRESULTs?
/// <summary>
/// Wraps a managed stream instance into an interface pointer consumable by COM.
/// </summary>
internal sealed class ManagedIStream : IStream, IDisposable
{
private const int STGTY_STREAM = 2;
private const int STGM_READWRITE = 2;
private const int LOCK_EXCLUSIVE = 2;
private Stream _source;
/// <summary>
/// Initializes a new instance of the ManagedIStream class with the specified managed Stream object.
/// </summary>
/// <param name="source">
/// The stream that this IStream reference is wrapping.
/// </param>
public ManagedIStream( Stream source )
{
Verify.IsNotNull( source, "source" );
_source = source;
}
private void _Validate()
{
if( null == _source )
{
throw new ObjectDisposedException( "this" );
}
}
// Comments are taken from MSDN IStream documentation.
#region IStream Members
/// <summary>
/// Creates a new stream object with its own seek pointer that
/// references the same bytes as the original stream.
/// </summary>
/// <param name="ppstm">
/// When this method returns, contains the new stream object. This parameter is passed uninitialized.
/// </param>
/// <remarks>
/// For more information, see the existing documentation for IStream::Clone in the MSDN library.
/// This class doesn't implement Clone. A COMException is thrown if it is used.
/// </remarks>
[SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)" )]
[Obsolete( "The method is not implemented", true )]
public void Clone( out IStream ppstm )
{
ppstm = null;
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed( "The method is not implemented." );
}
/// <summary>
/// Ensures that any changes made to a stream object that is open in transacted
/// mode are reflected in the parent storage.
/// </summary>
/// <param name="grfCommitFlags">
/// A value that controls how the changes for the stream object are committed.
/// </param>
/// <remarks>
/// For more information, see the existing documentation for IStream::Commit in the MSDN library.
/// </remarks>
public void Commit( int grfCommitFlags )
{
_Validate();
_source.Flush();
}
/// <summary>
/// Copies a specified number of bytes from the current seek pointer in the
/// stream to the current seek pointer in another stream.
/// </summary>
/// <param name="pstm">
/// A reference to the destination stream.
/// </param>
/// <param name="cb">
/// The number of bytes to copy from the source stream.
/// </param>
/// <param name="pcbRead">
/// On successful return, contains the actual number of bytes read from the source.
/// (Note the native signature is to a ULARGE_INTEGER*, so 64 bits are written
/// to this parameter on success.)
/// </param>
/// <param name="pcbWritten">
/// On successful return, contains the actual number of bytes written to the destination.
/// (Note the native signature is to a ULARGE_INTEGER*, so 64 bits are written
/// to this parameter on success.)
/// </param>
[SuppressMessage( "Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0" )]
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
public void CopyTo( IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten )
{
Verify.IsNotNull( pstm, "pstm" );
_Validate();
// Reasonbly sized buffer, don't try to copy large streams in bulk.
var buffer = new byte[ 4096 ];
long cbWritten = 0;
while( cbWritten < cb )
{
int cbRead = _source.Read( buffer, 0, buffer.Length );
if( 0 == cbRead )
{
break;
}
// COM documentation is a bit vague here whether NULL is valid for the third parameter.
// Going to assume it is, as most implementations I've seen treat it as optional.
// It's possible this will break on some IStream implementations.
pstm.Write( buffer, cbRead, IntPtr.Zero );
cbWritten += cbRead;
}
if( IntPtr.Zero != pcbRead )
{
Marshal.WriteInt64( pcbRead, cbWritten );
}
if( IntPtr.Zero != pcbWritten )
{
Marshal.WriteInt64( pcbWritten, cbWritten );
}
}
/// <summary>
/// Restricts access to a specified range of bytes in the stream.
/// </summary>
/// <param name="libOffset">
/// The byte offset for the beginning of the range.
/// </param>
/// <param name="cb">
/// The length of the range, in bytes, to restrict.
/// </param>
/// <param name="dwLockType">
/// The requested restrictions on accessing the range.
/// </param>
/// <remarks>
/// For more information, see the existing documentation for IStream::LockRegion in the MSDN library.
/// This class doesn't implement LockRegion. A COMException is thrown if it is used.
/// </remarks>
[SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)" ), Obsolete( "The method is not implemented", true )]
public void LockRegion( long libOffset, long cb, int dwLockType )
{
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed( "The method is not implemented." );
}
/// <summary>
/// Reads a specified number of bytes from the stream object into memory starting at the current seek pointer.
/// </summary>
/// <param name="pv">
/// When this method returns, contains the data read from the stream. This parameter is passed uninitialized.
/// </param>
/// <param name="cb">
/// The number of bytes to read from the stream object.
/// </param>
/// <param name="pcbRead">
/// A pointer to a ULONG variable that receives the actual number of bytes read from the stream object.
/// </param>
/// <remarks>
/// For more information, see the existing documentation for ISequentialStream::Read in the MSDN library.
/// </remarks>
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
public void Read( byte[] pv, int cb, IntPtr pcbRead )
{
_Validate();
int cbRead = _source.Read( pv, 0, cb );
if( IntPtr.Zero != pcbRead )
{
Marshal.WriteInt32( pcbRead, cbRead );
}
}
/// <summary>
/// Discards all changes that have been made to a transacted stream since the last Commit call.
/// </summary>
/// <remarks>
/// This class doesn't implement Revert. A COMException is thrown if it is used.
/// </remarks>
[SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)" ), Obsolete( "The method is not implemented", true )]
public void Revert()
{
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed( "The method is not implemented." );
}
/// <summary>
/// Changes the seek pointer to a new location relative to the beginning of the
/// stream, to the end of the stream, or to the current seek pointer.
/// </summary>
/// <param name="dlibMove">
/// The displacement to add to dwOrigin.
/// </param>
/// <param name="dwOrigin">
/// The origin of the seek. The origin can be the beginning of the file, the current seek pointer, or the end of the file.
/// </param>
/// <param name="plibNewPosition">
/// On successful return, contains the offset of the seek pointer from the beginning of the stream.
/// (Note the native signature is to a ULARGE_INTEGER*, so 64 bits are written
/// to this parameter on success.)
/// </param>
/// <remarks>
/// For more information, see the existing documentation for IStream::Seek in the MSDN library.
/// </remarks>
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
public void Seek( long dlibMove, int dwOrigin, IntPtr plibNewPosition )
{
_Validate();
long position = _source.Seek( dlibMove, ( SeekOrigin )dwOrigin );
if( IntPtr.Zero != plibNewPosition )
{
Marshal.WriteInt64( plibNewPosition, position );
}
}
/// <summary>
/// Changes the size of the stream object.
/// </summary>
/// <param name="libNewSize">
/// The new size of the stream as a number of bytes.
/// </param>
/// <remarks>
/// For more information, see the existing documentation for IStream::SetSize in the MSDN library.
/// </remarks>
public void SetSize( long libNewSize )
{
_Validate();
_source.SetLength( libNewSize );
}
/// <summary>
/// Retrieves the STATSTG structure for this stream.
/// </summary>
/// <param name="pstatstg">
/// When this method returns, contains a STATSTG structure that describes this stream object.
/// This parameter is passed uninitialized.
/// </param>
/// <param name="grfStatFlag">
/// Members in the STATSTG structure that this method does not return, thus saving some memory allocation operations.
/// </param>
public void Stat( out STATSTG pstatstg, int grfStatFlag )
{
pstatstg = default( STATSTG );
_Validate();
pstatstg.type = STGTY_STREAM;
pstatstg.cbSize = _source.Length;
pstatstg.grfMode = STGM_READWRITE;
pstatstg.grfLocksSupported = LOCK_EXCLUSIVE;
}
/// <summary>
/// Removes the access restriction on a range of bytes previously restricted with the LockRegion method.
/// </summary>
/// <param name="libOffset">The byte offset for the beginning of the range.
/// </param>
/// <param name="cb">
/// The length, in bytes, of the range to restrict.
/// </param>
/// <param name="dwLockType">
/// The access restrictions previously placed on the range.
/// </param>
/// <remarks>
/// For more information, see the existing documentation for IStream::UnlockRegion in the MSDN library.
/// This class doesn't implement UnlockRegion. A COMException is thrown if it is used.
/// </remarks>
[SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "Standard.HRESULT.ThrowIfFailed(System.String)" )]
[Obsolete( "The method is not implemented", true )]
public void UnlockRegion( long libOffset, long cb, int dwLockType )
{
HRESULT.STG_E_INVALIDFUNCTION.ThrowIfFailed( "The method is not implemented." );
}
/// <summary>
/// Writes a specified number of bytes into the stream object starting at the current seek pointer.
/// </summary>
/// <param name="pv">
/// The buffer to write this stream to.
/// </param>
/// <param name="cb">
/// The number of bytes to write to the stream.
/// </param>
/// <param name="pcbWritten">
/// On successful return, contains the actual number of bytes written to the stream object.
/// If the caller sets this pointer to null, this method does not provide the actual number
/// of bytes written.
/// </param>
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
public void Write( byte[] pv, int cb, IntPtr pcbWritten )
{
_Validate();
_source.Write( pv, 0, cb );
if( IntPtr.Zero != pcbWritten )
{
Marshal.WriteInt32( pcbWritten, cb );
}
}
#endregion
#region IDisposable Members
/// <summary>
/// Releases resources controlled by this object.
/// </summary>
/// <remarks>
/// Dispose can be called multiple times, but trying to use the object
/// after it has been disposed will generally throw ObjectDisposedExceptions.
/// </remarks>
public void Dispose()
{
_source = null;
}
#endregion
}
}

1071
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/Utilities.cs

File diff suppressed because it is too large

328
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/Standard/Verify.cs

@ -1,328 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
// This file contains general utilities to aid in development.
// Classes here generally shouldn't be exposed publicly since
// they're not particular to any library functionality.
// Because the classes here are internal, it's likely this file
// might be included in multiple assemblies.
namespace Standard
{
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Threading;
/// <summary>
/// A static class for retail validated assertions.
/// Instead of breaking into the debugger an exception is thrown.
/// </summary>
internal static class Verify
{
/// <summary>
/// Ensure that the current thread's apartment state is what's expected.
/// </summary>
/// <param name="requiredState">
/// The required apartment state for the current thread.
/// </param>
/// <param name="message">
/// The message string for the exception to be thrown if the state is invalid.
/// </param>
/// <exception cref="InvalidOperationException">
/// Thrown if the calling thread's apartment state is not the same as the requiredState.
/// </exception>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void IsApartmentState( ApartmentState requiredState, string message )
{
if( Thread.CurrentThread.GetApartmentState() != requiredState )
{
throw new InvalidOperationException( message );
}
}
/// <summary>
/// Ensure that an argument is neither null nor empty.
/// </summary>
/// <param name="value">The string to validate.</param>
/// <param name="name">The name of the parameter that will be presented if an exception is thrown.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[SuppressMessage( "Microsoft.Performance", "CA1820:TestForEmptyStringsUsingStringLength" )]
[DebuggerStepThrough]
public static void IsNeitherNullNorEmpty( string value, string name )
{
// catch caller errors, mixing up the parameters. Name should never be empty.
Assert.IsNeitherNullNorEmpty( name );
// Notice that ArgumentNullException and ArgumentException take the parameters in opposite order :P
const string errorMessage = "The parameter can not be either null or empty.";
if( null == value )
{
throw new ArgumentNullException( name, errorMessage );
}
if( "" == value )
{
throw new ArgumentException( errorMessage, name );
}
}
/// <summary>
/// Ensure that an argument is neither null nor does it consist only of whitespace.
/// </summary>
/// <param name="value">The string to validate.</param>
/// <param name="name">The name of the parameter that will be presented if an exception is thrown.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[SuppressMessage( "Microsoft.Performance", "CA1820:TestForEmptyStringsUsingStringLength" )]
[DebuggerStepThrough]
public static void IsNeitherNullNorWhitespace( string value, string name )
{
// catch caller errors, mixing up the parameters. Name should never be empty.
Assert.IsNeitherNullNorEmpty( name );
// Notice that ArgumentNullException and ArgumentException take the parameters in opposite order :P
const string errorMessage = "The parameter can not be either null or empty or consist only of white space characters.";
if( null == value )
{
throw new ArgumentNullException( name, errorMessage );
}
if( "" == value.Trim() )
{
throw new ArgumentException( errorMessage, name );
}
}
/// <summary>Verifies that an argument is not null.</summary>
/// <typeparam name="T">Type of the object to validate. Must be a class.</typeparam>
/// <param name="obj">The object to validate.</param>
/// <param name="name">The name of the parameter that will be presented if an exception is thrown.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void IsNotDefault<T>( T obj, string name ) where T : struct
{
if( default( T ).Equals( obj ) )
{
throw new ArgumentException( "The parameter must not be the default value.", name );
}
}
/// <summary>Verifies that an argument is not null.</summary>
/// <typeparam name="T">Type of the object to validate. Must be a class.</typeparam>
/// <param name="obj">The object to validate.</param>
/// <param name="name">The name of the parameter that will be presented if an exception is thrown.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void IsNotNull<T>( T obj, string name ) where T : class
{
if( null == obj )
{
throw new ArgumentNullException( name );
}
}
/// <summary>Verifies that an argument is null.</summary>
/// <typeparam name="T">Type of the object to validate. Must be a class.</typeparam>
/// <param name="obj">The object to validate.</param>
/// <param name="name">The name of the parameter that will be presented if an exception is thrown.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void IsNull<T>( T obj, string name ) where T : class
{
if( null != obj )
{
throw new ArgumentException( "The parameter must be null.", name );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void PropertyIsNotNull<T>( T obj, string name ) where T : class
{
if( null == obj )
{
throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, "The property {0} cannot be null at this time.", name ) );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void PropertyIsNull<T>( T obj, string name ) where T : class
{
if( null != obj )
{
throw new InvalidOperationException( string.Format( CultureInfo.InvariantCulture, "The property {0} must be null at this time.", name ) );
}
}
/// <summary>
/// Verifies the specified statement is true. Throws an ArgumentException if it's not.
/// </summary>
/// <param name="statement">The statement to be verified as true.</param>
/// <param name="name">Name of the parameter to include in the ArgumentException.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void IsTrue( bool statement, string name )
{
if( !statement )
{
throw new ArgumentException( "", name );
}
}
/// <summary>
/// Verifies the specified statement is true. Throws an ArgumentException if it's not.
/// </summary>
/// <param name="statement">The statement to be verified as true.</param>
/// <param name="name">Name of the parameter to include in the ArgumentException.</param>
/// <param name="message">The message to include in the ArgumentException.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void IsTrue( bool statement, string name, string message )
{
if( !statement )
{
throw new ArgumentException( message, name );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void AreEqual<T>( T expected, T actual, string parameterName, string message )
{
if( null == expected )
{
// Two nulls are considered equal, regardless of type semantics.
if( null != actual && !actual.Equals( expected ) )
{
throw new ArgumentException( message, parameterName );
}
}
else if( !expected.Equals( actual ) )
{
throw new ArgumentException( message, parameterName );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void AreNotEqual<T>( T notExpected, T actual, string parameterName, string message )
{
if( null == notExpected )
{
// Two nulls are considered equal, regardless of type semantics.
if( null == actual || actual.Equals( notExpected ) )
{
throw new ArgumentException( message, parameterName );
}
}
else if( notExpected.Equals( actual ) )
{
throw new ArgumentException( message, parameterName );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void UriIsAbsolute( Uri uri, string parameterName )
{
Verify.IsNotNull( uri, parameterName );
if( !uri.IsAbsoluteUri )
{
throw new ArgumentException( "The URI must be absolute.", parameterName );
}
}
/// <summary>
/// Verifies that the specified value is within the expected range. The assertion fails if it isn't.
/// </summary>
/// <param name="lowerBoundInclusive">The lower bound inclusive value.</param>
/// <param name="value">The value to verify.</param>
/// <param name="upperBoundExclusive">The upper bound exclusive value.</param>
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void BoundedInteger( int lowerBoundInclusive, int value, int upperBoundExclusive, string parameterName )
{
if( value < lowerBoundInclusive || value >= upperBoundExclusive )
{
throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "The integer value must be bounded with [{0}, {1})", lowerBoundInclusive, upperBoundExclusive ), parameterName );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void BoundedDoubleInc( double lowerBoundInclusive, double value, double upperBoundInclusive, string message, string parameter )
{
if( value < lowerBoundInclusive || value > upperBoundInclusive )
{
throw new ArgumentException( message, parameter );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void TypeSupportsInterface( Type type, Type interfaceType, string parameterName )
{
Assert.IsNeitherNullNorEmpty( parameterName );
Verify.IsNotNull( type, "type" );
Verify.IsNotNull( interfaceType, "interfaceType" );
if( type.GetInterface( interfaceType.Name ) == null )
{
throw new ArgumentException( "The type of this parameter does not support a required interface", parameterName );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
public static void FileExists( string filePath, string parameterName )
{
Verify.IsNeitherNullNorEmpty( filePath, parameterName );
if( !File.Exists( filePath ) )
{
throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "No file exists at \"{0}\"", filePath ), parameterName );
}
}
[SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
[DebuggerStepThrough]
internal static void ImplementsInterface( object parameter, Type interfaceType, string parameterName )
{
Assert.IsNotNull( parameter );
Assert.IsNotNull( interfaceType );
Assert.IsTrue( interfaceType.IsInterface );
bool isImplemented = false;
foreach( var ifaceType in parameter.GetType().GetInterfaces() )
{
if( ifaceType == interfaceType )
{
isImplemented = true;
break;
}
}
if( !isImplemented )
{
throw new ArgumentException( string.Format( CultureInfo.InvariantCulture, "The parameter must implement interface {0}.", interfaceType.ToString() ), parameterName );
}
}
}
}

122
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/SystemCommands.cs

@ -1,122 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
namespace Microsoft.Windows.Shell
{
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using Standard;
public static class SystemCommands
{
public static RoutedCommand CloseWindowCommand
{
get; private set;
}
public static RoutedCommand MaximizeWindowCommand
{
get; private set;
}
public static RoutedCommand MinimizeWindowCommand
{
get; private set;
}
public static RoutedCommand RestoreWindowCommand
{
get; private set;
}
public static RoutedCommand ShowSystemMenuCommand
{
get; private set;
}
static SystemCommands()
{
CloseWindowCommand = new RoutedCommand( "CloseWindow", typeof( SystemCommands ) );
MaximizeWindowCommand = new RoutedCommand( "MaximizeWindow", typeof( SystemCommands ) );
MinimizeWindowCommand = new RoutedCommand( "MinimizeWindow", typeof( SystemCommands ) );
RestoreWindowCommand = new RoutedCommand( "RestoreWindow", typeof( SystemCommands ) );
ShowSystemMenuCommand = new RoutedCommand( "ShowSystemMenu", typeof( SystemCommands ) );
}
private static void _PostSystemCommand( Window window, SC command )
{
IntPtr hwnd = new WindowInteropHelper( window ).Handle;
if( hwnd == IntPtr.Zero || !NativeMethods.IsWindow( hwnd ) )
{
return;
}
NativeMethods.PostMessage( hwnd, WM.SYSCOMMAND, new IntPtr( ( int )command ), IntPtr.Zero );
}
public static void CloseWindow( Window window )
{
Verify.IsNotNull( window, "window" );
_PostSystemCommand( window, SC.CLOSE );
}
public static void MaximizeWindow( Window window )
{
Verify.IsNotNull( window, "window" );
_PostSystemCommand( window, SC.MAXIMIZE );
}
public static void MinimizeWindow( Window window )
{
Verify.IsNotNull( window, "window" );
_PostSystemCommand( window, SC.MINIMIZE );
}
public static void RestoreWindow( Window window )
{
Verify.IsNotNull( window, "window" );
_PostSystemCommand( window, SC.RESTORE );
}
/// <summary>Display the system menu at a specified location.</summary>
/// <param name="screenLocation">The location to display the system menu, in logical screen coordinates.</param>
public static void ShowSystemMenu( Window window, Point screenLocation )
{
Verify.IsNotNull( window, "window" );
ShowSystemMenuPhysicalCoordinates( window, DpiHelper.LogicalPixelsToDevice( screenLocation ) );
}
internal static void ShowSystemMenuPhysicalCoordinates( Window window, Point physicalScreenLocation )
{
const uint TPM_RETURNCMD = 0x0100;
const uint TPM_LEFTBUTTON = 0x0;
Verify.IsNotNull( window, "window" );
IntPtr hwnd = new WindowInteropHelper( window ).Handle;
if( hwnd == IntPtr.Zero || !NativeMethods.IsWindow( hwnd ) )
{
return;
}
IntPtr hmenu = NativeMethods.GetSystemMenu( hwnd, false );
uint cmd = NativeMethods.TrackPopupMenuEx( hmenu, TPM_LEFTBUTTON | TPM_RETURNCMD, ( int )physicalScreenLocation.X, ( int )physicalScreenLocation.Y, hwnd, IntPtr.Zero );
if( 0 != cmd )
{
NativeMethods.PostMessage( hwnd, WM.SYSCOMMAND, new IntPtr( cmd ), IntPtr.Zero );
}
}
}
}

606
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/SystemParameters2.cs

@ -1,606 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Microsoft.Windows.Shell
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using Standard;
[SuppressMessage( "Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable" )]
public class SystemParameters2 : INotifyPropertyChanged
{
private delegate void _SystemMetricUpdate( IntPtr wParam, IntPtr lParam );
[ThreadStatic]
private static SystemParameters2 _threadLocalSingleton;
private MessageWindow _messageHwnd;
private bool _isGlassEnabled;
private Color _glassColor;
private SolidColorBrush _glassColorBrush;
private Thickness _windowResizeBorderThickness;
private Thickness _windowNonClientFrameThickness;
private double _captionHeight;
private Size _smallIconSize;
private string _uxThemeName;
private string _uxThemeColor;
private bool _isHighContrast;
private CornerRadius _windowCornerRadius;
private Rect _captionButtonLocation;
private readonly Dictionary<WM, List<_SystemMetricUpdate>> _UpdateTable;
#region Initialization and Update Methods
// Most properties exposed here have a way of being queried directly
// and a way of being notified of updates via a window message.
// This region is a grouping of both, for each of the exposed properties.
private void _InitializeIsGlassEnabled()
{
IsGlassEnabled = NativeMethods.DwmIsCompositionEnabled();
}
private void _UpdateIsGlassEnabled( IntPtr wParam, IntPtr lParam )
{
// Neither the wParam or lParam are used in this case.
_InitializeIsGlassEnabled();
}
private void _InitializeGlassColor()
{
bool isOpaque;
uint color;
NativeMethods.DwmGetColorizationColor( out color, out isOpaque );
color |= isOpaque ? 0xFF000000 : 0;
WindowGlassColor = Utility.ColorFromArgbDword( color );
var glassBrush = new SolidColorBrush( WindowGlassColor );
glassBrush.Freeze();
WindowGlassBrush = glassBrush;
}
private void _UpdateGlassColor( IntPtr wParam, IntPtr lParam )
{
bool isOpaque = lParam != IntPtr.Zero;
uint color = unchecked(( uint )( int )wParam.ToInt64());
color |= isOpaque ? 0xFF000000 : 0;
WindowGlassColor = Utility.ColorFromArgbDword( color );
var glassBrush = new SolidColorBrush( WindowGlassColor );
glassBrush.Freeze();
WindowGlassBrush = glassBrush;
}
private void _InitializeCaptionHeight()
{
Point ptCaption = new Point( 0, NativeMethods.GetSystemMetrics( SM.CYCAPTION ) );
WindowCaptionHeight = DpiHelper.DevicePixelsToLogical( ptCaption ).Y;
}
private void _UpdateCaptionHeight( IntPtr wParam, IntPtr lParam )
{
_InitializeCaptionHeight();
}
private void _InitializeWindowResizeBorderThickness()
{
Size frameSize = new Size(
NativeMethods.GetSystemMetrics( SM.CXSIZEFRAME ),
NativeMethods.GetSystemMetrics( SM.CYSIZEFRAME ) );
Size frameSizeInDips = DpiHelper.DeviceSizeToLogical( frameSize );
WindowResizeBorderThickness = new Thickness( frameSizeInDips.Width, frameSizeInDips.Height, frameSizeInDips.Width, frameSizeInDips.Height );
}
private void _UpdateWindowResizeBorderThickness( IntPtr wParam, IntPtr lParam )
{
_InitializeWindowResizeBorderThickness();
}
private void _InitializeWindowNonClientFrameThickness()
{
Size frameSize = new Size(
NativeMethods.GetSystemMetrics( SM.CXSIZEFRAME ),
NativeMethods.GetSystemMetrics( SM.CYSIZEFRAME ) );
Size frameSizeInDips = DpiHelper.DeviceSizeToLogical( frameSize );
int captionHeight = NativeMethods.GetSystemMetrics( SM.CYCAPTION );
double captionHeightInDips = DpiHelper.DevicePixelsToLogical( new Point( 0, captionHeight ) ).Y;
WindowNonClientFrameThickness = new Thickness( frameSizeInDips.Width, frameSizeInDips.Height + captionHeightInDips, frameSizeInDips.Width, frameSizeInDips.Height );
}
private void _UpdateWindowNonClientFrameThickness( IntPtr wParam, IntPtr lParam )
{
_InitializeWindowNonClientFrameThickness();
}
private void _InitializeSmallIconSize()
{
SmallIconSize = new Size(
NativeMethods.GetSystemMetrics( SM.CXSMICON ),
NativeMethods.GetSystemMetrics( SM.CYSMICON ) );
}
private void _UpdateSmallIconSize( IntPtr wParam, IntPtr lParam )
{
_InitializeSmallIconSize();
}
private void _LegacyInitializeCaptionButtonLocation()
{
// This calculation isn't quite right, but it's pretty close.
// I expect this is good enough for the scenarios where this is expected to be used.
int captionX = NativeMethods.GetSystemMetrics( SM.CXSIZE );
int captionY = NativeMethods.GetSystemMetrics( SM.CYSIZE );
int frameX = NativeMethods.GetSystemMetrics( SM.CXSIZEFRAME ) + NativeMethods.GetSystemMetrics( SM.CXEDGE );
int frameY = NativeMethods.GetSystemMetrics( SM.CYSIZEFRAME ) + NativeMethods.GetSystemMetrics( SM.CYEDGE );
Rect captionRect = new Rect( 0, 0, captionX * 3, captionY );
captionRect.Offset( -frameX - captionRect.Width, frameY );
WindowCaptionButtonsLocation = captionRect;
}
[SuppressMessage( "Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands" )]
private void _InitializeCaptionButtonLocation()
{
// There is a completely different way to do this on XP.
if( !Utility.IsOSVistaOrNewer || !NativeMethods.IsThemeActive() )
{
_LegacyInitializeCaptionButtonLocation();
return;
}
var tbix = new TITLEBARINFOEX { cbSize = Marshal.SizeOf( typeof( TITLEBARINFOEX ) ) };
IntPtr lParam = Marshal.AllocHGlobal( tbix.cbSize );
try
{
Marshal.StructureToPtr( tbix, lParam, false );
// This might flash a window in the taskbar while being calculated.
// WM_GETTITLEBARINFOEX doesn't work correctly unless the window is visible while processing.
NativeMethods.ShowWindow( _messageHwnd.Handle, SW.SHOW );
NativeMethods.SendMessage( _messageHwnd.Handle, WM.GETTITLEBARINFOEX, IntPtr.Zero, lParam );
tbix = ( TITLEBARINFOEX )Marshal.PtrToStructure( lParam, typeof( TITLEBARINFOEX ) );
}
finally
{
NativeMethods.ShowWindow( _messageHwnd.Handle, SW.HIDE );
Utility.SafeFreeHGlobal( ref lParam );
}
// TITLEBARINFOEX has information relative to the screen. We need to convert the containing rect
// to instead be relative to the top-right corner of the window.
RECT rcAllCaptionButtons = RECT.Union( tbix.rgrect_CloseButton, tbix.rgrect_MinimizeButton );
// For all known themes, the RECT for the maximize box shouldn't add anything to the union of the minimize and close boxes.
Assert.AreEqual( rcAllCaptionButtons, RECT.Union( rcAllCaptionButtons, tbix.rgrect_MaximizeButton ) );
RECT rcWindow = NativeMethods.GetWindowRect( _messageHwnd.Handle );
// Reorient the Top/Right to be relative to the top right edge of the Window.
var deviceCaptionLocation = new Rect(
rcAllCaptionButtons.Left - rcWindow.Width - rcWindow.Left,
rcAllCaptionButtons.Top - rcWindow.Top,
rcAllCaptionButtons.Width,
rcAllCaptionButtons.Height );
Rect logicalCaptionLocation = DpiHelper.DeviceRectToLogical( deviceCaptionLocation );
WindowCaptionButtonsLocation = logicalCaptionLocation;
}
private void _UpdateCaptionButtonLocation( IntPtr wParam, IntPtr lParam )
{
_InitializeCaptionButtonLocation();
}
private void _InitializeHighContrast()
{
HIGHCONTRAST hc = NativeMethods.SystemParameterInfo_GetHIGHCONTRAST();
HighContrast = ( hc.dwFlags & HCF.HIGHCONTRASTON ) != 0;
}
private void _UpdateHighContrast( IntPtr wParam, IntPtr lParam )
{
_InitializeHighContrast();
}
private void _InitializeThemeInfo()
{
if( !NativeMethods.IsThemeActive() )
{
UxThemeName = "Classic";
UxThemeColor = "";
return;
}
string name;
string color;
string size;
NativeMethods.GetCurrentThemeName( out name, out color, out size );
// Consider whether this is the most useful way to expose this...
UxThemeName = System.IO.Path.GetFileNameWithoutExtension( name );
UxThemeColor = color;
}
private void _UpdateThemeInfo( IntPtr wParam, IntPtr lParam )
{
_InitializeThemeInfo();
}
private void _InitializeWindowCornerRadius()
{
// The radius of window corners isn't exposed as a true system parameter.
// It instead is a logical size that we're approximating based on the current theme.
// There aren't any known variations based on theme color.
Assert.IsNeitherNullNorEmpty( UxThemeName );
// These radii are approximate. The way WPF does rounding is different than how
// rounded-rectangle HRGNs are created, which is also different than the actual
// round corners on themed Windows. For now we're not exposing anything to
// mitigate the differences.
var cornerRadius = default( CornerRadius );
// This list is known to be incomplete and very much not future-proof.
// On XP there are at least a couple of shipped themes that this won't catch,
// "Zune" and "Royale", but WPF doesn't know about these either.
// If a new theme was to replace Aero, then this will fall back on "classic" behaviors.
// This isn't ideal, but it's not the end of the world. WPF will generally have problems anyways.
switch( UxThemeName.ToUpperInvariant() )
{
case "LUNA":
cornerRadius = new CornerRadius( 6, 6, 0, 0 );
break;
case "AERO":
// Aero has two cases. One with glass and one without...
if( NativeMethods.DwmIsCompositionEnabled() )
{
cornerRadius = new CornerRadius( 8 );
}
else
{
cornerRadius = new CornerRadius( 6, 6, 0, 0 );
}
break;
case "CLASSIC":
case "ZUNE":
case "ROYALE":
default:
cornerRadius = new CornerRadius( 0 );
break;
}
WindowCornerRadius = cornerRadius;
}
private void _UpdateWindowCornerRadius( IntPtr wParam, IntPtr lParam )
{
// Neither the wParam or lParam are used in this case.
_InitializeWindowCornerRadius();
}
#endregion
/// <summary>
/// Private constructor. The public way to access this class is through the static Current property.
/// </summary>
private SystemParameters2()
{
// This window gets used for calculations about standard caption button locations
// so it has WS_OVERLAPPEDWINDOW as a style to give it normal caption buttons.
// This window may be shown during calculations of caption bar information, so create it at a location that's likely offscreen.
_messageHwnd = new MessageWindow( ( CS )0, WS.OVERLAPPEDWINDOW | WS.DISABLED, ( WS_EX )0, new Rect( -16000, -16000, 100, 100 ), "", _WndProc );
_messageHwnd.Dispatcher.ShutdownStarted += ( sender, e ) => Utility.SafeDispose( ref _messageHwnd );
// Fixup the default values of the DPs.
_InitializeIsGlassEnabled();
_InitializeGlassColor();
_InitializeCaptionHeight();
_InitializeWindowNonClientFrameThickness();
_InitializeWindowResizeBorderThickness();
_InitializeCaptionButtonLocation();
_InitializeSmallIconSize();
_InitializeHighContrast();
_InitializeThemeInfo();
// WindowCornerRadius isn't exposed by true system parameters, so it requires the theme to be initialized first.
_InitializeWindowCornerRadius();
_UpdateTable = new Dictionary<WM, List<_SystemMetricUpdate>>
{
{ WM.THEMECHANGED,
new List<_SystemMetricUpdate>
{
_UpdateThemeInfo,
_UpdateHighContrast,
_UpdateWindowCornerRadius,
_UpdateCaptionButtonLocation, } },
{ WM.SETTINGCHANGE,
new List<_SystemMetricUpdate>
{
_UpdateCaptionHeight,
_UpdateWindowResizeBorderThickness,
_UpdateSmallIconSize,
_UpdateHighContrast,
_UpdateWindowNonClientFrameThickness,
_UpdateCaptionButtonLocation, } },
{ WM.DWMNCRENDERINGCHANGED, new List<_SystemMetricUpdate> { _UpdateIsGlassEnabled } },
{ WM.DWMCOMPOSITIONCHANGED, new List<_SystemMetricUpdate> { _UpdateIsGlassEnabled } },
{ WM.DWMCOLORIZATIONCOLORCHANGED, new List<_SystemMetricUpdate> { _UpdateGlassColor } },
};
}
public static SystemParameters2 Current
{
get
{
if( _threadLocalSingleton == null )
{
_threadLocalSingleton = new SystemParameters2();
}
return _threadLocalSingleton;
}
}
private IntPtr _WndProc( IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam )
{
// Don't do this if called within the SystemParameters2 constructor
if( _UpdateTable != null )
{
List<_SystemMetricUpdate> handlers;
if( _UpdateTable.TryGetValue( msg, out handlers ) )
{
Assert.IsNotNull( handlers );
foreach( var handler in handlers )
{
handler( wParam, lParam );
}
}
}
return NativeMethods.DefWindowProc( hwnd, msg, wParam, lParam );
}
public bool IsGlassEnabled
{
get
{
// return _isGlassEnabled;
// It turns out there may be some lag between someone asking this
// and the window getting updated. It's not too expensive, just always do the check.
return NativeMethods.DwmIsCompositionEnabled();
}
private set
{
if( value != _isGlassEnabled )
{
_isGlassEnabled = value;
_NotifyPropertyChanged( "IsGlassEnabled" );
}
}
}
public Color WindowGlassColor
{
get
{
return _glassColor;
}
private set
{
if( value != _glassColor )
{
_glassColor = value;
_NotifyPropertyChanged( "WindowGlassColor" );
}
}
}
public SolidColorBrush WindowGlassBrush
{
get
{
return _glassColorBrush;
}
private set
{
Assert.IsNotNull( value );
Assert.IsTrue( value.IsFrozen );
if( _glassColorBrush == null || value.Color != _glassColorBrush.Color )
{
_glassColorBrush = value;
_NotifyPropertyChanged( "WindowGlassBrush" );
}
}
}
public Thickness WindowResizeBorderThickness
{
get
{
return _windowResizeBorderThickness;
}
private set
{
if( value != _windowResizeBorderThickness )
{
_windowResizeBorderThickness = value;
_NotifyPropertyChanged( "WindowResizeBorderThickness" );
}
}
}
public Thickness WindowNonClientFrameThickness
{
get
{
return _windowNonClientFrameThickness;
}
private set
{
if( value != _windowNonClientFrameThickness )
{
_windowNonClientFrameThickness = value;
_NotifyPropertyChanged( "WindowNonClientFrameThickness" );
}
}
}
public double WindowCaptionHeight
{
get
{
return _captionHeight;
}
private set
{
if( value != _captionHeight )
{
_captionHeight = value;
_NotifyPropertyChanged( "WindowCaptionHeight" );
}
}
}
public Size SmallIconSize
{
get
{
return new Size( _smallIconSize.Width, _smallIconSize.Height );
}
private set
{
if( value != _smallIconSize )
{
_smallIconSize = value;
_NotifyPropertyChanged( "SmallIconSize" );
}
}
}
[SuppressMessage( "Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ux" )]
[SuppressMessage( "Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ux" )]
public string UxThemeName
{
get
{
return _uxThemeName;
}
private set
{
if( value != _uxThemeName )
{
_uxThemeName = value;
_NotifyPropertyChanged( "UxThemeName" );
}
}
}
[SuppressMessage( "Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ux" )]
[SuppressMessage( "Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ux" )]
public string UxThemeColor
{
get
{
return _uxThemeColor;
}
private set
{
if( value != _uxThemeColor )
{
_uxThemeColor = value;
_NotifyPropertyChanged( "UxThemeColor" );
}
}
}
public bool HighContrast
{
get
{
return _isHighContrast;
}
private set
{
if( value != _isHighContrast )
{
_isHighContrast = value;
_NotifyPropertyChanged( "HighContrast" );
}
}
}
public CornerRadius WindowCornerRadius
{
get
{
return _windowCornerRadius;
}
private set
{
if( value != _windowCornerRadius )
{
_windowCornerRadius = value;
_NotifyPropertyChanged( "WindowCornerRadius" );
}
}
}
public Rect WindowCaptionButtonsLocation
{
get
{
return _captionButtonLocation;
}
private set
{
if( value != _captionButtonLocation )
{
_captionButtonLocation = value;
_NotifyPropertyChanged( "WindowCaptionButtonsLocation" );
}
}
}
#region INotifyPropertyChanged Members
private void _NotifyPropertyChanged( string propertyName )
{
Assert.IsNeitherNullNorEmpty( propertyName );
var handler = PropertyChanged;
if( handler != null )
{
handler( this, new PropertyChangedEventArgs( propertyName ) );
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
}

303
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/WindowChrome.cs

@ -1,303 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
/**************************************************************************\
Copyright Microsoft Corporation. All Rights Reserved.
\**************************************************************************/
namespace Microsoft.Windows.Shell
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Data;
using Standard;
public class WindowChrome : Freezable
{
private struct _SystemParameterBoundProperty
{
public string SystemParameterPropertyName
{
get; set;
}
public DependencyProperty DependencyProperty
{
get; set;
}
}
// Named property available for fully extending the glass frame.
public static Thickness GlassFrameCompleteThickness
{
get
{
return new Thickness( -1 );
}
}
#region Attached Properties
public static readonly DependencyProperty WindowChromeProperty = DependencyProperty.RegisterAttached(
"WindowChrome",
typeof( WindowChrome ),
typeof( WindowChrome ),
new PropertyMetadata( null, _OnChromeChanged ) );
private static void _OnChromeChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
// The different design tools handle drawing outside their custom window objects differently.
// Rather than try to support this concept in the design surface let the designer draw its own
// chrome anyways.
// There's certainly room for improvement here.
if( System.ComponentModel.DesignerProperties.GetIsInDesignMode( d ) )
{
return;
}
var window = ( Window )d;
var newChrome = ( WindowChrome )e.NewValue;
Assert.IsNotNull( window );
// Update the ChromeWorker with this new object.
// If there isn't currently a worker associated with the Window then assign a new one.
// There can be a many:1 relationship of to Window to WindowChrome objects, but a 1:1 for a Window and a WindowChromeWorker.
WindowChromeWorker chromeWorker = WindowChromeWorker.GetWindowChromeWorker( window );
if( chromeWorker == null )
{
chromeWorker = new WindowChromeWorker();
WindowChromeWorker.SetWindowChromeWorker( window, chromeWorker );
}
chromeWorker.SetWindowChrome( newChrome );
}
[SuppressMessage( "Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0" )]
[SuppressMessage( "Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters" )]
public static WindowChrome GetWindowChrome( Window window )
{
Verify.IsNotNull( window, "window" );
return ( WindowChrome )window.GetValue( WindowChromeProperty );
}
[SuppressMessage( "Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0" )]
[SuppressMessage( "Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters" )]
public static void SetWindowChrome( Window window, WindowChrome chrome )
{
Verify.IsNotNull( window, "window" );
window.SetValue( WindowChromeProperty, chrome );
}
public static readonly DependencyProperty IsHitTestVisibleInChromeProperty = DependencyProperty.RegisterAttached(
"IsHitTestVisibleInChrome",
typeof( bool ),
typeof( WindowChrome ),
new FrameworkPropertyMetadata( false, FrameworkPropertyMetadataOptions.Inherits ) );
[SuppressMessage( "Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0" )]
[SuppressMessage( "Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters" )]
public static bool GetIsHitTestVisibleInChrome( IInputElement inputElement )
{
Verify.IsNotNull( inputElement, "inputElement" );
var dobj = inputElement as DependencyObject;
if( dobj == null )
{
throw new ArgumentException( "The element must be a DependencyObject", "inputElement" );
}
return ( bool )dobj.GetValue( IsHitTestVisibleInChromeProperty );
}
[SuppressMessage( "Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0" )]
[SuppressMessage( "Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters" )]
public static void SetIsHitTestVisibleInChrome( IInputElement inputElement, bool hitTestVisible )
{
Verify.IsNotNull( inputElement, "inputElement" );
var dobj = inputElement as DependencyObject;
if( dobj == null )
{
throw new ArgumentException( "The element must be a DependencyObject", "inputElement" );
}
dobj.SetValue( IsHitTestVisibleInChromeProperty, hitTestVisible );
}
#endregion
#region Dependency Properties
public static readonly DependencyProperty CaptionHeightProperty = DependencyProperty.Register(
"CaptionHeight",
typeof( double ),
typeof( WindowChrome ),
new PropertyMetadata(
0d,
( d, e ) => ( ( WindowChrome )d )._OnPropertyChangedThatRequiresRepaint() ),
value => ( double )value >= 0d );
/// <summary>The extent of the top of the window to treat as the caption.</summary>
public double CaptionHeight
{
get
{
return ( double )GetValue( CaptionHeightProperty );
}
set
{
SetValue( CaptionHeightProperty, value );
}
}
public static readonly DependencyProperty ResizeBorderThicknessProperty = DependencyProperty.Register(
"ResizeBorderThickness",
typeof( Thickness ),
typeof( WindowChrome ),
new PropertyMetadata( default( Thickness ) ),
( value ) => Utility.IsThicknessNonNegative( ( Thickness )value ) );
public Thickness ResizeBorderThickness
{
get
{
return ( Thickness )GetValue( ResizeBorderThicknessProperty );
}
set
{
SetValue( ResizeBorderThicknessProperty, value );
}
}
public static readonly DependencyProperty GlassFrameThicknessProperty = DependencyProperty.Register(
"GlassFrameThickness",
typeof( Thickness ),
typeof( WindowChrome ),
new PropertyMetadata(
default( Thickness ),
( d, e ) => ( ( WindowChrome )d )._OnPropertyChangedThatRequiresRepaint(),
( d, o ) => _CoerceGlassFrameThickness( ( Thickness )o ) ) );
private static object _CoerceGlassFrameThickness( Thickness thickness )
{
// If it's explicitly set, but set to a thickness with at least one negative side then
// coerce the value to the stock GlassFrameCompleteThickness.
if( !Utility.IsThicknessNonNegative( thickness ) )
{
return GlassFrameCompleteThickness;
}
return thickness;
}
public Thickness GlassFrameThickness
{
get
{
return ( Thickness )GetValue( GlassFrameThicknessProperty );
}
set
{
SetValue( GlassFrameThicknessProperty, value );
}
}
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
"CornerRadius",
typeof( CornerRadius ),
typeof( WindowChrome ),
new PropertyMetadata(
default( CornerRadius ),
( d, e ) => ( ( WindowChrome )d )._OnPropertyChangedThatRequiresRepaint() ),
( value ) => Utility.IsCornerRadiusValid( ( CornerRadius )value ) );
public CornerRadius CornerRadius
{
get
{
return ( CornerRadius )GetValue( CornerRadiusProperty );
}
set
{
SetValue( CornerRadiusProperty, value );
}
}
#region ShowSystemMenu
/// <summary>
/// Gets or sets the ShowSystemMenu property. This dependency property
/// indicates if the system menu should be shown at right click on the caption.
/// </summary>
public bool ShowSystemMenu
{
get;
set;
}
#endregion
#endregion
protected override Freezable CreateInstanceCore()
{
return new WindowChrome();
}
private static readonly List<_SystemParameterBoundProperty> _BoundProperties = new List<_SystemParameterBoundProperty>
{
new _SystemParameterBoundProperty { DependencyProperty = CornerRadiusProperty, SystemParameterPropertyName = "WindowCornerRadius" },
new _SystemParameterBoundProperty { DependencyProperty = CaptionHeightProperty, SystemParameterPropertyName = "WindowCaptionHeight" },
new _SystemParameterBoundProperty { DependencyProperty = ResizeBorderThicknessProperty, SystemParameterPropertyName = "WindowResizeBorderThickness" },
new _SystemParameterBoundProperty { DependencyProperty = GlassFrameThicknessProperty, SystemParameterPropertyName = "WindowNonClientFrameThickness" },
};
public WindowChrome()
{
// Effective default values for some of these properties are set to be bindings
// that set them to system defaults.
// A more correct way to do this would be to Coerce the value iff the source of the DP was the default value.
// Unfortunately with the current property system we can't detect whether the value being applied at the time
// of the coersion is the default.
foreach( var bp in _BoundProperties )
{
// This list must be declared after the DP's are assigned.
Assert.IsNotNull( bp.DependencyProperty );
BindingOperations.SetBinding(
this,
bp.DependencyProperty,
new Binding
{
Source = SystemParameters2.Current,
Path = new PropertyPath( bp.SystemParameterPropertyName ),
Mode = BindingMode.OneWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
} );
}
}
private void _OnPropertyChangedThatRequiresRepaint()
{
var handler = PropertyChangedThatRequiresRepaint;
if( handler != null )
{
handler( this, EventArgs.Empty );
}
}
internal event EventHandler PropertyChangedThatRequiresRepaint;
}
}

1228
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/Shell/WindowChromeWorker.cs

File diff suppressed because it is too large

120
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/TransformExtentions.cs

@ -1,120 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.Windows;
using System.Windows.Media;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal static class TransformExtensions
{
public static Point PointToScreenDPI( this Visual visual, Point pt )
{
Point resultPt = visual.PointToScreen( pt );
return TransformToDeviceDPI( visual, resultPt );
}
public static Point PointToScreenDPIWithoutFlowDirection( this FrameworkElement element, Point point )
{
if( FrameworkElement.GetFlowDirection( element ) == FlowDirection.RightToLeft )
{
var actualSize = element.TransformActualSizeToAncestor();
Point leftToRightPoint = new Point(
actualSize.Width - point.X,
point.Y );
return element.PointToScreenDPI( leftToRightPoint );
}
return element.PointToScreenDPI( point );
}
public static Rect GetScreenArea( this FrameworkElement element )
{
// return new Rect(element.PointToScreenDPI(new Point()),
// element.TransformActualSizeToAncestor());
//}
//public static Rect GetScreenAreaWithoutFlowDirection(this FrameworkElement element)
//{
var point = element.PointToScreenDPI( new Point() );
if( FrameworkElement.GetFlowDirection( element ) == FlowDirection.RightToLeft )
{
var actualSize = element.TransformActualSizeToAncestor();
Point leftToRightPoint = new Point(
actualSize.Width - point.X,
point.Y );
return new Rect( leftToRightPoint,
actualSize );
}
return new Rect( point,
element.TransformActualSizeToAncestor() );
}
public static Point TransformToDeviceDPI( this Visual visual, Point pt )
{
Matrix m = PresentationSource.FromVisual( visual ).CompositionTarget.TransformToDevice;
return new Point( pt.X / m.M11, pt.Y / m.M22 );
}
public static Size TransformFromDeviceDPI( this Visual visual, Size size )
{
Matrix m = PresentationSource.FromVisual( visual ).CompositionTarget.TransformToDevice;
return new Size( size.Width * m.M11, size.Height * m.M22 );
}
public static Point TransformFromDeviceDPI( this Visual visual, Point pt )
{
Matrix m = PresentationSource.FromVisual( visual ).CompositionTarget.TransformToDevice;
return new Point( pt.X * m.M11, pt.Y * m.M22 );
}
public static bool CanTransform( this Visual visual )
{
return PresentationSource.FromVisual( visual ) != null;
}
public static Size TransformActualSizeToAncestor( this FrameworkElement element )
{
if( PresentationSource.FromVisual( element ) == null )
return new Size( element.ActualWidth, element.ActualHeight );
var parentWindow = PresentationSource.FromVisual( element ).RootVisual;
var transformToWindow = element.TransformToAncestor( parentWindow );
return transformToWindow.TransformBounds( new Rect( 0, 0, element.ActualWidth, element.ActualHeight ) ).Size;
}
public static Size TransformSizeToAncestor( this FrameworkElement element, Size sizeToTransform )
{
if( PresentationSource.FromVisual( element ) == null )
return sizeToTransform;
var parentWindow = PresentationSource.FromVisual( element ).RootVisual;
var transformToWindow = element.TransformToAncestor( parentWindow );
return transformToWindow.TransformBounds( new Rect( 0, 0, sizeToTransform.Width, sizeToTransform.Height ) ).Size;
}
public static GeneralTransform TansformToAncestor( this FrameworkElement element )
{
if( PresentationSource.FromVisual( element ) == null )
return new MatrixTransform( Matrix.Identity );
var parentWindow = PresentationSource.FromVisual( element ).RootVisual;
return element.TransformToAncestor( parentWindow );
}
}
}

108
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/WeakDictionary.cs

@ -1,108 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class WeakDictionary<K, V> where K : class
{
#region Members
private List<WeakReference> _keys = new List<WeakReference>();
private List<V> _values = new List<V>();
#endregion
#region constructors
public WeakDictionary()
{
}
#endregion
#region Public Methods
public V this[ K key ]
{
get
{
V valueToReturn;
if( !GetValue( key, out valueToReturn ) )
throw new ArgumentException();
return valueToReturn;
}
set
{
SetValue( key, value );
}
}
public bool ContainsKey( K key )
{
CollectGarbage();
return -1 != _keys.FindIndex( k => k.GetValueOrDefault<K>() == key );
}
public void SetValue( K key, V value )
{
CollectGarbage();
int vIndex = _keys.FindIndex( k => k.GetValueOrDefault<K>() == key );
if( vIndex > -1 )
_values[ vIndex ] = value;
else
{
_values.Add( value );
_keys.Add( new WeakReference( key ) );
}
}
public bool GetValue( K key, out V value )
{
CollectGarbage();
int vIndex = _keys.FindIndex( k => k.GetValueOrDefault<K>() == key );
value = default( V );
if( vIndex == -1 )
return false;
value = _values[ vIndex ];
return true;
}
#endregion
#region Private Methods
private void CollectGarbage()
{
int vIndex = 0;
do
{
vIndex = _keys.FindIndex( vIndex, k => !k.IsAlive );
if( vIndex >= 0 )
{
_keys.RemoveAt( vIndex );
_values.RemoveAt( vIndex );
}
}
while( vIndex >= 0 );
}
#endregion
}
}

42
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/WindowActivateEventArgs.cs

@ -1,42 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class WindowActivateEventArgs : EventArgs
{
#region Constructors
public WindowActivateEventArgs( IntPtr hwndActivating )
{
HwndActivating = hwndActivating;
}
#endregion
#region Properties
public IntPtr HwndActivating
{
get;
private set;
}
#endregion
}
}

116
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/WindowHookHandler.cs

@ -1,116 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
namespace Xceed.Wpf.AvalonDock.Controls
{
internal class FocusChangeEventArgs : EventArgs
{
#region Constructors
public FocusChangeEventArgs( IntPtr gotFocusWinHandle, IntPtr lostFocusWinHandle )
{
GotFocusWinHandle = gotFocusWinHandle;
LostFocusWinHandle = lostFocusWinHandle;
}
#endregion
#region Properties
public IntPtr GotFocusWinHandle
{
get;
private set;
}
public IntPtr LostFocusWinHandle
{
get;
private set;
}
#endregion
}
internal class WindowHookHandler
{
#region Members
private IntPtr _windowHook;
private Win32Helper.HookProc _hookProc;
private ReentrantFlag _insideActivateEvent = new ReentrantFlag();
#endregion
#region Constructors
public WindowHookHandler()
{
}
#endregion
#region Public Methods
public void Attach()
{
_hookProc = new Win32Helper.HookProc( this.HookProc );
_windowHook = Win32Helper.SetWindowsHookEx(
Win32Helper.HookType.WH_CBT,
_hookProc,
IntPtr.Zero,
( int )Win32Helper.GetCurrentThreadId() );
}
public void Detach()
{
Win32Helper.UnhookWindowsHookEx( _windowHook );
}
public int HookProc( int code, IntPtr wParam, IntPtr lParam )
{
if( code == Win32Helper.HCBT_SETFOCUS )
{
if( FocusChanged != null )
FocusChanged( this, new FocusChangeEventArgs( wParam, lParam ) );
}
else if( code == Win32Helper.HCBT_ACTIVATE )
{
if( _insideActivateEvent.CanEnter )
{
using( _insideActivateEvent.Enter() )
{
//if (Activate != null)
// Activate(this, new WindowActivateEventArgs(wParam));
}
}
}
return Win32Helper.CallNextHookEx( _windowHook, code, wParam, lParam );
}
#endregion
#region Events
public event EventHandler<FocusChangeEventArgs> FocusChanged;
//public event EventHandler<WindowActivateEventArgs> Activate;
#endregion
}
}

48
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/ActivateCommandLayoutItemFromLayoutModelConverter.cs

@ -1,48 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class ActivateCommandLayoutItemFromLayoutModelConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
//when this converter is called layout could be constructing so many properties here are potentially not valid
var layoutModel = value as LayoutContent;
if( layoutModel == null )
return null;
if( layoutModel.Root == null )
return null;
if( layoutModel.Root.Manager == null )
return null;
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel( layoutModel );
if( layoutItemModel == null )
return Binding.DoNothing;
return layoutItemModel.ActivateCommand;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

41
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AnchorSideToAngleConverter.cs

@ -1,41 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Converters
{
[ValueConversion( typeof( AnchorSide ), typeof( double ) )]
public class AnchorSideToAngleConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
AnchorSide side = ( AnchorSide )value;
if( side == AnchorSide.Left ||
side == AnchorSide.Right )
return 90.0;
return Binding.DoNothing;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

42
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AnchorSideToOrientationConverter.cs

@ -1,42 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using System.Windows.Controls;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Converters
{
[ValueConversion( typeof( AnchorSide ), typeof( Orientation ) )]
public class AnchorSideToOrientationConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
AnchorSide side = ( AnchorSide )value;
if( side == AnchorSide.Left ||
side == AnchorSide.Right )
return Orientation.Vertical;
return Orientation.Horizontal;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

49
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AnchorableContextMenuHideVisibilityConverter.cs

@ -1,49 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class AnchorableContextMenuHideVisibilityConverter : IMultiValueConverter
{
public object Convert( object[] values, Type targetType, object parameter, CultureInfo culture )
{
if( ( values.Count() == 2 )
&& ( values[ 0 ] != DependencyProperty.UnsetValue )
&& ( values[ 1 ] != DependencyProperty.UnsetValue )
&& ( values[ 1 ] is bool ) )
{
var canClose = ( bool )values[ 1 ];
return canClose ? Visibility.Collapsed : values[ 0 ];
}
else
{
return values[ 0 ];
}
}
public object[] ConvertBack( object value, Type[] targetTypes, object parameter, CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

49
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/AutoHideCommandLayoutItemFromLayoutModelConverter.cs

@ -1,49 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
using Xceed.Wpf.AvalonDock.Controls;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class AutoHideCommandLayoutItemFromLayoutModelConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
//when this converter is called layout could be constructing so many properties here are potentially not valid
var layoutModel = value as LayoutContent;
if( layoutModel == null )
return null;
if( layoutModel.Root == null )
return null;
if( layoutModel.Root.Manager == null )
return null;
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel( layoutModel ) as LayoutAnchorableItem;
if( layoutItemModel == null )
return Binding.DoNothing;
return layoutItemModel.AutoHideCommand;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

87
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/BoolToVisibilityConverter.cs

@ -1,87 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Converters
{
[ValueConversion( typeof( bool ), typeof( Visibility ) )]
public class BoolToVisibilityConverter : IValueConverter
{
#region IValueConverter Members
/// <summary>
/// Converts a value.
/// </summary>
/// <param name="value">The value produced by the binding source.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value is bool && targetType == typeof( Visibility ) )
{
bool val = ( bool )value;
if( val )
return Visibility.Visible;
else
if( parameter != null && parameter is Visibility )
return parameter;
else
return Visibility.Collapsed;
}
if( value == null )
{
if( parameter != null && parameter is Visibility )
return parameter;
else
return Visibility.Collapsed;
}
return Visibility.Visible;
///throw new ArgumentException("Invalid argument/return type. Expected argument: bool and return type: Visibility");
}
/// <summary>
/// Converts a value.
/// </summary>
/// <param name="value">The value that is produced by the binding target.</param>
/// <param name="targetType">The type to convert to.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value is Visibility && targetType == typeof( bool ) )
{
Visibility val = ( Visibility )value;
if( val == Visibility.Visible )
return true;
else
return false;
}
throw new ArgumentException( "Invalid argument/return type. Expected argument: Visibility and return type: bool" );
}
#endregion
}
}

49
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/HideCommandLayoutItemFromLayoutModelConverter.cs

@ -1,49 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
using Xceed.Wpf.AvalonDock.Controls;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class HideCommandLayoutItemFromLayoutModelConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
//when this converter is called layout could be constructing so many properties here are potentially not valid
var layoutModel = value as LayoutContent;
if( layoutModel == null )
return null;
if( layoutModel.Root == null )
return null;
if( layoutModel.Root.Manager == null )
return null;
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel( layoutModel ) as LayoutAnchorableItem;
if( layoutItemModel == null )
return Binding.DoNothing;
return layoutItemModel.HideCommand;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

78
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/InverseBoolToVisibilityConverter.cs

@ -1,78 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using System.Windows;
namespace Xceed.Wpf.AvalonDock.Converters
{
[ValueConversion( typeof( bool ), typeof( Visibility ) )]
public class InverseBoolToVisibilityConverter : IValueConverter
{
#region IValueConverter Members
/// <summary>
/// Converts a value.
/// </summary>
/// <param name="value">The value produced by the binding source.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value is bool && targetType == typeof( Visibility ) )
{
bool val = !( bool )value;
if( val )
return Visibility.Visible;
else
if( parameter != null && parameter is Visibility )
return parameter;
else
return Visibility.Collapsed;
}
throw new ArgumentException( "Invalid argument/return type. Expected argument: bool and return type: Visibility" );
}
/// <summary>
/// Converts a value.
/// </summary>
/// <param name="value">The value that is produced by the binding target.</param>
/// <param name="targetType">The type to convert to.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value is Visibility && targetType == typeof( bool ) )
{
Visibility val = ( Visibility )value;
if( val == Visibility.Visible )
return false;
else
return true;
}
throw new ArgumentException( "Invalid argument/return type. Expected argument: Visibility and return type: bool" );
}
#endregion
}
}

47
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/LayoutItemFromLayoutModelConverter.cs

@ -1,47 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class LayoutItemFromLayoutModelConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
var layoutModel = value as LayoutContent;
if( layoutModel == null )
return null;
if( layoutModel.Root == null )
return null;
if( layoutModel.Root.Manager == null )
return null;
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel( layoutModel );
if( layoutItemModel == null )
return Binding.DoNothing;
return layoutItemModel;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

37
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/NullToDoNothingConverter.cs

@ -1,37 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class NullToDoNothingConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value == null )
return Binding.DoNothing;
return value;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

39
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Converters/UriSourceToBitmapImageConverter.cs

@ -1,39 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
namespace Xceed.Wpf.AvalonDock.Converters
{
public class UriSourceToBitmapImageConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value == null )
return Binding.DoNothing;
//return (Uri)value;
return new Image() { Source = new BitmapImage( ( Uri )value ) };
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
throw new NotImplementedException();
}
}
}

3324
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DockingManager.cs

File diff suppressed because it is too large

35
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DocumentClosedEventArgs.cs

@ -1,35 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock
{
public class DocumentClosedEventArgs : EventArgs
{
public DocumentClosedEventArgs( LayoutDocument document )
{
Document = document;
}
public LayoutDocument Document
{
get;
private set;
}
}
}

35
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DocumentClosingEventArgs.cs

@ -1,35 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System.ComponentModel;
using Xceed.Wpf.AvalonDock.Layout;
namespace Xceed.Wpf.AvalonDock
{
public class DocumentClosingEventArgs : CancelEventArgs
{
public DocumentClosingEventArgs( LayoutDocument document )
{
Document = document;
}
public LayoutDocument Document
{
get;
private set;
}
}
}

58
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Extentions.cs

@ -1,58 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Collections;
namespace Xceed.Wpf.AvalonDock
{
internal static class Extensions
{
public static bool Contains( this IEnumerable collection, object item )
{
foreach( var o in collection )
if( o == item )
return true;
return false;
}
public static void ForEach<T>( this IEnumerable<T> collection, Action<T> action )
{
foreach( T v in collection )
action( v );
}
public static int IndexOf<T>( this T[] array, T value ) where T : class
{
for( int i = 0; i < array.Length; i++ )
if( array[ i ] == value )
return i;
return -1;
}
public static V GetValueOrDefault<V>( this WeakReference wr )
{
if( wr == null || !wr.IsAlive )
return default( V );
return ( V )wr.Target;
}
}
}

26
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/AnchorSide.cs

@ -1,26 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
namespace Xceed.Wpf.AvalonDock.Layout
{
public enum AnchorSide
{
Left,
Top,
Right,
Bottom
}
}

30
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/AnchorableShowStrategy.cs

@ -1,30 +0,0 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
namespace Xceed.Wpf.AvalonDock.Layout
{
[Flags]
public enum AnchorableShowStrategy : byte
{
Most = 0x0001,
Left = 0x0002,
Right = 0x0004,
Top = 0x0010,
Bottom = 0x0020,
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save