Dont expose execution mode
This commit is contained in:
Родитель
c29848f9a4
Коммит
c7da3492ae
|
@ -24,81 +24,6 @@ namespace Microsoft.Toolkit.Sample.UWP.App
|
|||
{
|
||||
this.Initialize();
|
||||
this.InitializeComponent();
|
||||
|
||||
if (ExecutionMode == Microsoft.Toolkit.Win32.UI.XamlHost.ExecutionMode.UWP)
|
||||
{
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
if (this.ExecutionMode == Microsoft.Toolkit.Win32.UI.XamlHost.ExecutionMode.Win32)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (e.PrelaunchActivated == false)
|
||||
{
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,9 +45,6 @@
|
|||
<ProjectReference Include="..\Microsoft.Toolkit.Sample.UWP.App\Microsoft.Toolkit.Sample.UWP.App.csproj" Condition="'$(TargetFramework)'=='netcoreapp3.0'">
|
||||
<Private>true</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.Toolkit.Win32.UI.XamlHost\Microsoft.Toolkit.Win32.UI.XamlHost.Managed.csproj">
|
||||
<Private>true</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.Toolkit.Wpf.UI.Controls.WebView\Microsoft.Toolkit.Wpf.UI.Controls.WebView.csproj">
|
||||
<Private>true</Private>
|
||||
</ProjectReference>
|
||||
|
@ -58,6 +55,22 @@
|
|||
<Private>true</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<XamlApp-Platform Condition="'$(Platform)'=='x86'">Win32</XamlApp-Platform>
|
||||
<XamlApp-Platform Condition="'$(Platform)'=='x64'">x64</XamlApp-Platform>
|
||||
<XamlApp-Platform Condition="'$(Platform)'=='AnyCPU'">x64</XamlApp-Platform>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.Toolkit.Win32.UI.XamlApplication.Package\Microsoft.Toolkit.Win32.UI.XamlApplication.Package.csproj">
|
||||
<PrivateAssets>analyzers</PrivateAssets>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Microsoft.Toolkit.Win32.UI.XamlHost\Microsoft.Toolkit.Win32.UI.XamlHost.Managed.csproj">
|
||||
<PrivateAssets>analyzers</PrivateAssets>
|
||||
</ProjectReference>
|
||||
<Reference Include="..\$(XamlApp-Platform)\$(Configuration)\Microsoft.Toolkit.Win32.UI.XamlApplication\Microsoft.Toolkit.Win32.UI.XamlHost.winmd" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Assets\storelogo-sdk.png" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
|
||||
namespace winrt::Microsoft::Toolkit::Win32::UI::XamlHost::implementation
|
||||
{
|
||||
enum ExecutionMode
|
||||
{
|
||||
UWP = 0,
|
||||
Win32 = 1,
|
||||
};
|
||||
|
||||
class XamlApplication : public XamlApplicationT<XamlApplication, Windows::UI::Xaml::Markup::IXamlMetadataProvider>
|
||||
{
|
||||
public:
|
||||
|
@ -19,10 +25,6 @@ namespace winrt::Microsoft::Toolkit::Win32::UI::XamlHost::implementation
|
|||
void Close();
|
||||
|
||||
winrt::Windows::Foundation::IClosable WindowsXamlManager() const;
|
||||
winrt::Microsoft::Toolkit::Win32::UI::XamlHost::ExecutionMode ExecutionMode() const
|
||||
{
|
||||
return m_executionMode;
|
||||
}
|
||||
|
||||
winrt::Windows::UI::Xaml::Markup::IXamlType GetXamlType(winrt::Windows::UI::Xaml::Interop::TypeName const& type);
|
||||
winrt::Windows::UI::Xaml::Markup::IXamlType GetXamlType(winrt::hstring const& fullName);
|
||||
|
@ -36,7 +38,7 @@ namespace winrt::Microsoft::Toolkit::Win32::UI::XamlHost::implementation
|
|||
}
|
||||
|
||||
private:
|
||||
winrt::Microsoft::Toolkit::Win32::UI::XamlHost::ExecutionMode m_executionMode = ExecutionMode::Win32;
|
||||
ExecutionMode m_executionMode = ExecutionMode::Win32;
|
||||
winrt::Windows::UI::Xaml::Hosting::WindowsXamlManager m_windowsXamlManager = nullptr;
|
||||
winrt::Windows::Foundation::Collections::IVector<winrt::Windows::UI::Xaml::Markup::IXamlMetadataProvider> m_providers = winrt::single_threaded_vector<Windows::UI::Xaml::Markup::IXamlMetadataProvider>();
|
||||
bool m_bIsClosed = false;
|
||||
|
|
|
@ -6,12 +6,6 @@ namespace Microsoft.Toolkit.Win32.UI.XamlHost
|
|||
Windows.Foundation.Collections.IVector<Windows.UI.Xaml.Markup.IXamlMetadataProvider> MetadataProviders { get; };
|
||||
};
|
||||
|
||||
enum ExecutionMode
|
||||
{
|
||||
UWP = 0,
|
||||
Win32 = 1,
|
||||
};
|
||||
|
||||
[default_interface]
|
||||
unsealed runtimeclass XamlApplication : Windows.UI.Xaml.Application, IXamlMetadataContainer, Windows.Foundation.IClosable
|
||||
{
|
||||
|
@ -19,7 +13,6 @@ namespace Microsoft.Toolkit.Win32.UI.XamlHost
|
|||
protected XamlApplication();
|
||||
protected void Initialize();
|
||||
|
||||
ExecutionMode ExecutionMode{ get; };
|
||||
Windows.Foundation.IClosable WindowsXamlManager{ get; };
|
||||
Boolean IsDisposed { get; };
|
||||
}
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
</CreateItem>
|
||||
<Copy SourceFiles="%(FilterPri.Identity)" ContinueOnError="true" DestinationFolder="$(OutDir)\"/>
|
||||
|
||||
<CreateItem Include="%(BuildOutputs.RelativeDir)AppxManifest*.xml">
|
||||
<Output ItemName="AppxManifest" TaskParameter="Include"/>
|
||||
</CreateItem>
|
||||
<Copy SourceFiles="%(Filter.Identity)" ContinueOnError="true" DestinationFolder="$(OutDir)"/>
|
||||
|
||||
<GetAssemblyIdentity AssemblyFiles="@(FilterBin)" ContinueOnError="true">
|
||||
<Output
|
||||
TaskParameter="Assemblies"
|
||||
|
|
Загрузка…
Ссылка в новой задаче