Skip to content

Commit

Permalink
Merge pull request #375 from wieslawsoltes/ReactiveGenerator
Browse files Browse the repository at this point in the history
Use ReactiveGenerator
  • Loading branch information
wieslawsoltes authored Dec 14, 2024
2 parents 9b5a3a3 + f9f2c24 commit 371b790
Show file tree
Hide file tree
Showing 24 changed files with 185 additions and 334 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resources:
variables:
BuildConfiguration: 'Release'
BuildPlatform: 'Any CPU'
PublishFramework: 'net8.0'
PublishFramework: 'net9.0'
PublishProject: 'DockMvvmSample'
PublishRuntime: ''
Workloads: 'wasm-tools wasm-experimental'
Expand Down
3 changes: 2 additions & 1 deletion build/build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>
Expand All @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.3.0" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/DockMvvmSample/DockMvvmSample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<IsPackable>False</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion samples/DockXamlSample/DockXamlSample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<IsPackable>False</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion samples/Notepad/Notepad.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<IsPackable>False</IsPackable>
Expand Down
14 changes: 6 additions & 8 deletions src/Avalonia.Controls.Recycling/ControlRecycling.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Avalonia.Controls.Recycling.Model;
using Avalonia.Controls.Templates;
Expand Down Expand Up @@ -64,14 +63,13 @@ public void Add(object data, object control)
/// <returns></returns>
public object? Build(object? data, object? existing, object? parent)
{
if (data is null)
var key = data;
if (key is null)
{
return null;
}

var key = data;

if (TryToUseIdAsKey && data is IControlRecyclingIdProvider idProvider)
if (TryToUseIdAsKey && key is IControlRecyclingIdProvider idProvider)
{
if (!string.IsNullOrWhiteSpace(idProvider.GetControlRecyclingId()))
{
Expand All @@ -84,15 +82,15 @@ public void Add(object data, object control)
return control;
}

var dataTemplate = (parent as Control)?.FindDataTemplate(data);
var dataTemplate = (parent as Control)?.FindDataTemplate(key);

control = dataTemplate?.Build(data);
control = dataTemplate?.Build(key);
if (control is null)
{
return null;
}

Add(key, control);
Add(key!, control);

return control;
}
Expand Down
22 changes: 12 additions & 10 deletions src/Dock.Model.ReactiveUI/Controls/DockDock.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
using System.Runtime.Serialization;
using Dock.Model.Controls;
using Dock.Model.ReactiveUI.Core;
using ReactiveUI;

namespace Dock.Model.ReactiveUI.Controls;

/// <summary>
/// Docking panel dock.
/// </summary>
[DataContract(IsReference = true)]
public class DockDock : DockBase, IDockDock
{
private bool _lastChildFill = true;
public partial class DockDock : DockBase, IDockDock
{
/// <summary>
/// Initializes new instance of the <see cref="DockDock"/> class.
/// </summary>
public DockDock()
{
_lastChildFill = true;
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool LastChildFill
{
get => _lastChildFill;
set => this.RaiseAndSetIfChanged(ref _lastChildFill, value);
}
}
[Reactive]
public partial bool LastChildFill { get; set; }
}
4 changes: 2 additions & 2 deletions src/Dock.Model.ReactiveUI/Controls/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Dock.Model.ReactiveUI.Controls;
/// Document.
/// </summary>
[DataContract(IsReference = true)]
public class Document : DockableBase, IDocument
public partial class Document : DockableBase, IDocument
{
}
}
12 changes: 3 additions & 9 deletions src/Dock.Model.ReactiveUI/Controls/DocumentDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
using System.Windows.Input;
using Dock.Model.Controls;
using Dock.Model.ReactiveUI.Core;
using ReactiveUI;

namespace Dock.Model.ReactiveUI.Controls;

/// <summary>
/// Document dock.
/// </summary>
[DataContract(IsReference = true)]
public class DocumentDock : DockBase, IDocumentDock
public partial class DocumentDock : DockBase, IDocumentDock
{
private bool _canCreateDocument;

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool CanCreateDocument
{
get => _canCreateDocument;
set => this.RaiseAndSetIfChanged(ref _canCreateDocument, value);
}
[Reactive]
public partial bool CanCreateDocument { get; set; }

/// <inheritdoc/>
[IgnoreDataMember]
Expand Down
14 changes: 4 additions & 10 deletions src/Dock.Model.ReactiveUI/Controls/ProportionalDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
using Dock.Model.Controls;
using Dock.Model.Core;
using Dock.Model.ReactiveUI.Core;
using ReactiveUI;

namespace Dock.Model.ReactiveUI.Controls;

/// <summary>
/// Proportional dock.
/// </summary>
[DataContract(IsReference = true)]
public class ProportionalDock : DockBase, IProportionalDock
public partial class ProportionalDock : DockBase, IProportionalDock
{
private Orientation _orientation;

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public Orientation Orientation
{
get => _orientation;
set => this.RaiseAndSetIfChanged(ref _orientation, value);
}
}
[Reactive]
public partial Orientation Orientation { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Dock.Model.ReactiveUI.Controls;
/// Proportional dock splitter.
/// </summary>
[DataContract(IsReference = true)]
public class ProportionalDockSplitter : DockableBase, IProportionalDockSplitter
public partial class ProportionalDockSplitter : DockableBase, IProportionalDockSplitter
{
}
}
76 changes: 20 additions & 56 deletions src/Dock.Model.ReactiveUI/Controls/RootDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,98 +12,62 @@ namespace Dock.Model.ReactiveUI.Controls;
/// Root dock.
/// </summary>
[DataContract(IsReference = true)]
public class RootDock : DockBase, IRootDock
public partial class RootDock : DockBase, IRootDock
{
private bool _isFocusableRoot = true;
private IList<IDockable>? _hiddenDockables;
private IList<IDockable>? _leftPinnedDockables;
private IList<IDockable>? _rightPinnedDockables;
private IList<IDockable>? _topPinnedDockables;
private IList<IDockable>? _bottomPinnedDockables;
private IToolDock? _pinnedDock;
private IDockWindow? _window;
private IList<IDockWindow>? _windows;

/// <summary>
/// Initializes new instance of the <see cref="RootDock"/> class.
/// </summary>
public RootDock()
{
_isFocusableRoot = true;
ShowWindows = ReactiveCommand.Create(() => _navigateAdapter.ShowWindows());
ExitWindows = ReactiveCommand.Create(() => _navigateAdapter.ExitWindows());
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsFocusableRoot
{
get => _isFocusableRoot;
set => this.RaiseAndSetIfChanged(ref _isFocusableRoot, value);
}
[Reactive]
public partial bool IsFocusableRoot { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IList<IDockable>? HiddenDockables
{
get => _hiddenDockables;
set => this.RaiseAndSetIfChanged(ref _hiddenDockables, value);
}
[Reactive]
public partial IList<IDockable>? HiddenDockables { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IList<IDockable>? LeftPinnedDockables
{
get => _leftPinnedDockables;
set => this.RaiseAndSetIfChanged(ref _leftPinnedDockables, value);
}
[Reactive]
public partial IList<IDockable>? LeftPinnedDockables { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IList<IDockable>? RightPinnedDockables
{
get => _rightPinnedDockables;
set => this.RaiseAndSetIfChanged(ref _rightPinnedDockables, value);
}
[Reactive]
public partial IList<IDockable>? RightPinnedDockables { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IList<IDockable>? TopPinnedDockables
{
get => _topPinnedDockables;
set => this.RaiseAndSetIfChanged(ref _topPinnedDockables, value);
}
[Reactive]
public partial IList<IDockable>? TopPinnedDockables { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IList<IDockable>? BottomPinnedDockables
{
get => _bottomPinnedDockables;
set => this.RaiseAndSetIfChanged(ref _bottomPinnedDockables, value);
}
[Reactive]
public partial IList<IDockable>? BottomPinnedDockables { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IToolDock? PinnedDock
{
get => _pinnedDock;
set => this.RaiseAndSetIfChanged(ref _pinnedDock, value);
}
[Reactive]
public partial IToolDock? PinnedDock { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IDockWindow? Window
{
get => _window;
set => this.RaiseAndSetIfChanged(ref _window, value);
}
[Reactive]
public partial IDockWindow? Window { get; set; }

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public IList<IDockWindow>? Windows
{
get => _windows;
set => this.RaiseAndSetIfChanged(ref _windows, value);
}
[Reactive]
public partial IList<IDockWindow>? Windows { get; set; }

/// <inheritdoc/>
[IgnoreDataMember]
Expand Down
4 changes: 2 additions & 2 deletions src/Dock.Model.ReactiveUI/Controls/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ namespace Dock.Model.ReactiveUI.Controls;
/// Tool.
/// </summary>
[DataContract(IsReference = true)]
public class Tool : DockableBase, ITool, IDocument
public partial class Tool : DockableBase, ITool, IDocument
{
}
}
Loading

0 comments on commit 371b790

Please sign in to comment.