Skip to content

Commit

Permalink
Refactor into projects
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Sep 23, 2024
1 parent a5acb9f commit 5e08ea6
Show file tree
Hide file tree
Showing 36 changed files with 223 additions and 50 deletions.
28 changes: 28 additions & 0 deletions Dock.sln
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dock.Model.ReactiveUI", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dock.Model.ReactiveUI.UnitTests", "tests\Dock.Model.ReactiveUI.UnitTests\Dock.Model.ReactiveUI.UnitTests.csproj", "{E6A49621-154E-4A00-A54A-39C3BA55799A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Controls.ProportionalStackPanel", "src\Avalonia.Controls.ProportionalStackPanel\Avalonia.Controls.ProportionalStackPanel.csproj", "{CCA814C4-8369-4AD6-A2DA-59F54D01CE26}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Controls.Recycling", "src\Avalonia.Controls.Recycling\Avalonia.Controls.Recycling.csproj", "{9FF95B40-ECA7-440B-9342-688C53F1AE8E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.MarkupExtension", "src\Avalonia.MarkupExtension\Avalonia.MarkupExtension.csproj", "{B6762749-9061-49AE-A994-777DB6018A45}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Controls.Recycling.Model", "src\Avalonia.Controls.Recycling.Model\Avalonia.Controls.Recycling.Model.csproj", "{B1858CD4-5477-4AEF-A31E-AC7F92927D64}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -162,6 +170,22 @@ Global
{E6A49621-154E-4A00-A54A-39C3BA55799A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6A49621-154E-4A00-A54A-39C3BA55799A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6A49621-154E-4A00-A54A-39C3BA55799A}.Release|Any CPU.Build.0 = Release|Any CPU
{CCA814C4-8369-4AD6-A2DA-59F54D01CE26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCA814C4-8369-4AD6-A2DA-59F54D01CE26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCA814C4-8369-4AD6-A2DA-59F54D01CE26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCA814C4-8369-4AD6-A2DA-59F54D01CE26}.Release|Any CPU.Build.0 = Release|Any CPU
{9FF95B40-ECA7-440B-9342-688C53F1AE8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FF95B40-ECA7-440B-9342-688C53F1AE8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FF95B40-ECA7-440B-9342-688C53F1AE8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FF95B40-ECA7-440B-9342-688C53F1AE8E}.Release|Any CPU.Build.0 = Release|Any CPU
{B6762749-9061-49AE-A994-777DB6018A45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6762749-9061-49AE-A994-777DB6018A45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6762749-9061-49AE-A994-777DB6018A45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6762749-9061-49AE-A994-777DB6018A45}.Release|Any CPU.Build.0 = Release|Any CPU
{B1858CD4-5477-4AEF-A31E-AC7F92927D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1858CD4-5477-4AEF-A31E-AC7F92927D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1858CD4-5477-4AEF-A31E-AC7F92927D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1858CD4-5477-4AEF-A31E-AC7F92927D64}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -187,6 +211,10 @@ Global
{6ACDD1B2-CC63-4F4D-8E99-3F8948CA2A6E} = {FC61A082-2335-4C45-A38C-1EBEEA7BBE0A}
{2CDD7BD2-3432-4F47-8865-EC8D7E652628} = {FC61A082-2335-4C45-A38C-1EBEEA7BBE0A}
{E6A49621-154E-4A00-A54A-39C3BA55799A} = {71FD12F4-0BCB-422A-9FB0-4137E898E991}
{CCA814C4-8369-4AD6-A2DA-59F54D01CE26} = {FC61A082-2335-4C45-A38C-1EBEEA7BBE0A}
{9FF95B40-ECA7-440B-9342-688C53F1AE8E} = {FC61A082-2335-4C45-A38C-1EBEEA7BBE0A}
{B6762749-9061-49AE-A994-777DB6018A45} = {FC61A082-2335-4C45-A38C-1EBEEA7BBE0A}
{B1858CD4-5477-4AEF-A31E-AC7F92927D64} = {FC61A082-2335-4C45-A38C-1EBEEA7BBE0A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5617659E-FC7E-40D7-9D62-258513329CA1}
Expand Down
6 changes: 3 additions & 3 deletions samples/DockMvvmSample/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DockMvvmSample"
xmlns:idc="using:Dock.Avalonia.Controls"
xmlns:idcr="using:Dock.Avalonia.Controls.Recycling"
xmlns:acr="using:Avalonia.Controls.Recycling"
xmlns:core="using:Dock.Model.Core"
Name="Dock Avalonia Demo"
x:Class="DockMvvmSample.App">
Expand All @@ -12,13 +12,13 @@
</Application.DataTemplates>

<Application.Resources>
<idcr:ControlRecycling x:Key="ControlRecyclingKey" />
<acr:ControlRecycling x:Key="ControlRecyclingKey" />
</Application.Resources>

<Application.Styles>

<Style Selector="idc|DockControl">
<Setter Property="(idcr:ControlRecyclingDataTemplate.ControlRecycling)" Value="{StaticResource ControlRecyclingKey}" />
<Setter Property="(acr:ControlRecyclingDataTemplate.ControlRecycling)" Value="{StaticResource ControlRecyclingKey}" />
</Style>

<Style Selector="idc|DocumentControl">
Expand Down
6 changes: 3 additions & 3 deletions samples/DockXamlSample/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DockXamlSample.App"
xmlns:idc="using:Dock.Avalonia.Controls"
xmlns:idcr="using:Dock.Avalonia.Controls.Recycling"
xmlns:acr="using:Avalonia.Controls.Recycling"
Name="Dock Avalonia Demo"
RequestedThemeVariant="Light">

<Application.Resources>
<idcr:ControlRecycling x:Key="ControlRecyclingKey" TryToUseIdAsKey="True" />
<acr:ControlRecycling x:Key="ControlRecyclingKey" TryToUseIdAsKey="True" />
<Color x:Key="RegionColor">Transparent</Color>
</Application.Resources>

Expand All @@ -23,7 +23,7 @@
</Style>

<Style Selector="idc|DockControl">
<Setter Property="(idcr:ControlRecyclingDataTemplate.ControlRecycling)" Value="{StaticResource ControlRecyclingKey}" />
<Setter Property="(acr:ControlRecyclingDataTemplate.ControlRecycling)" Value="{StaticResource ControlRecyclingKey}" />
</Style>

</Application.Styles>
Expand Down
6 changes: 3 additions & 3 deletions samples/Notepad/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Notepad"
xmlns:idc="using:Dock.Avalonia.Controls"
xmlns:idcr="using:Dock.Avalonia.Controls.Recycling"
xmlns:acr="using:Avalonia.Controls.Recycling"
x:Class="Notepad.App"
Name="Notepad"
RequestedThemeVariant="Light">
Expand All @@ -12,7 +12,7 @@
</Application.DataTemplates>

<Application.Resources>
<idcr:ControlRecycling x:Key="ControlRecyclingKey" />
<acr:ControlRecycling x:Key="ControlRecyclingKey" />
</Application.Resources>

<Application.Styles>
Expand All @@ -22,7 +22,7 @@
<StyleInclude Source="avares://Dock.Avalonia/Themes/DockFluentTheme.axaml" />

<Style Selector="idc|DockControl">
<Setter Property="(idcr:ControlRecyclingDataTemplate.ControlRecycling)" Value="{StaticResource ControlRecyclingKey}" />
<Setter Property="(acr:ControlRecyclingDataTemplate.ControlRecycling)" Value="{StaticResource ControlRecyclingKey}" />
</Style>

</Application.Styles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<PackageId>Avalonia.Controls.ProportionalStackPanel</PackageId>
</PropertyGroup>

<Import Project="..\..\build\Base.props" />
<Import Project="..\..\build\SignAssembly.props" />
<Import Project="..\..\build\SourceLink.props" />
<Import Project="..\..\build\ReferenceAssemblies.props" />
<Import Project="..\..\build\Avalonia.props" />

<ItemGroup>
<AvaloniaResource Include="Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Avalonia.Metadata;

[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls")]
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Diagnostics;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Layout;

namespace Dock.Avalonia.Controls;
namespace Avalonia.Controls;

/// <summary>
/// A Panel that stacks controls either horizontally or vertically, with proportional resizing.
Expand Down Expand Up @@ -452,13 +450,31 @@ private double CalculateDimension(
sumOfFractions += childDimension - flooredChildDimension;

// if the sum of fractions made up a whole pixel/pixels, add it to the dimension
if (Math.Round(sumOfFractions, 1) - Math.Clamp(Math.Floor(sumOfFractions), 1, double.MaxValue) >= 0)
var round = Math.Round(sumOfFractions, 1);

#if NETSTANDARD2_0
var clamp = Clamp(Math.Floor(sumOfFractions), 1, double.MaxValue);
#else
var clamp = Math.Clamp(Math.Floor(sumOfFractions), 1, double.MaxValue);
#endif
if (round - clamp >= 0)
{
sumOfFractions -= Math.Round(sumOfFractions);
return Math.Max(0, flooredChildDimension + 1);
}

return Math.Max(0, flooredChildDimension);

#if NETSTANDARD2_0
static T Clamp<T>(T value, T min, T max) where T : IComparable<T>
{
if (value.CompareTo(min) < 0)
return min;
if (value.CompareTo(max) > 0)
return max;
return value;
}
#endif
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;
using System.Diagnostics;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.VisualTree;

namespace Dock.Avalonia.Controls;
namespace Avalonia.Controls;

/// <summary>
/// Represents a control that lets the user change the size of elements in a <see cref="ProportionalStackPanel"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<PackageId>Avalonia.Controls.Recycling.Model</PackageId>
</PropertyGroup>

<Import Project="..\..\build\Base.props" />
<Import Project="..\..\build\SignAssembly.props" />
<Import Project="..\..\build\SourceLink.props" />
<Import Project="..\..\build\ReferenceAssemblies.props" />

<ItemGroup>
<AvaloniaResource Include="Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Dock.Model.Core;
namespace Avalonia.Controls.Recycling.Model;

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Avalonia.Controls.Recycling.Model;

/// <summary>
///
/// </summary>
public interface IControlRecyclingIdProvider
{
/// <summary>
///
/// </summary>
/// <returns></returns>
string? GetControlRecyclingId();
}
28 changes: 28 additions & 0 deletions src/Avalonia.Controls.Recycling/Avalonia.Controls.Recycling.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<PackageId>Avalonia.Controls.Recycling</PackageId>
</PropertyGroup>

<Import Project="..\..\build\Base.props" />
<Import Project="..\..\build\SignAssembly.props" />
<Import Project="..\..\build\SourceLink.props" />
<Import Project="..\..\build\ReferenceAssemblies.props" />
<Import Project="..\..\build\Avalonia.props" />

<ItemGroup>
<AvaloniaResource Include="Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Avalonia.Controls.Recycling.Model\Avalonia.Controls.Recycling.Model.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Recycling.Model;
using Avalonia.Controls.Templates;
using Dock.Model.Core;

namespace Dock.Avalonia.Controls.Recycling;
namespace Avalonia.Controls.Recycling;

/// <summary>
///
Expand Down Expand Up @@ -73,14 +71,14 @@ public void Add(object data, object control)

var key = data;

if (TryToUseIdAsKey && data is IDockable dockable)
if (TryToUseIdAsKey && data is IControlRecyclingIdProvider idProvider)
{
#if DEBUG
Console.WriteLine($"Build: {data}, Id='{dockable.Id}'");
Console.WriteLine($"Build: {data}, Id='{idProvider.GetControlRecyclingId()}'");
#endif
if (!string.IsNullOrWhiteSpace(dockable.Id))
if (!string.IsNullOrWhiteSpace(idProvider.GetControlRecyclingId()))
{
key = dockable.Id;
key = idProvider.GetControlRecyclingId();
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/Avalonia.Controls.Recycling/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Avalonia.Metadata;

[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Controls.Recycling")]
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Recycling.Model;
using Avalonia.Controls.Templates;
using Avalonia.Data;
using Dock.Model.Core;
using Dock.Settings;

namespace Dock.Avalonia.Controls.Recycling;
namespace Avalonia.Controls.Recycling;

/// <summary>
///
Expand Down
24 changes: 24 additions & 0 deletions src/Avalonia.MarkupExtension/Avalonia.MarkupExtension.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<PackageId>Avalonia.MarkupExtension</PackageId>
</PropertyGroup>

<Import Project="..\..\build\Base.props" />
<Import Project="..\..\build\SignAssembly.props" />
<Import Project="..\..\build\SourceLink.props" />
<Import Project="..\..\build\ReferenceAssemblies.props" />
<Import Project="..\..\build\Avalonia.props" />

<ItemGroup>
<AvaloniaResource Include="Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Avalonia.Markup.Xaml;

namespace Dock.Avalonia.MarkupExtension;
namespace Avalonia.MarkupExtension;

/// <summary>
/// Loads XAML <see cref="object"/> from a URI.
Expand Down
3 changes: 3 additions & 0 deletions src/Avalonia.MarkupExtension/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Avalonia.Metadata;

[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.MarkupExtension")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace Dock.Avalonia.MarkupExtension;
namespace Avalonia.MarkupExtension;

/// <summary>
/// References named object.
Expand Down
1 change: 1 addition & 0 deletions src/Dock.Avalonia/Controls/ToolDockControl.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.VisualTree;
Expand Down
Loading

0 comments on commit 5e08ea6

Please sign in to comment.