Skip to content

Commit 33b1900

Browse files
Merge pull request #330 from microsoft/user/t-limay/StyleTransfer-framerate
CPP version and framerate calculation
2 parents 9a46a88 + 3bb165a commit 33b1900

33 files changed

+3009
-2403
lines changed

Samples/StyleTransfer/App.xaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<Application
2-
x:Class="StyleTransfer.App"
3-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:local="using:StyleTransfer">
6-
7-
<Application.Resources>
8-
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
9-
</Application.Resources>
10-
11-
</Application>
1+
<Application
2+
x:Class="StyleTransfer.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:StyleTransfer">
6+
7+
<Application.Resources>
8+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
9+
</Application.Resources>
10+
11+
</Application>

Samples/StyleTransfer/App.xaml.cs

Lines changed: 102 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,102 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Runtime.InteropServices.WindowsRuntime;
6-
using Windows.ApplicationModel;
7-
using Windows.ApplicationModel.Activation;
8-
using Windows.Foundation;
9-
using Windows.Foundation.Collections;
10-
using Windows.UI.Xaml;
11-
using Windows.UI.Xaml.Controls;
12-
using Windows.UI.Xaml.Controls.Primitives;
13-
using Windows.UI.Xaml.Data;
14-
using Windows.UI.Xaml.Input;
15-
using Windows.UI.Xaml.Media;
16-
using Windows.UI.Xaml.Navigation;
17-
18-
namespace StyleTransfer
19-
{
20-
/// <summary>
21-
/// Provides application-specific behavior to supplement the default Application class.
22-
/// </summary>
23-
sealed partial class App : Application
24-
{
25-
/// <summary>
26-
/// Initializes the singleton application object. This is the first line of authored code
27-
/// executed, and as such is the logical equivalent of main() or WinMain().
28-
/// </summary>
29-
public App()
30-
{
31-
this.InitializeComponent();
32-
this.Suspending += OnSuspending;
33-
}
34-
35-
/// <summary>
36-
/// Invoked when the application is launched normally by the end user. Other entry points
37-
/// will be used such as when the application is launched to open a specific file.
38-
/// </summary>
39-
/// <param name="e">Details about the launch request and process.</param>
40-
protected override void OnLaunched(LaunchActivatedEventArgs e)
41-
{
42-
Frame rootFrame = Window.Current.Content as Frame;
43-
44-
// Do not repeat app initialization when the Window already has content,
45-
// just ensure that the window is active
46-
if (rootFrame == null)
47-
{
48-
// Create a Frame to act as the navigation context and navigate to the first page
49-
rootFrame = new Frame();
50-
51-
rootFrame.NavigationFailed += OnNavigationFailed;
52-
53-
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
54-
{
55-
//TODO: Load state from previously suspended application
56-
}
57-
58-
// Place the frame in the current Window
59-
Window.Current.Content = rootFrame;
60-
}
61-
62-
if (e.PrelaunchActivated == false)
63-
{
64-
if (rootFrame.Content == null)
65-
{
66-
// When the navigation stack isn't restored navigate to the first page,
67-
// configuring the new page by passing required information as a navigation
68-
// parameter
69-
rootFrame.Navigate(typeof(MainPage), e.Arguments);
70-
}
71-
// Ensure the current window is active
72-
Window.Current.Activate();
73-
}
74-
}
75-
76-
/// <summary>
77-
/// Invoked when Navigation to a certain page fails
78-
/// </summary>
79-
/// <param name="sender">The Frame which failed navigation</param>
80-
/// <param name="e">Details about the navigation failure</param>
81-
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
82-
{
83-
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
84-
}
85-
86-
/// <summary>
87-
/// Invoked when application execution is being suspended. Application state is saved
88-
/// without knowing whether the application will be terminated or resumed with the contents
89-
/// of memory still intact.
90-
/// </summary>
91-
/// <param name="sender">The source of the suspend request.</param>
92-
/// <param name="e">Details about the suspend request.</param>
93-
private void OnSuspending(object sender, SuspendingEventArgs e)
94-
{
95-
var deferral = e.SuspendingOperation.GetDeferral();
96-
//TODO: Save application state and stop any background activity
97-
deferral.Complete();
98-
}
99-
}
100-
}
1+
using GalaSoft.MvvmLight.Threading;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Runtime.InteropServices.WindowsRuntime;
7+
using Windows.ApplicationModel;
8+
using Windows.ApplicationModel.Activation;
9+
using Windows.Foundation;
10+
using Windows.Foundation.Collections;
11+
using Windows.UI.Xaml;
12+
using Windows.UI.Xaml.Controls;
13+
using Windows.UI.Xaml.Controls.Primitives;
14+
using Windows.UI.Xaml.Data;
15+
using Windows.UI.Xaml.Input;
16+
using Windows.UI.Xaml.Media;
17+
using Windows.UI.Xaml.Navigation;
18+
19+
namespace StyleTransfer
20+
{
21+
/// <summary>
22+
/// Provides application-specific behavior to supplement the default Application class.
23+
/// </summary>
24+
sealed partial class App : Application
25+
{
26+
/// <summary>
27+
/// Initializes the singleton application object. This is the first line of authored code
28+
/// executed, and as such is the logical equivalent of main() or WinMain().
29+
/// </summary>
30+
public App()
31+
{
32+
this.InitializeComponent();
33+
this.Suspending += OnSuspending;
34+
}
35+
36+
/// <summary>
37+
/// Invoked when the application is launched normally by the end user. Other entry points
38+
/// will be used such as when the application is launched to open a specific file.
39+
/// </summary>
40+
/// <param name="e">Details about the launch request and process.</param>
41+
protected override void OnLaunched(LaunchActivatedEventArgs e)
42+
{
43+
Frame rootFrame = Window.Current.Content as Frame;
44+
45+
// Do not repeat app initialization when the Window already has content,
46+
// just ensure that the window is active
47+
if (rootFrame == null)
48+
{
49+
// Create a Frame to act as the navigation context and navigate to the first page
50+
rootFrame = new Frame();
51+
52+
rootFrame.NavigationFailed += OnNavigationFailed;
53+
54+
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
55+
{
56+
//TODO: Load state from previously suspended application
57+
}
58+
59+
// Place the frame in the current Window
60+
Window.Current.Content = rootFrame;
61+
}
62+
63+
if (e.PrelaunchActivated == false)
64+
{
65+
if (rootFrame.Content == null)
66+
{
67+
// When the navigation stack isn't restored navigate to the first page,
68+
// configuring the new page by passing required information as a navigation
69+
// parameter
70+
rootFrame.Navigate(typeof(MainPage), e.Arguments);
71+
}
72+
// Ensure the current window is active
73+
Window.Current.Activate();
74+
}
75+
DispatcherHelper.Initialize();
76+
}
77+
78+
/// <summary>
79+
/// Invoked when Navigation to a certain page fails
80+
/// </summary>
81+
/// <param name="sender">The Frame which failed navigation</param>
82+
/// <param name="e">Details about the navigation failure</param>
83+
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
84+
{
85+
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
86+
}
87+
88+
/// <summary>
89+
/// Invoked when application execution is being suspended. Application state is saved
90+
/// without knowing whether the application will be terminated or resumed with the contents
91+
/// of memory still intact.
92+
/// </summary>
93+
/// <param name="sender">The source of the suspend request.</param>
94+
/// <param name="e">Details about the suspend request.</param>
95+
private void OnSuspending(object sender, SuspendingEventArgs e)
96+
{
97+
var deferral = e.SuspendingOperation.GetDeferral();
98+
//TODO: Save application state and stop any background activity
99+
deferral.Complete();
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)