Exemplo n.º 1
0
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Microsoft.Toolkit.Uwp.Helpers.SystemInformation.TrackAppUse(e);

            ApplicationViewTitleBar TitleBar = ApplicationView.GetForCurrentView().TitleBar;

            TitleBar.ButtonBackgroundColor         = Colors.Transparent;
            TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            if (Window.Current.Content is Frame frame)
            {
                if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                {
                    if (!string.IsNullOrWhiteSpace(e.Arguments) && WIN_Native_API.CheckExist(e.Arguments))
                    {
                        TabContainer.CreateNewTab(null, new string[] { e.Arguments });
                    }
                    else
                    {
                        TabContainer.CreateNewTab(null, Array.Empty <string>());
                    }
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(e.Arguments) && WIN_Native_API.CheckExist(e.Arguments))
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, new string[] { e.Arguments });
                    Window.Current.Content = extendedSplash;
                }
                else
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen);
                    Window.Current.Content = extendedSplash;
                }
            }

            Window.Current.Activate();
        }
Exemplo n.º 2
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            ApplicationViewTitleBar TitleBar = ApplicationView.GetForCurrentView().TitleBar;

            TitleBar.ButtonBackgroundColor         = Colors.Transparent;
            TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            if (Window.Current.Content is Frame frame)
            {
                if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                {
                    if (!string.IsNullOrWhiteSpace(e.Arguments) && WIN_Native_API.CheckExist(e.Arguments))
                    {
                        await TabContainer.CreateNewTabAndOpenTargetFolder(e.Arguments).ConfigureAwait(true);
                    }
                    else
                    {
                        await TabContainer.CreateNewTabAndOpenTargetFolder(string.Empty).ConfigureAwait(true);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(e.Arguments) && WIN_Native_API.CheckExist(e.Arguments))
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, $"PathActivate||{e.Arguments}");
                    Window.Current.Content = extendedSplash;
                }
                else
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen);
                    Window.Current.Content = extendedSplash;
                }
            }

            Window.Current.Activate();
        }
Exemplo n.º 3
0
        protected override void OnFileActivated(FileActivatedEventArgs args)
        {
            try
            {
                if (args.Verb == "USBArrival")
                {
                    CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                    var viewTitleBar = ApplicationView.GetForCurrentView().TitleBar;
                    viewTitleBar.ButtonBackgroundColor         = Colors.Transparent;
                    viewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                    viewTitleBar.ButtonForegroundColor         = (Color)Resources["SystemBaseHighColor"];

                    ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, false, $"PathActivate||{args.Files[0].Path}");
                    Window.Current.Content = extendedSplash;

                    Window.Current.Activate();
                }
            }
            catch (Exception ex)
            {
                ExceptionTracer.RequestBlueScreen(ex);
            }
        }
Exemplo n.º 4
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            ApplicationViewTitleBar TitleBar = ApplicationView.GetForCurrentView().TitleBar;

            TitleBar.ButtonBackgroundColor         = Colors.Transparent;
            TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            switch (args)
            {
            case CommandLineActivatedEventArgs CmdArgs:
            {
                string[] Arguments = CmdArgs.Operation.Arguments.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                if (Window.Current.Content is Frame frame)
                {
                    if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                    {
                        if (Arguments.Length > 1)
                        {
                            string Path = string.Join(" ", Arguments.Skip(1));

                            if (string.IsNullOrWhiteSpace(Path) || Regex.IsMatch(Path, @"::\{[0-9A-F\-]+\}", RegexOptions.IgnoreCase))
                            {
                                await TabContainer.CreateNewTabAsync();
                            }
                            else
                            {
                                await TabContainer.CreateNewTabAsync(Path == "."?CmdArgs.Operation.CurrentDirectoryPath : Path);
                            }
                        }
                        else
                        {
                            await TabContainer.CreateNewTabAsync();
                        }
                    }
                }
                else
                {
                    string Path = string.Join(" ", Arguments.Skip(1));

                    if (Arguments.Length > 1)
                    {
                        if (string.IsNullOrWhiteSpace(Path) || Regex.IsMatch(Path, @"::\{[0-9A-F\-]+\}", RegexOptions.IgnoreCase))
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(CmdArgs.SplashScreen);
                            Window.Current.Content = extendedSplash;
                        }
                        else
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(CmdArgs.SplashScreen, new List <string[]> {
                                    new string[] { Path == "." ? CmdArgs.Operation.CurrentDirectoryPath : Path }
                                });
                            Window.Current.Content = extendedSplash;
                        }
                    }
                    else
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(CmdArgs.SplashScreen);
                        Window.Current.Content = extendedSplash;
                    }
                }

                break;
            }

            case ProtocolActivatedEventArgs ProtocalArgs:
            {
                if (!string.IsNullOrWhiteSpace(ProtocalArgs.Uri.AbsolutePath))
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(ProtocalArgs.SplashScreen, new List <string[]> {
                            Uri.UnescapeDataString(ProtocalArgs.Uri.AbsolutePath).Split("||", StringSplitOptions.RemoveEmptyEntries)
                        });
                    Window.Current.Content = extendedSplash;
                }
                else
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(ProtocalArgs.SplashScreen);
                    Window.Current.Content = extendedSplash;
                }

                break;
            }

            case not ToastNotificationActivatedEventArgs:
            {
                ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                Window.Current.Content = extendedSplash;
                break;
            }
            }

            Window.Current.Activate();
        }
Exemplo n.º 5
0
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            Microsoft.Toolkit.Uwp.Helpers.SystemInformation.Instance.TrackAppUse(e);

            ApplicationViewTitleBar TitleBar = ApplicationView.GetForCurrentView().TitleBar;

            TitleBar.ButtonBackgroundColor         = Colors.Transparent;
            TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            if (Window.Current.Content is Frame frame)
            {
                if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                {
                    if (!string.IsNullOrWhiteSpace(e.Arguments) && await FileSystemStorageItemBase.CheckExistAsync(e.Arguments))
                    {
                        await TabContainer.CreateNewTabAsync(e.Arguments);
                    }
                    else
                    {
                        await TabContainer.CreateNewTabAsync();
                    }
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(e.Arguments) && await FileSystemStorageItemBase.CheckExistAsync(e.Arguments))
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, new List <string[]> {
                        new string[] { e.Arguments }
                    });
                    Window.Current.Content = extendedSplash;
                }
                else
                {
                    StartupMode Mode = StartupModeController.GetStartupMode();

                    switch (Mode)
                    {
                    case StartupMode.CreateNewTab:
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen);
                        Window.Current.Content = extendedSplash;
                        break;
                    }

                    case StartupMode.LastOpenedTab:
                    {
                        List <string[]> LastOpenedPathArray = await StartupModeController.GetAllPathAsync(Mode).ToListAsync();

                        StartupModeController.Clear(StartupMode.LastOpenedTab);

                        if (LastOpenedPathArray.Count == 0)
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen);
                            Window.Current.Content = extendedSplash;
                        }
                        else
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, LastOpenedPathArray);
                            Window.Current.Content = extendedSplash;
                        }

                        break;
                    }

                    case StartupMode.SpecificTab:
                    {
                        string[] SpecificPathArray = await StartupModeController.GetAllPathAsync(Mode).Select((Item) => Item.FirstOrDefault()).OfType <string>().ToArrayAsync();

                        if (SpecificPathArray.Length == 0)
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen);
                            Window.Current.Content = extendedSplash;
                        }
                        else
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, SpecificPathArray);
                            Window.Current.Content = extendedSplash;
                        }

                        break;
                    }
                    }
                }
            }

            Window.Current.Activate();
        }
Exemplo n.º 6
0
        protected override async void OnActivated(IActivatedEventArgs args)
        {
            ApplicationViewTitleBar TitleBar = ApplicationView.GetForCurrentView().TitleBar;

            TitleBar.ButtonBackgroundColor         = Colors.Transparent;
            TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            if (args is CommandLineActivatedEventArgs CmdArgs)
            {
                string[] Arguments = CmdArgs.Operation.Arguments.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                if (Window.Current.Content is Frame frame)
                {
                    if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                    {
                        if (Arguments.Length > 1)
                        {
                            string Path = string.Join(" ", Arguments.Skip(1));

                            if (Regex.IsMatch(Path, @"::\{[0-9A-F\-]+\}", RegexOptions.IgnoreCase))
                            {
                                await TabContainer.CreateNewTabAndOpenTargetFolder(string.Empty).ConfigureAwait(true);
                            }
                            else
                            {
                                await TabContainer.CreateNewTabAndOpenTargetFolder(Path).ConfigureAwait(true);
                            }
                        }
                        else
                        {
                            await TabContainer.CreateNewTabAndOpenTargetFolder(string.Empty).ConfigureAwait(true);
                        }
                    }
                }
                else
                {
                    string Path = string.Join(" ", Arguments.Skip(1));

                    if (Arguments.Length > 1 && !Regex.IsMatch(Path, @"::\{[0-9A-F\-]+\}", RegexOptions.IgnoreCase))
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, $"PathActivate||{Path}");
                        Window.Current.Content = extendedSplash;
                    }
                    else
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                        Window.Current.Content = extendedSplash;
                    }
                }
            }
            else if (args is ProtocolActivatedEventArgs ProtocalArgs)
            {
                if (!string.IsNullOrWhiteSpace(ProtocalArgs.Uri.LocalPath))
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, $"PathActivate||{ProtocalArgs.Uri.LocalPath}");
                    Window.Current.Content = extendedSplash;
                }
                else
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                    Window.Current.Content = extendedSplash;
                }
            }
            else
            {
                ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                Window.Current.Content = extendedSplash;
            }

            Window.Current.Activate();
        }
Exemplo n.º 7
0
        protected override void OnActivated(IActivatedEventArgs args)
        {
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            var viewTitleBar = ApplicationView.GetForCurrentView().TitleBar;

            viewTitleBar.ButtonBackgroundColor         = Colors.Transparent;
            viewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            viewTitleBar.ButtonForegroundColor         = (Color)Resources["SystemBaseHighColor"];

            if (Window.Current.Content is Frame mainPageFrame)
            {
                var cmdArgs  = args as CommandLineActivatedEventArgs;
                var mainPage = mainPageFrame.Content as MainPage;
                Window.Current.Activate();
                mainPage.NavView.IsBackEnabled = (TabViewContainer.CurrentTabNavigation?.CanGoBack).GetValueOrDefault();
                mainPage.Nav.Navigate(typeof(TabViewContainer), null, new SlideNavigationTransitionInfo()
                {
                    Effect = SlideNavigationTransitionEffect.FromLeft
                });
                TabViewContainer tabViewContainer = mainPage.Nav.Content as TabViewContainer;
                _ = tabViewContainer.CreateNewTabAndOpenTargetFolder(cmdArgs.Operation.Arguments.Substring(16));
            }
            else //Window.Current.Content is Frame(MainPage)
            {
                if (args is CommandLineActivatedEventArgs CmdArgs)
                {
                    if (string.IsNullOrWhiteSpace(CmdArgs.Operation.Arguments))
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                        Window.Current.Content = extendedSplash;
                    }
                    else
                    {
                        //此处采用了简略解析方法,只能解析“RX-Explorer.exe {PathToOpen}”的命令行格式,其他的(包括有路径前缀的)解析不了。如果有需要,后面再修改。

                        if (CmdArgs.Operation.Arguments.StartsWith("RX-Explorer.exe"))
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, false, $"PathActivate||{CmdArgs.Operation.Arguments.Split(" ").LastOrDefault()}");
                            Window.Current.Content = extendedSplash;
                        }
                        else
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                            Window.Current.Content = extendedSplash;
                        }
                    }
                }
                else if (args is ProtocolActivatedEventArgs ProtocalArgs)
                {
                    if (!string.IsNullOrWhiteSpace(ProtocalArgs.Uri.LocalPath))
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, false, $"PathActivate||{ProtocalArgs.Uri.LocalPath}");
                        Window.Current.Content = extendedSplash;
                    }
                    else
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                        Window.Current.Content = extendedSplash;
                    }
                }
                else
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                    Window.Current.Content = extendedSplash;
                }

                Window.Current.Activate();
            }
        }
Exemplo n.º 8
0
        private async Task OnLaunchOrOnActivate(IActivatedEventArgs args)
        {
            SystemInformation.Instance.TrackAppUse(args);

            ApplicationViewTitleBar TitleBar = ApplicationView.GetForCurrentView().TitleBar;

            TitleBar.ButtonBackgroundColor         = Colors.Transparent;
            TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            TitleBar.ButtonForegroundColor         = AppThemeController.Current.Theme == ElementTheme.Dark ? Colors.White : Colors.Black;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            switch (args)
            {
            case LaunchActivatedEventArgs LaunchArgs:
            {
                if (Window.Current.Content is Frame frame)
                {
                    if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                    {
                        if (!string.IsNullOrWhiteSpace(LaunchArgs.Arguments) && await FileSystemStorageItemBase.CheckExistAsync(LaunchArgs.Arguments))
                        {
                            await TabContainer.CreateNewTabAsync(LaunchArgs.Arguments);
                        }
                        else
                        {
                            await TabContainer.CreateNewTabAsync();
                        }
                    }
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(LaunchArgs.Arguments) || !await FileSystemStorageItemBase.CheckExistAsync(LaunchArgs.Arguments))
                    {
                        await LaunchWithStartupMode(LaunchArgs);
                    }
                    else
                    {
                        ExtendedSplash extendedSplash = new ExtendedSplash(LaunchArgs.SplashScreen, new List <string[]> {
                                new string[] { LaunchArgs.Arguments }
                            });
                        Window.Current.Content = extendedSplash;
                    }
                }

                break;
            }

            case CommandLineActivatedEventArgs CmdArgs:
            {
                string[] Arguments = CmdArgs.Operation.Arguments.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                if (Window.Current.Content is Frame frame)
                {
                    if (frame.Content is MainPage Main && Main.Nav.Content is TabViewContainer TabContainer)
                    {
                        if (Arguments.Length > 1)
                        {
                            string Path = string.Join(" ", Arguments.Skip(1));

                            if (string.IsNullOrWhiteSpace(Path) || Regex.IsMatch(Path, @"::\{[0-9A-F\-]+\}", RegexOptions.IgnoreCase))
                            {
                                await TabContainer.CreateNewTabAsync();
                            }
                            else
                            {
                                await TabContainer.CreateNewTabAsync(Path == "."?CmdArgs.Operation.CurrentDirectoryPath : Path);
                            }
                        }
                        else
                        {
                            await TabContainer.CreateNewTabAsync();
                        }
                    }
                }
                else
                {
                    string Path = string.Join(" ", Arguments.Skip(1));

                    if (Arguments.Length > 1)
                    {
                        if (string.IsNullOrWhiteSpace(Path) || Regex.IsMatch(Path, @"::\{[0-9A-F\-]+\}", RegexOptions.IgnoreCase))
                        {
                            await LaunchWithStartupMode(CmdArgs);
                        }
                        else
                        {
                            ExtendedSplash extendedSplash = new ExtendedSplash(CmdArgs.SplashScreen, new List <string[]> {
                                    new string[] { Path == "." ? CmdArgs.Operation.CurrentDirectoryPath : Path }
                                });
                            Window.Current.Content = extendedSplash;
                        }
                    }
                    else
                    {
                        await LaunchWithStartupMode(CmdArgs);
                    }
                }

                break;
            }

            case ProtocolActivatedEventArgs ProtocalArgs:
            {
                if (!string.IsNullOrWhiteSpace(ProtocalArgs.Uri.AbsolutePath))
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(ProtocalArgs.SplashScreen, new List <string[]> {
                            Uri.UnescapeDataString(ProtocalArgs.Uri.AbsolutePath).Split("||", StringSplitOptions.RemoveEmptyEntries)
                        });
                    Window.Current.Content = extendedSplash;
                }
                else
                {
                    ExtendedSplash extendedSplash = new ExtendedSplash(ProtocalArgs.SplashScreen);
                    Window.Current.Content = extendedSplash;
                }

                break;
            }

            case not ToastNotificationActivatedEventArgs:
            {
                ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);
                Window.Current.Content = extendedSplash;

                break;
            }
            }

            Window.Current.Activate();
        }