Init
2
Libs/READ_ME.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
The file Xceed.Wpf.Samples.SampleData.dll has been created from Xceed.Silverlight.Samples.SampleData.dll of the Silverlight ListBox.
|
||||
Only the Silverlight has been changed to Wpf.
|
||||
BIN
Libs/Xceed.Wpf.Samples.SampleData.dll
Normal file
32
Src/Xceed.Wpf.AvalonDock.Themes.Metro/AssemblyVersionInfo.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.1";
|
||||
[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";
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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 = ".*";
|
||||
|
||||
}
|
||||
42
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Brushes.xaml
Normal file
@@ -0,0 +1,42 @@
|
||||
<!--***********************************************************************************
|
||||
|
||||
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
|
||||
|
||||
**********************************************************************************-->
|
||||
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor1"
|
||||
Color="White"/>
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor2"
|
||||
Color="Black"/>
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor3"
|
||||
Color="#41B1E1"/>
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor4"
|
||||
Color="#5EA1C0"/>
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor5"
|
||||
Color="#333333"/>
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor6"
|
||||
Color="#8C8E94"/>
|
||||
|
||||
<SolidColorBrush x:Key="AvalonDock_ThemeMetro_BaseColor7"
|
||||
Color="#EEEEEE"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/DockDocumentTop.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/DockPaneEmpty.png
Normal file
|
After Width: | Height: | Size: 946 B |
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/HTabGroup.png
Normal file
|
After Width: | Height: | Size: 358 B |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/Locked.png
Normal file
|
After Width: | Height: | Size: 357 B |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinAutoHide.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinClose.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinClose_Black.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinClose_Dark.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinDocMenu.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinMaximize.png
Normal file
|
After Width: | Height: | Size: 187 B |
|
After Width: | Height: | Size: 182 B |
|
After Width: | Height: | Size: 187 B |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinMenu.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinMenu_Black.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinMenu_Dark.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinRestore.png
Normal file
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 199 B |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/PinRestore_Dark.png
Normal file
|
After Width: | Height: | Size: 202 B |
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Images/VTabGroup.png
Normal file
|
After Width: | Height: | Size: 403 B |
33
Src/Xceed.Wpf.AvalonDock.Themes.Metro/MetroTheme.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Themes
|
||||
{
|
||||
public class MetroTheme : Theme
|
||||
{
|
||||
public override Uri GetResourceUri()
|
||||
{
|
||||
return new Uri(
|
||||
"/Xceed.Wpf.AvalonDock.Themes.Metro;component/Theme.xaml",
|
||||
UriKind.Relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle( "Xceed Toolkit for WPF - AvalonDock Metro Theme" )]
|
||||
[assembly: AssemblyDescription( "This assembly implements the Metro Theme for the AvalonDock layout system." )]
|
||||
|
||||
[assembly: AssemblyCompany( "Xceed Software Inc." )]
|
||||
[assembly: AssemblyProduct( "Xceed Toolkit for WPF - AvalonDock" )]
|
||||
[assembly: AssemblyCopyright( "Copyright (C) Xceed Software Inc. 2007-2016" )]
|
||||
|
||||
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: CLSCompliant( true )]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
[assembly: XmlnsDefinition( "http://schemas.xceed.com/wpf/xaml/avalondock", "Xceed.Wpf.AvalonDock.Themes" )]
|
||||
|
||||
#pragma warning disable 1699
|
||||
[assembly: AssemblyDelaySign( false )]
|
||||
[assembly: AssemblyKeyFile( @"..\..\sn.snk" )]
|
||||
[assembly: AssemblyKeyName( "" )]
|
||||
#pragma warning restore 1699
|
||||
1489
Src/Xceed.Wpf.AvalonDock.Themes.Metro/Theme.xaml
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{89286EB4-B4A1-418C-839A-067B00F442D8}</ProjectGuid>
|
||||
<OutputType>library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Xceed.Wpf.AvalonDock.Themes.Metro</RootNamespace>
|
||||
<AssemblyName>Xceed.Wpf.AvalonDock.Themes.Metro</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyVersionInfo.cs" />
|
||||
<Compile Include="AssemblyVersionInfoCommon.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MetroTheme.cs" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Brushes.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Theme.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\DockAnchorableBottom.png" />
|
||||
<Resource Include="Images\DockAnchorableLeft.png" />
|
||||
<Resource Include="Images\DockAnchorableRight.png" />
|
||||
<Resource Include="Images\DockAnchorableTop.png" />
|
||||
<Resource Include="Images\DockDocumentAsAnchorableBottom.png" />
|
||||
<Resource Include="Images\DockDocumentAsAnchorableLeft.png" />
|
||||
<Resource Include="Images\DockDocumentAsAnchorableRight.png" />
|
||||
<Resource Include="Images\DockDocumentAsAnchorableTop.png" />
|
||||
<Resource Include="Images\DockDocumentBottom.png" />
|
||||
<Resource Include="Images\DockDocumentInside.png" />
|
||||
<Resource Include="Images\DockDocumentLeft.png" />
|
||||
<Resource Include="Images\DockDocumentRight.png" />
|
||||
<Resource Include="Images\DockDocumentTop.png" />
|
||||
<Resource Include="Images\DockPaneEmpty.png" />
|
||||
<Resource Include="Images\DockPaneLargeEmpty.png" />
|
||||
<Resource Include="Images\HTabGroup.png" />
|
||||
<Resource Include="Images\Locked.png" />
|
||||
<Resource Include="Images\PinAutoHide.png" />
|
||||
<Resource Include="Images\PinAutoHide_Black.png" />
|
||||
<Resource Include="Images\PinAutoHide_Dark.png" />
|
||||
<Resource Include="Images\PinClose.png" />
|
||||
<Resource Include="Images\PinClose_Black.png" />
|
||||
<Resource Include="Images\PinClose_Dark.png" />
|
||||
<Resource Include="Images\PinDocMenu.png" />
|
||||
<Resource Include="Images\PinDocMenu_Black.png" />
|
||||
<Resource Include="Images\PinMaximize.png" />
|
||||
<Resource Include="Images\PinMaximize_Black.png" />
|
||||
<Resource Include="Images\PinMaximize_Dark.png" />
|
||||
<Resource Include="Images\PinMenu.png" />
|
||||
<Resource Include="Images\PinMenu_Black.png" />
|
||||
<Resource Include="Images\PinMenu_Dark.png" />
|
||||
<Resource Include="Images\PinRestore.png" />
|
||||
<Resource Include="Images\PinRestore_Black.png" />
|
||||
<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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/obj/Debug/Brushes.baml
Normal file
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/obj/Debug/Theme.baml
Normal file
@@ -0,0 +1,22 @@
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\Xceed.Wpf.AvalonDock.Themes.Metro.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\Xceed.Wpf.AvalonDock.Themes.Metro.pdb
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\Xceed.Wpf.AvalonDock.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\Xceed.Wpf.AvalonDock.pdb
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\de\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\es\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\fr\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\hu\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\it\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\pt-BR\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\ro\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\ru\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\sv\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\bin\Debug\zh-Hans\Xceed.Wpf.AvalonDock.resources.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Xceed.Wpf.AvalonDock.Themes.Metro.csprojResolveAssemblyReference.cache
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Brushes.baml
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Xceed.Wpf.AvalonDock.Themes.Metro_MarkupCompile.cache
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Xceed.Wpf.AvalonDock.Themes.Metro_MarkupCompile.lref
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Theme.baml
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Xceed.Wpf.AvalonDock.Themes.Metro.g.resources
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Xceed.Wpf.AvalonDock.Themes.Metro.dll
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\Xceed.Wpf.AvalonDock.Themes.Metro.pdb
|
||||
@@ -0,0 +1,20 @@
|
||||
Xceed.Wpf.AvalonDock.Themes.Metro
|
||||
|
||||
|
||||
library
|
||||
C#
|
||||
.cs
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\
|
||||
Xceed.Wpf.AvalonDock.Themes.Metro
|
||||
none
|
||||
false
|
||||
DEBUG;TRACE
|
||||
|
||||
2-109355679
|
||||
|
||||
4559672327
|
||||
1335344989
|
||||
Brushes.xaml;Theme.xaml;
|
||||
|
||||
False
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Xceed.Wpf.AvalonDock.Themes.Metro
|
||||
|
||||
|
||||
library
|
||||
C#
|
||||
.cs
|
||||
C:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\obj\Debug\
|
||||
Xceed.Wpf.AvalonDock.Themes.Metro
|
||||
none
|
||||
false
|
||||
DEBUG;TRACE
|
||||
|
||||
2-109355679
|
||||
|
||||
8-649181370
|
||||
1335344989
|
||||
Brushes.xaml;Theme.xaml;
|
||||
|
||||
False
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
FC:\boneyard\WPFToolkit\Src\Xceed.Wpf.AvalonDock.Themes.Metro\Theme.xaml;;
|
||||
|
||||
BIN
Src/Xceed.Wpf.AvalonDock.Themes.Metro/sn.snk
Normal file
32
Src/Xceed.Wpf.AvalonDock/AssemblyVersionInfo.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.1";
|
||||
[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
Src/Xceed.Wpf.AvalonDock/AssemblyVersionInfoCommon.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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 = ".*";
|
||||
|
||||
}
|
||||
71
Src/Xceed.Wpf.AvalonDock/Commands/RelayCommand.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Commands
|
||||
{
|
||||
internal class RelayCommand : ICommand
|
||||
{
|
||||
#region Fields
|
||||
|
||||
readonly Action<object> _execute;
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class AnchorablePaneControlOverlayArea : OverlayArea
|
||||
{
|
||||
internal AnchorablePaneControlOverlayArea(
|
||||
IOverlayWindow overlayWindow,
|
||||
LayoutAnchorablePaneControl anchorablePaneControl)
|
||||
: base(overlayWindow)
|
||||
{
|
||||
|
||||
_anchorablePaneControl = anchorablePaneControl;
|
||||
base.SetScreenDetectionArea(new Rect(
|
||||
_anchorablePaneControl.PointToScreenDPI(new Point()),
|
||||
_anchorablePaneControl.TransformActualSizeToAncestor()));
|
||||
|
||||
}
|
||||
|
||||
LayoutAnchorablePaneControl _anchorablePaneControl;
|
||||
}
|
||||
}
|
||||
336
Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneDropTarget.cs
Normal file
@@ -0,0 +1,336 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
internal class AnchorablePaneDropTarget : DropTarget<LayoutAnchorablePaneControl>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
LayoutAnchorablePaneControl _targetPane;
|
||||
|
||||
int _tabIndex = -1;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTabPanel.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class AnchorablePaneTabPanel : Panel
|
||||
{
|
||||
public AnchorablePaneTabPanel()
|
||||
{
|
||||
FlowDirection = System.Windows.FlowDirection.LeftToRight;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
189
Src/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
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
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#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); }
|
||||
}
|
||||
|
||||
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)
|
||||
SetLayoutItem(Model.Root.Manager.GetLayoutItemFromModel(Model));
|
||||
else
|
||||
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)
|
||||
{
|
||||
SetValue(LayoutItemPropertyKey, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void OnHide()
|
||||
{
|
||||
Model.Hide();
|
||||
}
|
||||
|
||||
private void OnToggleAutoHide()
|
||||
{
|
||||
Model.ToggleAutoHide();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool _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);
|
||||
}
|
||||
}
|
||||
}
|
||||
90
Src/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Threading;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
class AutoHideWindowManager
|
||||
{
|
||||
DockingManager _manager;
|
||||
|
||||
internal AutoHideWindowManager(DockingManager manager)
|
||||
{
|
||||
_manager = manager;
|
||||
SetupCloseTimer();
|
||||
}
|
||||
|
||||
|
||||
WeakReference _currentAutohiddenAnchor = null;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
DispatcherTimer _closeTimer = null;
|
||||
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();
|
||||
};
|
||||
}
|
||||
|
||||
void StartCloseTimer()
|
||||
{
|
||||
_closeTimer.Start();
|
||||
|
||||
}
|
||||
|
||||
void StopCloseTimer()
|
||||
{
|
||||
_closeTimer.Stop();
|
||||
_manager.AutoHideWindow.Hide();
|
||||
_currentAutohiddenAnchor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Src/Xceed.Wpf.AvalonDock/Controls/BindingHelper.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
class BindingHelper
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Src/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class ContextMenuEx : ContextMenu
|
||||
{
|
||||
static ContextMenuEx()
|
||||
{
|
||||
}
|
||||
|
||||
public ContextMenuEx()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
248
Src/Xceed.Wpf.AvalonDock/Controls/DockingManagerDropTarget.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
internal class DockingManagerDropTarget : DropTarget<DockingManager>
|
||||
{
|
||||
internal DockingManagerDropTarget(DockingManager manager, Rect detectionRect, DropTargetType type)
|
||||
: base(manager, detectionRect, type)
|
||||
{
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
DockingManager _manager;
|
||||
|
||||
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(_manager.Layout.RootPanel);
|
||||
newOrientedPanel.Children.Add(floatingWindow.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(_manager.Layout.RootPanel);
|
||||
newOrientedPanel.Children.Add(floatingWindow.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class DockingManagerOverlayArea : OverlayArea
|
||||
{
|
||||
internal DockingManagerOverlayArea(IOverlayWindow overlayWindow, DockingManager manager)
|
||||
: base(overlayWindow)
|
||||
{
|
||||
_manager = manager;
|
||||
|
||||
base.SetScreenDetectionArea(new Rect(
|
||||
_manager.PointToScreenDPI(new Point()),
|
||||
_manager.TransformActualSizeToAncestor()));
|
||||
}
|
||||
|
||||
DockingManager _manager;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class DocumentPaneControlOverlayArea : OverlayArea
|
||||
{
|
||||
|
||||
|
||||
internal DocumentPaneControlOverlayArea(
|
||||
IOverlayWindow overlayWindow,
|
||||
LayoutDocumentPaneControl documentPaneControl)
|
||||
: base(overlayWindow)
|
||||
{
|
||||
_documentPaneControl = documentPaneControl;
|
||||
base.SetScreenDetectionArea(new Rect(
|
||||
_documentPaneControl.PointToScreenDPI(new Point()),
|
||||
_documentPaneControl.TransformActualSizeToAncestor()));
|
||||
}
|
||||
|
||||
LayoutDocumentPaneControl _documentPaneControl;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
internal class DocumentPaneDropAsAnchorableTarget : DropTarget<LayoutDocumentPaneControl>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
LayoutDocumentPaneControl _targetPane;
|
||||
|
||||
int _tabIndex = -1;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
503
Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneDropTarget.cs
Normal file
@@ -0,0 +1,503 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
internal class DocumentPaneDropTarget : DropTarget<LayoutDocumentPaneControl>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
LayoutDocumentPaneControl _targetPane;
|
||||
|
||||
int _tabIndex = -1;
|
||||
|
||||
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 previousContainer = ((ILayoutPreviousContainer)sourceModel).PreviousContainer;
|
||||
if( object.ReferenceEquals( previousContainer, targetModel ) && (sourceModel.PreviousContainerIndex != -1) )
|
||||
{
|
||||
i = sourceModel.PreviousContainerIndex;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
105
Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneGroupDropTarget.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
internal class DocumentPaneGroupDropTarget : DropTarget<LayoutDocumentPaneGroupControl>
|
||||
{
|
||||
internal DocumentPaneGroupDropTarget(LayoutDocumentPaneGroupControl paneControl, Rect detectionRect, DropTargetType type)
|
||||
: base(paneControl, detectionRect, type)
|
||||
{
|
||||
_targetPane = paneControl;
|
||||
}
|
||||
|
||||
LayoutDocumentPaneGroupControl _targetPane;
|
||||
|
||||
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())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
106
Src/Xceed.Wpf.AvalonDock/Controls/DocumentPaneTabPanel.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class DocumentPaneTabPanel : Panel
|
||||
{
|
||||
public DocumentPaneTabPanel()
|
||||
{
|
||||
FlowDirection = System.Windows.FlowDirection.LeftToRight;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
190
Src/Xceed.Wpf.AvalonDock/Controls/DragService.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Input;
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
class DragService
|
||||
{
|
||||
DockingManager _manager;
|
||||
LayoutFloatingWindowControl _floatingWindow;
|
||||
|
||||
public DragService(LayoutFloatingWindowControl floatingWindow)
|
||||
{
|
||||
_floatingWindow = floatingWindow;
|
||||
_manager = floatingWindow.Model.Root.Manager;
|
||||
|
||||
|
||||
GetOverlayWindowHosts();
|
||||
}
|
||||
|
||||
List<IOverlayWindowHost> _overlayWindowHosts = new List<IOverlayWindowHost>();
|
||||
void GetOverlayWindowHosts()
|
||||
{
|
||||
_overlayWindowHosts.AddRange(_manager.GetFloatingWindowsByZOrder().OfType<LayoutAnchorableFloatingWindowControl>().Where(fw => fw != _floatingWindow && fw.IsVisible));
|
||||
_overlayWindowHosts.Add(_manager);
|
||||
}
|
||||
|
||||
IOverlayWindowHost _currentHost;
|
||||
IOverlayWindow _currentWindow;
|
||||
List<IDropArea> _currentWindowAreas = new List<IDropArea>();
|
||||
IDropTarget _currentDropTarget;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
77
Src/Xceed.Wpf.AvalonDock/Controls/DropArea.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
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
|
||||
{
|
||||
internal DropArea(T areaElement, DropAreaType type)
|
||||
{
|
||||
_element = areaElement;
|
||||
_detectionRect = areaElement.GetScreenArea();
|
||||
_type = type;
|
||||
}
|
||||
|
||||
Rect _detectionRect;
|
||||
|
||||
public Rect DetectionRect
|
||||
{
|
||||
get { return _detectionRect; }
|
||||
}
|
||||
|
||||
DropAreaType _type;
|
||||
|
||||
public DropAreaType Type
|
||||
{
|
||||
get { return _type; }
|
||||
}
|
||||
|
||||
T _element;
|
||||
public T AreaElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return _element;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
132
Src/Xceed.Wpf.AvalonDock/Controls/DropDownButton.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class DropDownButton : ToggleButton
|
||||
{
|
||||
public DropDownButton()
|
||||
{
|
||||
this.Unloaded += new RoutedEventHandler(DropDownButton_Unloaded);
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void OnContextMenuClosed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Debug.Assert(IsChecked.GetValueOrDefault());
|
||||
var ctxMenu = sender as ContextMenu;
|
||||
ctxMenu.Closed -= new RoutedEventHandler(OnContextMenuClosed);
|
||||
IsChecked = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
118
Src/Xceed.Wpf.AvalonDock/Controls/DropDownControlArea.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Input;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
public class DropDownControlArea : UserControl
|
||||
{
|
||||
//static DropDownControlArea()
|
||||
//{
|
||||
// //IsHitTestVisibleProperty.OverrideMetadata(typeof(DropDownControlArea), new FrameworkPropertyMetadata(true));
|
||||
//}
|
||||
|
||||
public DropDownControlArea()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
115
Src/Xceed.Wpf.AvalonDock/Controls/DropTarget.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Rect[] _detectionRect;
|
||||
|
||||
public Rect[] DetectionRects
|
||||
{
|
||||
get { return _detectionRect; }
|
||||
}
|
||||
|
||||
|
||||
T _targetElement;
|
||||
public T TargetElement
|
||||
{
|
||||
get { return _targetElement; }
|
||||
}
|
||||
|
||||
DropTargetType _type;
|
||||
|
||||
public DropTargetType Type
|
||||
{
|
||||
get { return _type; }
|
||||
}
|
||||
|
||||
protected virtual void Drop(LayoutAnchorableFloatingWindow floatingWindow)
|
||||
{ }
|
||||
|
||||
protected virtual void Drop(LayoutDocumentFloatingWindow floatingWindow)
|
||||
{ }
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Src/Xceed.Wpf.AvalonDock/Controls/DropTargetBase.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
abstract class DropTargetBase : DependencyObject
|
||||
{
|
||||
#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
|
||||
}
|
||||
}
|
||||
50
Src/Xceed.Wpf.AvalonDock/Controls/DropTargetType.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
120
Src/Xceed.Wpf.AvalonDock/Controls/Extentions.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
268
Src/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs
Normal file
@@ -0,0 +1,268 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
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 Focus Management
|
||||
static List<DockingManager> _managers = new List<DockingManager>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static FullWeakDictionary<ILayoutElement, IInputElement> _modelFocusedElement = new FullWeakDictionary<ILayoutElement, IInputElement>();
|
||||
static WeakDictionary<ILayoutElement, IntPtr> _modelFocusedWindowHandle = new WeakDictionary<ILayoutElement, IntPtr>();
|
||||
|
||||
/// <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;
|
||||
}
|
||||
static WeakReference _lastFocusedElement;
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static WindowHookHandler _windowHandler = null;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static DispatcherOperation _setFocusAsyncOperation;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static WeakReference _lastFocusedElementBeforeEnterMenuMode = null;
|
||||
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);
|
||||
}
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
106
Src/Xceed.Wpf.AvalonDock/Controls/FullWeakDictionary.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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.Text;
|
||||
|
||||
namespace Xceed.Wpf.AvalonDock.Controls
|
||||
{
|
||||
class FullWeakDictionary<K,V> where K : class
|
||||
{
|
||||
public FullWeakDictionary()
|
||||
{}
|
||||
|
||||
List<WeakReference> _keys = new List<WeakReference>();
|
||||
List<WeakReference> _values = new List<WeakReference>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||