chore: Continued adjusting
This commit is contained in:
Родитель
ff9deee7d3
Коммит
7488f34ca6
|
@ -11,7 +11,7 @@ using Microsoft.UI.Xaml.Controls.Primitives;
|
|||
|
||||
namespace Microsoft.UI.Xaml;
|
||||
|
||||
public partial class Application
|
||||
partial class Application
|
||||
{
|
||||
partial void InitializePartial()
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ using LaunchActivatedEventArgs = Windows.ApplicationModel.Activation.LaunchActiv
|
|||
namespace Microsoft.UI.Xaml
|
||||
{
|
||||
[Register("UnoAppDelegate")]
|
||||
public partial class Application : UIApplicationDelegate
|
||||
partial class Application : UIApplicationDelegate
|
||||
{
|
||||
private bool _preventSecondaryActivationHandling;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ using NativeHandle = ObjCRuntime.NativeHandle;
|
|||
namespace Microsoft.UI.Xaml
|
||||
{
|
||||
[Register("UnoAppDelegate")]
|
||||
public partial class Application : NSApplicationDelegate
|
||||
partial class Application : NSApplicationDelegate
|
||||
{
|
||||
private NSUrl[] _launchUrls;
|
||||
|
||||
|
|
|
@ -12,97 +12,90 @@ using Microsoft.UI.Xaml.Media;
|
|||
using Uno.UI.Dispatching;
|
||||
using Uno.UI.Xaml.Core;
|
||||
|
||||
namespace Microsoft.UI.Xaml
|
||||
namespace Microsoft.UI.Xaml;
|
||||
|
||||
partial class Application
|
||||
{
|
||||
public partial class Application : IApplicationEvents
|
||||
private static bool _startInvoked;
|
||||
|
||||
[ThreadStatic]
|
||||
private static Application _current;
|
||||
|
||||
partial void InitializePartial()
|
||||
{
|
||||
private static bool _startInvoked;
|
||||
|
||||
[ThreadStatic]
|
||||
private static Application _current;
|
||||
|
||||
partial void InitializePartial()
|
||||
if (!_startInvoked)
|
||||
{
|
||||
if (!_startInvoked)
|
||||
throw new InvalidOperationException("The application must be started using Application.Start first, e.g. Microsoft.UI.Xaml.Application.Start(_ => new App());");
|
||||
}
|
||||
|
||||
SetCurrentLanguage();
|
||||
|
||||
CoreApplication.SetInvalidateRender(compositionTarget =>
|
||||
{
|
||||
Debug.Assert(compositionTarget is null or CompositionTarget);
|
||||
|
||||
if (compositionTarget is CompositionTarget { Root: { } root })
|
||||
{
|
||||
throw new InvalidOperationException("The application must be started using Application.Start first, e.g. Microsoft.UI.Xaml.Application.Start(_ => new App());");
|
||||
}
|
||||
|
||||
SetCurrentLanguage();
|
||||
|
||||
CoreApplication.SetInvalidateRender(compositionTarget =>
|
||||
{
|
||||
Debug.Assert(compositionTarget is null or CompositionTarget);
|
||||
|
||||
if (compositionTarget is CompositionTarget { Root: { } root })
|
||||
foreach (var cRoot in CoreServices.Instance.ContentRootCoordinator.ContentRoots)
|
||||
{
|
||||
foreach (var cRoot in CoreServices.Instance.ContentRootCoordinator.ContentRoots)
|
||||
if (cRoot?.XamlRoot is { } xRoot && ReferenceEquals(xRoot.VisualTree.RootElement.Visual, root))
|
||||
{
|
||||
if (cRoot?.XamlRoot is { } xRoot && ReferenceEquals(xRoot.VisualTree.RootElement.Visual, root))
|
||||
{
|
||||
xRoot.QueueInvalidateRender();
|
||||
return;
|
||||
}
|
||||
xRoot.QueueInvalidateRender();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
internal ISkiaApplicationHost? Host { get; set; }
|
||||
|
||||
internal static SynchronizationContext ApplicationSynchronizationContext { get; private set; }
|
||||
|
||||
private void SetCurrentLanguage()
|
||||
{
|
||||
if (CultureInfo.CurrentUICulture.IetfLanguageTag == "" &&
|
||||
CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "iv")
|
||||
{
|
||||
try
|
||||
{
|
||||
// Fallback to English
|
||||
var cultureInfo = CultureInfo.CreateSpecificCulture("en");
|
||||
CultureInfo.CurrentUICulture = cultureInfo;
|
||||
CultureInfo.CurrentCulture = cultureInfo;
|
||||
Thread.CurrentThread.CurrentCulture = cultureInfo;
|
||||
Thread.CurrentThread.CurrentUICulture = cultureInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Log().Error($"Failed to set default culture", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static partial void StartPartial()
|
||||
{
|
||||
_startInvoked = true;
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
ApplicationSynchronizationContext = new NativeDispatcherSynchronizationContext(NativeDispatcher.Main, NativeDispatcherPriority.Normal)
|
||||
);
|
||||
|
||||
callback(new ApplicationInitializationCallbackParams());
|
||||
|
||||
_current.InvokeOnLaunched();
|
||||
}
|
||||
|
||||
private void InvokeOnLaunched()
|
||||
{
|
||||
using (WritePhaseEventTrace(TraceProvider.LauchedStart, TraceProvider.LauchedStop))
|
||||
{
|
||||
InitializationCompleted();
|
||||
|
||||
// OnLaunched should execute only for full apps, not for individual islands.
|
||||
if (CoreApplication.IsFullFledgedApp)
|
||||
{
|
||||
OnLaunched(new LaunchActivatedEventArgs(ActivationKind.Launch, GetCommandLineArgsWithoutExecutable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void ForceSetRequestedTheme(ApplicationTheme theme) => _requestedTheme = theme;
|
||||
});
|
||||
}
|
||||
|
||||
internal interface IApplicationEvents
|
||||
internal ISkiaApplicationHost? Host { get; set; }
|
||||
|
||||
internal static SynchronizationContext ApplicationSynchronizationContext { get; private set; }
|
||||
|
||||
private void SetCurrentLanguage()
|
||||
{
|
||||
if (CultureInfo.CurrentUICulture.IetfLanguageTag == "" &&
|
||||
CultureInfo.CurrentUICulture.TwoLetterISOLanguageName == "iv")
|
||||
{
|
||||
try
|
||||
{
|
||||
// Fallback to English
|
||||
var cultureInfo = CultureInfo.CreateSpecificCulture("en");
|
||||
CultureInfo.CurrentUICulture = cultureInfo;
|
||||
CultureInfo.CurrentCulture = cultureInfo;
|
||||
Thread.CurrentThread.CurrentCulture = cultureInfo;
|
||||
Thread.CurrentThread.CurrentUICulture = cultureInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Log().Error($"Failed to set default culture", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static partial void StartPartial()
|
||||
{
|
||||
_startInvoked = true;
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
ApplicationSynchronizationContext = new NativeDispatcherSynchronizationContext(NativeDispatcher.Main, NativeDispatcherPriority.Normal)
|
||||
);
|
||||
|
||||
_current.InvokeOnLaunched();
|
||||
}
|
||||
|
||||
private void InvokeOnLaunched()
|
||||
{
|
||||
using (WritePhaseEventTrace(TraceProvider.LauchedStart, TraceProvider.LauchedStop))
|
||||
{
|
||||
InitializationCompleted();
|
||||
|
||||
// OnLaunched should execute only for full apps, not for individual islands.
|
||||
if (CoreApplication.IsFullFledgedApp)
|
||||
{
|
||||
OnLaunched(new LaunchActivatedEventArgs(ActivationKind.Launch, GetCommandLineArgsWithoutExecutable()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void ForceSetRequestedTheme(ApplicationTheme theme) => _requestedTheme = theme;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ using NativeMethods = __Microsoft.UI.Xaml.Application.NativeMethods;
|
|||
|
||||
namespace Microsoft.UI.Xaml
|
||||
{
|
||||
public partial class Application
|
||||
partial class Application
|
||||
{
|
||||
private static bool _startInvoked;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче