コード例 #1
0
        static OSInfo()
        {
            // WebAssembly w/ .NET 5.0
            if (RuntimeInformation.OSDescription.ToLowerInvariant() == "browser")
            {
                Kind         = OSKind.WebAssembly;
                UserHomePath = "";
                return;
            }

            // WebAssembly w/ .NET Core 3.1
            if (RuntimeInformation.OSDescription == "web" && RuntimeInformation.FrameworkDescription.StartsWith("Mono"))
            {
                Kind         = OSKind.WebAssembly;
                UserHomePath = "";
                return;
            }

            // Windows
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Kind         = OSKind.Windows;
                UserHomePath = Environment.GetEnvironmentVariable("USERPROFILE") ?? "";
                return;
            }

            // Unix
            Kind = RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
                ? OSKind.MacOS
                : OSKind.Unix;
            UserHomePath = Environment.GetEnvironmentVariable("HOME") ?? "";
        }
コード例 #2
0
        public NavigationViewModel()
        {
            IApplicationContext context = this.GetService <IApplicationService>().GetContext();
            OSKind operatingSystem      = context.Platform.OperatingSystem;

            List <NavigationItem> items = new List <NavigationItem>();

            if (operatingSystem == OSKind.iOS)
            {
                items.Add(new NavigationItem("Image Slider", "Feature", typeof(ImageSliderViewModel)));
                items.Add(new NavigationItem("Custom Template", "Feature", typeof(ItemSliderViewModel)));
                items.Add(new NavigationItem("Item List", "Feature", typeof(ItemListViewModel)));
                items.Add(new NavigationItem("Slide Show", "Feature", typeof(AutoSlideViewModel)));
                items.Add(new NavigationItem("Page Indicator", "Feature", typeof(BulletIndicatorViewModel)));
            }
            else if (operatingSystem == OSKind.Android)
            {
                items.Add(new NavigationItem("Image Slider", "Feature", typeof(ImageSliderViewModel)));
                items.Add(new NavigationItem("Circular Image Slider", "Feature", typeof(CircularImageSliderViewModel)));
                items.Add(new NavigationItem("Custom Template", "Feature", typeof(ItemSliderViewModel)));
                items.Add(new NavigationItem("Item List", "Feature", typeof(ItemListViewModel)));
                items.Add(new NavigationItem("Slide Show", "Feature", typeof(AutoSlideViewModel)));
                items.Add(new NavigationItem("Slide Direction", "Feature", typeof(SlideDirectionViewModel)));
                items.Add(new NavigationItem("Navigation", "Feature", typeof(NavigationImageSliderViewModel)));

                items.Add(new NavigationItem("Bullet Indicator", "Slider Indicator", typeof(BulletIndicatorViewModel)));
                items.Add(new NavigationItem("Strip Indicator", "Slider Indicator", typeof(StripIndicatorViewModel)));
            }

            this.SourceItems = items;
            this.RefreshGroupItems();
        }
コード例 #3
0
    static OSInfo()
    {
        // WebAssembly w/ .NET 5.0
        if (StringComparer.Ordinal.Equals("browser", RuntimeInformation.OSDescription.ToLowerInvariant()))
        {
            Kind         = OSKind.WebAssembly;
            UserHomePath = "";
            return;
        }

        // WebAssembly w/ .NET Core 3.1
        if (StringComparer.Ordinal.Equals("web", RuntimeInformation.OSDescription) &&
            RuntimeInformation.FrameworkDescription.StartsWith("Mono", StringComparison.Ordinal))
        {
            Kind         = OSKind.WebAssembly;
            UserHomePath = "";
            return;
        }

        // Windows
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
            Kind         = OSKind.Windows;
            UserHomePath = Environment.GetEnvironmentVariable("USERPROFILE") ?? "";
            return;
        }

        // Unix
        Kind = RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
            ? OSKind.MacOS
            : OSKind.OtherUnix;
        UserHomePath = Environment.GetEnvironmentVariable("HOME") ?? "";
    }
コード例 #4
0
        public static async void RegisterBackgroundTask(OSKind kind)
        {
            try
            {
                BackgroundAccessStatus status = BackgroundAccessStatus.Unspecified;
                if (kind == OSKind.WindowsPhone)
                {
                    status = await ApplicationPackageManager.CheckAppVersion();
                }
                else if (kind == OSKind.Windows)
                {
                    status = await BackgroundExecutionManager.RequestAccessAsync();
                }

                if (status == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity ||
                    status == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
                {
                    foreach (var task in BackgroundTaskRegistration.AllTasks)
                    {
                        if (task.Value.Name == taskName)
                        {
                            task.Value.Unregister(true);
                        }
                    }

                    BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();
                    taskBuilder.Name = taskName;
                    taskBuilder.TaskEntryPoint = (kind == OSKind.Windows) ? taskEntryPointWindows : taskEntryPointWindowsPhone;
                    taskBuilder.SetTrigger(new TimeTrigger(15, false));
                    var registration = taskBuilder.Register();
                }
            }
            catch (Exception)
            {
               
                //new MessageDialog(e.Message).ShowAsync();
            }

        }
コード例 #5
0
        public static async void RegisterBackgroundTask(OSKind kind)
        {
            try
            {
                BackgroundAccessStatus status = BackgroundAccessStatus.Unspecified;
                if (kind == OSKind.WindowsPhone)
                {
                    status = await ApplicationPackageManager.CheckAppVersion();
                }
                else if (kind == OSKind.Windows)
                {
                    status = await BackgroundExecutionManager.RequestAccessAsync();
                }

                if (status == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity ||
                    status == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
                {
                    foreach (var task in BackgroundTaskRegistration.AllTasks)
                    {
                        if (task.Value.Name == taskName)
                        {
                            task.Value.Unregister(true);
                        }
                    }

                    BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();
                    taskBuilder.Name           = taskName;
                    taskBuilder.TaskEntryPoint = (kind == OSKind.Windows) ? taskEntryPointWindows : taskEntryPointWindowsPhone;
                    taskBuilder.SetTrigger(new TimeTrigger(15, false));
                    var registration = taskBuilder.Register();
                }
            }
            catch (Exception)
            {
                //new MessageDialog(e.Message).ShowAsync();
            }
        }