File: App.xaml.cpp

package info (click to toggle)
mediainfo 20.09-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,732 kB
  • sloc: cpp: 15,682; objc: 2,760; sh: 1,343; xml: 926; python: 259; perl: 207; makefile: 173
file content (104 lines) | stat: -rw-r--r-- 3,533 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
*  Use of this source code is governed by a BSD-style license that can
*  be found in the License.html file in the root of the source tree.
*/

//---------------------------------------------------------------------------
#include "pch.h"
#include "AppCore.h"

//---------------------------------------------------------------------------
using namespace MediaInfo;

using namespace Platform;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;

//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
App::App()
{
    InitializeComponent();

    Suspending+=ref new SuspendingEventHandler(this, &App::OnSuspending);
}

//---------------------------------------------------------------------------
void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ Event)
{
    Frame^ RootFrame=dynamic_cast<Frame^>(Window::Current->Content);

    if (!RootFrame)
    {
        RootFrame=ref new Frame();
        RootFrame->NavigationFailed+=ref new NavigationFailedEventHandler(this, &App::OnNavigationFailed);

        if (!Event->PrelaunchActivated)
            Window::Current->Content=RootFrame;
    }

    if (!Event->PrelaunchActivated)
    {
        if (!RootFrame->Content)
            RootFrame->Navigate(TypeName(MainPage::typeid), Event->Arguments);

        Window::Current->Activate();
    }

    MainPage^ Page=dynamic_cast<MainPage^>(RootFrame->Content);
}

//---------------------------------------------------------------------------
void App::OnSuspending(Object^, SuspendingEventArgs^)
{
}

//---------------------------------------------------------------------------
void App::OnNavigationFailed(Platform::Object^, NavigationFailedEventArgs^ Event)
{
    throw ref new FailureException("Failed to load Page "+Event->SourcePageType.Name);
}

//---------------------------------------------------------------------------
void App::OnFileActivated(FileActivatedEventArgs^ Event)
{
    if (!Event->Files->Size)
        return;

    Frame^ RootFrame=dynamic_cast<Frame^>(Window::Current->Content);

    if (!RootFrame)
    {
        RootFrame=ref new Frame();
        RootFrame->NavigationFailed+=ref new NavigationFailedEventHandler(this, &App::OnNavigationFailed);
        Window::Current->Content=RootFrame;

        if (!RootFrame->Content)
            RootFrame->Navigate(TypeName(MainPage::typeid), nullptr);
    }
    else if (!RootFrame->Content || TypeName(RootFrame->Content->GetType()).Name!=TypeName(MainPage::typeid).Name)
    {
        RootFrame->Navigate(TypeName(MainPage::typeid), nullptr);


    }

    Window::Current->Activate();

    MainPage^ Page=dynamic_cast<MainPage^>(RootFrame->Content);
    Page->Open_Files(Event->Files);
}