diff --git a/nukebuild/Build.cs b/nukebuild/Build.cs index 890967ae4f..fe877dc49c 100644 --- a/nukebuild/Build.cs +++ b/nukebuild/Build.cs @@ -268,6 +268,8 @@ partial class Build : NukeBuild .DependsOn(CreateIntermediateNugetPackages) .Executes(() => { + BuildTasksPatcher.PatchBuildTasksInPackage(Parameters.NugetIntermediateRoot / "Avalonia.Build.Tasks." + + Parameters.Version + ".nupkg"); var config = Numerge.MergeConfiguration.LoadFile(RootDirectory / "nukebuild" / "numerge.config"); EnsureCleanDirectory(Parameters.NugetRoot); if(!Numerge.NugetPackageMerger.Merge(Parameters.NugetIntermediateRoot, Parameters.NugetRoot, config, diff --git a/nukebuild/BuildTasksPatcher.cs b/nukebuild/BuildTasksPatcher.cs new file mode 100644 index 0000000000..44f01da669 --- /dev/null +++ b/nukebuild/BuildTasksPatcher.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.IO.Compression; +using System.Linq; +using ILRepacking; +using Mono.Cecil; + +public class BuildTasksPatcher +{ + public static void PatchBuildTasksInPackage(string packagePath) + { + using (var archive = new ZipArchive(File.Open(packagePath, FileMode.Open, FileAccess.ReadWrite), + ZipArchiveMode.Update)) + { + + foreach (var entry in archive.Entries.ToList()) + { + if (entry.Name == "Avalonia.Build.Tasks.dll") + { + var temp = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".dll"); + var output = temp + ".output"; + var patched = new MemoryStream(); + try + { + entry.ExtractToFile(temp, true); + var repack = new ILRepacking.ILRepack(new RepackOptions() + { + Internalize = true, + InputAssemblies = new[] + { + temp, typeof(Mono.Cecil.AssemblyDefinition).Assembly.GetModules()[0] + .FullyQualifiedName + }, + SearchDirectories = new string[0], + OutputFile = output + }); + repack.Repack(); + + + // 'hurr-durr assembly with the same name is already loaded' prevention + using (var asm = AssemblyDefinition.ReadAssembly(output, + new ReaderParameters { ReadWrite = true, InMemory = true, })) + { + asm.Name = new AssemblyNameDefinition( + "Avalonia.Build.Tasks." + + Guid.NewGuid().ToString().Replace("-", ""), + new Version(0, 0, 0)); + asm.Write(patched); + patched.Position = 0; + } + } + finally + { + try + { + if (File.Exists(temp)) + File.Delete(temp); + if (File.Exists(output)) + File.Delete(output); + } + catch + { + //ignore + } + } + + var fn = entry.FullName; + entry.Delete(); + var newEntry = archive.CreateEntry(fn, CompressionLevel.Optimal); + using (var s = newEntry.Open()) + patched.CopyTo(s); + } + } + } + } +} \ No newline at end of file diff --git a/nukebuild/_build.csproj b/nukebuild/_build.csproj index 584c36d033..4c64d4ff93 100644 --- a/nukebuild/_build.csproj +++ b/nukebuild/_build.csproj @@ -14,6 +14,9 @@ + + + diff --git a/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj b/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj index 449c1b483a..65dcfd21d2 100644 --- a/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj +++ b/src/Avalonia.Build.Tasks/Avalonia.Build.Tasks.csproj @@ -49,25 +49,6 @@ - - - - - - $(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework) - - - - - - - - - - - - - diff --git a/src/Avalonia.Controls/ComboBox.cs b/src/Avalonia.Controls/ComboBox.cs index 6557346b1f..75a0e41e7b 100644 --- a/src/Avalonia.Controls/ComboBox.cs +++ b/src/Avalonia.Controls/ComboBox.cs @@ -7,6 +7,7 @@ using Avalonia.Controls.Shapes; using Avalonia.Controls.Templates; using Avalonia.Input; using Avalonia.Interactivity; +using Avalonia.Layout; using Avalonia.LogicalTree; using Avalonia.Media; using Avalonia.VisualTree; @@ -63,6 +64,18 @@ namespace Avalonia.Controls public static readonly StyledProperty PlaceholderForegroundProperty = AvaloniaProperty.Register(nameof(PlaceholderForeground)); + /// + /// Defines the property. + /// + public static readonly StyledProperty HorizontalContentAlignmentProperty = + ContentControl.HorizontalContentAlignmentProperty.AddOwner(); + + /// + /// Defines the property. + /// + public static readonly StyledProperty VerticalContentAlignmentProperty = + ContentControl.VerticalContentAlignmentProperty.AddOwner(); + private bool _isDropDownOpen; private Popup _popup; private object _selectionBoxItem; @@ -133,6 +146,24 @@ namespace Avalonia.Controls set { SetValue(VirtualizationModeProperty, value); } } + /// + /// Gets or sets the horizontal alignment of the content within the control. + /// + public HorizontalAlignment HorizontalContentAlignment + { + get { return GetValue(HorizontalContentAlignmentProperty); } + set { SetValue(HorizontalContentAlignmentProperty, value); } + } + + /// + /// Gets or sets the vertical alignment of the content within the control. + /// + public VerticalAlignment VerticalContentAlignment + { + get { return GetValue(VerticalContentAlignmentProperty); } + set { SetValue(VerticalContentAlignmentProperty, value); } + } + /// protected override IItemContainerGenerator CreateItemContainerGenerator() { diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index f75184c686..c4571505ba 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -95,6 +95,7 @@ namespace Avalonia.Controls.Presenters static ContentPresenter() { AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty, CornerRadiusProperty); + AffectsArrange(HorizontalContentAlignmentProperty, VerticalContentAlignmentProperty); AffectsMeasure(BorderThicknessProperty, PaddingProperty); ContentProperty.Changed.AddClassHandler((x, e) => x.ContentChanged(e)); ContentTemplateProperty.Changed.AddClassHandler((x, e) => x.ContentChanged(e)); diff --git a/src/Avalonia.Desktop/AppBuilderDesktopExtensions.cs b/src/Avalonia.Desktop/AppBuilderDesktopExtensions.cs index 36f762d625..7c4a489328 100644 --- a/src/Avalonia.Desktop/AppBuilderDesktopExtensions.cs +++ b/src/Avalonia.Desktop/AppBuilderDesktopExtensions.cs @@ -46,10 +46,6 @@ namespace Avalonia where TAppBuilder : AppBuilderBase, new() => builder.UseX11(); - static void LoadDirect2D1(TAppBuilder builder) - where TAppBuilder : AppBuilderBase, new() - => builder.UseDirect2D1(); - static void LoadSkia(TAppBuilder builder) where TAppBuilder : AppBuilderBase, new() => builder.UseSkia(); diff --git a/src/Avalonia.Desktop/Avalonia.Desktop.csproj b/src/Avalonia.Desktop/Avalonia.Desktop.csproj index f45b0c54e3..72b7b5c1e7 100644 --- a/src/Avalonia.Desktop/Avalonia.Desktop.csproj +++ b/src/Avalonia.Desktop/Avalonia.Desktop.csproj @@ -5,8 +5,7 @@ - - + diff --git a/src/Avalonia.Themes.Default/ComboBox.xaml b/src/Avalonia.Themes.Default/ComboBox.xaml index 95bd9550a5..ae5b902ae8 100644 --- a/src/Avalonia.Themes.Default/ComboBox.xaml +++ b/src/Avalonia.Themes.Default/ComboBox.xaml @@ -1,10 +1,29 @@ + + + + + Item 1 + Item 2 + + + Item 1 + Item 2 + + + + - + + + - + - + - + - - - + - + - + + + + + + + diff --git a/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml b/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml index c26dec3d34..66ccea99b5 100644 --- a/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml +++ b/src/Avalonia.Themes.Fluent/ComboBoxItem.xaml @@ -1,17 +1,19 @@ - - + + Item 1 - Item 2 - - - - Item 1 - Item 2 - - + Item 2 long + Item 3 + Item 4 + + @@ -19,12 +21,11 @@ - - + Padding="{TemplateBinding Padding}" /> + + + + + + + + - + -