コード例 #1
0
ファイル: AppCop.cs プロジェクト: xuan2261/Minista
        protected async override void OnFileActivated(FileActivatedEventArgs e)
        {
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                }
            }
            catch { }
            try
            {
                Frame rootFrame = CreateRootFrame();
                var   isNull    = false;
                if (rootFrame.Content == null)
                //if (!(Window.Current.Content is Frame rootFrame))
                {
                    isNull = true;
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        bool       loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                        SplashView extendedSplash = new SplashView(e.SplashScreen, loadState);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                    //await Task.Delay(6500);
                }
                rootFrame.Content.GetType().PrintDebug();
                Window.Current.Content.GetType().PrintDebug();
                Window.Current.Activate();
                if (isNull)
                {
                    await Task.Delay(6500);
                }
                try
                {
                    MainPage.Current?.HandleUriFile(e as FileActivatedEventArgs);
                }
                catch { }
                //if (Helper.InstaApi != null)
                //{
                //    if (Helper.InstaApi.IsUserAuthenticated)
                //    {


                //        return;
                //    }
                //}
            }
            catch { }
        }
コード例 #2
0
        protected async override void OnFileActivated(FileActivatedEventArgs e)
        {
            if (Helper.DontUseTimersAndOtherStuff)
            {
                return;
            }
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                }
            }
            catch { }
            try
            {
                Frame rootFrame = CreateRootFrame();
                var   isNull    = false;
                if (rootFrame.Content == null)
                {
                    isNull = true;
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        SplashView extendedSplash = new SplashView(e.SplashScreen);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    Window.Current.Content = rootFrame;
                }
                rootFrame.Content.GetType().PrintDebug();
                Window.Current.Content.GetType().PrintDebug();
                Window.Current.Activate();
                if (isNull)
                {
                    if (e.Files?.Count > 0 && e.Files[0] is StorageFile file)
                    {
                        if (file.Path.Contains(".mi-theme"))
                        {
                            var json = await FileIO.ReadTextAsync(file);

                            ThemeHelper.InitTheme(json);
                            return;
                        }
                    }
                    await Task.Delay(6500);
                }
                try
                {
                    MainPage.Current?.HandleUriFile(e);
                }
                catch { }
            }
            catch { }
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: xuan2261/Minista
        protected override void OnActivated(IActivatedEventArgs e)
        {
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                }
            }
            catch { }
            if (e.Kind == ActivationKind.Protocol)
            {
                var uriArgs = e as ProtocolActivatedEventArgs;
                System.Diagnostics.Debug.WriteLine("URI>>>>>> " + uriArgs.Uri.ToString());
                MainPage.NavigationUriProtocol = uriArgs.Uri.ToString();

                // Ensure the current window is active
                //Window.Current.Activate();

                Frame rootFrame = CreateRootFrame();
                if (rootFrame.Content == null)
                //if (!(Window.Current.Content is Frame rootFrame))
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        bool       loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                        SplashView extendedSplash = new SplashView(e.SplashScreen, loadState);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
                else
                {
                    MainPage.Current?.HandleUriProtocol();
                }

                rootFrame.Content.GetType().PrintDebug();
                Window.Current.Content.GetType().PrintDebug();
                Window.Current.Activate();
            }
            else if (e.Kind == ActivationKind.ToastNotification)
            {
                e.GetType().PrintDebug();
                var args = e as ToastNotificationActivatedEventArgs;
                args.PrintDebug();
                Frame rootFrame = CreateRootFrame();
                if (rootFrame.Content == null)
                //if (!(Window.Current.Content is Frame rootFrame))
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        bool       loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                        SplashView extendedSplash = new SplashView(e.SplashScreen, loadState);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
                else
                {
                    MainPage.Current?.HandleUriProtocol();
                }

                rootFrame.Content.GetType().PrintDebug();
                Window.Current.Content.GetType().PrintDebug();
                Window.Current.Activate();
            }
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: xuan2261/Minista
        /// <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 async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch");

            if (e != null)
            {
                if (e.PreviousExecutionState == ApplicationExecutionState.Running)
                {
                    Window.Current.Activate();
                    return;
                }
            }
            Helper.ChangeAppMinSize(540, 744);

            try
            {
                //StoreServicesNotificationChannelParameters parameters =
                //    new StoreServicesNotificationChannelParameters();
                //parameters.CustomNotificationChannelUri = "Assign your channel URI here";

                //StoreServicesEngagementManager engagementManager = StoreServicesEngagementManager.GetDefault();
                //await engagementManager.RegisterNotificationChannelAsync(parameters);

                await Helper.RunInBackground(async() =>
                {
                    StoreServicesEngagementManager engagementManager = StoreServicesEngagementManager.GetDefault();

                    await engagementManager.RegisterNotificationChannelAsync();
                });
            }
            catch
            {
                //
            }

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = CreateRootFrame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool       loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    SplashView extendedSplash = new SplashView(e.SplashScreen, loadState);
                    rootFrame.Content = extendedSplash;
                    //rootFrame.Content = new Views.BlankPage1();

                    Window.Current.Content = rootFrame;
                }
                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (canEnablePrelaunch)
                {
                    TryEnablePrelaunch();
                }
                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();
            }
        }
コード例 #5
0
ファイル: AppCop.cs プロジェクト: xuan2261/Minista
        protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs e)
        {
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                }
            }
            catch { }
            try
            {
                Frame rootFrame = CreateRootFrame();
                var   isNull    = false;
                var   isRunning = false;
                if (rootFrame.Content == null)
                //if (!(Window.Current.Content is Frame rootFrame))
                {
                    isRunning = isNull = true;
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        bool       loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                        SplashView extendedSplash = new SplashView(e.SplashScreen, loadState);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    else
                    {
                        bool       loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                        SplashView extendedSplash = new SplashView(e.SplashScreen, loadState);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
                //rootFrame.Content.GetType().PrintDebug();
                //Window.Current.Content.GetType().PrintDebug();
                //if(!isRunning)
                Window.Current.Activate();
                if (isNull)
                {
                    await Task.Delay(6500);
                }
                try
                {
                    ShareOperation shareOperation = e.ShareOperation;
                    //Debug.WriteLine(string.Join("\n", shareOperation.Data.AvailableFormats));
                    if (shareOperation.Data.Contains(StandardDataFormats.StorageItems))
                    {
                        var items = await shareOperation.Data.GetStorageItemsAsync();

                        if (items.Count > 0)
                        {
                            if (items[0] is StorageFile file)
                            {
                                MainPage.Current?.HandleUriFile(file);
                            }
                        }
                    }
                }
                catch { }
                //if (Helper.InstaApi != null)
                //{
                //    if (Helper.InstaApi.IsUserAuthenticated)
                //    {


                //        return;
                //    }
                //}
            }
            catch { }
            // Code to handle activation goes here.
            //ShareOperation shareOperation = args.ShareOperation;
            //Debug.WriteLine(string.Join("\n", shareOperation.Data.AvailableFormats));
            //if (shareOperation.Data.Contains(StandardDataFormats.StorageItems))
            //{
            //    var items = await shareOperation.Data.GetStorageItemsAsync();

            //    if (items.Count > 0)
            //    {
            //        var ff = items[0] as StorageFile;
            //    }
            //}
            //else if (shareOperation.Data.Contains(StandardDataFormats.ApplicationLink))
            //{
            //    var items = await shareOperation.Data.GetApplicationLinkAsync();

            //}
            //else if (shareOperation.Data.Contains(StandardDataFormats.WebLink))
            //{
            //    var items = await shareOperation.Data.GetWebLinkAsync();

            //}
            //else if (shareOperation.Data.Contains(StandardDataFormats.Bitmap))
            //{
            //    var items = await shareOperation.Data.GetBitmapAsync();

            //}
        }
コード例 #6
0
ファイル: App.xaml.cs プロジェクト: ramtinak/Minista
        protected /*async*/ override void OnLaunched(LaunchActivatedEventArgs e)
        {
            PushHelperX.Register();
            bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch");

            if (e != null)
            {
                if (e.PreviousExecutionState == ApplicationExecutionState.Running)
                {
                    Window.Current.Activate();
                    return;
                }
            }
            Helper.ChangeAppMinSize(540, 744);
            if (!(Window.Current.Content is Frame rootFrame))
            {
                rootFrame = CreateRootFrame();
                rootFrame.NavigationFailed += OnNavigationFailed;
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    SplashView extendedSplash = new SplashView(e.SplashScreen);
                    rootFrame.Content      = extendedSplash;
                    Window.Current.Content = rootFrame;
                }
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (canEnablePrelaunch)
                {
                    TryEnablePrelaunch();
                }
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                Window.Current.Activate();
            }
            DeviceHelper.GetDeviceInfo();
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                    RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested;
                }
            }
            catch { }
            try
            {
                UserAgentHelper.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36");
            }
            catch { }
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    FocusVisualKind = FocusVisualKind.Reveal;
                }
            }
            catch { }
            //try
            //{
            //    await Helper.RunInBackground(async () =>
            //    {
            //        StoreServicesEngagementManager engagementManager = StoreServicesEngagementManager.GetDefault();

            //        await engagementManager.RegisterNotificationChannelAsync();
            //    });
            //}
            //catch
            //{
            //}
        }
コード例 #7
0
        protected override async void OnActivated(IActivatedEventArgs e)
        {
            if (Helper.DontUseTimersAndOtherStuff)
            {
                return;
            }
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                }
            }
            catch { }
            if (e.Kind == ActivationKind.Protocol)
            {
                var uriArgs = e as ProtocolActivatedEventArgs;
                Debug.WriteLine("URI>>>>>> " + uriArgs.Uri.ToString());
                MainPage.NavigationUriProtocol = uriArgs.Uri.ToString();

                // Ensure the current window is active
                //Window.Current.Activate();

                Frame rootFrame = CreateRootFrame();
                if (rootFrame.Content == null)
                //if (!(Window.Current.Content is Frame rootFrame))
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        SplashView extendedSplash = new SplashView(e.SplashScreen);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
                else
                {
                    MainPage.Current?.HandleUriProtocol();
                }

                rootFrame.Content.GetType().PrintDebug();
                Window.Current.Content.GetType().PrintDebug();
                Window.Current.Activate();
            }
            else if (e.Kind == ActivationKind.ToastNotification)
            {
                e.GetType().PrintDebug();

                var args = e as ToastNotificationActivatedEventArgs;
                args.PrintDebug();
                Debug.WriteLine("--------------------+OnActivated+------------------");
                Debug.WriteLine(args.Argument);
                Debug.WriteLine("UserInput: ");
                if (args?.UserInput?.Count > 0)
                {
                    foreach (var val in args.UserInput)
                    {
                        Debug.WriteLine(val.Key + " : " + JsonConvert.SerializeObject(val.Value));
                    }
                }
                Debug.WriteLine("--------------------+------------------");
                Frame rootFrame = CreateRootFrame();
                bool  wait      = false;
                if (rootFrame.Content == null)
                {
                    wait = true;
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        SplashView extendedSplash = new SplashView(e.SplashScreen);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
                else
                {
                    HandleActivation(args, false);
                    MainPage.Current?.HandleUriProtocol();
                }

                rootFrame.Content.GetType().PrintDebug();
                Window.Current.Content.GetType().PrintDebug();
                Window.Current.Activate();

                // wait
                if (wait)
                {
                    await Task.Delay(3500);

                    HandleActivation(args, true);
                }
            }
        }
コード例 #8
0
        protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs e)
        {
            if (Helper.DontUseTimersAndOtherStuff)
            {
                return;
            }
            try
            {
                if (DeviceUtil.IsXbox)
                {
                    Helper.FullscreenModeInXbox();
                }
            }
            catch { }
            try
            {
                Frame rootFrame = CreateRootFrame();
                var   isNull    = false;
                var   isRunning = false;
                if (rootFrame.Content == null)
                {
                    isRunning = isNull = true;
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                    {
                        SplashView extendedSplash = new SplashView(e.SplashScreen);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    else
                    {
                        SplashView extendedSplash = new SplashView(e.SplashScreen);
                        rootFrame.Content      = extendedSplash;
                        Window.Current.Content = rootFrame;
                    }
                    Window.Current.Content = rootFrame;
                }
                Window.Current.Activate();
                if (isNull)
                {
                    await Task.Delay(6500);
                }
                try
                {
                    ShareOperation shareOperation = e.ShareOperation;
                    if (shareOperation.Data.Contains(StandardDataFormats.StorageItems))
                    {
                        var items = await shareOperation.Data.GetStorageItemsAsync();

                        if (items.Count > 0)
                        {
                            if (items[0] is StorageFile file)
                            {
                                MainPage.Current?.HandleUriFile(file);
                            }
                        }
                    }
                }
                catch { }
            }
            catch { }
        }