зеркало из https://github.com/DeGsoft/maui-linux.git
Merge branch '3.2.0'
This commit is contained in:
Коммит
a94074463e
|
@ -118,19 +118,27 @@ echo foo > Xamarin.Forms.Platform.UAP\bin\debug\FormsEmbeddedPageWrapper.xbf
|
|||
|
||||
if "%1" == "droid" (
|
||||
%NUGET_EXE% restore .xamarin.forms.android.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.android.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" /p:WarningLevel=0 .xamarin.forms.android.nuget.sln
|
||||
)
|
||||
if "%1" == "ios" (
|
||||
%NUGET_EXE% restore .xamarin.forms.ios.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.ios.nuget.sln
|
||||
)
|
||||
if "%1" == "droidios" (
|
||||
%NUGET_EXE% restore .xamarin.forms.android.nuget.sln
|
||||
%NUGET_EXE% restore .xamarin.forms.ios.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" /p:WarningLevel=0 .xamarin.forms.android.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.ios.nuget.sln
|
||||
)
|
||||
if "%1" == "uap" (
|
||||
%NUGET_EXE% restore .xamarin.forms.uap.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.uap.nuget.sln /t:restore
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.uap.nuget.sln
|
||||
)
|
||||
if "%1" == "all" (
|
||||
%NUGET_EXE% restore .xamarin.forms.sln
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.nuget.sln
|
||||
msbuild /v:m /p:platform="any cpu" .xamarin.forms.uap.nuget.sln /t:restore
|
||||
msbuild /v:m /p:platform="any cpu" /p:WarningLevel=0 .xamarin.forms.nuget.sln
|
||||
)
|
||||
|
||||
if "%DEBUG_VERSION%"=="" set DEBUG_VERSION=0
|
||||
|
|
|
@ -19,13 +19,6 @@
|
|||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -26,13 +26,6 @@
|
|||
</NuGetPackageImportStamp>
|
||||
<XFDisableTargetsValidation>True</XFDisableTargetsValidation>
|
||||
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -20,13 +20,6 @@
|
|||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -540,7 +540,7 @@ namespace Xamarin.Forms.Build.Tasks
|
|||
static IEnumerable<Instruction> CompiledBindingGetSetter(TypeReference tSourceRef, TypeReference tPropertyRef, IList<Tuple<PropertyDefinition, string>> properties, ElementNode node, ILContext context)
|
||||
{
|
||||
if (properties == null || properties.Count == 0) {
|
||||
yield return Instruction.Create(OpCodes.Ldnull);
|
||||
yield return Create(Ldnull);
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ namespace Xamarin.Forms.Build.Tasks
|
|||
var lastProperty = properties.LastOrDefault();
|
||||
var setterRef = lastProperty?.Item1.SetMethod;
|
||||
if (setterRef == null) {
|
||||
yield return Instruction.Create(OpCodes.Ldnull); //throw or not ?
|
||||
yield return Create(Ldnull); //throw or not ?
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
@ -586,12 +586,12 @@ namespace Xamarin.Forms.Build.Tasks
|
|||
var indexerArg = properties[i].Item2;
|
||||
if (indexerArg != null) {
|
||||
if (property.GetMethod.Parameters [0].ParameterType == module.TypeSystem.String)
|
||||
il.Emit(OpCodes.Ldstr, indexerArg);
|
||||
il.Emit(Ldstr, indexerArg);
|
||||
else if (property.GetMethod.Parameters [0].ParameterType == module.TypeSystem.Int32) {
|
||||
int index;
|
||||
if (!int.TryParse(indexerArg, out index))
|
||||
throw new XamlParseException($"Binding: {indexerArg} could not be parsed as an index for a {property.Name}", node as IXmlLineInfo);
|
||||
il.Emit(OpCodes.Ldc_I4, index);
|
||||
il.Emit(Ldc_I4, index);
|
||||
}
|
||||
}
|
||||
if (property.GetMethod.IsVirtual)
|
||||
|
@ -603,25 +603,23 @@ namespace Xamarin.Forms.Build.Tasks
|
|||
var indexer = properties.Last().Item2;
|
||||
if (indexer != null) {
|
||||
if (lastProperty.Item1.GetMethod.Parameters [0].ParameterType == module.TypeSystem.String)
|
||||
il.Emit(OpCodes.Ldstr, indexer);
|
||||
il.Emit(Ldstr, indexer);
|
||||
else if (lastProperty.Item1.GetMethod.Parameters [0].ParameterType == module.TypeSystem.Int32) {
|
||||
int index;
|
||||
if (!int.TryParse(indexer, out index))
|
||||
throw new XamlParseException($"Binding: {indexer} could not be parsed as an index for a {lastProperty.Item1.Name}", node as IXmlLineInfo);
|
||||
il.Emit(OpCodes.Ldc_I4, index);
|
||||
il.Emit(Ldc_I4, index);
|
||||
}
|
||||
}
|
||||
if (tPropertyRef.IsValueType)
|
||||
il.Emit(Ldarga_S, (byte)1);
|
||||
else
|
||||
il.Emit(Ldarg_1);
|
||||
|
||||
il.Emit(Ldarg_1);
|
||||
|
||||
if (setterRef.IsVirtual)
|
||||
il.Emit(Callvirt, module.ImportReference(setterRef));
|
||||
else
|
||||
il.Emit(Call, module.ImportReference(setterRef));
|
||||
|
||||
il.Emit(OpCodes.Ret);
|
||||
il.Emit(Ret);
|
||||
|
||||
context.Body.Method.DeclaringType.Methods.Add(setter);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="AndroidControlGallery.AndroidControlGallery" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="15" />
|
||||
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="26" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
|
|
@ -29,13 +29,6 @@
|
|||
<AndroidTlsProvider>
|
||||
</AndroidTlsProvider>
|
||||
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<AndroidKeyStore>True</AndroidKeyStore>
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 3524, "ICommand binding from a TapGestureRecognizer on a Span doesn't work")]
|
||||
#if UITEST
|
||||
[NUnit.Framework.Category(UITestCategories.Gestures)]
|
||||
#endif
|
||||
public class Issue3524 : TestContentPage
|
||||
{
|
||||
const string kText = "Click Me To Increment";
|
||||
|
||||
public Command TapCommand { get; set; }
|
||||
public String Text { get; set; } = kText;
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
FormattedString formattedString = new FormattedString();
|
||||
var span = new Span() { AutomationId = kText };
|
||||
span.Text = kText;
|
||||
var tapGesture = new TapGestureRecognizer();
|
||||
tapGesture.SetBinding(TapGestureRecognizer.CommandProperty, "TapCommand");
|
||||
span.GestureRecognizers.Add(tapGesture);
|
||||
formattedString.Spans.Add(span);
|
||||
BindingContext = this;
|
||||
var label = new Label()
|
||||
{
|
||||
AutomationId = kText,
|
||||
HorizontalOptions = LayoutOptions.Center
|
||||
};
|
||||
|
||||
label.FormattedText = formattedString;
|
||||
TapCommand = new Command(() =>
|
||||
{
|
||||
i++;
|
||||
span.Text = $"{kText}: {i}";
|
||||
});
|
||||
|
||||
Content = new ContentView()
|
||||
{
|
||||
Content = new StackLayout()
|
||||
{
|
||||
Children =
|
||||
{
|
||||
label
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#if UITEST
|
||||
[Test]
|
||||
public void SpanGestureCommand()
|
||||
{
|
||||
RunningApp.WaitForElement(kText);
|
||||
RunningApp.Tap(kText);
|
||||
RunningApp.WaitForElement($"{kText}: 1");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -8,7 +8,8 @@
|
|||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>Xamarin.Forms.Controls.Issues</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue3524.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2004.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue3333.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2338.cs" />
|
||||
|
|
|
@ -1,10 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public static class BindableObjectExtensions
|
||||
{
|
||||
internal static void PropagateBindingContext<T>(this BindableObject self, IList<T> children)
|
||||
{
|
||||
PropagateBindingContext(self, children, BindableObject.SetInheritedBindingContext);
|
||||
}
|
||||
|
||||
internal static void PropagateBindingContext<T>(this BindableObject self, IList<T> children, Action<BindableObject, object> setChildBindingContext)
|
||||
{
|
||||
if (children == null || children.Count == 0)
|
||||
return;
|
||||
|
||||
var bc = self.BindingContext;
|
||||
|
||||
for (var i = 0; i < children.Count; i++)
|
||||
{
|
||||
var bo = children[i] as BindableObject;
|
||||
if (bo == null)
|
||||
continue;
|
||||
|
||||
setChildBindingContext(bo, bc);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
|
||||
string stringFormat = null)
|
||||
{
|
||||
|
|
|
@ -319,21 +319,10 @@ namespace Xamarin.Forms
|
|||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
var gotBindingContext = false;
|
||||
object bc = null;
|
||||
|
||||
for (var index = 0; index < LogicalChildrenInternal.Count; index++)
|
||||
this.PropagateBindingContext(LogicalChildrenInternal, (child, bc) =>
|
||||
{
|
||||
Element child = LogicalChildrenInternal[index];
|
||||
|
||||
if (!gotBindingContext)
|
||||
{
|
||||
bc = BindingContext;
|
||||
gotBindingContext = true;
|
||||
}
|
||||
|
||||
SetChildInheritedBindingContext(child, bc);
|
||||
}
|
||||
SetChildInheritedBindingContext((Element)child, bc);
|
||||
});
|
||||
|
||||
if (_bindableResources != null)
|
||||
foreach (BindableObject item in _bindableResources)
|
||||
|
|
|
@ -103,11 +103,18 @@ namespace Xamarin.Forms
|
|||
set { SetValue(TextDecorationsProperty, value); }
|
||||
}
|
||||
|
||||
public double LineHeight {
|
||||
public double LineHeight
|
||||
{
|
||||
get { return (double)GetValue(LineHeightElement.LineHeightProperty); }
|
||||
set { SetValue(LineHeightElement.LineHeightProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
this.PropagateBindingContext(GestureRecognizers);
|
||||
base.OnBindingContextChanged();
|
||||
}
|
||||
|
||||
void IFontElement.OnFontFamilyChanged(string oldValue, string newValue)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -154,24 +154,7 @@ namespace Xamarin.Forms
|
|||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
var gotBindingContext = false;
|
||||
object bc = null;
|
||||
|
||||
for (var i = 0; i < GestureRecognizers.Count; i++)
|
||||
{
|
||||
var bo = GestureRecognizers[i] as BindableObject;
|
||||
if (bo == null)
|
||||
continue;
|
||||
|
||||
if (!gotBindingContext)
|
||||
{
|
||||
bc = BindingContext;
|
||||
gotBindingContext = true;
|
||||
}
|
||||
|
||||
SetInheritedBindingContext(bo, bc);
|
||||
}
|
||||
|
||||
this.PropagateBindingContext(GestureRecognizers);
|
||||
base.OnBindingContextChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</ItemGroup>
|
||||
<Import Project="..\Xamarin.Flex\Xamarin.Flex.projitems" Label="Shared" Condition="Exists('..\Xamarin.Flex\Xamarin.Flex.projitems')" />
|
||||
<UsingTask TaskName="XFCorePostProcessor.Tasks.FixXFCoreAssembly" AssemblyFile="..\XFCorePostProcessor.Tasks\bin\Debug\netstandard2.0\XFCorePostProcessor.Tasks.dll" />
|
||||
<Target AfterTargets="AfterCompile" Name="ShameHat">
|
||||
<Target Condition="$(DesignTimeBuild) != true AND $(BuildingProject) == true" AfterTargets="AfterCompile" Name="ShameHat">
|
||||
<FixXFCoreAssembly Assembly="$(IntermediateOutputPath)$(TargetFileName)" ReferencePath="@(ReferencePath)" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -20,13 +20,6 @@
|
|||
<RestorePackages>true</RestorePackages>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -16,13 +16,6 @@
|
|||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<AndroidCodeGenTarget>XAJavaInterop1</AndroidCodeGenTarget>
|
||||
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
|
||||
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -19,12 +17,6 @@
|
|||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -247,7 +248,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
protected override void OnDetachedFromWindow()
|
||||
{
|
||||
base.OnDetachedFromWindow();
|
||||
PageController.SendDisappearing();
|
||||
PageController?.SendDisappearing();
|
||||
}
|
||||
|
||||
protected virtual void OnElementChanged(VisualElement oldElement, VisualElement newElement)
|
||||
|
|
|
@ -273,8 +273,10 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
|
|||
for (int i = 0; i < _renderer.ChildCount; i++)
|
||||
viewsToRemove.Add(_renderer.GetChildAt(i));
|
||||
|
||||
foreach (var root in _navModel.Roots)
|
||||
renderersToDispose.Add(Android.Platform.GetRenderer(root));
|
||||
foreach (IVisualElementRenderer rootRenderer in _navModel.Roots.Select(Android.Platform.GetRenderer))
|
||||
{
|
||||
rootRenderer?.Dispose();
|
||||
}
|
||||
|
||||
_navModel = new NavigationModel();
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
public static IVisualElementRenderer GetRenderer(VisualElement bindable)
|
||||
{
|
||||
return (IVisualElementRenderer)bindable.GetValue(RendererProperty);
|
||||
return (IVisualElementRenderer)bindable?.GetValue(RendererProperty);
|
||||
}
|
||||
|
||||
public static void SetRenderer(VisualElement bindable, IVisualElementRenderer value)
|
||||
|
|
|
@ -217,6 +217,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
void UpdateLineHeight()
|
||||
{
|
||||
_lastSizeRequest = null;
|
||||
if (Element.LineHeight == -1)
|
||||
_view.SetLineSpacing(_lineSpacingExtraDefault, _lineSpacingMultiplierDefault);
|
||||
else if (Element.LineHeight >= 0)
|
||||
|
|
|
@ -22,12 +22,6 @@
|
|||
<AndroidTlsProvider>
|
||||
</AndroidTlsProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
|
|
|
@ -142,6 +142,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
UpdateLineBreakMode(Control);
|
||||
UpdateMaxLines(Control);
|
||||
UpdateDetectReadingOrderFromContent(Control);
|
||||
UpdateLineHeight(Control);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
var span = element.FormattedText.Spans[i];
|
||||
|
||||
var location = currentLocation;
|
||||
var length = span.Text.Length;
|
||||
var length = span.Text?.Length ?? 0;
|
||||
|
||||
if (length == 0)
|
||||
continue;
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Xamarin.Forms.Xaml.UnitTests.Gh3539"
|
||||
xmlns:local="using:Xamarin.Forms.Xaml.UnitTests">
|
||||
<StackLayout x:DataType="local:Gh3539ViewModel">
|
||||
<StackLayout.BindingContext>
|
||||
<local:Gh3539ViewModel Color="Sienna" />
|
||||
</StackLayout.BindingContext>
|
||||
<BoxView Color="{Binding Color}"
|
||||
VerticalOptions="FillAndExpand" />
|
||||
<StackLayout Margin="10, 0">
|
||||
<Label Text="{Binding Name}" />
|
||||
<Slider Value="{Binding Hue}" />
|
||||
<Label Text="{Binding Hue, StringFormat='Hue = {0:F2}'}" />
|
||||
<Slider Value="{Binding Saturation}" />
|
||||
<Label Text="{Binding Saturation, StringFormat='Saturation = {0:F2}'}" />
|
||||
<Slider Value="{Binding Luminosity}" />
|
||||
<Label Text="{Binding Luminosity, StringFormat='Luminosity = {0:F2}'}" />
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ContentPage>
|
|
@ -0,0 +1,214 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Core.UnitTests;
|
||||
|
||||
namespace Xamarin.Forms.Xaml.UnitTests
|
||||
{
|
||||
public class Gh3539ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
Color color;
|
||||
string name;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public double Hue {
|
||||
set {
|
||||
if (color.Hue != value) {
|
||||
Color = Color.FromHsla(value, color.Saturation, color.Luminosity);
|
||||
}
|
||||
}
|
||||
get {
|
||||
return color.Hue;
|
||||
}
|
||||
}
|
||||
|
||||
public double Saturation {
|
||||
set {
|
||||
if (color.Saturation != value) {
|
||||
Color = Color.FromHsla(color.Hue, value, color.Luminosity);
|
||||
}
|
||||
}
|
||||
get {
|
||||
return color.Saturation;
|
||||
}
|
||||
}
|
||||
|
||||
public double Luminosity {
|
||||
set {
|
||||
if (color.Luminosity != value) {
|
||||
Color = Color.FromHsla(color.Hue, color.Saturation, value);
|
||||
}
|
||||
}
|
||||
get {
|
||||
return color.Luminosity;
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color {
|
||||
set {
|
||||
if (color != value) {
|
||||
color = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Hue"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Saturation"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Luminosity"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Color"));
|
||||
|
||||
Name = Gh3539NamedColor.GetNearestColorName(color);
|
||||
}
|
||||
}
|
||||
get {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name {
|
||||
private set {
|
||||
if (name != value) {
|
||||
name = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name"));
|
||||
}
|
||||
}
|
||||
get {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Gh3539NamedColor : IEquatable<Gh3539NamedColor>, IComparable<Gh3539NamedColor>
|
||||
{
|
||||
// Instance members
|
||||
private Gh3539NamedColor()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name { private set; get; }
|
||||
|
||||
public string FriendlyName { private set; get; }
|
||||
|
||||
public Color Color { private set; get; }
|
||||
|
||||
public string RgbDisplay { private set; get; }
|
||||
|
||||
public bool Equals(Gh3539NamedColor other)
|
||||
{
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public int CompareTo(Gh3539NamedColor other)
|
||||
{
|
||||
return Name.CompareTo(other.Name);
|
||||
}
|
||||
|
||||
// Static members
|
||||
static Gh3539NamedColor()
|
||||
{
|
||||
List<Gh3539NamedColor> all = new List<Gh3539NamedColor>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
// Loop through the public static fields of the Color structure.
|
||||
foreach (FieldInfo fieldInfo in typeof(Color).GetRuntimeFields()) {
|
||||
if (fieldInfo.IsPublic &&
|
||||
fieldInfo.IsStatic &&
|
||||
fieldInfo.FieldType == typeof(Color)) {
|
||||
// Convert the name to a friendly name.
|
||||
string name = fieldInfo.Name;
|
||||
stringBuilder.Clear();
|
||||
int index = 0;
|
||||
|
||||
foreach (char ch in name) {
|
||||
if (index != 0 && Char.IsUpper(ch)) {
|
||||
stringBuilder.Append(' ');
|
||||
}
|
||||
stringBuilder.Append(ch);
|
||||
index++;
|
||||
}
|
||||
|
||||
// Instantiate a NamedColor object.
|
||||
Color color = (Color)fieldInfo.GetValue(null);
|
||||
|
||||
Gh3539NamedColor namedColor = new Gh3539NamedColor {
|
||||
Name = name,
|
||||
FriendlyName = stringBuilder.ToString(),
|
||||
Color = color,
|
||||
RgbDisplay = String.Format("{0:X2}-{1:X2}-{2:X2}",
|
||||
(int)(255 * color.R),
|
||||
(int)(255 * color.G),
|
||||
(int)(255 * color.B))
|
||||
};
|
||||
|
||||
// Add it to the collection.
|
||||
all.Add(namedColor);
|
||||
}
|
||||
}
|
||||
all.TrimExcess();
|
||||
all.Sort();
|
||||
All = all;
|
||||
}
|
||||
|
||||
public static IList<Gh3539NamedColor> All { private set; get; }
|
||||
|
||||
public static Gh3539NamedColor Find(string name)
|
||||
{
|
||||
return ((List<Gh3539NamedColor>)All).Find(nc => nc.Name == name);
|
||||
}
|
||||
|
||||
public static string GetNearestColorName(Color color)
|
||||
{
|
||||
double shortestDistance = 1000;
|
||||
Gh3539NamedColor closestColor = null;
|
||||
|
||||
foreach (Gh3539NamedColor namedColor in Gh3539NamedColor.All) {
|
||||
double distance = Math.Sqrt(Math.Pow(color.R - namedColor.Color.R, 2) +
|
||||
Math.Pow(color.G - namedColor.Color.G, 2) +
|
||||
Math.Pow(color.B - namedColor.Color.B, 2));
|
||||
|
||||
if (distance < shortestDistance) {
|
||||
shortestDistance = distance;
|
||||
closestColor = namedColor;
|
||||
}
|
||||
}
|
||||
return closestColor.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Gh3539 : ContentPage
|
||||
{
|
||||
public Gh3539()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public Gh3539(bool useCompiledXaml)
|
||||
{
|
||||
//this stub will be replaced at compile time
|
||||
}
|
||||
|
||||
|
||||
[TestFixture]
|
||||
class Tests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Device.PlatformServices = new MockPlatformServices();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Device.PlatformServices = null;
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
public void CompiledBindingCodeIsValid(bool useCompiledXaml)
|
||||
{
|
||||
var layout = new Gh3539(useCompiledXaml);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -637,6 +637,9 @@
|
|||
<Compile Include="Issues\Gh3512.xaml.cs">
|
||||
<DependentUpon>Gh3512.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Issues\Gh3539.xaml.cs">
|
||||
<DependentUpon>Gh3280.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" Condition="'$(BuildingInsideVisualStudio)' == 'true' AND Exists('..\.nuspec\Xamarin.Forms.Build.Tasks.dll')" />
|
||||
|
@ -1159,6 +1162,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Issues\Gh3539.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче