├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug.yml │ └── feature.yml ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── ci.yml │ └── docs.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Directory.Build.props ├── LICENSE ├── README.md ├── XPlat.sln ├── YOUR-PROJECTS.md ├── assets ├── Logo.afdesign ├── Logo.png ├── ProjectBanner.afdesign ├── ProjectBanner.png ├── ProjectIcon.jpg └── ProjectIcon.png ├── build └── GetBuildVersion.psm1 ├── docs ├── .gitignore ├── README.md ├── api │ ├── .gitignore │ └── index.md ├── articles │ ├── available-packages.md │ ├── intro.md │ └── toc.yml ├── docfx.json ├── images │ ├── Logo.png │ └── ProjectBanner.png ├── index.md ├── templates │ └── material │ │ ├── partials │ │ └── head.tmpl.partial │ │ └── styles │ │ └── main.css └── toc.yml ├── global.json └── src ├── XPlat.ApplicationModel.DataTransfer ├── Clipboard.Android.cs ├── Clipboard.Windows.cs ├── Clipboard.iOS.cs ├── DataPackage.Android.cs ├── DataPackage.Windows.cs ├── DataPackage.iOS.cs ├── DataPackageView.Android.cs ├── DataPackageView.Windows.cs ├── DataPackageView.iOS.cs ├── IDataPackage.cs ├── IDataPackageView.cs └── XPlat.ApplicationModel.DataTransfer.csproj ├── XPlat.ApplicationModel ├── IPackage.cs ├── IPackage2.cs ├── IPackage3.cs ├── IPackageId.cs ├── Package.Android.cs ├── Package.Windows.cs ├── Package.iOS.cs ├── PackageId.Android.cs ├── PackageId.Windows.cs ├── PackageId.iOS.cs ├── PackageVersion.cs └── XPlat.ApplicationModel.csproj ├── XPlat.Core ├── Exceptions │ └── AppPermissionInvalidException.cs ├── Extensions │ ├── CollectionExtensions.cs │ ├── NSDateExtensions.cs │ └── NSObjectExtensions.cs ├── Helpers │ ├── ApplicationManfiestHelper.Android.cs │ ├── ParseHelper.cs │ └── RequestCodeHelper.cs ├── Threading │ └── Tasks │ │ ├── TaskSchedulerAwaiter.cs │ │ └── TimeoutTask.cs └── XPlat.Core.csproj ├── XPlat.Device.Display ├── DisplayRequest.Android.cs ├── DisplayRequest.Windows.cs ├── DisplayRequest.iOS.cs ├── IDisplayRequest.cs └── XPlat.Device.Display.csproj ├── XPlat.Device.Geolocation ├── BasicGeoposition.cs ├── Extensions │ ├── GeolocationAccessStatusExtensions.cs │ └── PositionStatusExtensions.cs ├── Geocoordinate.cs ├── GeolocationAccessStatus.cs ├── Geolocator.Android.cs ├── Geolocator.Windows.cs ├── Geolocator.iOS.cs ├── GeolocatorException.cs ├── GeolocatorLocationListener.Android.cs ├── Geopoint.cs ├── Geoposition.cs ├── IGeocoordinate.cs ├── IGeolocator.cs ├── IGeopoint.cs ├── IGeoposition.cs ├── IStatusChangedEventArgs.cs ├── LocationRetriever.Android.cs ├── PositionAccuracy.cs ├── PositionChangedEventArgs.cs ├── PositionStatus.cs ├── StatusChangedEventArgs.cs └── XPlat.Device.Geolocation.csproj ├── XPlat.Device.Launcher ├── Extensions │ └── LaunchQuerySupportStatusExtensions.cs ├── ILauncher.cs ├── LaunchQuerySupportStatus.cs ├── Launcher.Android.cs ├── Launcher.Windows.cs ├── Launcher.iOS.cs └── XPlat.Device.Launcher.csproj ├── XPlat.Device.Power ├── BatteryStatus.cs ├── BatteryStatusChangedEventArgs.cs ├── BatteryStatusChangedEventHandler.cs ├── Extensions │ └── BatteryStatusExtensions.cs ├── IPowerManager.cs ├── PowerManager.Android.cs ├── PowerManager.Windows.cs ├── PowerManager.iOS.cs ├── PowerReceiver.Android.cs └── XPlat.Device.Power.csproj ├── XPlat.Device.Profile ├── AnalyticsInfo.Android.cs ├── AnalyticsInfo.Windows.cs ├── AnalyticsInfo.iOS.cs ├── AnalyticsVersionInfo.Android.cs ├── AnalyticsVersionInfo.Windows.cs ├── AnalyticsVersionInfo.iOS.cs ├── IAnalyticsVersionInfo.cs ├── Resources │ ├── values-large │ │ └── strings.xml │ ├── values-sw600dp │ │ └── strings.xml │ └── values │ │ └── strings.xml └── XPlat.Device.Profile.csproj ├── XPlat.Foundation ├── Collections │ ├── CollectionChange.cs │ ├── IMapChangedEventArgs`1.cs │ ├── IObservableMap`2.cs │ ├── IPropertySet.cs │ ├── MapChangedEventHandler`2.cs │ └── StringMapChangedEventArgs.cs ├── Size.cs ├── TypedEventHandler`2.cs └── XPlat.Foundation.csproj ├── XPlat.Media.Capture ├── CameraCaptureUI.Android.cs ├── CameraCaptureUI.Windows.cs ├── CameraCaptureUIActivity.Android.cs ├── CameraCaptureUIMaxPhotoResolution.cs ├── CameraCaptureUIMaxVideoResolution.cs ├── CameraCaptureUIMode.cs ├── CameraCaptureUIPhotoCaptureSettings.cs ├── CameraCaptureUIVideoCaptureSettings.cs ├── CameraFileCaptured.Android.cs ├── Extensions │ ├── BitmapExtensions.cs │ ├── CameraCaptureUIMaxPhotoResolutionExtensions.cs │ ├── CameraCaptureUIMaxVideoResolutionExtensions.cs │ └── StorageFileExtensions.cs ├── ICameraCaptureUI.cs ├── ICameraCaptureUIPhotoCaptureSettings.cs ├── ICameraCaptureUIVideoCaptureSettings.cs └── XPlat.Media.Capture.csproj ├── XPlat.Services.Maps ├── Extensions │ ├── MapLocationDesiredAccuracyExtensions.cs │ └── MapLocationFinderStatusExtensions.cs ├── IMapAddress.cs ├── IMapLocation.cs ├── IMapLocationFinderResult.cs ├── MapAddress.cs ├── MapLocation.cs ├── MapLocationDesiredAccuracy.cs ├── MapLocationFinder.Android.cs ├── MapLocationFinder.Windows.cs ├── MapLocationFinder.iOS.cs ├── MapLocationFinderResult.cs ├── MapLocationFinderStatus.cs └── XPlat.Services.Maps.csproj ├── XPlat.Storage.Pickers ├── FileOpenPicker.Android.cs ├── FileOpenPicker.Windows.cs ├── FileOpenPickerActivity.Android.cs ├── FileOpenPickerFilesReceived.cs ├── IFileOpenPicker.cs └── XPlat.Storage.Pickers.csproj ├── XPlat.Storage ├── ApplicationData.Android.cs ├── ApplicationData.Windows.cs ├── ApplicationData.iOS.cs ├── ApplicationDataContainer.Android.cs ├── ApplicationDataContainer.Windows.cs ├── ApplicationDataContainer.iOS.cs ├── ApplicationDataContainerSettings.Android.cs ├── ApplicationDataContainerSettings.Windows.cs ├── ApplicationDataContainerSettings.iOS.cs ├── ApplicationDataCreateDisposition.cs ├── ApplicationDataLocality.cs ├── CreationCollisionOption.cs ├── Extensions │ ├── ApplicationDataCreateDispositionExtensions.cs │ ├── ApplicationDataLocalityExtensions.cs │ ├── CreationCollisionOptionExtensions.cs │ ├── FileAccessModeExtensions.cs │ ├── FileAttributesExtensions.cs │ ├── NameCollisionOptionExtensions.cs │ ├── StorageFileExtensions.cs │ └── StorageItemContentPropertiesExtensions.cs ├── FileAccessMode.cs ├── FileAttributes.cs ├── FileProperties │ ├── BasicProperties.Android.cs │ ├── BasicProperties.Windows.cs │ ├── BasicProperties.iOS.cs │ ├── IBasicProperties.cs │ ├── IImageProperties.cs │ ├── IMusicProperties.cs │ ├── IStorageItemContentProperties.cs │ ├── IVideoProperties.cs │ ├── ImageProperties.Android.cs │ ├── ImageProperties.Windows.cs │ ├── MusicProperties.Android.cs │ ├── MusicProperties.Windows.cs │ ├── PhotoOrientation.cs │ ├── StorageItemContentProperties.Android.cs │ ├── StorageItemContentProperties.Windows.cs │ ├── VideoOrientation.cs │ ├── VideoProperties.Android.cs │ └── VideoProperties.Windows.cs ├── Helpers │ ├── MimeTypeHelper.cs │ └── StorageHelper.cs ├── IApplicationData.cs ├── IApplicationDataContainer.cs ├── IApplicationDataExtras.cs ├── IStorageFile.cs ├── IStorageFileExtras.cs ├── IStorageFolder.cs ├── IStorageFolder2.cs ├── IStorageFolderExtras.cs ├── IStorageItem.cs ├── IStorageItem2.cs ├── IStorageItemProperties.cs ├── KnownFolders.Android.cs ├── KnownFolders.Windows.cs ├── NameCollisionOption.cs ├── Search │ └── IStorageFolderQueryOperations.cs ├── StorageFile.Android.cs ├── StorageFile.Windows.cs ├── StorageFile.iOS.cs ├── StorageFileIOException.cs ├── StorageFolder.Android.cs ├── StorageFolder.Windows.cs ├── StorageFolder.iOS.cs ├── StorageItemCreationException.cs ├── StorageItemException.cs ├── StorageItemNotFoundException.cs ├── StorageItemTypes.cs └── XPlat.Storage.csproj ├── XPlat.UI.Controls ├── Orientation.cs └── XPlat.UI.Controls.csproj ├── XPlat.UI.Core ├── CoreDispatcher.Android.cs ├── CoreDispatcher.Windows.cs ├── CoreDispatcher.iOS.cs ├── CoreDispatcherPriority.cs ├── DispatchedHandler.cs ├── Extensions │ └── CoreDispatcherPriorityExtensions.cs ├── ICoreDispatcher.cs └── XPlat.UI.Core.csproj ├── XPlat.UI.Popups ├── Extensions │ └── UICommandExtensions.cs ├── IMessageDialog.cs ├── IUICommand.cs ├── MessageDialog.Android.cs ├── MessageDialog.Windows.cs ├── MessageDialog.iOS.cs ├── UICommand.cs ├── UICommandInvokedHandler.cs └── XPlat.UI.Popups.csproj └── XPlat.UI ├── Color.cs ├── ColorHelper.cs ├── Colors.cs ├── DispatcherTimer.cs ├── IDispatcherTimer.cs ├── Thickness.cs ├── ThicknessHelper.cs └── XPlat.UI.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [jamesmcroft] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['buymeacoffee.com/jamesmcroft'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: Bug 2 | description: Log a bug to help us improve 3 | title: "[Bug] " 4 | labels: [bug] 5 | body: 6 | - type: textarea 7 | validations: 8 | required: true 9 | attributes: 10 | label: Describe the bug 11 | description: Please describe below the details of the issue and steps taken to reproduce. 12 | - type: textarea 13 | attributes: 14 | label: What is the expected behavior? 15 | description: Please describe below what you expected to happen. 16 | - type: dropdown 17 | attributes: 18 | label: Package 19 | options: 20 | - "ApplicationModel" 21 | - "ApplicationModel.DataTransfer" 22 | - "Core" 23 | - "Device.Display" 24 | - "Device.Geolocation" 25 | - "Device.Launcher" 26 | - "Device.Power" 27 | - "Device.Profile" 28 | - "Foundation" 29 | - "Media.Capture" 30 | - "Services.Maps" 31 | - "Storage" 32 | - "Storage.Pickers" 33 | - "UI" 34 | - "UI.Controls" 35 | - "UI.Core" 36 | - "UI.Popups" 37 | - type: textarea 38 | attributes: 39 | label: Other information 40 | description: Please provide any additional information, links, screenshots, or projects with reproduced issues below if applicable 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.yml: -------------------------------------------------------------------------------- 1 | name: Feature 2 | description: Suggest a new feature or idea 3 | title: "[Feature] " 4 | labels: [feature-request] 5 | body: 6 | - type: textarea 7 | validations: 8 | required: true 9 | attributes: 10 | label: Describe the feature 11 | description: Please describe below a summary of your feature request. 12 | - type: textarea 13 | validations: 14 | required: true 15 | attributes: 16 | label: Rationale for the feature 17 | description: Please describe a list of reasons why the feature should be added. 18 | - type: textarea 19 | attributes: 20 | label: Scope of the feature 21 | description: Please describe a list of must, should, could, and won't capabilities for the feature. 22 | - type: textarea 23 | attributes: 24 | label: Open questions 25 | description: Please provide any questions that you may have around this feature that are not currently answered. 26 | - type: textarea 27 | attributes: 28 | label: Other information 29 | description: Please provide any additional information, links, screenshots, or samples below if applicable. 30 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Fixes # 2 | 3 | 4 | 5 | 6 | ## PR checklist 7 | 8 | - [ ] Samples have been added/updated (where applicable) 9 | - [ ] Tests have been added/updated (where applicable) and pass 10 | - [ ] Documentation has been added/updated for changes 11 | - [ ] Code styling has been met on new source file changes 12 | - [ ] Contains **NO** breaking changes 13 | 14 | 15 | 16 | ## Other information 17 | 18 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | branches: 8 | - main 9 | paths: 10 | - src/** 11 | - samples/** 12 | - tests/** 13 | - build/** 14 | - .github/workflows/ci.yml 15 | - global.json 16 | pull_request: 17 | branches: 18 | - main 19 | paths: 20 | - src/** 21 | - samples/** 22 | - tests/** 23 | - build/** 24 | - .github/workflows/ci.yml 25 | - global.json 26 | workflow_dispatch: 27 | 28 | jobs: 29 | build: 30 | 31 | env: 32 | BUILD_CONFIG: 'Release' 33 | SOLUTION: 'XPlat.sln' 34 | 35 | runs-on: windows-latest 36 | 37 | steps: 38 | - uses: actions/checkout@v2 39 | 40 | - name: Get Build Version 41 | run: | 42 | Import-Module .\build\GetBuildVersion.psm1 43 | Write-Host $Env:GITHUB_REF 44 | $version = GetBuildVersion -VersionString $Env:GITHUB_REF 45 | echo "BUILD_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append 46 | shell: pwsh 47 | 48 | - name: Setup NuGet 49 | uses: NuGet/setup-nuget@v1.0.5 50 | 51 | - name: Restore dependencies 52 | run: nuget restore $SOLUTION 53 | 54 | - name: Setup .NET Core 3.1 55 | uses: actions/setup-dotnet@v1 56 | with: 57 | dotnet-version: 3.1.x 58 | 59 | - name: Setup .NET 5.0 60 | uses: actions/setup-dotnet@v1 61 | with: 62 | dotnet-version: 5.0.x 63 | 64 | - name: Setup MSBuild 65 | uses: microsoft/setup-msbuild@v1.0.2 66 | 67 | - name: Build 68 | run: msbuild $env:SOLUTION /p:Configuration=$env:BUILD_CONFIG /p:Platform="Any CPU" -p:Version=$env:BUILD_VERSION 69 | 70 | - name: Run tests 71 | run: dotnet test /p:Configuration=$env:BUILD_CONFIG /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --no-restore --no-build --verbosity normal 72 | 73 | - name: Publish 74 | if: startsWith(github.ref, 'refs/tags/v') 75 | run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} 76 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - src/** 9 | - docs/** 10 | - .github/workflows/docs.yml 11 | pull_request: 12 | branches: 13 | - main 14 | paths: 15 | - docs/** 16 | - .github/workflows/docs.yml 17 | workflow_dispatch: 18 | 19 | jobs: 20 | generate-docs: 21 | 22 | runs-on: windows-latest 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | 27 | - name: Setup .NET Core 3.1 28 | uses: actions/setup-dotnet@v1 29 | with: 30 | dotnet-version: 3.1.x 31 | 32 | - name: Setup .NET 5.0 33 | uses: actions/setup-dotnet@v1 34 | with: 35 | dotnet-version: 5.0.x 36 | 37 | - name: Setup DocFX 38 | uses: crazy-max/ghaction-chocolatey@v1 39 | with: 40 | args: install docfx 41 | 42 | - name: DocFX Build 43 | working-directory: docs 44 | run: docfx .\docfx.json 45 | continue-on-error: false 46 | 47 | - name: Publish 48 | if: github.event_name == 'push' 49 | uses: peaceiris/actions-gh-pages@v3 50 | with: 51 | github_token: ${{ secrets.GITHUB_TOKEN }} 52 | publish_dir: docs/_site 53 | force_orphan: true 54 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | XPlat Windows APIs project banner 2 | 3 | # Contributing 4 | 5 | These guidelines are designed to help you as a contributor to bring your code and skills to the XPlat Windows APIs project to make it better. 6 | 7 | ## What can I contribute to? 8 | 9 | Our [issue tracker](https://github.com/jamesmcroft/XPlat-Windows-APIs/issues) contains a collection of features and issues waiting to be worked on! If you see any item marked with **Help Wanted**, we'd like to see you put your skills to use and contribute whatever you can to help develop the feature. 10 | 11 | This can be in the form of contributing to the conversation around the feature or issue, providing code and submitting a pull request, adding a new feature request or bug, or even helping to update our documentation. 12 | 13 | We know that not everyone can do everything, so any little helps. If you can only develop the iOS or Android component but not the other, that's fine! We accept any contribution whether big or small. 14 | 15 | ## Code Styling 16 | 17 | We do have a coding style in place, but as a contributor, we're happy for you to code in a way that makes your feel comfortable. We will do the work to make sure everything is in tip top shape before we release to the public. 18 | 19 | ## Bug Hunting 20 | 21 | We're more than happy for you to contribute to our project through testing. We're all developers and we often miss things so finding bugs in the project's code is definitely approved of. Please remember to start a new issue in our [issue tracker](https://github.com/jamesmcroft/XPlat-Windows-APIs/issues) so we can keep an eye on them and get bugs fixed. 22 | 23 | Even better, if you know how to fix it, follow up your issue with a pull request! 24 | 25 | ## Testing And Documentation 26 | 27 | We're including unit tests for the project. While we will aim to have the best coverage as possible across the entire project, it could always be improved on. If you find an area that is missing tests or could have more tests for, feel free to raise an issue or help out by writing some tests! 28 | 29 | As well as testing, we aim to document the entire project in terms of both developer guidelines such as these and our own API documentation. If you find something that is wrong or is missing, again, feel free to raise an issue or contribute towards the documentation. 30 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | true 6 | true 7 | snupkg 8 | true 9 | 1.0.0.0 10 | XPlat Apps 11 | XPlat Apps 12 | Copyright (C) XPlat Apps. All rights reserved. 13 | https://github.com/XPlat-Apps/XPlat-Windows-APIs 14 | LICENSE 15 | ProjectIcon.png 16 | https://github.com/XPlat-Apps/XPlat-Windows-APIs/releases 17 | en 18 | true 19 | 8.0 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) XPlat Apps 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /YOUR-PROJECTS.md: -------------------------------------------------------------------------------- 1 | XPlat Windows APIs project banner 2 | 3 | # Made with XPlat 4 | 5 | We want to showcase all of the awesome apps that have been built with XPlat Windows APIs! 6 | 7 | So, if you have a project you want to share with the world, drop it in the list below! 8 | 9 | | Project | Link | 10 | | ------ | ------ | 11 | | MVP Community App (Windows) | [Windows Store](https://www.microsoft.com/store/productId/9NM26MMRJBPF) | 12 | -------------------------------------------------------------------------------- /assets/Logo.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/assets/Logo.afdesign -------------------------------------------------------------------------------- /assets/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/assets/Logo.png -------------------------------------------------------------------------------- /assets/ProjectBanner.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/assets/ProjectBanner.afdesign -------------------------------------------------------------------------------- /assets/ProjectBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/assets/ProjectBanner.png -------------------------------------------------------------------------------- /assets/ProjectIcon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/assets/ProjectIcon.jpg -------------------------------------------------------------------------------- /assets/ProjectIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/assets/ProjectIcon.png -------------------------------------------------------------------------------- /build/GetBuildVersion.psm1: -------------------------------------------------------------------------------- 1 | Function GetBuildVersion { 2 | Param ( 3 | [string]$VersionString 4 | ) 5 | 6 | # Process through regex 7 | $VersionString -match "(?\d+)(\.(?\d+))?(\.(?\d+))?(\-(?
[0-9A-Za-z\-\.]+))?(\+(?\d+))?" | Out-Null
 8 | 
 9 |     if ($matches -eq $null) {
10 |         return "1.0.0-build"
11 |     }
12 | 
13 |     # Extract the build metadata
14 |     $BuildRevision = [uint64]$matches['build']
15 |     # Extract the pre-release tag
16 |     $PreReleaseTag = [string]$matches['pre']
17 |     # Extract the patch
18 |     $Patch = [uint64]$matches['patch']
19 |     # Extract the minor
20 |     $Minor = [uint64]$matches['minor']
21 |     # Extract the major
22 |     $Major = [uint64]$matches['major']
23 | 
24 |     $Version = [string]$Major + '.' + [string]$Minor + '.' + [string]$Patch;
25 |     if ($PreReleaseTag -ne [string]::Empty) {
26 |         $Version = $Version + '-' + $PreReleaseTag
27 |     }
28 | 
29 |     if ($BuildRevision -ne 0) {
30 |         $Version = $Version + '.' + [string]$BuildRevision
31 |     }
32 | 
33 |     return $Version
34 | }


--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
 1 | ###############
 2 | #    folder   #
 3 | ###############
 4 | /**/DROP/
 5 | /**/TEMP/
 6 | /**/packages/
 7 | /**/bin/
 8 | /**/obj/
 9 | _site
10 | 


--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
 1 | # XPlat Documentation
 2 | 
 3 | This folder contains source code for the generation of XPlat's documentation.
 4 | 
 5 | ## Contributing to the docs
 6 | 
 7 | ### Install dependencies
 8 | 
 9 | Download and install docfx on your computer.
10 | 
11 | #### MacOS
12 | 
13 | ```
14 | brew install docfx
15 | ```
16 | 
17 | #### Windows
18 | 
19 | ```
20 | choco install docfx
21 | ```
22 | 
23 | ### Running locally
24 | 
25 | ```
26 | docfx .\docfx.json --serve
27 | ```
28 | 
29 | This will run the docs on `http://localhost:8080`


--------------------------------------------------------------------------------
/docs/api/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | #  temp file  #
3 | ###############
4 | *.yml
5 | .manifest
6 | 


--------------------------------------------------------------------------------
/docs/api/index.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | uid: api-docs
 3 | title: Explore the APIs
 4 | ---
 5 | 
 6 | # Explore the APIs
 7 | 
 8 | Here you'll find all of the generated code documentation for the XPlat Windows APIs projects, similar to what you might find on Microsoft Docs!
 9 | 
10 | This documentation is designed to show you how each component of XPlat Windows APIs is constructed and provide a reference for you when building your projects.
11 | 


--------------------------------------------------------------------------------
/docs/articles/intro.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | uid: xplat-intro
 3 | title: Overview
 4 | ---
 5 | 
 6 | XPlat project banner
 7 | 
 8 | # XPlat Windows APIs
 9 | 
10 | XPlat Windows APIs are designed to make it easier for developers adjusted to developing with the Windows Runtime APIs (UWP) to take those skills cross-platform with their applications in .NET.
11 | 
12 | As each application platform offers their own unique platform-specific APIs, XPlat attempts to bring all of those APIs under one umbrella using a UWP like API, allowing a developer to learn a single API which works with any application built for Windows and Xamarin for Android and iOS.
13 | 
14 | For a Windows developer, this is appealing as it allows you to easily migrate your existing Windows code to Xamarin shared code with minimal changes through the use of XPlat Windows APIs which mimic the UWP API alternatives.
15 | 
16 | ## Why should I use this project?
17 | 
18 | You've spent years developing Windows applications and you've been using the Windows Runtime APIs (UWP) to build modern app experiences. Now you want to take your existing apps and skills cross-platform with Xamarin, but you don't know where to start because you don't know what APIs to use!
19 | 
20 | I had this same problem!
21 | 
22 | That's where XPlat Windows APIs started, a set of APIs which mimic those Windows APIs but that are cross-platform, supporting both Android and iOS.
23 | 
24 | Use your existing skills and build epic cross-platform applications.


--------------------------------------------------------------------------------
/docs/articles/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Overview
2 |   topicHref: intro.md
3 | - name: Get started
4 |   items:
5 |     - name: Available packages
6 |       href: available-packages.md
7 | 


--------------------------------------------------------------------------------
/docs/docfx.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "metadata": [
 3 |     {
 4 |       "src": [
 5 |         {
 6 |           "src": "../",
 7 |           "files": [
 8 |             "src/**.csproj"
 9 |           ],
10 |           "exclude": [
11 |             "**/bin/**",
12 |             "**/obj/**",
13 |             "_site/**"
14 |           ]
15 |         }
16 |       ],
17 |       "dest": "api",
18 |       "disableGitFeatures": false,
19 |       "disableDefaultFilter": false,
20 |       "properties": {
21 |         "TargetFramework": "netstandard2.0"
22 |       }
23 |     }
24 |   ],
25 |   "build": {
26 |     "content": [
27 |       {
28 |         "files": [
29 |           "api/**.yml",
30 |           "api/index.md"
31 |         ]
32 |       },
33 |       {
34 |         "files": [
35 |           "articles/**.md",
36 |           "articles/**/toc.yml",
37 |           "toc.yml",
38 |           "*.md"
39 |         ]
40 |       }
41 |     ],
42 |     "resource": [
43 |       {
44 |         "files": [
45 |           "images/**"
46 |         ]
47 |       }
48 |     ],
49 |     "overwrite": [
50 |       {
51 |         "files": [
52 |           "apidoc/**.md"
53 |         ],
54 |         "exclude": [
55 |           "obj/**",
56 |           "_site/**"
57 |         ]
58 |       }
59 |     ],
60 |     "dest": "_site",
61 |     "globalMetadataFiles": [],
62 |     "fileMetadataFiles": [],
63 |     "template": [
64 |       "default",
65 |       "templates/material"
66 |     ],
67 |     "postProcessors": [],
68 |     "markdownEngineName": "markdig",
69 |     "noLangKeyword": false,
70 |     "keepFileLink": false,
71 |     "cleanupCacheHistory": false,
72 |     "disableGitFeatures": false,
73 |     "globalMetadata": {
74 |       "_appLogoPath": "images/Logo.png",
75 |       "_appFaviconPath": "images/Logo.png",
76 |       "_appTitle": "XPlat Windows APIs",
77 |       "_appFooter": "Copyright (c) XPlat Apps",
78 |       "_enableSearch": true,
79 |       "_enableNewTab": true
80 |     }
81 |   }
82 | }


--------------------------------------------------------------------------------
/docs/images/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/docs/images/Logo.png


--------------------------------------------------------------------------------
/docs/images/ProjectBanner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XPlat-Apps/XPlat-Windows-APIs/6bae7026dc2466e13f319759d70cc237ce9989e3/docs/images/ProjectBanner.png


--------------------------------------------------------------------------------
/docs/templates/material/partials/head.tmpl.partial:
--------------------------------------------------------------------------------
 1 | {{!Copyright (c) Oscar Vasquez. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}
 2 | 
 3 | 
 4 |   
 5 |   
 6 |   {{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}} {{#_appTitle}}| {{_appTitle}} {{/_appTitle}}
 7 |   
 8 |   
 9 |   
10 |   {{#_description}}{{/_description}}
11 |   
12 |   
13 |   
14 |   
15 |    
16 |   
17 |   
18 |   {{#_noindex}}{{/_noindex}}
19 |   {{#_enableSearch}}{{/_enableSearch}}
20 |   {{#_enableNewTab}}{{/_enableNewTab}}
21 | 


--------------------------------------------------------------------------------
/docs/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Docs
2 |   href: docs/
3 |   homepage: articles/intro.md
4 | - name: APIs
5 |   href: api/


--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 |   "msbuild-sdks": {
3 |     "MSBuild.Sdk.Extras": "3.0.44"
4 |   }
5 | }


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/Clipboard.Windows.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if WINDOWS_UWP
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     using System;
 8 |     using System.Threading.Tasks;
 9 | 
10 |     /// Gets and sets information from the clipboard object.
11 |     public static class Clipboard
12 |     {
13 |         /// Occurs when the data stored in the Clipboard changes.
14 |         public static event EventHandler ContentChanged;
15 | 
16 |         /// Gets the current content that is stored in the clipboard object.
17 |         /// Contains the content of the Clipboard.
18 |         public static DataPackageView GetContent()
19 |         {
20 |             return Windows.ApplicationModel.DataTransfer.Clipboard.GetContent();
21 |         }
22 | 
23 |         /// Gets the current text content that is stored in the clipboard object.
24 |         /// The text.
25 |         public static async Task GetTextAsync()
26 |         {
27 |             return await GetContent().GetTextAsync();
28 |         }
29 | 
30 |         /// Sets the current content that is stored in the clipboard object.
31 |         /// Contains the content of the clipboard. If NULL, the clipboard is emptied.
32 |         /// Thrown if  throws an exception.
33 |         public static void SetContent(DataPackage content)
34 |         {
35 |             Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(content);
36 |             ContentChanged?.Invoke(typeof(Clipboard), content);
37 |         }
38 | 
39 |         /// Sets the current text that is stored in the clipboard object.
40 |         /// The text.
41 |         /// Thrown if  throws an exception.
42 |         public static void SetText(string text)
43 |         {
44 |             var dataPackage = new DataPackage();
45 |             dataPackage.SetText(text);
46 |             SetContent(dataPackage);
47 |         }
48 | 
49 |         /// Removes all data from the Clipboard.
50 |         /// Use the  method when you want to cancel an action that put data on the clipboard.
51 |         /// A delegate callback throws an exception.
52 |         public static void Clear()
53 |         {
54 |             Windows.ApplicationModel.DataTransfer.Clipboard.Clear();
55 |             ContentChanged?.Invoke(typeof(Clipboard), null);
56 |         }
57 |     }
58 | }
59 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/DataPackage.Android.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __ANDROID__
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     /// Contains the data that a user wants to exchange with another app.
 8 |     public class DataPackage : IDataPackage
 9 |     {
10 |         /// 
11 |         /// Initializes a new instance of the  class.
12 |         /// 
13 |         public DataPackage()
14 |         {
15 |         }
16 | 
17 |         internal string Text { get; private set; }
18 | 
19 |         /// Sets the text that a DataPackage contains.
20 |         /// The text.
21 |         public void SetText(string value)
22 |         {
23 |             this.Text = value;
24 |         }
25 |     }
26 | }
27 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/DataPackage.Windows.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if WINDOWS_UWP
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     /// Contains the data that a user wants to exchange with another app.
 8 |     public class DataPackage : IDataPackage
 9 |     {
10 |         /// 
11 |         /// Initializes a new instance of the  class.
12 |         /// 
13 |         public DataPackage()
14 |         {
15 |             this.Originator = new Windows.ApplicationModel.DataTransfer.DataPackage();
16 |         }
17 | 
18 |         /// Gets the originating Windows DataPackage instance.
19 |         public Windows.ApplicationModel.DataTransfer.DataPackage Originator { get; }
20 | 
21 |         /// 
22 |         /// Allows conversion of a  to the  without direct casting.
23 |         /// 
24 |         /// 
25 |         /// The .
26 |         /// 
27 |         /// 
28 |         /// The .
29 |         /// 
30 |         public static implicit operator Windows.ApplicationModel.DataTransfer.DataPackage(DataPackage dataPackage)
31 |         {
32 |             return dataPackage?.Originator;
33 |         }
34 | 
35 |         /// Sets the text that a DataPackage contains.
36 |         /// The text.
37 |         public void SetText(string value)
38 |         {
39 |             this.Originator.SetText(value);
40 |         }
41 |     }
42 | }
43 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/DataPackage.iOS.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __IOS__
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     /// Contains the data that a user wants to exchange with another app.
 8 |     public class DataPackage : IDataPackage
 9 |     {
10 |         /// 
11 |         /// Initializes a new instance of the  class.
12 |         /// 
13 |         public DataPackage()
14 |         {
15 |         }
16 | 
17 |         internal string Text { get; private set; }
18 | 
19 |         /// Sets the text that a DataPackage contains.
20 |         /// The text.
21 |         public void SetText(string value)
22 |         {
23 |             this.Text = value;
24 |         }
25 |     }
26 | }
27 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/DataPackageView.Android.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __ANDROID__
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     using System.Threading.Tasks;
 8 | 
 9 |     /// A read-only version of a DataPackage. Apps that receive shared content get this object when acquiring content.
10 |     public class DataPackageView : DataPackage, IDataPackageView
11 |     {
12 |         /// 
13 |         /// Initializes a new instance of the  class.
14 |         /// 
15 |         internal DataPackageView()
16 |         {
17 |         }
18 | 
19 |         /// Gets the text in the DataPackageView object.
20 |         /// The text.
21 |         public Task GetTextAsync()
22 |         {
23 |             return Task.FromResult(this.Text);
24 |         }
25 |     }
26 | }
27 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/DataPackageView.Windows.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if WINDOWS_UWP
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     using System;
 8 |     using System.Threading.Tasks;
 9 | 
10 |     /// A read-only version of a DataPackage. Apps that receive shared content get this object when acquiring content.
11 |     public class DataPackageView : IDataPackageView
12 |     {
13 |         /// 
14 |         /// Initializes a new instance of the  class.
15 |         /// 
16 |         /// 
17 |         /// The originating Windows DataPackageView instance.
18 |         /// 
19 |         internal DataPackageView(Windows.ApplicationModel.DataTransfer.DataPackageView originator)
20 |         {
21 |             this.Originator = originator;
22 |         }
23 | 
24 |         /// Gets the originating Windows DataPackageView instance.
25 |         public Windows.ApplicationModel.DataTransfer.DataPackageView Originator { get; }
26 | 
27 |         /// 
28 |         /// Allows conversion of a  to the  without direct casting.
29 |         /// 
30 |         /// 
31 |         /// The .
32 |         /// 
33 |         /// 
34 |         /// The .
35 |         /// 
36 |         public static implicit operator DataPackageView(Windows.ApplicationModel.DataTransfer.DataPackageView dataPackageView)
37 |         {
38 |             return new DataPackageView(dataPackageView);
39 |         }
40 |         
41 |         /// Gets the text in the DataPackageView object.
42 |         /// The text.
43 |         public async Task GetTextAsync()
44 |         {
45 |             return await this.Originator.GetTextAsync();
46 |         }
47 |     }
48 | }
49 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/DataPackageView.iOS.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __IOS__
 5 | namespace XPlat.ApplicationModel.DataTransfer
 6 | {
 7 |     using System.Threading.Tasks;
 8 | 
 9 |     /// A read-only version of a DataPackage. Apps that receive shared content get this object when acquiring content.
10 |     public class DataPackageView : DataPackage, IDataPackageView
11 |     {
12 |         /// 
13 |         /// Initializes a new instance of the  class.
14 |         /// 
15 |         internal DataPackageView()
16 |         {
17 |         }
18 | 
19 |         /// Gets the text in the DataPackageView object.
20 |         /// The text.
21 |         public Task GetTextAsync()
22 |         {
23 |             return Task.FromResult(this.Text);
24 |         }
25 |     }
26 | }
27 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/IDataPackage.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.ApplicationModel.DataTransfer
 5 | {
 6 |     /// Contains the data that a user wants to exchange with another app.
 7 |     public interface IDataPackage
 8 |     {
 9 |         /// Sets the text that a DataPackage contains.
10 |         /// The text.
11 |         void SetText(string value);
12 |     }
13 | }


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/IDataPackageView.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.ApplicationModel.DataTransfer
 5 | {
 6 |     using System.Threading.Tasks;
 7 | 
 8 |     /// A read-only version of a DataPackage. Apps that receive shared content get this object when acquiring content.
 9 |     public interface IDataPackageView
10 |     {
11 |         /// Gets the text in the DataPackageView object.
12 |         /// The text.
13 |         Task GetTextAsync();
14 |     }
15 | }


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel.DataTransfer/XPlat.ApplicationModel.DataTransfer.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.ApplicationModel.DataTransfer APIs
 7 |     
 8 |       This package includes Windows.ApplicationModel.DataTransfer like APIs cross-platform such as:
 9 |       - Clipboard for providing information from the clipboard.
10 |       - DataPackage for providing the data that a user wants to exchange with another app.
11 |       - DataPackageView for providing a read-only version of a DataPackage.
12 |     
13 |     XPlat API ApplicationModel DataTransfer Windows UWP iOS Android Xamarin DataTransfer Clipboard Copy Paste
14 |     XPlat.ApplicationModel.DataTransfer
15 |   
16 | 
17 | 
18 | 


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel/IPackage.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.ApplicationModel
 5 | {
 6 |     using System.Collections.Generic;
 7 | 
 8 |     using XPlat.Storage;
 9 | 
10 |     /// Provides information about a package.
11 |     public interface IPackage
12 |     {
13 |         /// Gets the package identity of the current package.
14 |         IPackageId Id { get; }
15 | 
16 |         /// Gets the location of the installed package.
17 |         IStorageFolder InstalledLocation { get; }
18 | 
19 |         /// Gets the packages on which the current package depends.
20 |         IReadOnlyList Dependencies { get; }
21 |     }
22 | }


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel/IPackage2.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.ApplicationModel
 5 | {
 6 |     using System;
 7 | 
 8 |     /// Provides information about a package.
 9 |     public interface IPackage2
10 |     {
11 |         /// Gets the display name of the package.
12 |         string DisplayName { get; }
13 | 
14 |         /// Gets the logo of the package.
15 |         Uri Logo { get; }
16 | 
17 |         /// Indicates whether the package is installed in development mode.
18 |         bool IsDevelopmentMode { get; }
19 |     }
20 | }


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel/IPackage3.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.ApplicationModel
 5 | {
 6 |     using System;
 7 | 
 8 |     /// Provides information about a package.
 9 |     public interface IPackage3
10 |     {
11 |         /// Gets the date on which the application package was installed or last updated.
12 |         DateTimeOffset InstalledDate { get; }
13 |     }
14 | }
15 | 


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel/IPackageId.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.ApplicationModel
 5 | {
 6 |     /// Provides package identification info, such as name, version, and publisher.
 7 |     public interface IPackageId
 8 |     {
 9 |         /// Gets the name of the package.
10 |         string Name { get; }
11 | 
12 |         /// Gets the package version info.
13 |         PackageVersion Version { get; }
14 | 
15 |         /// Gets the full name of the package.
16 |         string FullName { get; }
17 |     }
18 | }


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel/PackageId.iOS.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __IOS__
 5 | namespace XPlat.ApplicationModel
 6 | {
 7 |     using System;
 8 | 
 9 |     using global::Foundation;
10 | 
11 |     /// Provides package identification info, such as name, version, and publisher.
12 |     public class PackageId : IPackageId
13 |     {
14 |         private readonly WeakReference originatorReference;
15 | 
16 |         /// 
17 |         /// Initializes a new instance of the  class with the application bundle.
18 |         /// 
19 |         /// The application bundle.
20 |         /// Thrown if  is .
21 |         public PackageId(NSBundle bundle)
22 |         {
23 |             if (bundle == null)
24 |             {
25 |                 throw new ArgumentNullException(nameof(bundle));
26 |             }
27 | 
28 |             this.originatorReference = new WeakReference(bundle);
29 |         }
30 | 
31 |         /// Gets the name of the package.
32 |         public string Name => this.Originator?.ObjectForInfoDictionary("CFBundleDisplayName")?.ToString();
33 | 
34 |         /// Gets the package version info.
35 |         public PackageVersion Version => this.Originator;
36 | 
37 |         /// Gets the full name of the package.
38 |         public string FullName => this.Originator?.ObjectForInfoDictionary("CFBundleName")?.ToString();
39 | 
40 |         /// Gets the original iOS NSBundle reference object.
41 |         public NSBundle Originator =>
42 |             this.originatorReference != null && this.originatorReference.IsAlive
43 |                 ? this.originatorReference.Target as NSBundle
44 |                 : null;
45 |     }
46 | }
47 | #endif


--------------------------------------------------------------------------------
/src/XPlat.ApplicationModel/XPlat.ApplicationModel.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.ApplicationModel APIs
 7 |     
 8 |       This package includes Windows.ApplicationModel like APIs cross-platform such as:
 9 |       - Package for providing information about the installed application.
10 |       - PackageId for providing package identification info, such as name, version, and publisher.
11 |       - PackageVersion for providing package version info.
12 |     
13 |     XPlat API ApplicationModel Windows UWP iOS Android Xamarin Package
14 |     XPlat.ApplicationModel
15 |   
16 | 
17 |   
18 |     
19 |   
20 | 
21 | 
22 | 


--------------------------------------------------------------------------------
/src/XPlat.Core/Exceptions/AppPermissionInvalidException.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.Exceptions
 5 | {
 6 |     using System;
 7 | 
 8 |     /// 
 9 |     /// Defines an exception that is thrown when an application permission is not set.
10 |     /// 
11 |     public class AppPermissionInvalidException : Exception
12 |     {
13 |         /// 
14 |         /// Initializes a new instance of the  class.
15 |         /// 
16 |         /// 
17 |         /// The permission which could not be found.
18 |         /// 
19 |         /// 
20 |         /// The message to store.
21 |         /// 
22 |         public AppPermissionInvalidException(string permission, string message)
23 |             : this(permission, message, null)
24 |         {
25 |         }
26 | 
27 |         /// 
28 |         /// Initializes a new instance of the  class.
29 |         /// 
30 |         /// 
31 |         /// The permission which could not be found.
32 |         /// 
33 |         /// 
34 |         /// The message to store.
35 |         /// 
36 |         /// 
37 |         /// The inner exception.
38 |         /// 
39 |         public AppPermissionInvalidException(string permission, string message, Exception innerException)
40 |             : base(message, innerException)
41 |         {
42 |             this.PermissionCode = permission;
43 |         }
44 | 
45 |         /// 
46 |         /// Gets the permission which could not be found.
47 |         /// 
48 |         public string PermissionCode { get; }
49 |     }
50 | }


--------------------------------------------------------------------------------
/src/XPlat.Core/Extensions/NSDateExtensions.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __IOS__
 5 | namespace XPlat.Extensions
 6 | {
 7 |     using System;
 8 |     using Foundation;
 9 | 
10 |     /// 
11 |     /// Defines a collection of extensions for NSDate objects.
12 |     /// 
13 |     public static class NSDateExtensions
14 |     {
15 |         private static readonly DateTimeOffset DateReference = new DateTimeOffset(2001, 1, 1, 0, 0, 0, TimeSpan.Zero);
16 | 
17 |         /// 
18 |         /// Converts an NSDate object to a DateTimeOffset object.
19 |         /// 
20 |         /// The date to convert to a DateTimeOffset.
21 |         /// Returns the converted DateTimeOffset value.
22 |         public static DateTimeOffset ToDateTimeOffset(this NSDate date)
23 |         {
24 |             return date.Equals(NSDate.DistantPast)
25 |                 ? DateTimeOffset.MinValue
26 |                 : (date.Equals(NSDate.DistantFuture)
27 |                     ? DateTimeOffset.MaxValue
28 |                     : DateReference.AddSeconds(date.SecondsSinceReferenceDate));
29 |         }
30 |     }
31 | }
32 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Core/Helpers/ApplicationManfiestHelper.Android.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __ANDROID__
 5 | namespace XPlat.Helpers
 6 | {
 7 |     using System;
 8 |     using System.Globalization;
 9 |     using System.Linq;
10 |     using Android.App;
11 |     using Android.Content.PM;
12 | 
13 |     /// 
14 |     /// Defines a helper for the Android .
15 |     /// 
16 |     public static class PackageManagerHelper
17 |     {
18 |         /// 
19 |         /// Determines whether a content provider exists with the specified .
20 |         /// 
21 |         /// The content provider name.
22 |         /// True if the content provider exists; otherwise, false.
23 |         /// Thrown if  is .
24 |         public static bool CheckContentProviderExists(string providerName)
25 |         {
26 |             if (string.IsNullOrWhiteSpace(providerName))
27 |             {
28 |                 throw new ArgumentNullException(nameof(providerName));
29 |             }
30 | 
31 |             PackageInfo myPackage = Application.Context.PackageManager.GetInstalledPackages(PackageInfoFlags.Providers)
32 |                 .FirstOrDefault(
33 |                     packageInfo => packageInfo.PackageName.Equals(
34 |                         Application.Context.PackageName,
35 |                         StringComparison.CurrentCultureIgnoreCase));
36 | 
37 |             return myPackage != null
38 |                    && myPackage.Providers.Any(providerInfo =>
39 |                        CultureInfo.CurrentCulture.CompareInfo.IndexOf(providerInfo.Name, providerName,
40 |                            CompareOptions.IgnoreCase) >= 0);
41 |         }
42 |     }
43 | }
44 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Core/Helpers/RequestCodeHelper.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.Helpers
 5 | {
 6 |     /// Represents a helper for generating request codes for applications.
 7 |     public static class RequestCodeHelper
 8 |     {
 9 |         /// 
10 |         /// Gets the previously generated request code.
11 |         /// 
12 |         public static int LastRequestCode { get; private set; }
13 | 
14 |         /// Generates an integer request code.
15 |         /// Returns a value ranging from 1 to 65535 (ushort.MaxValue).
16 |         public static int GenerateRequestCode()
17 |         {
18 |             // Request codes have a maximum value of 65535.
19 |             if (LastRequestCode == ushort.MaxValue)
20 |             {
21 |                 LastRequestCode = 0;
22 |             }
23 | 
24 |             return ++LastRequestCode;
25 |         }
26 | 
27 |         /// Resets the request code.
28 |         public static void Reset()
29 |         {
30 |             LastRequestCode = 0;
31 |         }
32 |     }
33 | }


--------------------------------------------------------------------------------
/src/XPlat.Core/Threading/Tasks/TimeoutTask.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.Threading.Tasks
 5 | {
 6 |     using System;
 7 |     using System.Threading.Tasks;
 8 | 
 9 |     /// 
10 |     /// Defines a task that is actioned when the timeout occurs unless cancelled.
11 |     /// 
12 |     public class TimeoutTask
13 |     {
14 |         private readonly TimeSpan timeout;
15 | 
16 |         private readonly Action timeoutAction;
17 | 
18 |         private bool taskCancelled;
19 | 
20 |         /// 
21 |         /// Initializes a new instance of the  class.
22 |         /// 
23 |         /// 
24 |         /// The timeout period.
25 |         /// 
26 |         /// 
27 |         /// The action to perform when the timeout occurs.
28 |         /// 
29 |         public TimeoutTask(TimeSpan timeout, Action timeoutAction)
30 |         {
31 |             this.timeout = timeout;
32 |             this.timeoutAction = timeoutAction;
33 | 
34 |             Task.Factory.StartNew(this.OnTimeout, TaskCreationOptions.LongRunning);
35 |         }
36 | 
37 |         /// 
38 |         /// Cancels the timeout task to prevent the timeout action from occurring.
39 |         /// 
40 |         public void Cancel()
41 |         {
42 |             this.taskCancelled = true;
43 |         }
44 | 
45 |         private void OnTimeout()
46 |         {
47 |             DateTime start = DateTime.UtcNow;
48 |             while (!this.taskCancelled)
49 |             {
50 |                 if (DateTime.UtcNow - start < this.timeout)
51 |                 {
52 |                     Task.Delay(1).Wait();
53 |                     continue;
54 |                 }
55 | 
56 |                 this.timeoutAction?.Invoke();
57 |                 return;
58 |             }
59 |         }
60 |     }
61 | }


--------------------------------------------------------------------------------
/src/XPlat.Core/XPlat.Core.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Extended Core APIs
 7 |     
 8 |       This package includes additional extensions to support common components cross-platform such as:
 9 |       - TimeoutTask for providing a task that is actioned when the timeout occurs unless cancelled.
10 |       - RequestCodeHelper for providing a helper for generating request codes for Android applications.
11 |       - CollectionExtensions for providing additional extensions to enumerable objects.
12 |     
13 |     XPlat API Core Windows UWP iOS Android Xamarin Extensions
14 |     XPlat.Core
15 |     XPlat
16 |   
17 | 
18 | 
19 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Display/DisplayRequest.Android.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __ANDROID__
 5 | namespace XPlat.Device.Display
 6 | {
 7 |     using System;
 8 |     using Android.Views;
 9 |     using XPlat.Exceptions;
10 | 
11 |     /// Represents a display request.
12 |     public class DisplayRequest : IDisplayRequest
13 |     {
14 |         /// Initializes a new instance of the  class.
15 |         /// 
16 |         /// The current Android window.
17 |         /// 
18 |         public DisplayRequest(Window currentWindow)
19 |         {
20 |             this.Originator = currentWindow;
21 |         }
22 | 
23 |         /// 
24 |         /// Gets the Android windows associated with this request.
25 |         /// 
26 |         public Window Originator { get; }
27 | 
28 |         /// Activates a display request.
29 |         /// Thrown if android.permission.WAKE_LOCK is not permitted.
30 |         public void RequestActive()
31 |         {
32 |             try
33 |             {
34 |                 this.Originator?.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);
35 |             }
36 |             catch (Exception ex)
37 |             {
38 |                 throw new AppPermissionInvalidException("android.permission.WAKE_LOCK", ex.ToString(), ex);
39 |             }
40 |         }
41 | 
42 |         /// Deactivates a display request.
43 |         /// Thrown if android.permission.WAKE_LOCK is not permitted.
44 |         public void RequestRelease()
45 |         {
46 |             try
47 |             {
48 |                 this.Originator?.ClearFlags(WindowManagerFlags.KeepScreenOn);
49 |             }
50 |             catch (Exception ex)
51 |             {
52 |                 throw new AppPermissionInvalidException("android.permission.WAKE_LOCK", ex.ToString(), ex);
53 |             }
54 |         }
55 |     }
56 | }
57 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Display/DisplayRequest.Windows.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if WINDOWS_UWP
 5 | namespace XPlat.Device.Display
 6 | {
 7 |     /// Represents a display request.
 8 |     public class DisplayRequest : IDisplayRequest
 9 |     {
10 |         /// Initializes a new instance of the  class.
11 |         public DisplayRequest()
12 |         {
13 |             this.Originator = new Windows.System.Display.DisplayRequest();
14 |         }
15 | 
16 |         /// 
17 |         /// Gets the originating .
18 |         /// 
19 |         public Windows.System.Display.DisplayRequest Originator { get; }
20 | 
21 |         /// Activates a display request.
22 |         public void RequestActive()
23 |         {
24 |             this.Originator?.RequestActive();
25 |         }
26 | 
27 |         /// Deactivates a display request.
28 |         public void RequestRelease()
29 |         {
30 |             this.Originator?.RequestRelease();
31 |         }
32 |     }
33 | }
34 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Display/DisplayRequest.iOS.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | #if __IOS__
 5 | namespace XPlat.Device.Display
 6 | {
 7 |     using UIKit;
 8 | 
 9 |     /// Represents a display request.
10 |     public class DisplayRequest : IDisplayRequest
11 |     {
12 |         /// Activates a display request.
13 |         public void RequestActive()
14 |         {
15 |             UIApplication.SharedApplication.IdleTimerDisabled = true;
16 |         }
17 | 
18 |         /// Deactivates a display request.
19 |         public void RequestRelease()
20 |         {
21 |             UIApplication.SharedApplication.IdleTimerDisabled = false;
22 |         }
23 |     }
24 | }
25 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Display/IDisplayRequest.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.Device.Display
 5 | {
 6 |     /// Represents a display request.
 7 |     public interface IDisplayRequest
 8 |     {
 9 |         /// Activates a display request.
10 |         void RequestActive();
11 | 
12 |         /// Deactivates a display request.
13 |         void RequestRelease();
14 |     }
15 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Display/XPlat.Device.Display.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.System.Display APIs
 7 |     
 8 |       This package includes Windows.System.Display like APIs cross-platform such as:
 9 |       - DisplayRequest for providing a lock on the screen sleep period.
10 |     
11 |     XPlat API System Display Windows UWP iOS Android Xamarin DisplayRequest
12 |     XPlat.Device.Display
13 |   
14 | 
15 |   
16 |     
17 |   
18 | 
19 | 
20 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/GeolocationAccessStatus.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.Device.Geolocation
 5 | {
 6 |     /// Indicates if your app has permission to access location data.
 7 |     public enum GeolocationAccessStatus
 8 |     {
 9 |         /// Permission to access location was not specified.
10 |         Unspecified,
11 | 
12 |         /// Permission to access location was granted.
13 |         Allowed,
14 | 
15 |         /// Permission to access location was denied.
16 |         Denied,
17 |     }
18 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/GeolocatorException.cs:
--------------------------------------------------------------------------------
 1 | // XPlat Apps licenses this file to you under the MIT license.
 2 | // See the LICENSE file in the project root for more information.
 3 | 
 4 | namespace XPlat.Device.Geolocation
 5 | {
 6 |     using System;
 7 | 
 8 |     /// 
 9 |     /// Defines an exception for an error in the .
10 |     /// 
11 |     public class GeolocatorException : Exception
12 |     {
13 |         /// 
14 |         /// Initializes a new instance of the  class.
15 |         /// 
16 |         public GeolocatorException()
17 |             : this(string.Empty)
18 |         {
19 |         }
20 | 
21 |         /// Initializes a new instance of the  class with a specified error message.
22 |         /// The error message that explains the reason for the exception.
23 |         public GeolocatorException(string message)
24 |             : this(message, null)
25 |         {
26 |         }
27 | 
28 |         /// Initializes a new instance of the  class with a specified error message and a reference to the inner exception that is the cause of this exception.
29 |         /// The error message that explains the reason for the exception.
30 |         /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
31 |         public GeolocatorException(string message, Exception innerException)
32 |             : base(message, innerException)
33 |         {
34 |         }
35 |     }
36 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/Geoposition.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Geolocation
 2 | {
 3 |     /// Represents a location that may contain latitude and longitude data.
 4 |     public class Geoposition : IGeoposition
 5 |     {
 6 |         /// 
 7 |         /// Initializes a new instance of the  class.
 8 |         /// 
 9 |         public Geoposition()
10 |         {
11 |         }
12 | 
13 |         /// 
14 |         /// Initializes a new instance of the  class.
15 |         /// 
16 |         /// 
17 |         /// The coordinate.
18 |         /// 
19 |         public Geoposition(Geocoordinate coordinate)
20 |         {
21 |             this.Coordinate = coordinate;
22 |         }
23 | 
24 | #if WINDOWS_UWP
25 |         /// 
26 |         /// Initializes a new instance of the  class.
27 |         /// 
28 |         public Geoposition(Windows.Devices.Geolocation.Geocoordinate coordinate)
29 |         {
30 |             this.Coordinate = new Geocoordinate(coordinate);
31 |         }
32 | 
33 |         /// 
34 |         /// Initializes a new instance of the  class.
35 |         /// 
36 |         public Geoposition(Windows.Devices.Geolocation.Geoposition position)
37 |         {
38 |             this.Coordinate = new Geocoordinate(position.Coordinate);
39 |         }
40 | 
41 |         public static implicit operator Geoposition(Windows.Devices.Geolocation.Geocoordinate geocoordinate)
42 |         {
43 |             return new Geoposition(geocoordinate);
44 |         }
45 | 
46 |         public static implicit operator Geoposition(Windows.Devices.Geolocation.Geoposition geoposition)
47 |         {
48 |             return new Geoposition(geoposition);
49 |         }
50 | #elif __ANDROID__
51 |         /// 
52 |         /// Initializes a new instance of the  class.
53 |         /// 
54 |         public Geoposition(Android.Locations.Location location)
55 |         {
56 |             this.Coordinate = new Geocoordinate(location);
57 |         }
58 | #elif __IOS__
59 |         /// 
60 |         /// Initializes a new instance of the  class.
61 |         /// 
62 |         public Geoposition(CoreLocation.CLLocation location)
63 |         {
64 |             this.Coordinate = new Geocoordinate(location);
65 |         }
66 | #endif
67 | 
68 |         /// Gets or sets the latitude and longitude associated with a geographic location.
69 |         public Geocoordinate Coordinate { get; set; }
70 |     }
71 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/IGeocoordinate.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Geolocation
 2 | {
 3 |     using System;
 4 | 
 5 |     /// Contains the information for identifying a geographic location.
 6 |     public interface IGeocoordinate
 7 |     {
 8 |         /// Gets or sets the latitude in degrees. The valid range of values is from -90.0 to 90.0.
 9 |         double Latitude { get; set; }
10 | 
11 |         /// Gets or sets the longitude in degrees. The valid range of values is from -180.0 to 180.0.
12 |         double Longitude { get; set; }
13 | 
14 |         /// Gets or sets the altitude of the location, in meters.
15 |         double Altitude { get; set; }
16 | 
17 |         /// Gets or sets the accuracy of the location in meters.
18 |         double Accuracy { get; set; }
19 | 
20 |         /// Gets or sets the current heading in degrees relative to true north.
21 |         double Heading { get; set; }
22 | 
23 |         /// Gets or sets the speed in meters per second.
24 |         double Speed { get; set; }
25 | 
26 |         /// Gets or sets the system time at which the location was determined.
27 |         DateTimeOffset Timestamp { get; set; }
28 | 
29 |         /// Gets or sets the location of the Geocoordinate.
30 |         Geopoint Point { get; set; }
31 |     }
32 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/IGeopoint.cs:
--------------------------------------------------------------------------------
1 | namespace XPlat.Device.Geolocation
2 | {
3 |     /// Describes a geographic point.
4 |     public interface IGeopoint
5 |     {
6 |         /// Gets or sets the position of a geographic point.
7 |         BasicGeoposition Position { get; set; }
8 |     }
9 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/IGeoposition.cs:
--------------------------------------------------------------------------------
1 | namespace XPlat.Device.Geolocation
2 | {
3 |     /// Represents a location that may contain latitude and longitude data.
4 |     public interface IGeoposition
5 |     {
6 |         /// Gets or sets the latitude and longitude associated with a geographic location.
7 |         Geocoordinate Coordinate { get; set; }
8 |     }
9 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/IStatusChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace XPlat.Device.Geolocation
2 | {
3 |     /// Provides information for the StatusChanged event.
4 |     public interface IStatusChangedEventArgs
5 |     {
6 |         /// Gets the updated status of the Geolocator object.
7 |         PositionStatus Status { get; }
8 |     }
9 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/PositionAccuracy.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Geolocation
 2 | {
 3 |     /// Indicates the requested accuracy level for the location data that the application uses.
 4 |     public enum PositionAccuracy
 5 |     {
 6 |         /// Optimize for power, performance, and other cost considerations.
 7 |         Default,
 8 | 
 9 |         /// Deliver the most accurate report possible. This includes using services that might charge money, or consuming higher levels of battery power or connection bandwidth. An accuracy level of High may degrade system performance and should be used only when necessary.
10 |         High
11 |     }
12 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/PositionChangedEventArgs.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Geolocation
 2 | {
 3 |     /// Provides data for the PositionChanged event.
 4 |     public class PositionChangedEventArgs
 5 |     {
 6 |         /// 
 7 |         /// Initializes a new instance of the  class.
 8 |         /// 
 9 |         /// 
10 |         /// The location data associated with the PositionChanged event.
11 |         /// 
12 |         public PositionChangedEventArgs(Geoposition position)
13 |         {
14 |             this.Position = position;
15 |         }
16 | 
17 | #if WINDOWS_UWP
18 |         /// 
19 |         /// Initializes a new instance of the  class.
20 |         /// 
21 |         public PositionChangedEventArgs(Windows.Devices.Geolocation.PositionChangedEventArgs eventArgs)
22 |         {
23 |             this.Position = new Geoposition(eventArgs.Position);
24 |         }
25 | 
26 |         /// 
27 |         /// Initializes a new instance of the  class.
28 |         /// 
29 |         public PositionChangedEventArgs(Windows.Devices.Geolocation.Geoposition position)
30 |         {
31 |             this.Position = new Geoposition(position);
32 |         }
33 | #elif __ANDROID__
34 |         /// 
35 |         /// Initializes a new instance of the  class.
36 |         /// 
37 |         public PositionChangedEventArgs(Android.Locations.Location location)
38 |         {
39 |             this.Position = new Geoposition(location);
40 |         }
41 | #elif __IOS__
42 |         /// 
43 |         /// Initializes a new instance of the  class.
44 |         /// 
45 |         public PositionChangedEventArgs(CoreLocation.CLLocation location)
46 |         {
47 |             this.Position = new Geoposition(location);
48 |         }
49 | #endif
50 | 
51 |         /// 
52 |         /// Gets the location data associated with the PositionChanged event.
53 |         /// 
54 |         public Geoposition Position { get; }
55 |     }
56 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/PositionStatus.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Geolocation
 2 | {
 3 |     /// Indicates the ability of the Geolocator object to provide location data.
 4 |     public enum PositionStatus
 5 |     {
 6 |         /// Location data is available.
 7 |         Ready,
 8 | 
 9 |         /// Location services is initializing. This is the status if a GPS is the source of location data and the GPS receiver does not yet have the required number of satellites in view to obtain an accurate position.
10 |         Initializing,
11 | 
12 |         /// No location data is available from any source. LocationStatus will have this value if the application calls GetGeopositionAsync or registers an event handler for the PositionChanged event, before data is available from a location sensor. Once data is available LocationStatus transitions to the Ready state.
13 |         NoData,
14 | 
15 |         /// Location settings are turned off. This status indicates that the user has not granted the application permission to access location.
16 |         Disabled,
17 | 
18 |         /// An operation to retrieve location has not yet been initialized. LocationStatus will have this value if the application has not yet called GetGeopositionAsync or registered an event handler for the PositionChanged event. LocationStatus may also have this value if your app doesn't have permission to access location. Call the RequestAccessAsync before accessing the user's location. At that time, your app must be in the foreground and RequestAccessAsync must be called from the UI thread. Until the user grants your app permission to their location, your app can't access location data.
19 |         NotInitialized,
20 | 
21 |         /// Location services is not available.
22 |         NotAvailable,
23 |     }
24 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/StatusChangedEventArgs.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Geolocation
 2 | {
 3 |     /// Provides information for the StatusChanged event.
 4 |     public class StatusChangedEventArgs : IStatusChangedEventArgs
 5 |     {
 6 |         /// 
 7 |         /// Initializes a new instance of the  class.
 8 |         /// 
 9 |         /// 
10 |         /// The position status.
11 |         /// 
12 |         public StatusChangedEventArgs(PositionStatus status)
13 |         {
14 |             this.Status = status;
15 |         }
16 | 
17 | #if WINDOWS_UWP
18 |         /// 
19 |         /// Initializes a new instance of the  class.
20 |         /// 
21 |         public StatusChangedEventArgs(Windows.Devices.Geolocation.PositionStatus status)
22 |         {
23 |             this.Status =
24 |                 XPlat.Device.Geolocation.Extensions.PositionStatusExtensions.ToInternalPositionStatus(status);
25 |         }
26 | 
27 |         /// 
28 |         /// Initializes a new instance of the  class.
29 |         /// 
30 |         public StatusChangedEventArgs(Windows.Devices.Geolocation.StatusChangedEventArgs eventArgs)
31 |         {
32 |             this.Status =
33 |                 XPlat.Device.Geolocation.Extensions.PositionStatusExtensions
34 |                     .ToInternalPositionStatus(eventArgs.Status);
35 |         }
36 | 
37 |         public static implicit operator StatusChangedEventArgs(Windows.Devices.Geolocation.StatusChangedEventArgs eventArgs)
38 |         {
39 |             return new StatusChangedEventArgs(eventArgs);
40 |         }
41 | #endif
42 | 
43 |         /// Gets the updated status of the Geolocator object.
44 |         public PositionStatus Status { get; }
45 |     }
46 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Geolocation/XPlat.Device.Geolocation.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.Devices.Geolocation APIs
 7 |     
 8 |       This package includes Windows.Devices.Geolocation like APIs cross-platform such as:
 9 |       - BasicGeoposition for providing basic information to describe a geographic position.
10 |       - Geocoordinate for providing information for identifying a geographic location.
11 |       - Geopoint for describing a geographic point.
12 |       - Geoposition for describing a location that may contain latitude and longitude data.
13 |       - Geolocator for providing access to the current geographic location of the device.
14 |     
15 |     XPlat API Devices Geolocation Windows UWP iOS Android Xamarin Geoposition Geolocator
16 |     XPlat.Device.Geolocation
17 |   
18 | 
19 |   
20 |     
21 |     
22 |   
23 | 
24 | 
25 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Launcher/ILauncher.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device
 2 | {
 3 |     using System;
 4 |     using System.Threading.Tasks;
 5 |     using XPlat.Storage;
 6 | 
 7 |     /// Starts the default app associated with the specified file or URI.
 8 |     public interface ILauncher
 9 |     {
10 |         /// Launches a file explorer and displays the contents of the specified folder.
11 |         /// The result of the operation.
12 |         /// The folder to display in a file explorer.
13 |         Task LaunchFolderAsync(IStorageFolder folder);
14 | 
15 |         /// 
16 |         /// Starts the default app associated with the URI scheme name for the specified URI.
17 |         /// 
18 |         /// 
19 |         /// The URI.
20 |         /// 
21 |         /// 
22 |         /// Returns true if the default app for the URI scheme was launched; false otherwise.
23 |         /// 
24 |         Task LaunchUriAsync(Uri uri);
25 | 
26 |         /// 
27 |         /// Asynchronously query whether an app can be activated for the specified URI.
28 |         /// 
29 |         /// 
30 |         /// The URI for which to query support.
31 |         /// 
32 |         /// 
33 |         /// A value that indicates whether an application is available to launch the URI.
34 |         /// 
35 |         Task QueryUriSupportAsync(Uri uri);
36 | 
37 |         /// Starts the default app associated with the specified file.
38 |         /// The launch operation.
39 |         /// The file.
40 |         Task LaunchFileAsync(IStorageFile file);
41 |     }
42 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Launcher/LaunchQuerySupportStatus.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device
 2 | {
 3 |     /// Specifies whether an app is available that supports activation.
 4 |     public enum LaunchQuerySupportStatus
 5 |     {
 6 |         /// An app that handles the activation is available and may be activated.
 7 |         Available,
 8 | 
 9 |         /// No app is installed to handle the activation.
10 |         AppNotInstalled,
11 | 
12 |         /// An app that handles the activation is installed but not available because it is being updated by the store or it was installed on a removable device that is not available.
13 |         AppUnavailable,
14 | 
15 |         /// The app does not handle the activation.
16 |         NotSupported,
17 | 
18 |         /// An unknown error was encountered while determining whether an app supports the activation.
19 |         Unknown,
20 |     }
21 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Launcher/Launcher.Windows.cs:
--------------------------------------------------------------------------------
 1 | #if WINDOWS_UWP
 2 | namespace XPlat.Device
 3 | {
 4 |     using System;
 5 |     using System.Threading.Tasks;
 6 |     using Windows.System;
 7 |     using XPlat.Device.Extensions;
 8 |     using XPlat.Storage;
 9 | 
10 |     /// Starts the default app associated with the specified file or URI.
11 |     public class Launcher : ILauncher
12 |     {
13 |         /// Launches a file explorer and displays the contents of the specified folder.
14 |         /// The result of the operation.
15 |         /// The folder to display in a file explorer.
16 |         public async Task LaunchFolderAsync(IStorageFolder folder)
17 |         {
18 |             Windows.Storage.StorageFolder windowsFolder = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(folder.Path);
19 | 
20 |             return await Windows.System.Launcher.LaunchFolderAsync(windowsFolder);
21 |         }
22 | 
23 |         public async Task LaunchUriAsync(Uri uri)
24 |         {
25 |             return await Windows.System.Launcher.LaunchUriAsync(uri);
26 |         }
27 | 
28 |         public async Task QueryUriSupportAsync(Uri uri)
29 |         {
30 |             Windows.System.LaunchQuerySupportStatus status = await Windows.System.Launcher.QueryUriSupportAsync(uri, LaunchQuerySupportType.Uri);
31 |             return status.ToInternalLaunchQuerySupportStatus();
32 |         }
33 | 
34 |         /// Starts the default app associated with the specified file.
35 |         /// The launch operation.
36 |         /// The file.
37 |         public async Task LaunchFileAsync(IStorageFile file)
38 |         {
39 |             Windows.Storage.StorageFile windowsFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(file.Path);
40 |             return await Windows.System.Launcher.LaunchFileAsync(windowsFile);
41 |         }
42 |     }
43 | }
44 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Launcher/XPlat.Device.Launcher.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.System.Launcher APIs
 7 |     
 8 |       This package includes Windows.System.Launcher like APIs cross-platform such as:
 9 |       - Launcher for launching a default app associated with a specified file or URI.
10 |     
11 |     XPlat API Launcher Windows UWP iOS Android Xamarin Toolkit File URI
12 |     XPlat.Device.Launcher
13 |     XPlat.Device
14 |   
15 | 
16 |   
17 |     
18 |   
19 | 
20 |   
21 |     
22 |   
23 | 
24 | 
25 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Power/BatteryStatus.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Power
 2 | {
 3 |     /// Indicates the status of the battery.
 4 |     public enum BatteryStatus
 5 |     {
 6 |         /// The battery or battery controller is not present.
 7 |         NotPresent,
 8 | 
 9 |         /// The battery is discharging.
10 |         Discharging,
11 | 
12 |         /// The battery is idle.
13 |         Idle,
14 | 
15 |         /// The battery is charging.
16 |         Charging,
17 |     }
18 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Power/BatteryStatusChangedEventArgs.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Power
 2 | {
 3 |     using System;
 4 | 
 5 |     public class BatteryStatusChangedEventArgs : EventArgs
 6 |     {
 7 |         public BatteryStatusChangedEventArgs(BatteryStatus batteryStatus, int remainingChargePercent)
 8 |         {
 9 |             this.BatteryStatus = batteryStatus;
10 |             this.RemainingChargePercent = remainingChargePercent;
11 |             this.CheckTime = DateTime.UtcNow;
12 |         }
13 | 
14 |         public BatteryStatus BatteryStatus { get; }
15 | 
16 |         public int RemainingChargePercent { get; }
17 | 
18 |         public DateTime CheckTime { get; }
19 |     }
20 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Power/BatteryStatusChangedEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace XPlat.Device.Power
2 | {
3 |     public delegate void BatteryStatusChangedEventHandler(object sender, BatteryStatusChangedEventArgs args);
4 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Power/Extensions/BatteryStatusExtensions.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Power.Extensions
 2 | {
 3 |     using System;
 4 | 
 5 |     public static class BatteryStatusExtensions
 6 |     {
 7 | #if WINDOWS_UWP
 8 |         public static BatteryStatus ToInternalBatteryStatus(this Windows.System.Power.BatteryStatus status)
 9 |         {
10 |             switch (status)
11 |             {
12 |                 case Windows.System.Power.BatteryStatus.NotPresent:
13 |                     return BatteryStatus.NotPresent;
14 |                 case Windows.System.Power.BatteryStatus.Discharging:
15 |                     return BatteryStatus.Discharging;
16 |                 case Windows.System.Power.BatteryStatus.Idle:
17 |                     return BatteryStatus.Idle;
18 |                 case Windows.System.Power.BatteryStatus.Charging:
19 |                     return BatteryStatus.Charging;
20 |                 default:
21 |                     throw new ArgumentOutOfRangeException(nameof(status), status, null);
22 |             }
23 |         }
24 | #endif
25 |     }
26 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Power/IPowerManager.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Power
 2 | {
 3 |     using System;
 4 | 
 5 |     /// Provides access to information about a device's battery and power supply status.
 6 |     public interface IPowerManager
 7 |     {
 8 |         /// Occurs when BatteryStatus changes.
 9 |         event EventHandler BatteryStatusChanged;
10 | 
11 |         /// Occurs when RemainingChargePercent changes.
12 |         event EventHandler RemainingChargePercentChanged;
13 | 
14 |         /// Gets the device's battery status.
15 |         BatteryStatus BatteryStatus { get; }
16 | 
17 |         /// Gets the total percentage of charge remaining from all batteries connected to the device.
18 |         int RemainingChargePercent { get; }
19 |     }
20 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Power/XPlat.Device.Power.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.System.Power APIs
 7 |     
 8 |       This package includes Windows.System.Power like APIs cross-platform such as:
 9 |       - PowerManager for providing access to information about a device's battery and power supply status.
10 |     
11 |     XPlat API Power Windows UWP iOS Android Xamarin PowerManager
12 |     XPlat.Device.Power
13 |   
14 | 
15 |   
16 |     
17 |   
18 | 
19 | 
20 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/AnalyticsInfo.Android.cs:
--------------------------------------------------------------------------------
 1 | #if __ANDROID__
 2 | namespace XPlat.Device.Profile
 3 | {
 4 |     /// Provides information about the device for profiling purposes.
 5 |     public static class AnalyticsInfo
 6 |     {
 7 |         /// Gets version info about the device family.
 8 |         /// Version info about the device family.
 9 |         public static AnalyticsVersionInfo VersionInfo => new AnalyticsVersionInfo();
10 | 
11 |         /// Gets the device form factor. For example, the app could be running on a phone, tablet, desktop, and so on.
12 |         /// The device form factor.
13 |         public static string DeviceForm => DetermineDeviceForm();
14 | 
15 |         private static string DetermineDeviceForm()
16 |         {
17 |             string deviceFamily = AnalyticsVersionInfo.DetermineDeviceFamily();
18 | 
19 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyDesktop))
20 |             {
21 |                 return "Desktop";
22 |             }
23 | 
24 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyCar))
25 |             {
26 |                 return "Car";
27 |             }
28 | 
29 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyMobile))
30 |             {
31 |                 return "Mobile";
32 |             }
33 | 
34 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyTablet))
35 |             {
36 |                 return "Tablet";
37 |             }
38 | 
39 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyTelevision))
40 |             {
41 |                 return "Television";
42 |             }
43 | 
44 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyWatch) || deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyVirtualReality))
45 |             {
46 |                 return "Wearable";
47 |             }
48 | 
49 |             return "Unknown";
50 |         }
51 |     }
52 | }
53 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/AnalyticsInfo.Windows.cs:
--------------------------------------------------------------------------------
 1 | #if WINDOWS_UWP
 2 | namespace XPlat.Device.Profile
 3 | {
 4 |     /// Provides information about the device for profiling purposes.
 5 |     public static class AnalyticsInfo
 6 |     {
 7 |         /// Gets version info about the device family.
 8 |         /// Version info about the device family.
 9 |         public static AnalyticsVersionInfo VersionInfo =>
10 |             new AnalyticsVersionInfo(Windows.System.Profile.AnalyticsInfo.VersionInfo);
11 | 
12 |         /// Gets the device form factor. For example, the app could be running on a phone, tablet, desktop, and so on.
13 |         /// The device form factor.
14 |         public static string DeviceForm => Windows.System.Profile.AnalyticsInfo.DeviceForm;
15 |     }
16 | }
17 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/AnalyticsInfo.iOS.cs:
--------------------------------------------------------------------------------
 1 | #if __IOS__
 2 | namespace XPlat.Device.Profile
 3 | {
 4 |     /// Provides information about the device for profiling purposes.
 5 |     public static class AnalyticsInfo
 6 |     {
 7 |         /// Gets version info about the device family.
 8 |         /// Version info about the device family.
 9 |         public static AnalyticsVersionInfo VersionInfo => new AnalyticsVersionInfo();
10 | 
11 |         /// Gets the device form factor. For example, the app could be running on a phone, tablet, desktop, and so on.
12 |         /// The device form factor.
13 |         public static string DeviceForm => DetermineDeviceForm();
14 | 
15 |         private static string DetermineDeviceForm()
16 |         {
17 |             string deviceFamily = AnalyticsVersionInfo.DetermineDeviceFamily();
18 | 
19 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyDesktop))
20 |             {
21 |                 return "Desktop";
22 |             }
23 | 
24 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyCar))
25 |             {
26 |                 return "Car";
27 |             }
28 | 
29 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyMobile))
30 |             {
31 |                 return "Mobile";
32 |             }
33 | 
34 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyTablet))
35 |             {
36 |                 return "Tablet";
37 |             }
38 | 
39 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyTelevision))
40 |             {
41 |                 return "Television";
42 |             }
43 | 
44 |             if (deviceFamily.Equals(AnalyticsVersionInfo.DeviceFamilyWatch))
45 |             {
46 |                 return "Wearable";
47 |             }
48 | 
49 |             return "Unknown";
50 |         }
51 |     }
52 | }
53 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/AnalyticsVersionInfo.Windows.cs:
--------------------------------------------------------------------------------
 1 | #if WINDOWS_UWP
 2 | namespace XPlat.Device.Profile
 3 | {
 4 |     using System;
 5 | 
 6 |     /// Provides version information about the device family.
 7 |     public class AnalyticsVersionInfo : IAnalyticsVersionInfo
 8 |     {
 9 |         public AnalyticsVersionInfo(Windows.System.Profile.AnalyticsVersionInfo versionInfo)
10 |         {
11 |             if (versionInfo == null)
12 |             {
13 |                 throw new ArgumentNullException(nameof(versionInfo));
14 |             }
15 | 
16 |             this.DeviceFamily = versionInfo.DeviceFamily;
17 |             this.DeviceFamilyVersion = versionInfo.DeviceFamilyVersion;
18 |         }
19 | 
20 |         /// Gets a string that represents the type of device the application is running on.
21 |         public string DeviceFamily { get; }
22 | 
23 |         /// Gets the version within the device family.
24 |         public string DeviceFamilyVersion { get; }
25 |     }
26 | }
27 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/AnalyticsVersionInfo.iOS.cs:
--------------------------------------------------------------------------------
 1 | #if __IOS__
 2 | namespace XPlat.Device.Profile
 3 | {
 4 |     using UIKit;
 5 | 
 6 |     /// Provides version information about the device family.
 7 |     public class AnalyticsVersionInfo : IAnalyticsVersionInfo
 8 |     {
 9 |         internal const string DeviceFamilyCar = "Apple.CarPlay";
10 | 
11 |         internal const string DeviceFamilyDesktop = "Apple.MacOS";
12 | 
13 |         internal const string DeviceFamilyMobile = "Apple.iPhone";
14 | 
15 |         internal const string DeviceFamilyTablet = "Apple.iPad";
16 | 
17 |         internal const string DeviceFamilyTelevision = "Apple.TV";
18 | 
19 |         internal const string DeviceFamilyUnknown = "Apple.Unknown";
20 | 
21 |         internal const string DeviceFamilyWatch = "Apple.Watch";
22 | 
23 |         public string DeviceFamily => DetermineDeviceFamily();
24 | 
25 |         public string DeviceFamilyVersion => UIKit.UIDevice.CurrentDevice.SystemVersion;
26 | 
27 |         internal static string DetermineDeviceFamily()
28 |         {
29 |             switch (UIKit.UIDevice.CurrentDevice.UserInterfaceIdiom)
30 |             {
31 |                 case UIUserInterfaceIdiom.Phone:
32 |                     return DeviceFamilyMobile;
33 |                 case UIUserInterfaceIdiom.Pad:
34 |                     return DeviceFamilyTablet;
35 |                 case UIUserInterfaceIdiom.TV:
36 |                     return DeviceFamilyTelevision;
37 |                 case UIUserInterfaceIdiom.CarPlay:
38 |                     return DeviceFamilyCar;
39 |                 default:
40 |                     return DeviceFamilyUnknown;
41 |             }
42 |         }
43 |     }
44 | }
45 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/IAnalyticsVersionInfo.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Device.Profile
 2 | {
 3 |     /// Provides version information about the device family.
 4 |     public interface IAnalyticsVersionInfo
 5 |     {
 6 |         /// Gets a string that represents the type of device the application is running on.
 7 |         string DeviceFamily { get; }
 8 | 
 9 |         /// Gets the version within the device family.
10 |         string DeviceFamilyVersion { get; }
11 |     }
12 | }


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/Resources/values-large/strings.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   Android.Tablet
4 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/Resources/values-sw600dp/strings.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   Android.Tablet
4 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/Resources/values/strings.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |   Android.Mobile
4 | 


--------------------------------------------------------------------------------
/src/XPlat.Device.Profile/XPlat.Device.Profile.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.System.Profile APIs
 7 |     
 8 |       This package includes Windows.System.Profile like APIs cross-platform such as:
 9 |       - AnalyticsInfo for providing information about the device for profiling purposes.
10 |       - AnalyticsVersionInfo for providing version information about the device family.
11 |     
12 |     XPlat API Profile Windows UWP iOS Android Xamarin AnalyticsInfo
13 |     XPlat.Device.Profile
14 |   
15 | 
16 |   
17 |     true
18 |   
19 | 
20 |   
21 |     False
22 |   
23 | 
24 |   
25 |     
26 |     
27 |   
28 | 
29 |   
30 |     
31 |       Designer
32 |       MSBuild:Compile
33 |       PreserveNewest
34 |     
35 |   
36 | 
37 |   
38 |     
39 |     
40 |     
41 |     
42 |   
43 | 
44 | 
45 | 


--------------------------------------------------------------------------------
/src/XPlat.Foundation/Collections/CollectionChange.cs:
--------------------------------------------------------------------------------
 1 | // 
 2 | // Copyright (c) James Croft. All rights reserved.
 3 | // 
 4 | 
 5 | namespace XPlat.Foundation.Collections
 6 | {
 7 |     /// Describes the action that causes a change to a collection.
 8 |     public enum CollectionChange
 9 |     {
10 |         /// The collection is changed.
11 |         Reset,
12 | 
13 |         /// An item is added to the collection.
14 |         ItemInserted,
15 | 
16 |         /// An item is removed from the collection.
17 |         ItemRemoved,
18 | 
19 |         /// An item is changed in the collection.
20 |         ItemChanged,
21 |     }
22 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/Collections/IMapChangedEventArgs`1.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Foundation.Collections
 2 | {
 3 |     /// Provides data for the changed event of a map collection.
 4 |     /// The type of the keys in the map.
 5 |     public interface IMapChangedEventArgs
 6 |     {
 7 |         /// Gets the type of change that occurred in the map.
 8 |         CollectionChange CollectionChange { get; }
 9 | 
10 |         /// Gets the key of the item that changed.
11 |         K Key { get; }
12 |     }
13 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/Collections/IObservableMap`2.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Foundation.Collections
 2 | {
 3 |     using System.Collections.Generic;
 4 | 
 5 |     /// Notifies listeners of dynamic changes to a map, such as when items are added or removed.
 6 |     /// The type of the keys in the map.
 7 |     /// The type of the values in the map.
 8 |     public interface IObservableMap : IDictionary
 9 |     {
10 |         /// Occurs when the map changes.
11 |         event MapChangedEventHandler MapChanged;
12 |     }
13 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/Collections/IPropertySet.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Foundation.Collections
 2 | {
 3 |     /// Represents a property set, which is a set of PropertyValue objects with string keys.
 4 |     public interface IPropertySet : IObservableMap
 5 |     {
 6 |         /// 
 7 |         /// Gets a value from the set for the specified key as the specified type.
 8 |         /// 
 9 |         /// 
10 |         /// The key to retrieve.
11 |         /// 
12 |         /// 
13 |         /// The type of object expected.
14 |         /// 
15 |         /// 
16 |         /// When complete, the method will return the value for the specified key as the specified type.
17 |         /// 
18 |         T Get(string key)
19 |             where T : class;
20 |     }
21 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/Collections/MapChangedEventHandler`2.cs:
--------------------------------------------------------------------------------
1 | namespace XPlat.Foundation.Collections
2 | {
3 |     /// Represents the method that handles the changed event of an observable map.
4 |     /// The type of the keys in the map.
5 |     /// The type of the values in the map.
6 |     /// The observable map that changed.
7 |     /// The description of the change that occurred in the map.
8 |     public delegate void MapChangedEventHandler(IObservableMap sender, IMapChangedEventArgs @event);
9 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/Collections/StringMapChangedEventArgs.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Foundation.Collections
 2 | {
 3 |     public class StringMapChangedEventArgs : IMapChangedEventArgs
 4 |     {
 5 |         public StringMapChangedEventArgs(string key, CollectionChange collectionChange)
 6 |         {
 7 |             this.Key = key;
 8 |             this.CollectionChange = collectionChange;
 9 |         }
10 | 
11 |         /// Gets the type of change that occurred in the map.
12 |         public CollectionChange CollectionChange { get; }
13 | 
14 |         /// Gets the key of the item that changed.
15 |         public string Key { get; }
16 |     }
17 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/TypedEventHandler`2.cs:
--------------------------------------------------------------------------------
1 | namespace XPlat.Foundation
2 | {
3 |     /// Represents a method that handles general events.
4 |     /// The object type.
5 |     /// The type of event data generated by the event.
6 |     /// The event source.
7 |     /// The event data. If there is no event data, this parameter will be null.
8 |     public delegate void TypedEventHandler(TSender sender, TResult args);
9 | }


--------------------------------------------------------------------------------
/src/XPlat.Foundation/XPlat.Foundation.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     netstandard2.0
 5 |     true
 6 |     XPlat - Windows.Foundation APIs
 7 |     
 8 |       This package includes Windows.Foundation like APIs cross-platform such as:
 9 |       - Size for representing number values that specify a height and width.
10 |       - TypedEventHandler for representing a method that handles general events.
11 |     
12 |     XPlat API Foundation Windows UWP iOS Android Xamarin Size TypedEventHandler
13 |     XPlat.Foundation
14 |   
15 | 
16 | 


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/CameraCaptureUIMaxPhotoResolution.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Determines the highest resolution the user can select for capturing photos.
 4 |     public enum CameraCaptureUIMaxPhotoResolution
 5 |     {
 6 |         /// The user can select any resolution.
 7 |         HighestAvailable,
 8 | 
 9 |         /// The user can select resolutions up to 320 X 240, or a similar 16:9 resolution.
10 |         VerySmallQvga,
11 | 
12 |         /// The user can select resolutions up to 320 X 240, or a similar 16:9 resolution.
13 |         SmallVga,
14 | 
15 |         /// The user can select resolutions up to 1024 X 768, or a similar 16:9 resolution.
16 |         MediumXga,
17 | 
18 |         /// The user can select resolutions up to 1920 X 1080, or a similar 4:3 resolution.
19 |         Large3M,
20 | 
21 |         /// The user can select resolutions up to 5MP.
22 |         VeryLarge5M,
23 |     }
24 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/CameraCaptureUIMaxVideoResolution.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Determines the highest resolution the user can select for capturing video.
 4 |     public enum CameraCaptureUIMaxVideoResolution
 5 |     {
 6 |         /// The user can select any resolution.
 7 |         HighestAvailable,
 8 | 
 9 |         /// The user can select resolutions up to low definition resolutions.
10 |         LowDefinition,
11 | 
12 |         /// The user can select resolutions up to standard definition resolutions.
13 |         StandardDefinition,
14 | 
15 |         /// The user can select resolutions up to high definition resolutions.
16 |         HighDefinition,
17 |     }
18 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/CameraCaptureUIMode.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Determines whether the user interface for capturing from the attached camera allows capture of photos, videos, or both photos and videos.
 4 |     public enum CameraCaptureUIMode
 5 |     {
 6 |         /// Either a photo or video can be captured.
 7 |         PhotoOrVideo,
 8 | 
 9 |         /// The user can only capture a photo.
10 |         Photo,
11 | 
12 |         /// The user can only capture a video.
13 |         Video,
14 |     }
15 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/CameraCaptureUIPhotoCaptureSettings.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Provides settings for capturing photos.
 4 |     public class CameraCaptureUIPhotoCaptureSettings : ICameraCaptureUIPhotoCaptureSettings
 5 |     {
 6 |         /// 
 7 |         /// Initializes a new instance of the  class.
 8 |         /// 
 9 |         public CameraCaptureUIPhotoCaptureSettings()
10 |         {
11 |             this.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable;
12 |             this.AllowCropping = false;
13 |         }
14 | 
15 |         /// Determines the maximum resolution the user will be able to select.
16 |         public CameraCaptureUIMaxPhotoResolution MaxResolution { get; set; }
17 | 
18 |         /// Determines whether photo cropping will be enabled in the user interface for capture a photo.
19 |         public bool AllowCropping { get; set; }
20 |     }
21 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/CameraCaptureUIVideoCaptureSettings.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Provides settings for capturing videos. The settings include maximum resolution, maximum duration, and whether or not to allow trimming.
 4 |     public class CameraCaptureUIVideoCaptureSettings : ICameraCaptureUIVideoCaptureSettings
 5 |     {
 6 |         /// 
 7 |         /// Initializes a new instance of the  class.
 8 |         /// 
 9 |         public CameraCaptureUIVideoCaptureSettings()
10 |         {
11 |             this.MaxResolution = CameraCaptureUIMaxVideoResolution.HighestAvailable;
12 |             this.AllowTrimming = false;
13 |         }
14 | 
15 |         /// Determines the maximum resolution that the user can select.
16 |         public CameraCaptureUIMaxVideoResolution MaxResolution { get; set; }
17 | 
18 |         /// Determines the maximum duration of a video.
19 |         public float MaxDurationInSeconds { get; set; }
20 | 
21 |         /// Determines whether or not the video trimming user interface will be enabled.
22 |         public bool AllowTrimming { get; set; }
23 |     }
24 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/CameraFileCaptured.Android.cs:
--------------------------------------------------------------------------------
 1 | #if __ANDROID__
 2 | namespace XPlat.Media.Capture
 3 | {
 4 |     using XPlat.Storage;
 5 | 
 6 |     internal class CameraFileCaptured
 7 |     {
 8 |         public CameraFileCaptured(int requestId, IStorageFile file, bool cancel, bool permissionDenied)
 9 |         {
10 |             if (file == null)
11 |             {
12 |                 cancel = true;
13 |             }
14 | 
15 |             this.RequestId = requestId;
16 |             this.File = file;
17 |             this.Cancel = cancel;
18 |             this.PermissionDenied = permissionDenied;
19 |         }
20 | 
21 |         public bool Cancel { get; }
22 | 
23 |         public bool PermissionDenied { get; }
24 | 
25 |         public IStorageFile File { get; }
26 | 
27 |         public int RequestId { get; }
28 |     }
29 | }
30 | #endif


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/Extensions/CameraCaptureUIMaxVideoResolutionExtensions.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture.Extensions
 2 | {
 3 |     using System;
 4 | 
 5 |     public static class CameraCaptureUIMaxVideoResolutionExtensions
 6 |     {
 7 | #if WINDOWS_UWP
 8 |         public static CameraCaptureUIMaxVideoResolution ToInternalCameraCaptureUIMaxVideoResolution(
 9 |             this Windows.Media.Capture.CameraCaptureUIMaxVideoResolution resolution)
10 |         {
11 |             switch (resolution)
12 |             {
13 |                 case Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.HighestAvailable:
14 |                     return CameraCaptureUIMaxVideoResolution.HighestAvailable;
15 |                 case Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.LowDefinition:
16 |                     return CameraCaptureUIMaxVideoResolution.LowDefinition;
17 |                 case Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.StandardDefinition:
18 |                     return CameraCaptureUIMaxVideoResolution.StandardDefinition;
19 |                 case Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.HighDefinition:
20 |                     return CameraCaptureUIMaxVideoResolution.HighDefinition;
21 |                 default:
22 |                     throw new ArgumentOutOfRangeException(nameof(resolution), resolution, null);
23 |             }
24 |         }
25 | 
26 |         public static Windows.Media.Capture.CameraCaptureUIMaxVideoResolution
27 |             ToWindowsCameraCaptureUIMaxVideoResolution(this CameraCaptureUIMaxVideoResolution resolution)
28 |         {
29 |             switch (resolution)
30 |             {
31 |                 case CameraCaptureUIMaxVideoResolution.HighestAvailable:
32 |                     return Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.HighestAvailable;
33 |                 case CameraCaptureUIMaxVideoResolution.LowDefinition:
34 |                     return Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.LowDefinition;
35 |                 case CameraCaptureUIMaxVideoResolution.StandardDefinition:
36 |                     return Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.StandardDefinition;
37 |                 case CameraCaptureUIMaxVideoResolution.HighDefinition:
38 |                     return Windows.Media.Capture.CameraCaptureUIMaxVideoResolution.HighDefinition;
39 |                 default:
40 |                     throw new ArgumentOutOfRangeException(nameof(resolution), resolution, null);
41 |             }
42 |         }
43 | #endif
44 |     }
45 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/ICameraCaptureUI.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     using System.Threading.Tasks;
 4 | 
 5 |     using XPlat.Storage;
 6 | 
 7 |     /// Provides a full window UI for capturing video and photos from a camera.
 8 |     public interface ICameraCaptureUI
 9 |     {
10 |         /// Provides settings for capturing photos.
11 |         CameraCaptureUIPhotoCaptureSettings PhotoSettings { get; }
12 | 
13 |         /// Provides settings for capturing videos. The settings include maximum resolution, maximum duration, and whether or not to allow trimming.
14 |         CameraCaptureUIVideoCaptureSettings VideoSettings { get; }
15 | 
16 |         /// Launches the CameraCaptureUI user interface.
17 |         /// When this operation completes, an IStorageFile object is returned.
18 |         /// Specifies whether the user interface that will be shown allows the user to capture a photo, capture a video, or capture both photos and videos.
19 |         Task CaptureFileAsync(CameraCaptureUIMode mode);
20 |     }
21 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/ICameraCaptureUIPhotoCaptureSettings.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Provides settings for capturing photos.
 4 |     public interface ICameraCaptureUIPhotoCaptureSettings
 5 |     {
 6 |         /// Determines the maximum resolution the user will be able to select.
 7 |         CameraCaptureUIMaxPhotoResolution MaxResolution { get; set; }
 8 | 
 9 |         /// Determines whether photo cropping will be enabled in the user interface for capture a photo.
10 |         bool AllowCropping { get; set; }
11 |     }
12 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/ICameraCaptureUIVideoCaptureSettings.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Media.Capture
 2 | {
 3 |     /// Provides settings for capturing videos. The settings include maximum resolution, maximum duration, and whether or not to allow trimming.
 4 |     public interface ICameraCaptureUIVideoCaptureSettings
 5 |     {
 6 |         /// Determines the maximum resolution that the user can select.
 7 |         CameraCaptureUIMaxVideoResolution MaxResolution { get; set; }
 8 | 
 9 |         /// Determines the maximum duration of a video.
10 |         float MaxDurationInSeconds { get; set; }
11 | 
12 |         /// Determines whether or not the video trimming user interface will be enabled.
13 |         bool AllowTrimming { get; set; }
14 |     }
15 | }


--------------------------------------------------------------------------------
/src/XPlat.Media.Capture/XPlat.Media.Capture.csproj:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |   
 4 |     uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0
 5 |     true
 6 |     XPlat - Windows.Media.Capture APIs
 7 |     
 8 |       This package includes Windows.Media.Capture like APIs cross-platform such as:
 9 |       - CameraCaptureUI for providing a full window UI for capturing video and photos from a camera.
10 |     
11 |     XPlat API Media Capture Windows UWP iOS Android Xamarin CameraCaptureUI
12 |     XPlat.Media.Capture
13 |   
14 | 
15 |   
16 |     
17 |   
18 | 
19 |   
20 |     
21 |     
22 |   
23 | 
24 | 
25 | 


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/Extensions/MapLocationDesiredAccuracyExtensions.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Services.Maps.Extensions
 2 | {
 3 |     /// 
 4 |     /// Defines a collection of extensions for the MapLocationDesiredAccuracy enum.
 5 |     /// 
 6 |     public static class MapLocationDesiredAccuracyExtensions
 7 |     {
 8 | #if WINDOWS_UWP
 9 |         /// 
10 |         /// Converts the Windows MapLocationDesiredAccuracy enum to the internal XPlat equivalent.
11 |         /// 
12 |         /// The Windows MapLocationDesiredAccuracy to convert.
13 |         /// Returns the equivalent XPlat MapLocationDesiredAccuracy value.
14 |         public static MapLocationDesiredAccuracy ToInternalMapLocationDesiredAccuracy(
15 |             this Windows.Services.Maps.MapLocationDesiredAccuracy accuracy)
16 |         {
17 |             switch (accuracy)
18 |             {
19 |                 case Windows.Services.Maps.MapLocationDesiredAccuracy.High:
20 |                     return MapLocationDesiredAccuracy.High;
21 |                 case Windows.Services.Maps.MapLocationDesiredAccuracy.Low:
22 |                     return MapLocationDesiredAccuracy.Low;
23 |                 default:
24 |                     throw new System.ArgumentOutOfRangeException(nameof(accuracy), accuracy, null);
25 |             }
26 |         }
27 | 
28 |         /// 
29 |         /// Converts the XPlat MapLocationDesiredAccuracy enum to the Windows equivalent.
30 |         /// 
31 |         /// The XPlat MapLocationDesiredAccuracy to convert.
32 |         /// Returns the equivalent Windows MapLocationDesiredAccuracy value.
33 |         public static Windows.Services.Maps.MapLocationDesiredAccuracy ToWindowsMapLocationDesiredAccuracy(
34 |             this MapLocationDesiredAccuracy accuracy)
35 |         {
36 |             switch (accuracy)
37 |             {
38 |                 case MapLocationDesiredAccuracy.High:
39 |                     return Windows.Services.Maps.MapLocationDesiredAccuracy.High;
40 |                 case MapLocationDesiredAccuracy.Low:
41 |                     return Windows.Services.Maps.MapLocationDesiredAccuracy.Low;
42 |                 default:
43 |                     throw new System.ArgumentOutOfRangeException(nameof(accuracy), accuracy, null);
44 |             }
45 |         }
46 | #endif
47 |     }
48 | }
49 | 


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/IMapAddress.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Services.Maps
 2 | {
 3 |     /// Represents an address.
 4 |     public interface IMapAddress
 5 |     {
 6 |         /// Gets the building name of an address.
 7 |         string BuildingName { get; }
 8 | 
 9 |         /// Gets the building floor of an address.
10 |         string BuildingFloor { get; }
11 | 
12 |         /// Gets the building room of an address.
13 |         string BuildingRoom { get; }
14 | 
15 |         /// Gets the building wing of an address.
16 |         string BuildingWing { get; }
17 | 
18 |         /// Gets the street number of an address.
19 |         string StreetNumber { get; }
20 | 
21 |         /// Gets the street of an address.
22 |         string Street { get; }
23 | 
24 |         /// Gets the neighborhood of an address.
25 |         string Neighborhood { get; }
26 | 
27 |         /// Gets the district of an address.
28 |         string District { get; }
29 | 
30 |         /// Gets the town or city of an address.
31 |         string Town { get; }
32 | 
33 |         /// Gets the region (for example, the state or province) of an address.
34 |         string Region { get; }
35 | 
36 |         /// Gets the code for the region (for example, the state or province) of an address.
37 |         string RegionCode { get; }
38 | 
39 |         /// Gets the country of an address.
40 |         string Country { get; }
41 | 
42 |         /// Gets the country code of an address.
43 |         string CountryCode { get; }
44 | 
45 |         /// Gets the postal code of an address.
46 |         string PostCode { get; }
47 | 
48 |         /// Gets the continent of an address.
49 |         string Continent { get; }
50 |     }
51 | }


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/IMapLocation.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Services.Maps
 2 | {
 3 |     using XPlat.Device.Geolocation;
 4 | 
 5 |     /// Represents a geographic location.
 6 |     public interface IMapLocation
 7 |     {
 8 |         /// Gets the coordinates of a geographic location.
 9 |         Geopoint Point { get; }
10 | 
11 |         /// Gets the display name of a geographic location.
12 |         string DisplayName { get; }
13 | 
14 |         /// Gets the description of a geographic location.
15 |         string Description { get; }
16 | 
17 |         /// Gets the address of a geographic location.
18 |         MapAddress Address { get; }
19 |     }
20 | }
21 | 


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/IMapLocationFinderResult.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Services.Maps
 2 | {
 3 |     using System.Collections.Generic;
 4 | 
 5 |     /// Returns the result of a MapLocationFinder query.
 6 |     public interface IMapLocationFinderResult
 7 |     {
 8 |         /// Gets the list of locations found by a MapLocationFinder query.
 9 |         IReadOnlyList Locations { get; }
10 | 
11 |         /// Gets the status of a MapLocationFinder query.
12 |         MapLocationFinderStatus Status { get; }
13 |     }
14 | }


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/MapLocation.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Services.Maps
 2 | {
 3 |     using XPlat.Device.Geolocation;
 4 | 
 5 |     /// Represents a geographic location.
 6 |     public class MapLocation : IMapLocation
 7 |     {
 8 | #if WINDOWS_UWP
 9 |         /// 
10 |         /// Initializes a new instance of the  class.
11 |         /// 
12 |         public MapLocation(Windows.Services.Maps.MapLocation mapLocation)
13 |         {
14 |             this.Point = mapLocation.Point;
15 |             this.DisplayName = mapLocation.DisplayName;
16 |             this.Description = mapLocation.Description;
17 |             this.Address = mapLocation.Address;
18 |         }
19 | 
20 |         public static implicit operator MapLocation(Windows.Services.Maps.MapLocation mapAddress)
21 |         {
22 |             return new MapLocation(mapAddress);
23 |         }
24 | #elif __ANDROID__
25 |         /// 
26 |         /// Initializes a new instance of the  class.
27 |         /// 
28 |         public MapLocation(Android.Locations.Address mapLocation)
29 |         {
30 |             this.Point = new Geopoint(new BasicGeoposition(mapLocation.Latitude, mapLocation.Longitude, 0));
31 |             this.DisplayName = mapLocation.FeatureName;
32 |             this.Address = mapLocation;
33 |         }
34 | 
35 |         public static implicit operator MapLocation(Android.Locations.Address mapAddress)
36 |         {
37 |             return new MapLocation(mapAddress);
38 |         }
39 | #elif __IOS__
40 |         /// 
41 |         /// Initializes a new instance of the  class.
42 |         /// 
43 |         public MapLocation(CoreLocation.CLPlacemark mapLocation)
44 |         {
45 |             this.Point = new Geopoint(new BasicGeoposition(mapLocation.Location.Coordinate.Latitude, mapLocation.Location.Coordinate.Longitude, mapLocation.Location.Altitude));
46 |             this.DisplayName = mapLocation.Name;
47 |             this.Address = mapLocation;
48 |         }
49 | 
50 |         public static implicit operator MapLocation(CoreLocation.CLPlacemark mapAddress)
51 |         {
52 |             return new MapLocation(mapAddress);
53 |         }
54 | #endif
55 | 
56 |         /// Gets the coordinates of a geographic location.
57 |         public Geopoint Point { get; internal set; }
58 | 
59 |         /// Gets the display name of a geographic location.
60 |         public string DisplayName { get; internal set; }
61 | 
62 |         /// Gets the description of a geographic location.
63 |         public string Description { get; internal set; }
64 | 
65 |         /// Gets the address of a geographic location.
66 |         public MapAddress Address { get; internal set; }
67 |     }
68 | }
69 | 


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/MapLocationDesiredAccuracy.cs:
--------------------------------------------------------------------------------
 1 | namespace XPlat.Services.Maps
 2 | {
 3 |     /// Indicates the desired accuracy to use when converting latitude and longitude coordinates to a physical location like a city or address.
 4 |     public enum MapLocationDesiredAccuracy
 5 |     {
 6 |         /// Leverage the underlying REST API call to get richer and more accurate results.
 7 |         High,
 8 | 
 9 |         /// Leverage the maps disk cache to get accurate info up to the city level.
10 |         Low,
11 |     }
12 | }


--------------------------------------------------------------------------------
/src/XPlat.Services.Maps/MapLocationFinder.Android.cs:
--------------------------------------------------------------------------------
 1 | #if __ANDROID__
 2 | namespace XPlat.Services.Maps
 3 | {
 4 |     using System;
 5 |     using System.Collections.Generic;
 6 |     using System.Linq;
 7 |     using System.Threading.Tasks;
 8 | 
 9 |     using Android.App;
10 |     using Android.Locations;
11 | 
12 |     using Java.IO;
13 |     using Java.Lang;
14 | 
15 |     using XPlat.Device.Geolocation;
16 | 
17 |     /// Provides methods to convert addresses to geographic locations (geocoding) and to convert geographic locations to addresses (reverse geocoding).
18 |     public static class MapLocationFinder
19 |     {
20 |         /// Converts a geopoint to a collection of addresses with the desired accuracy (reverse geocoding).
21 |         /// The point for which you want to get locations.
22 |         /// The desired accuracy for which you want to get locations.
23 |         /// When this method completes successfully, it returns a list of locations contained in the MapLocationFinderResult.
24 |         public static async Task FindLocationsAtAsync(Geopoint queryPoint, MapLocationDesiredAccuracy accuracy)
25 |         {
26 |             using (var geocoder = new Geocoder(Application.Context))
27 |             {
28 |                 IList
locationFindResult = null; 29 | 30 | MapLocationFinderStatus status; 31 | 32 | try 33 | { 34 | locationFindResult = await geocoder.GetFromLocationAsync(queryPoint.Position.Latitude, queryPoint.Position.Longitude, 1); 35 | status = MapLocationFinderStatus.Success; 36 | } 37 | catch (IOException) 38 | { 39 | status = MapLocationFinderStatus.UnknownError; 40 | } 41 | catch (IllegalArgumentException) 42 | { 43 | status = MapLocationFinderStatus.BadLocation; 44 | } 45 | 46 | return new MapLocationFinderResult(locationFindResult, status); 47 | } 48 | } 49 | 50 | /// Converts a geographic location to a collection of addresses (reverse geocoding). 51 | /// The point for which you want to get locations. 52 | /// When this method completes successfully, it returns a list of locations contained in the MapLocationFinderResult. 53 | public static Task FindLocationsAtAsync(Geopoint queryPoint) 54 | { 55 | return FindLocationsAtAsync(queryPoint, MapLocationDesiredAccuracy.High); 56 | } 57 | } 58 | } 59 | #endif -------------------------------------------------------------------------------- /src/XPlat.Services.Maps/MapLocationFinder.Windows.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS_UWP 2 | namespace XPlat.Services.Maps 3 | { 4 | using System; 5 | using System.Threading.Tasks; 6 | 7 | using XPlat.Device.Geolocation; 8 | using XPlat.Services.Maps.Extensions; 9 | 10 | /// Provides methods to convert addresses to geographic locations (geocoding) and to convert geographic locations to addresses (reverse geocoding). 11 | public static class MapLocationFinder 12 | { 13 | /// Converts a geopoint to a collection of addresses with the desired accuracy (reverse geocoding). 14 | /// The point for which you want to get locations. 15 | /// The desired accuracy for which you want to get locations. 16 | /// When this method completes successfully, it returns a list of locations contained in the MapLocationFinderResult. 17 | public static async Task FindLocationsAtAsync(Geopoint queryPoint, MapLocationDesiredAccuracy accuracy) 18 | { 19 | Windows.Services.Maps.MapLocationFinderResult result = await Windows.Services.Maps.MapLocationFinder.FindLocationsAtAsync(queryPoint, accuracy.ToWindowsMapLocationDesiredAccuracy()); 20 | return result; 21 | } 22 | 23 | /// Converts a geographic location to a collection of addresses (reverse geocoding). 24 | /// The point for which you want to get locations. 25 | /// When this method completes successfully, it returns a list of locations contained in the MapLocationFinderResult. 26 | public static async Task FindLocationsAtAsync(Geopoint queryPoint) 27 | { 28 | Windows.Services.Maps.MapLocationFinderResult result = await Windows.Services.Maps.MapLocationFinder.FindLocationsAtAsync(queryPoint); 29 | return result; 30 | } 31 | } 32 | } 33 | #endif -------------------------------------------------------------------------------- /src/XPlat.Services.Maps/MapLocationFinder.iOS.cs: -------------------------------------------------------------------------------- 1 | #if __IOS__ 2 | namespace XPlat.Services.Maps 3 | { 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Net.Mime; 8 | using System.Threading.Tasks; 9 | 10 | using CoreLocation; 11 | 12 | using XPlat.Device.Geolocation; 13 | 14 | /// Provides methods to convert addresses to geographic locations (geocoding) and to convert geographic locations to addresses (reverse geocoding). 15 | public static class MapLocationFinder 16 | { 17 | /// Converts a geopoint to a collection of addresses with the desired accuracy (reverse geocoding). 18 | /// The point for which you want to get locations. 19 | /// The desired accuracy for which you want to get locations. 20 | /// When this method completes successfully, it returns a list of locations contained in the MapLocationFinderResult. 21 | public static async Task FindLocationsAtAsync(Geopoint queryPoint, MapLocationDesiredAccuracy accuracy) 22 | { 23 | var geocoder = new CLGeocoder(); 24 | 25 | CLPlacemark[] locationFindResult = null; 26 | 27 | MapLocationFinderStatus status; 28 | 29 | try 30 | { 31 | locationFindResult = await geocoder.ReverseGeocodeLocationAsync( 32 | new CLLocation(queryPoint.Position.Latitude, queryPoint.Position.Longitude)); 33 | 34 | status = MapLocationFinderStatus.Success; 35 | } 36 | catch (Exception) 37 | { 38 | status = MapLocationFinderStatus.UnknownError; 39 | } 40 | 41 | return new MapLocationFinderResult(locationFindResult, status); 42 | } 43 | 44 | /// Converts a geographic location to a collection of addresses (reverse geocoding). 45 | /// The point for which you want to get locations. 46 | /// When this method completes successfully, it returns a list of locations contained in the MapLocationFinderResult. 47 | public static Task FindLocationsAtAsync(Geopoint queryPoint) 48 | { 49 | return FindLocationsAtAsync(queryPoint, MapLocationDesiredAccuracy.High); 50 | } 51 | } 52 | } 53 | #endif -------------------------------------------------------------------------------- /src/XPlat.Services.Maps/MapLocationFinderStatus.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Services.Maps 2 | { 3 | /// Returns the status of a MapLocationFinder query. This enumeration provides values for the Status property of a MapLocationFinderResult. 4 | public enum MapLocationFinderStatus 5 | { 6 | /// Query search operation was successful. Check result size before accessing results. 7 | Success, 8 | 9 | /// The query returned an unknown error. 10 | UnknownError, 11 | 12 | /// The query provided credentials that are not valid. 13 | InvalidCredentials, 14 | 15 | /// The specified point cannot be converted to a location. For example, the point is in an ocean or a desert. 16 | BadLocation, 17 | 18 | /// The query encountered an internal error. 19 | IndexFailure, 20 | 21 | /// The query encountered a network failure. 22 | NetworkFailure, 23 | 24 | /// The query is not supported. 25 | NotSupported 26 | } 27 | } -------------------------------------------------------------------------------- /src/XPlat.Services.Maps/XPlat.Services.Maps.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.Services.Maps APIs 7 | 8 | This package includes Windows.Services.Maps like APIs cross-platform such as: 9 | - MapLocationFinder for providing methods to convert addresses to geographic locations (geocoding) and to convert geographic locations to addresses (reverse geocoding). 10 | - MapAddress for representing a physical address. 11 | - MapLocation for representing a geographic location. 12 | 13 | XPlat API Maps Windows UWP iOS Android Xamarin MapLocationFinder Geolocation Geocoding 14 | XPlat.Services.Maps 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/XPlat.Storage.Pickers/FileOpenPickerFilesReceived.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Pickers 2 | { 3 | using System.Collections.Generic; 4 | 5 | internal class FileOpenPickerFilesReceived 6 | { 7 | public FileOpenPickerFilesReceived(int requestCode, IEnumerable files, bool cancel) 8 | { 9 | if (files == null) 10 | { 11 | cancel = true; 12 | } 13 | 14 | this.RequestCode = requestCode; 15 | this.Files = files; 16 | this.Cancel = cancel; 17 | } 18 | 19 | public bool Cancel { get; } 20 | 21 | public IEnumerable Files { get; } 22 | 23 | public int RequestCode { get; } 24 | } 25 | } -------------------------------------------------------------------------------- /src/XPlat.Storage.Pickers/IFileOpenPicker.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Pickers 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | /// Represents a UI element that lets the user choose and open files. 7 | public interface IFileOpenPicker 8 | { 9 | /// Gets the collection of file types that the file open picker displays. 10 | IList FileTypeFilter { get; } 11 | 12 | /// Shows the file picker so that the user can pick one file. 13 | /// When the call to this method completes successfully, it returns a StorageFile object that represents the file that the user picked. 14 | Task PickSingleFileAsync(); 15 | 16 | /// Shows the file picker so that the user can pick multiple files. (Windows Store app) 17 | /// When the call to this method completes successfully, it returns a filePickerSelectedFilesArray object that contains all the files that were picked by the user. Picked files in this array are represented by storageFile objects. 18 | Task> PickMultipleFilesAsync(); 19 | } 20 | } -------------------------------------------------------------------------------- /src/XPlat.Storage.Pickers/XPlat.Storage.Pickers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.Storage.Pickers APIs 7 | 8 | This package includes Windows.Storage like APIs cross-platform such as: 9 | - FileOpenPicker representing a UI element that lets the user choose and open files. 10 | 11 | XPlat API Storage Pickers Windows UWP iOS Android Xamarin FileOpenPicker 12 | XPlat.Storage.Pickers 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/XPlat.Storage/ApplicationDataContainer.Android.cs: -------------------------------------------------------------------------------- 1 | #if __ANDROID__ 2 | namespace XPlat.Storage 3 | { 4 | using System; 5 | 6 | using XPlat.Foundation.Collections; 7 | 8 | /// Represents a container for app settings. 9 | public class ApplicationDataContainer : IApplicationDataContainer 10 | { 11 | private readonly ApplicationDataContainerSettings settings; 12 | 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// 17 | /// The locality. 18 | /// 19 | /// 20 | /// The name. 21 | /// 22 | internal ApplicationDataContainer(ApplicationDataLocality locality, string name) 23 | { 24 | this.Locality = locality; 25 | this.Name = name; 26 | this.settings = new ApplicationDataContainerSettings(); 27 | } 28 | 29 | /// Creates or opens the specified settings container in the current settings container. 30 | public IApplicationDataContainer CreateContainer(string name, ApplicationDataCreateDisposition disposition) 31 | { 32 | throw new NotSupportedException("CreateContainer is not currently supported by Android."); 33 | } 34 | 35 | /// Deletes the specified settings container, its subcontainers, and all application settings in the hierarchy. 36 | /// The name of the settings container. 37 | public void DeleteContainer(string name) 38 | { 39 | throw new NotSupportedException("DeleteContainer is not currently supported by Android."); 40 | } 41 | 42 | /// Gets the type (local or roaming) of the app data store that is associated with the current settings container. 43 | public ApplicationDataLocality Locality { get; } 44 | 45 | /// Gets the name of the current settings container. 46 | public string Name { get; } 47 | 48 | /// Gets an object that represents the settings in this settings container. 49 | public IPropertySet Values => this.settings; 50 | } 51 | } 52 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/ApplicationDataContainer.Windows.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS_UWP 2 | namespace XPlat.Storage 3 | { 4 | using XPlat.Foundation.Collections; 5 | using XPlat.Storage.Extensions; 6 | 7 | public class ApplicationDataContainer : IApplicationDataContainer 8 | { 9 | private readonly Windows.Storage.ApplicationDataContainer container; 10 | 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | /// 15 | /// The Windows ApplicationDataContainer. 16 | /// 17 | internal ApplicationDataContainer(Windows.Storage.ApplicationDataContainer container) 18 | { 19 | this.container = container; 20 | } 21 | 22 | /// Gets the type (local or roaming) of the app data store that is associated with the current settings container. 23 | public ApplicationDataLocality Locality => this.container.Locality.ToInternalApplicationDataLocality(); 24 | 25 | /// Gets the name of the current settings container. 26 | public string Name => this.container.Name; 27 | 28 | /// Gets an object that represents the settings in this settings container. 29 | public IPropertySet Values => new ApplicationDataContainerSettings(this.container.Values); 30 | 31 | public static implicit operator ApplicationDataContainer(Windows.Storage.ApplicationDataContainer container) 32 | { 33 | return new ApplicationDataContainer(container); 34 | } 35 | 36 | public static implicit operator Windows.Storage.ApplicationDataContainer( 37 | ApplicationDataContainer container) 38 | { 39 | return container.container; 40 | } 41 | 42 | /// Creates or opens the specified settings container in the current settings container. 43 | /// The settings container. 44 | /// The name of the container. 45 | /// One of the enumeration values. 46 | public IApplicationDataContainer CreateContainer(string name, ApplicationDataCreateDisposition disposition) 47 | { 48 | return new ApplicationDataContainer( 49 | this.container.CreateContainer(name, disposition.ToWindowsApplicationDataCreateDisposition())); 50 | } 51 | 52 | /// Deletes the specified settings container, its subcontainers, and all application settings in the hierarchy. 53 | /// The name of the settings container. 54 | public void DeleteContainer(string name) 55 | { 56 | this.container.DeleteContainer(name); 57 | } 58 | } 59 | } 60 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/ApplicationDataContainer.iOS.cs: -------------------------------------------------------------------------------- 1 | #if __IOS__ 2 | namespace XPlat.Storage 3 | { 4 | using System; 5 | 6 | using XPlat.Foundation.Collections; 7 | 8 | /// Represents a container for app settings. 9 | public class ApplicationDataContainer : IApplicationDataContainer 10 | { 11 | private readonly ApplicationDataContainerSettings settings; 12 | 13 | internal ApplicationDataContainer(ApplicationDataLocality locality, string name) 14 | { 15 | this.Locality = locality; 16 | this.Name = name; 17 | this.settings = new ApplicationDataContainerSettings(locality, name); 18 | } 19 | 20 | /// Gets the type (local or roaming) of the app data store that is associated with the current settings container. 21 | public ApplicationDataLocality Locality { get; } 22 | 23 | /// Gets the name of the current settings container. 24 | public string Name { get; } 25 | 26 | /// Gets an object that represents the settings in this settings container. 27 | public IPropertySet Values => this.settings; 28 | 29 | /// Creates or opens the specified settings container in the current settings container. 30 | /// The settings container. 31 | /// The name of the container. 32 | /// One of the enumeration values. 33 | public IApplicationDataContainer CreateContainer(string name, ApplicationDataCreateDisposition disposition) 34 | { 35 | if (disposition != ApplicationDataCreateDisposition.Existing) 36 | { 37 | throw new ArgumentException( 38 | "iOS only supports ApplicationDataCreateDisposition.Existing.", 39 | nameof(disposition)); 40 | } 41 | 42 | return new ApplicationDataContainer(ApplicationDataLocality.Shared, name); 43 | } 44 | 45 | /// Deletes the specified settings container, its subcontainers, and all application settings in the hierarchy. 46 | /// The name of the settings container. 47 | public void DeleteContainer(string name) 48 | { 49 | throw new NotSupportedException("DeleteContainer is not currently supported by iOS."); 50 | } 51 | } 52 | } 53 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/ApplicationDataCreateDisposition.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | /// Specifies options for creating application data containers or returning existing containers. This enumeration is used by the ApplicationDataContainer.CreateContainer method. 4 | public enum ApplicationDataCreateDisposition 5 | { 6 | /// Always returns the specified container. Creates the container if it does not exist. 7 | Always, 8 | 9 | /// Returns the specified container only if it already exists. Raises an exception of type System.Exception if the specified container does not exist. 10 | Existing, 11 | } 12 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/ApplicationDataLocality.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | /// Specifies the type of an application data store. 4 | public enum ApplicationDataLocality 5 | { 6 | /// The data resides in the local application data store. 7 | Local, 8 | 9 | /// The data resides in the roaming application data store. 10 | Roaming, 11 | 12 | /// The data resides in the temporary application data store. 13 | Temporary, 14 | 15 | /// The data resides in the local cache for the application data store. 16 | LocalCache, 17 | Shared 18 | } 19 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/CreationCollisionOption.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | /// Specifies what to do if a file or folder with the specified name already exists in the current folder when you create a new file or folder. 4 | public enum CreationCollisionOption 5 | { 6 | /// Automatically append a number to the base of the specified name if the file or folder already exists.For example, if MyFile.txt already exists, then the new file is named MyFile (2).txt. If MyFolder already exists, then the new folder is named MyFolder (2). 7 | GenerateUniqueName, 8 | 9 | /// Replace the existing item if the file or folder already exists. 10 | ReplaceExisting, 11 | 12 | /// Raise an exception of type System.Exception if the file or folder already exists. Methods that don't explicitly pass a value from the CreationCollisionOption enumeration use the FailIfExists value as the default when you try to create, rename, copy, or move a file or folder. 13 | FailIfExists, 14 | 15 | /// Return the existing item if the file or folder already exists. 16 | OpenIfExists, 17 | } 18 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/Extensions/ApplicationDataCreateDispositionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Extensions 2 | { 3 | using System; 4 | 5 | public static class ApplicationDataCreateDispositionExtensions 6 | { 7 | #if WINDOWS_UWP 8 | public static ApplicationDataCreateDisposition ToInternalApplicationDataCreateDisposition( 9 | this Windows.Storage.ApplicationDataCreateDisposition disposition) 10 | { 11 | switch (disposition) 12 | { 13 | case Windows.Storage.ApplicationDataCreateDisposition.Always: 14 | return ApplicationDataCreateDisposition.Always; 15 | case Windows.Storage.ApplicationDataCreateDisposition.Existing: 16 | return ApplicationDataCreateDisposition.Existing; 17 | default: 18 | throw new ArgumentOutOfRangeException(nameof(disposition), disposition, null); 19 | } 20 | } 21 | 22 | public static Windows.Storage.ApplicationDataCreateDisposition ToWindowsApplicationDataCreateDisposition( 23 | this ApplicationDataCreateDisposition disposition) 24 | { 25 | switch (disposition) 26 | { 27 | case ApplicationDataCreateDisposition.Always: 28 | return Windows.Storage.ApplicationDataCreateDisposition.Always; 29 | case ApplicationDataCreateDisposition.Existing: 30 | return Windows.Storage.ApplicationDataCreateDisposition.Existing; 31 | default: 32 | throw new ArgumentOutOfRangeException(nameof(disposition), disposition, null); 33 | } 34 | } 35 | #endif 36 | } 37 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/Extensions/ApplicationDataLocalityExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Extensions 2 | { 3 | using System; 4 | 5 | public static class ApplicationDataLocalityExtensions 6 | { 7 | #if WINDOWS_UWP 8 | 9 | public static ApplicationDataLocality ToInternalApplicationDataLocality( 10 | this Windows.Storage.ApplicationDataLocality locality) 11 | { 12 | switch (locality) 13 | { 14 | case Windows.Storage.ApplicationDataLocality.Local: 15 | return ApplicationDataLocality.Local; 16 | case Windows.Storage.ApplicationDataLocality.Roaming: 17 | return ApplicationDataLocality.Roaming; 18 | case Windows.Storage.ApplicationDataLocality.Temporary: 19 | return ApplicationDataLocality.Temporary; 20 | case Windows.Storage.ApplicationDataLocality.LocalCache: 21 | return ApplicationDataLocality.LocalCache; 22 | default: 23 | throw new ArgumentOutOfRangeException(nameof(locality), locality, null); 24 | } 25 | } 26 | 27 | public static Windows.Storage.ApplicationDataLocality ToWindowsApplicationDataLocality( 28 | this ApplicationDataLocality locality) 29 | { 30 | switch (locality) 31 | { 32 | case ApplicationDataLocality.Local: 33 | return Windows.Storage.ApplicationDataLocality.Local; 34 | case ApplicationDataLocality.Shared: 35 | case ApplicationDataLocality.Roaming: 36 | return Windows.Storage.ApplicationDataLocality.Roaming; 37 | case ApplicationDataLocality.Temporary: 38 | return Windows.Storage.ApplicationDataLocality.Temporary; 39 | case ApplicationDataLocality.LocalCache: 40 | return Windows.Storage.ApplicationDataLocality.LocalCache; 41 | default: 42 | throw new ArgumentOutOfRangeException(nameof(locality), locality, null); 43 | } 44 | } 45 | #endif 46 | } 47 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/Extensions/CreationCollisionOptionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Extensions 2 | { 3 | using System; 4 | 5 | public static class CreationCollisionOptionExtensions 6 | { 7 | #if WINDOWS_UWP 8 | public static CreationCollisionOption ToInternalCreationCollisionOption( 9 | this Windows.Storage.CreationCollisionOption option) 10 | { 11 | switch (option) 12 | { 13 | case Windows.Storage.CreationCollisionOption.GenerateUniqueName: 14 | return CreationCollisionOption.GenerateUniqueName; 15 | case Windows.Storage.CreationCollisionOption.ReplaceExisting: 16 | return CreationCollisionOption.ReplaceExisting; 17 | case Windows.Storage.CreationCollisionOption.FailIfExists: 18 | return CreationCollisionOption.FailIfExists; 19 | case Windows.Storage.CreationCollisionOption.OpenIfExists: 20 | return CreationCollisionOption.OpenIfExists; 21 | default: 22 | throw new ArgumentOutOfRangeException(nameof(option), option, null); 23 | } 24 | } 25 | 26 | public static Windows.Storage.CreationCollisionOption ToWindowsCreationCollisionOption( 27 | this CreationCollisionOption option) 28 | { 29 | switch (option) 30 | { 31 | case CreationCollisionOption.GenerateUniqueName: 32 | return Windows.Storage.CreationCollisionOption.GenerateUniqueName; 33 | case CreationCollisionOption.ReplaceExisting: 34 | return Windows.Storage.CreationCollisionOption.ReplaceExisting; 35 | case CreationCollisionOption.FailIfExists: 36 | return Windows.Storage.CreationCollisionOption.FailIfExists; 37 | case CreationCollisionOption.OpenIfExists: 38 | return Windows.Storage.CreationCollisionOption.OpenIfExists; 39 | default: 40 | throw new ArgumentOutOfRangeException(nameof(option), option, null); 41 | } 42 | } 43 | #endif 44 | } 45 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/Extensions/FileAccessModeExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Extensions 2 | { 3 | using System; 4 | 5 | public static class FileAccessModeExtensions 6 | { 7 | #if WINDOWS_UWP 8 | public static FileAccessMode ToInternalFileAccessMode(this Windows.Storage.FileAccessMode mode) 9 | { 10 | switch (mode) 11 | { 12 | case Windows.Storage.FileAccessMode.Read: 13 | return FileAccessMode.Read; 14 | case Windows.Storage.FileAccessMode.ReadWrite: 15 | return FileAccessMode.ReadWrite; 16 | default: 17 | throw new ArgumentOutOfRangeException(nameof(mode), mode, null); 18 | } 19 | } 20 | 21 | public static Windows.Storage.FileAccessMode ToWindowsFileAccessMode(this FileAccessMode mode) 22 | { 23 | switch (mode) 24 | { 25 | case FileAccessMode.Read: 26 | return Windows.Storage.FileAccessMode.Read; 27 | case FileAccessMode.ReadWrite: 28 | return Windows.Storage.FileAccessMode.ReadWrite; 29 | default: 30 | throw new ArgumentOutOfRangeException(nameof(mode), mode, null); 31 | } 32 | } 33 | #endif 34 | } 35 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/Extensions/NameCollisionOptionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Extensions 2 | { 3 | using System; 4 | 5 | public static class NameCollisionOptionExtensions 6 | { 7 | #if WINDOWS_UWP 8 | public static NameCollisionOption ToInternalNameCollisionOption(this Windows.Storage.NameCollisionOption option) 9 | { 10 | switch (option) 11 | { 12 | case Windows.Storage.NameCollisionOption.GenerateUniqueName: 13 | return NameCollisionOption.GenerateUniqueName; 14 | case Windows.Storage.NameCollisionOption.ReplaceExisting: 15 | return NameCollisionOption.ReplaceExisting; 16 | case Windows.Storage.NameCollisionOption.FailIfExists: 17 | return NameCollisionOption.FailIfExists; 18 | default: 19 | throw new ArgumentOutOfRangeException(nameof(option), option, null); 20 | } 21 | } 22 | 23 | public static Windows.Storage.NameCollisionOption ToWindowsNameCollisionOption(this NameCollisionOption option) 24 | { 25 | switch (option) 26 | { 27 | case NameCollisionOption.GenerateUniqueName: 28 | return Windows.Storage.NameCollisionOption.GenerateUniqueName; 29 | case NameCollisionOption.ReplaceExisting: 30 | return Windows.Storage.NameCollisionOption.ReplaceExisting; 31 | case NameCollisionOption.FailIfExists: 32 | return Windows.Storage.NameCollisionOption.FailIfExists; 33 | default: 34 | throw new ArgumentOutOfRangeException(nameof(option), option, null); 35 | } 36 | } 37 | #endif 38 | } 39 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileAccessMode.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | /// Specifies whether to access a file in read-only mode or in read/write mode. 4 | public enum FileAccessMode 5 | { 6 | /// Access the file stream in read-only mode. Keep read-only file streams open only while your app is actively reading from the file. You can use multiple independent read-only streams to read a file. If the file is changed while you're reading it, subsequent read operations fail. 7 | Read, 8 | 9 | /// Access the file stream in read/write mode. A file supports a single stream for writing. Writing is non-transactional and occurs in place; that is, data is written immediately to the target file without using a temporary file. Use read/write mode only when you're ready to write immediately in order to avoid conflicts with other operations. 10 | ReadWrite, 11 | } 12 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System; 4 | 5 | /// Describes the attributes of a file or folder. 6 | [Flags] 7 | public enum FileAttributes 8 | { 9 | /// The item is normal. That is, the item doesn't have any of the other values in the enumeration. 10 | Normal = 0, 11 | 12 | /// The item is read-only. 13 | ReadOnly = 1, 14 | 15 | /// The item is a directory. 16 | Directory = 16, 17 | 18 | /// The item is archived. 19 | Archive = 32, 20 | 21 | /// The item is a temporary file. 22 | Temporary = 256, 23 | 24 | /// The item is locally incomplete. Windows only. 25 | LocallyIncomplete = 512, 26 | } 27 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/BasicProperties.Android.cs: -------------------------------------------------------------------------------- 1 | #if __ANDROID__ 2 | namespace XPlat.Storage.FileProperties 3 | { 4 | using System; 5 | using System.IO; 6 | using System.Linq; 7 | 8 | /// Provides access to the basic properties, like the size of the item or the date the item was last modified, of the item (like a file or folder). 9 | public class BasicProperties : IBasicProperties 10 | { 11 | private readonly string filePath; 12 | 13 | private readonly bool isFolder; 14 | 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// 19 | /// The file path. 20 | /// 21 | internal BasicProperties(string filePath) 22 | : this(filePath, false) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// 30 | /// The file path. 31 | /// 32 | /// 33 | /// Indicates whether the properties are for a folder. 34 | /// 35 | internal BasicProperties(string filePath, bool isFolder) 36 | { 37 | this.filePath = filePath; 38 | this.isFolder = isFolder; 39 | } 40 | 41 | /// Gets the timestamp of the last time the file was modified. 42 | public DateTime DateModified => this.isFolder 43 | ? Directory.GetLastWriteTime(this.filePath) 44 | : File.GetCreationTime(this.filePath); 45 | 46 | /// Gets the size of the file. 47 | public ulong Size 48 | { 49 | get 50 | { 51 | if (this.isFolder) 52 | { 53 | string[] files = Directory.GetFiles(this.filePath, "*.*"); 54 | long length = files.Select(file => new FileInfo(file)).Select(fileInfo => fileInfo.Length).Sum(); 55 | return (ulong)length; 56 | } 57 | 58 | FileInfo info = new FileInfo(this.filePath); 59 | return (ulong)info.Length; 60 | } 61 | } 62 | } 63 | } 64 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/BasicProperties.Windows.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS_UWP 2 | namespace XPlat.Storage.FileProperties 3 | { 4 | using System; 5 | 6 | /// Provides access to the basic properties, like the size of the item or the date the item was last modified, of the item (like a file or folder). 7 | public class BasicProperties : IBasicProperties 8 | { 9 | public BasicProperties(DateTime dateModified, ulong size) 10 | { 11 | this.DateModified = dateModified; 12 | this.Size = size; 13 | } 14 | 15 | public BasicProperties(Windows.Storage.FileProperties.BasicProperties properties) 16 | { 17 | this.DateModified = properties.DateModified.DateTime; 18 | this.Size = properties.Size; 19 | } 20 | 21 | /// Gets the timestamp of the last time the file was modified. 22 | public DateTime DateModified { get; } 23 | 24 | /// Gets the size of the file. 25 | public ulong Size { get; } 26 | 27 | public static implicit operator BasicProperties(Windows.Storage.FileProperties.BasicProperties properties) 28 | { 29 | return new BasicProperties(properties); 30 | } 31 | } 32 | } 33 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/BasicProperties.iOS.cs: -------------------------------------------------------------------------------- 1 | #if __IOS__ 2 | namespace XPlat.Storage.FileProperties 3 | { 4 | using System; 5 | using System.IO; 6 | using System.Linq; 7 | 8 | /// Provides access to the basic properties, like the size of the item or the date the item was last modified, of the item (like a file or folder). 9 | public class BasicProperties : IBasicProperties 10 | { 11 | private readonly string filePath; 12 | 13 | private readonly bool isFolder; 14 | 15 | internal BasicProperties(string filePath) 16 | : this(filePath, false) 17 | { 18 | } 19 | 20 | internal BasicProperties(string filePath, bool isFolder) 21 | { 22 | this.filePath = filePath; 23 | this.isFolder = isFolder; 24 | } 25 | 26 | /// Gets the timestamp of the last time the file was modified. 27 | public DateTime DateModified => 28 | this.isFolder ? Directory.GetLastWriteTime(this.filePath) : File.GetCreationTime(this.filePath); 29 | 30 | /// Gets the size of the file. 31 | public ulong Size 32 | { 33 | get 34 | { 35 | if (this.isFolder) 36 | { 37 | string[] files = Directory.GetFiles(this.filePath, "*.*"); 38 | long length = files.Select(file => new FileInfo(file)).Select(fileInfo => fileInfo.Length).Sum(); 39 | return (ulong) length; 40 | } 41 | 42 | FileInfo info = new FileInfo(this.filePath); 43 | return (ulong) info.Length; 44 | } 45 | } 46 | } 47 | } 48 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/IBasicProperties.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | using System; 4 | 5 | /// Provides access to the basic properties, like the size of the item or the date the item was last modified, of the item (like a file or folder). 6 | public interface IBasicProperties 7 | { 8 | /// Gets the timestamp of the last time the file was modified. 9 | DateTime DateModified { get; } 10 | 11 | /// Gets the size of the file. 12 | ulong Size { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/IImageProperties.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | using System.Collections.Generic; 4 | 5 | /// Provides access to the image-related properties of an item (like a file or folder). 6 | public interface IImageProperties 7 | { 8 | /// Gets the title of the image. 9 | string Title { get; } 10 | 11 | /// Gets the rating associated with an image file. 12 | int Rating { get; } 13 | 14 | /// Gets the date when the image was taken. 15 | string DateTaken { get; } 16 | 17 | /// Gets the model of the camera that took the photo. 18 | string CameraModel { get; } 19 | 20 | /// Gets the manufacturer of the camera that took the photo. 21 | string CameraManufacturer { get; } 22 | 23 | /// Gets the latitude coordinate where the photo was taken. 24 | double? Latitude { get; } 25 | 26 | /// Gets the longitude coordinate where the photo was taken. 27 | double? Longitude { get; } 28 | 29 | /// Gets the Exchangeable Image File (EXIF) orientation flag of the photo. 30 | PhotoOrientation Orientation { get; } 31 | 32 | /// Gets the names of people who are tagged in the photo. 33 | IReadOnlyList PeopleNames { get; } 34 | 35 | /// Gets the height of the image. 36 | int Height { get; } 37 | 38 | /// Gets the collection of keywords associated with the image. 39 | IList Keywords { get; } 40 | 41 | /// Gets the width of the image. 42 | int Width { get; } 43 | } 44 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/IMusicProperties.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// Provides access to the music-related properties of an item (like a file or folder). 7 | public interface IMusicProperties 8 | { 9 | /// Gets the rating associated with a music file. 10 | int Rating { get; } 11 | 12 | /// Gets the name of the album artist of the song. 13 | string AlbumArtist { get; } 14 | 15 | /// Gets the artists that contributed to the song. 16 | string Artist { get; } 17 | 18 | /// Gets the name of the album that contains the song. 19 | string Album { get; } 20 | 21 | /// Gets the publisher of the song. 22 | string Publisher { get; } 23 | 24 | /// Gets the year that the song was released. 25 | int Year { get; } 26 | 27 | /// Gets the track number of the song on the song's album. 28 | int TrackNumber { get; } 29 | 30 | /// Gets the title of the song 31 | string Title { get; } 32 | 33 | /// Gets the subtitle of the song. 34 | string Subtitle { get; } 35 | 36 | /// Gets the producers of the song. 37 | IList Producers { get; } 38 | 39 | /// Gets the composers of the song. 40 | IList Composers { get; } 41 | 42 | /// Gets the conductors of the song. 43 | IList Conductors { get; } 44 | 45 | /// Gets the duration of the song in milliseconds. 46 | TimeSpan Duration { get; } 47 | 48 | /// Gets the songwriters. 49 | IList Writers { get; } 50 | 51 | /// Gets the names of music genres that the song belongs to. 52 | IList Genre { get; } 53 | 54 | /// Gets the bit rate of the song file. 55 | int Bitrate { get; } 56 | } 57 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/IStorageItemContentProperties.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | /// Provides access to the content-related properties of an item (like a file or folder). 7 | public interface IStorageItemContentProperties 8 | { 9 | /// Retrieves the music properties of the item (like a file of folder). 10 | /// When this method completes successfully, it returns a musicProperties object. 11 | Task GetMusicPropertiesAsync(); 12 | 13 | /// Retrieves the video properties of the item (like a file of folder). 14 | /// When this method completes successfully, it returns a videoProperties object. 15 | Task GetVideoPropertiesAsync(); 16 | 17 | /// Retrieves the image properties of the item (like a file of folder). 18 | /// When this method completes successfully, it returns an imageProperties object. 19 | Task GetImagePropertiesAsync(); 20 | 21 | Task> RetrievePropertiesAsync(IEnumerable propertiesToRetrieve); 22 | } 23 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/IVideoProperties.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// Provides access to the video-related properties of an item (like a file or folder). 7 | public interface IVideoProperties 8 | { 9 | /// Gets the year that the video was shot or released. 10 | int Year { get; } 11 | 12 | /// Gets the title of the video. 13 | string Title { get; } 14 | 15 | /// Gets the subtitle of the video. 16 | string Subtitle { get; } 17 | 18 | /// Gets the publisher of the video. 19 | string Publisher { get; } 20 | 21 | /// Gets the rating associated with a video file. 22 | int Rating { get; } 23 | 24 | /// Gets the latitude coordinate where the video was shot. 25 | double? Latitude { get; } 26 | 27 | /// Gets a VideoOrientation value that indicates how the video should be rotated to display it correctly. 28 | VideoOrientation Orientation { get; } 29 | 30 | /// Gets the duration of the video. 31 | TimeSpan Duration { get; } 32 | 33 | /// Gets the sum audio and video bitrate of the video. 34 | int Bitrate { get; } 35 | 36 | /// Gets the producers of the video. 37 | IList Producers { get; } 38 | 39 | /// Gets the directors of the video. 40 | IList Directors { get; } 41 | 42 | /// Gets the height of the video. 43 | int Height { get; } 44 | 45 | /// Gets the width of the video. 46 | int Width { get; } 47 | 48 | /// Gets the longitude coordinate where the video was shot. 49 | double? Longitude { get; } 50 | 51 | /// Gets the script writers for the video. 52 | IList Writers { get; } 53 | 54 | /// Gets the collection of keywords associated with the video. 55 | IList Keywords { get; } 56 | } 57 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/PhotoOrientation.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | /// Indicates the Exchangeable Image File (EXIF) orientation flag of the photo. This flag describes how to rotate the photo to display it correctly. 4 | public enum PhotoOrientation 5 | { 6 | /// An orientation flag is not set. 7 | Unspecified, 8 | 9 | /// No rotation needed. The photo can be displayed using its current orientation. 10 | Normal, 11 | 12 | /// Flip the photo horizontally. 13 | FlipHorizontal, 14 | 15 | /// Rotate the photo 180 degrees. 16 | Rotate180, 17 | 18 | /// Flip the photo vertically. 19 | FlipVertical, 20 | 21 | /// Rotate the photo counter-clockwise 90 degrees and then flip it horizontally. 22 | Transpose, 23 | 24 | /// Rotate the photo counter-clockwise 270 degrees. 25 | Rotate270, 26 | 27 | /// Rotate the photo counter-clockwise 270 degrees and then flip it horizontally. 28 | Transverse, 29 | 30 | /// Rotate the photo counter-clockwise 90 degrees. 31 | Rotate90, 32 | } 33 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/FileProperties/VideoOrientation.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.FileProperties 2 | { 3 | /// Indicates how to rotate the video to display it correctly. 4 | public enum VideoOrientation 5 | { 6 | /// No rotation needed. The video can be displayed using its current orientation. 7 | Normal = 0, 8 | 9 | /// Rotate the video 90 degrees. 10 | Rotate90 = 90, 11 | 12 | /// Rotate the video counter-clockwise 180 degrees. 13 | Rotate180 = 180, 14 | 15 | /// Rotate the video counter-clockwise 270 degrees. 16 | Rotate270 = 270, 17 | } 18 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IApplicationData.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// Provides access to the application data store. 6 | public interface IApplicationData 7 | { 8 | /// Removes all application data from the local, roaming, and temporary app data stores. 9 | /// An object that is used to manage the asynchronous clear operation. 10 | Task ClearAsync(); 11 | 12 | /// Removes all application data from the specified app data store. 13 | /// An object that is used to manage the asynchronous clear operation. 14 | /// One of the enumeration values. 15 | Task ClearAsync(ApplicationDataLocality locality); 16 | 17 | /// Gets the root folder in the local app data store. 18 | IStorageFolder LocalFolder { get; } 19 | 20 | /// Gets the application settings container in the local app data store. 21 | IApplicationDataContainer LocalSettings { get; } 22 | 23 | /// Gets the root folder in the roaming app data store. 24 | IStorageFolder RoamingFolder { get; } 25 | 26 | /// Gets the application settings container in the roaming app data store. 27 | IApplicationDataContainer RoamingSettings { get; } 28 | 29 | /// Gets the root folder in the temporary app data store. 30 | IStorageFolder TemporaryFolder { get; } 31 | } 32 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IApplicationDataContainer.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using XPlat.Foundation.Collections; 4 | 5 | /// Represents a container for app settings. 6 | public interface IApplicationDataContainer 7 | { 8 | /// Gets the type (local or roaming) of the app data store that is associated with the current settings container. 9 | ApplicationDataLocality Locality { get; } 10 | 11 | /// Gets the name of the current settings container. 12 | string Name { get; } 13 | 14 | /// Gets an object that represents the settings in this settings container. 15 | IPropertySet Values { get; } 16 | 17 | /// Creates or opens the specified settings container in the current settings container. 18 | /// The settings container. 19 | /// The name of the container. 20 | /// One of the enumeration values. 21 | IApplicationDataContainer CreateContainer(string name, ApplicationDataCreateDisposition disposition); 22 | 23 | /// Deletes the specified settings container, its subcontainers, and all application settings in the hierarchy. 24 | /// The name of the settings container. 25 | void DeleteContainer(string name); 26 | } 27 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IApplicationDataExtras.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// Provides additional extra methods for accessing data from the application data store. 6 | public interface IApplicationDataExtras 7 | { 8 | /// 9 | /// Retrieves a by the given . 10 | /// 11 | /// The path to the file. 12 | /// The . 13 | Task GetFileFromPathAsync(string path); 14 | } 15 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IStorageFileExtras.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System.IO; 4 | using System.Threading.Tasks; 5 | 6 | /// Provides additional extra methods for manipulating data for storage files. 7 | public interface IStorageFileExtras 8 | { 9 | /// 10 | /// Opens a stream over the current file for reading file contents. 11 | /// 12 | /// 13 | /// When this method completes, it returns the stream. 14 | /// 15 | Task OpenReadAsync(); 16 | 17 | /// 18 | /// Writes a string to the current file. 19 | /// 20 | /// 21 | /// The text to write out. 22 | /// 23 | /// 24 | /// An object that is used to manage the asynchronous operation. 25 | /// 26 | Task WriteTextAsync(string text); 27 | 28 | /// 29 | /// Reads the current file as a string. 30 | /// 31 | /// 32 | /// When this method completes, it returns the file's content as a string. 33 | /// 34 | Task ReadTextAsync(); 35 | 36 | /// 37 | /// Writes a byte array to the current file. 38 | /// 39 | /// 40 | /// The byte array to write out. 41 | /// 42 | /// 43 | /// An object that is used to manage the asynchronous operation. 44 | /// 45 | Task WriteBytesAsync(byte[] bytes); 46 | 47 | /// 48 | /// Reads the current file as a byte array. 49 | /// 50 | /// 51 | /// When this method completes, it returns the file's content as a byte array. 52 | /// 53 | Task ReadBytesAsync(); 54 | } 55 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IStorageFolder2.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// Manipulates folders and their contents, and provides information about them. 6 | public interface IStorageFolder2 7 | { 8 | /// Try to get a single file or sub-folder from the current folder by using the name of the item. 9 | /// When this method completes successfully, it returns the file or folder (type IStorageItem). 10 | /// The name (or path relative to the current folder) of the file or sub-folder to try to retrieve. 11 | Task TryGetItemAsync(string name); 12 | } 13 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IStorageFolderExtras.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// Provides additional extra methods for getting items from within storage folders. 6 | public interface IStorageFolderExtras 7 | { 8 | /// Gets the specified file from the current folder. 9 | /// The name of the file to retrieve. If the file does not exist in the current folder, the createIfNotExists flag will allow the API to create the file if set to true. 10 | /// A value indicating whether to create the file if it does not exist. 11 | /// When this method completes successfully, it returns an IStorageFile that represents the file. 12 | Task GetFileAsync(string name, bool createIfNotExists); 13 | 14 | /// Gets the specified folder from the current folder. 15 | /// The name of the child folder to retrieve. If the child folder does not exist in the current folder, the createIfNotExists flag will allow the API to create the folder if set to true. 16 | /// A value indicating whether to create the child folder if it does not exist. 17 | /// When this method completes successfully, it returns an IStorageFolder that represents the child folder. 18 | Task GetFolderAsync(string name, bool createIfNotExists); 19 | 20 | /// Clears the folder of it's contents. 21 | /// An object that is used to manage the asynchronous clear operation. 22 | Task ClearAsync(); 23 | } 24 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IStorageItem2.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// Manipulates storage items (files and folders) and their contents, and provides information about them. 6 | public interface IStorageItem2 : IStorageItem 7 | { 8 | /// Gets the parent folder of the current storage item. 9 | /// When this method completes, it returns the parent folder as a StorageFolder. 10 | Task GetParentAsync(); 11 | 12 | /// Indicates whether the current item is the same as the specified item. 13 | /// Returns true if the current storage item is the same as the specified storage item; otherwise false. 14 | /// The IStorageItem object that represents a storage item to compare against. 15 | bool IsEqual(IStorageItem item); 16 | } 17 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/IStorageItemProperties.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using XPlat.Storage.FileProperties; 4 | 5 | /// Provides access to common and content properties on items (like files and folders). 6 | public interface IStorageItemProperties 7 | { 8 | /// Gets the user-friendly name of the item. 9 | string DisplayName { get; } 10 | 11 | /// Gets an object that provides access to the content-related properties of the item. 12 | IStorageItemContentProperties Properties { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/KnownFolders.Android.cs: -------------------------------------------------------------------------------- 1 | #if __ANDROID__ 2 | namespace XPlat.Storage 3 | { 4 | using System.Threading.Tasks; 5 | 6 | using Android.OS; 7 | 8 | /// Provides access to common locations that contain user content. 9 | public static class KnownFolders 10 | { 11 | /// Gets the Camera Roll folder. 12 | public static IStorageFolder CameraRoll 13 | { 14 | get 15 | { 16 | Task cameraRoll = StorageFolder.GetFolderFromPathAsync( 17 | Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDcim).AbsolutePath); 18 | cameraRoll.Wait(); 19 | return cameraRoll.Result; 20 | } 21 | } 22 | 23 | /// Gets the Music library. 24 | public static IStorageFolder MusicLibrary 25 | { 26 | get 27 | { 28 | Task musicLibrary = StorageFolder.GetFolderFromPathAsync( 29 | System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyMusic)); 30 | musicLibrary.Wait(); 31 | return musicLibrary.Result; 32 | } 33 | } 34 | 35 | /// Gets the Pictures library. 36 | public static IStorageFolder PicturesLibrary 37 | { 38 | get 39 | { 40 | Task picturesLibrary = StorageFolder.GetFolderFromPathAsync( 41 | System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures)); 42 | picturesLibrary.Wait(); 43 | return picturesLibrary.Result; 44 | } 45 | } 46 | 47 | /// Gets the Videos library. 48 | public static IStorageFolder VideosLibrary 49 | { 50 | get 51 | { 52 | Task videosLibrary = StorageFolder.GetFolderFromPathAsync( 53 | System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos)); 54 | videosLibrary.Wait(); 55 | return videosLibrary.Result; 56 | } 57 | } 58 | 59 | /// Gets the Documents library. The Documents library is not intended for general use. 60 | public static IStorageFolder DocumentsLibrary 61 | { 62 | get 63 | { 64 | Task documentsLibrary = StorageFolder.GetFolderFromPathAsync( 65 | System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)); 66 | documentsLibrary.Wait(); 67 | return documentsLibrary.Result; 68 | } 69 | } 70 | } 71 | } 72 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/KnownFolders.Windows.cs: -------------------------------------------------------------------------------- 1 | #if WINDOWS_UWP 2 | namespace XPlat.Storage 3 | { 4 | /// Provides access to common locations that contain user content. 5 | public static class KnownFolders 6 | { 7 | /// Gets the Camera Roll folder. 8 | public static IStorageFolder CameraRoll => new StorageFolder(Windows.Storage.KnownFolders.CameraRoll); 9 | 10 | /// Gets the play lists folder. 11 | public static IStorageFolder Playlists => new StorageFolder(Windows.Storage.KnownFolders.Playlists); 12 | 13 | /// Gets the Saved Pictures folder. 14 | public static IStorageFolder SavedPictures => new StorageFolder(Windows.Storage.KnownFolders.SavedPictures); 15 | 16 | /// Gets the Documents library. The Documents library is not intended for general use. 17 | public static IStorageFolder DocumentsLibrary => new StorageFolder( 18 | Windows.Storage.KnownFolders.DocumentsLibrary); 19 | 20 | /// Gets the HomeGroup folder. 21 | public static IStorageFolder HomeGroup => new StorageFolder(Windows.Storage.KnownFolders.HomeGroup); 22 | 23 | /// Gets the folder of media server (Digital Living Network Alliance (DLNA)) devices. 24 | public static IStorageFolder MediaServerDevices => new StorageFolder( 25 | Windows.Storage.KnownFolders.MediaServerDevices); 26 | 27 | /// Gets the Music library. 28 | public static IStorageFolder MusicLibrary => new StorageFolder(Windows.Storage.KnownFolders.MusicLibrary); 29 | 30 | /// Gets the Pictures library. 31 | public static IStorageFolder PicturesLibrary => new StorageFolder(Windows.Storage.KnownFolders.PicturesLibrary); 32 | 33 | /// Gets the removable devices folder. 34 | public static IStorageFolder RemovableDevices => new StorageFolder( 35 | Windows.Storage.KnownFolders.RemovableDevices); 36 | 37 | /// Gets the Videos library. 38 | public static IStorageFolder VideosLibrary => new StorageFolder(Windows.Storage.KnownFolders.VideosLibrary); 39 | 40 | /// Gets the Objects 3D folder. 41 | public static IStorageFolder Objects3D => new StorageFolder(Windows.Storage.KnownFolders.Objects3D); 42 | 43 | /// Gets the recorded calls folder. 44 | public static IStorageFolder RecordedCalls => new StorageFolder(Windows.Storage.KnownFolders.RecordedCalls); 45 | 46 | /// Gets the App Captures folder. 47 | public static IStorageFolder AppCaptures => new StorageFolder(Windows.Storage.KnownFolders.AppCaptures); 48 | } 49 | } 50 | #endif -------------------------------------------------------------------------------- /src/XPlat.Storage/NameCollisionOption.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | /// Specifies what to do if a file or folder with the specified name already exists in the current folder when you copy, move, or rename a file or folder. 4 | public enum NameCollisionOption 5 | { 6 | /// Automatically append a number to the base of the specified name if the file or folder already exists.For example, if MyFile.txt already exists, then the new file is named MyFile (2).txt. If MyFolder already exists, then the new folder is named MyFolder (2). 7 | GenerateUniqueName, 8 | 9 | /// Replace the existing item if the file or folder already exists. 10 | ReplaceExisting, 11 | 12 | /// Raise an exception of type System.Exception if the file or folder already exists.Methods that don't explicitly pass a value from the NameCollisionOption enumeration use the FailIfExists value as the default when you try to create, rename, copy, or move a file or folder. 13 | FailIfExists, 14 | } 15 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/Search/IStorageFolderQueryOperations.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage.Search 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | /// Provides methods to create search queries and retrieve files from a folder. This interface is implemented by StorageFolder objects, which can represent file system folders, libraries, or virtual folders that are automatically generated when queries are created using group-based CommonFolderQuery values like GroupByAlbum. 7 | public interface IStorageFolderQueryOperations 8 | { 9 | /// Retrieves a list items like files, folders, or file groups, in a specified range (shallow enumeration). 10 | /// When this method completes successfully, it returns a list (type IVectorView) of items. Each item is the IStorageItem type and represents a file, folder, or file group. In this list, files are represented by StorageFile objects, and folders or file groups are represented by StorageFolder objects. 11 | /// The zero-based index of the first item in the range. This parameter defaults to 0. 12 | /// The maximum number of items to retrieve. Use -1 to retrieve all items. 13 | Task> GetItemsAsync(int startIndex, int maxItemsToRetrieve); 14 | } 15 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/StorageFileIOException.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System; 4 | 5 | public sealed class StorageFileIOException : StorageItemException 6 | { 7 | public StorageFileIOException(string storageItemName, string message) 8 | : base(storageItemName, message) 9 | { 10 | } 11 | 12 | public StorageFileIOException(string storageItemName, string message, Exception innerException) 13 | : base(storageItemName, message, innerException) 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/StorageItemCreationException.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System; 4 | 5 | public sealed class StorageItemCreationException : StorageItemException 6 | { 7 | public StorageItemCreationException(string storageItemName, string message) 8 | : base(storageItemName, message) 9 | { 10 | } 11 | 12 | public StorageItemCreationException(string storageItemName, string message, Exception innerException) 13 | : base(storageItemName, message, innerException) 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/StorageItemException.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System; 4 | 5 | public class StorageItemException : Exception 6 | { 7 | public StorageItemException(string storageItemName, string message) 8 | : base(message) 9 | { 10 | this.StorageItemName = storageItemName; 11 | } 12 | 13 | public StorageItemException(string storageItemName, string message, Exception innerException) 14 | : base(message, innerException) 15 | { 16 | this.StorageItemName = storageItemName; 17 | } 18 | 19 | public string StorageItemName { get; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/StorageItemNotFoundException.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System; 4 | 5 | public sealed class StorageItemNotFoundException : StorageItemException 6 | { 7 | public StorageItemNotFoundException(string storageItemName, string message) 8 | : base(storageItemName, message) 9 | { 10 | } 11 | 12 | public StorageItemNotFoundException(string storageItemName, string message, Exception innerException) 13 | : base(storageItemName, message, innerException) 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/StorageItemTypes.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.Storage 2 | { 3 | using System; 4 | 5 | /// Describes whether an item that implements the IStorageItem interface is a file or a folder. 6 | [Flags] 7 | public enum StorageItemTypes 8 | { 9 | /// A storage item that is neither a file nor a folder. 10 | None = 0, 11 | 12 | /// A file that is represented as a StorageFile instance. 13 | File = 1, 14 | 15 | /// A folder that is represented as a StorageFolder instance. 16 | Folder = 2, 17 | } 18 | } -------------------------------------------------------------------------------- /src/XPlat.Storage/XPlat.Storage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.Storage APIs 7 | 8 | This package includes Windows.Storage like APIs cross-platform such as: 9 | - ApplicationData for providing access to the application data store. 10 | - KnownFolders for providing access to common folder locations that contain user content. 11 | - StorageFile for providing information about a file and its contents, and ways to manipulate them. 12 | - StorageFolder for manipulating folders and their contents, and provides information about them. 13 | - ImageProperties for providing access to the image-related properties of an item (like a file or folder). 14 | - MusicProperties for providing access to the music-related properties of an item (like a file or folder). 15 | - VideoProperties for providing access to the video-related properties of an item (like a file or folder). 16 | 17 | XPlat API Storage Windows UWP iOS Android Xamarin StorageFile StorageFolder ApplicationData 18 | XPlat.Storage 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/XPlat.UI.Controls/Orientation.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Controls 2 | { 3 | /// Defines constants that specify the different orientations that a control or layout can have. 4 | public enum Orientation 5 | { 6 | /// The control or layout should be vertically oriented. 7 | Vertical, 8 | 9 | /// The control or layout should be horizontally oriented. 10 | Horizontal, 11 | } 12 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Controls/XPlat.UI.Controls.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.UI.Xaml.Controls APIs 7 | 8 | This package includes Windows.UI.Xaml.Controls like APIs cross-platform such as: 9 | - Orientation for providing constants that specify the different orientations that a control or layout can have. 10 | 11 | XPlat API UI XAML Controls Windows UWP iOS Android Xamarin Orientation 12 | XPlat.UI.Controls 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/XPlat.UI.Core/CoreDispatcherPriority.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Core 2 | { 3 | /// Defines the priority for window event dispatches. 4 | public enum CoreDispatcherPriority 5 | { 6 | /// Low priority. Delegates are processed if there are no higher priority events pending in the queue. 7 | Low = -1, 8 | 9 | /// Normal priority. Delegates are processed in the order they are scheduled. 10 | Normal = 0, 11 | 12 | /// High priority. Delegates are invoked immediately for all synchronous requests. Asynchronous requests are queued and processed before any other request type.Do not use this priority level in your app. It is reserved for system events. Using this priority can lead to the starvation of other messages, including system events. 13 | High = 1, 14 | } 15 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Core/DispatchedHandler.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Core 2 | { 3 | /// Represents the method that handles UI thread dispatch events. 4 | public delegate void DispatchedHandler(); 5 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Core/Extensions/CoreDispatcherPriorityExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XPlat.UI.Core.Extensions 4 | { 5 | public static class CoreDispatcherPriorityExtensions 6 | { 7 | #if WINDOWS_UWP 8 | public static CoreDispatcherPriority ToInternalCoreDispatcherPriority( 9 | this Windows.UI.Core.CoreDispatcherPriority priority) 10 | { 11 | switch (priority) 12 | { 13 | case Windows.UI.Core.CoreDispatcherPriority.Idle: 14 | case Windows.UI.Core.CoreDispatcherPriority.Low: 15 | return CoreDispatcherPriority.Low; 16 | case Windows.UI.Core.CoreDispatcherPriority.Normal: 17 | return CoreDispatcherPriority.Normal; 18 | case Windows.UI.Core.CoreDispatcherPriority.High: 19 | return CoreDispatcherPriority.High; 20 | default: 21 | throw new ArgumentOutOfRangeException(nameof(priority), priority, null); 22 | } 23 | } 24 | 25 | public static Windows.UI.Core.CoreDispatcherPriority ToWindowsCoreDispatcherPriority( 26 | this CoreDispatcherPriority priority) 27 | { 28 | switch (priority) 29 | { 30 | case CoreDispatcherPriority.Low: 31 | return Windows.UI.Core.CoreDispatcherPriority.Low; 32 | case CoreDispatcherPriority.Normal: 33 | return Windows.UI.Core.CoreDispatcherPriority.Normal; 34 | case CoreDispatcherPriority.High: 35 | return Windows.UI.Core.CoreDispatcherPriority.High; 36 | default: 37 | throw new ArgumentOutOfRangeException(nameof(priority), priority, null); 38 | } 39 | } 40 | #endif 41 | } 42 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Core/ICoreDispatcher.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Core 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// Provides the core event message dispatcher. Instances of this type are responsible for processing messages and dispatching the events to the UI thread. 6 | public interface ICoreDispatcher 7 | { 8 | /// Schedules the provided callback on the UI thread from a worker thread without waiting for a result. 9 | /// The callback on which the dispatcher returns when the event is dispatched. 10 | void Run(DispatchedHandler agileCallback); 11 | 12 | /// Schedules the provided callback on the UI thread from a worker thread without waiting for a result. 13 | /// Specifies the priority for event dispatch. 14 | /// The callback on which the dispatcher returns when the event is dispatched. 15 | void Run(CoreDispatcherPriority priority, DispatchedHandler agileCallback); 16 | 17 | /// Schedules the provided callback on the UI thread from a worker thread, and returns the results asynchronously. 18 | /// The object that provides handlers for the completed async event dispatch. 19 | /// The callback on which the dispatcher returns when the event is dispatched. 20 | Task RunAsync(DispatchedHandler agileCallback); 21 | 22 | /// Schedules the provided callback on the UI thread from a worker thread, and returns the results asynchronously. 23 | /// The object that provides handlers for the completed async event dispatch. 24 | /// Specifies the priority for event dispatch. 25 | /// The callback on which the dispatcher returns when the event is dispatched. 26 | Task RunAsync(CoreDispatcherPriority priority, DispatchedHandler agileCallback); 27 | } 28 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Core/XPlat.UI.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.UI.Core APIs 7 | 8 | This package includes Windows.UI.Core like APIs cross-platform such as: 9 | - CoreDispatcher for providing the core event message dispatcher. Instances of this type are responsible for processing messages and dispatching the events to the UI thread. 10 | 11 | XPlat API UI Core Windows UWP iOS Android Xamarin CoreDispatcher 12 | XPlat.UI.Core 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/XPlat.UI.Popups/Extensions/UICommandExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Popups.Extensions 2 | { 3 | public static class UICommandExtensions 4 | { 5 | #if WINDOWS_UWP 6 | /// 7 | /// Converts the Windows GeolocationAccessStatus enum to the internal XPlat equivalent. 8 | /// 9 | /// The Windows GeolocationAccessStatus to convert. 10 | /// Returns the equivalent XPlat GeolocationAccessStatus value. 11 | public static IUICommand ToInternalIUICommand( 12 | this Windows.UI.Popups.IUICommand windowsCommand) 13 | { 14 | return new UICommand(windowsCommand); 15 | } 16 | 17 | /// 18 | /// Converts the XPlat GeolocationAccessStatus enum to the Windows equivalent. 19 | /// 20 | /// The XPlat GeolocationAccessStatus to convert. 21 | /// Returns the equivalent Windows GeolocationAccessStatus value. 22 | public static Windows.UI.Popups.IUICommand ToWindowsIUICommand( 23 | this IUICommand internalCommand) 24 | { 25 | Windows.UI.Popups.UICommand windowsCommand = new Windows.UI.Popups.UICommand(); 26 | 27 | if (internalCommand != null) 28 | { 29 | windowsCommand.Id = internalCommand.Id; 30 | windowsCommand.Label = internalCommand.Label; 31 | windowsCommand.Invoked += command => { internalCommand.Invoked?.Invoke(internalCommand); }; 32 | } 33 | 34 | return windowsCommand; 35 | } 36 | #endif 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/XPlat.UI.Popups/IMessageDialog.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Popups 2 | { 3 | using System.Collections.Generic; 4 | using System.Threading.Tasks; 5 | 6 | /// Represents a dialog for showing messages to the user. 7 | public interface IMessageDialog 8 | { 9 | /// Gets or sets the title to display on the dialog, if any. 10 | string Title { get; set; } 11 | 12 | /// Gets an array of commands that appear in the command bar of the message dialog. These commands makes the dialog actionable. 13 | IList Commands { get; } 14 | 15 | /// Gets or sets the index of the command you want to use as the default. This is the command that fires by default when users perform positive actions such as accept. 16 | uint DefaultCommandIndex { get; set; } 17 | 18 | /// Gets or sets the index of the command you want to use as the cancel command. This is the command that fires when users perform negative actions such as cancel. 19 | uint CancelCommandIndex { get; set; } 20 | 21 | /// Gets or sets the message to be displayed to the user. 22 | string Content { get; set; } 23 | 24 | /// Begins an asynchronous operation showing a dialog. 25 | /// An object that represents the asynchronous operation. 26 | Task ShowAsync(); 27 | } 28 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Popups/IUICommand.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Popups 2 | { 3 | /// Represents a command in a context menu or message dialog box. 4 | public interface IUICommand 5 | { 6 | /// Gets or sets the label for the command. 7 | string Label { get; set; } 8 | 9 | /// Gets or sets the handler for the event that is fired when the user invokes the command. 10 | UICommandInvokedHandler Invoked { get; set; } 11 | 12 | /// Gets or sets the identifier of the command. 13 | object Id { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Popups/UICommandInvokedHandler.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI.Popups 2 | { 3 | /// Represents a callback function that handles the event that is fired when the user invokes a context menu command. 4 | /// Represents the invoked command. 5 | public delegate void UICommandInvokedHandler(IUICommand command); 6 | } -------------------------------------------------------------------------------- /src/XPlat.UI.Popups/XPlat.UI.Popups.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.UI.Popups APIs 7 | 8 | This package includes Windows.Storage like APIs cross-platform such as: 9 | - MessageDialog for representing a dialog for showing messages to the user. 10 | - UICommand for providing a command in a context menu. 11 | 12 | XPlat API UI Popups Windows UWP iOS Android Xamarin MessageDialog UICommand 13 | XPlat.UI.Popups 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/XPlat.UI/ColorHelper.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI 2 | { 3 | /// Provides static helper methods for processing Color values. C# and Microsoft Visual Basic code should use methods of Color instead. 4 | public class ColorHelper 5 | { 6 | /// Generates a Color structure, based on discrete **Byte** values for **ARGB** components. C# and Microsoft Visual Basic code should use **Color.FromArgb** instead. 7 | /// The **A** (transparency) component of the desired color. Range is 0-255. 8 | /// The **R** component of the desired color. Range is 0-255. 9 | /// The **G** component of the desired color. Range is 0-255. 10 | /// The **B** component of the desired color. Range is 0-255. 11 | /// The generated Color value. 12 | public static Color FromArgb(byte a, byte r, byte g, byte b) 13 | { 14 | return new Color(a, r, g, b); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/XPlat.UI/IDispatcherTimer.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI 2 | { 3 | using System; 4 | 5 | /// Provides a timer that is integrated into the Dispatcher queue, which is processed at a specified interval of time and at a specified priority. 6 | public interface IDispatcherTimer 7 | { 8 | /// Occurs when the timer interval has elapsed. 9 | event EventHandler Tick; 10 | 11 | /// Gets or sets the amount of time between timer ticks. 12 | TimeSpan Interval { get; set; } 13 | 14 | /// Gets a value indicating whether the timer is running. 15 | bool IsEnabled { get; } 16 | 17 | /// Starts the DispatcherTimer. 18 | void Start(); 19 | 20 | /// Stops the DispatcherTimer. 21 | void Stop(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/XPlat.UI/ThicknessHelper.cs: -------------------------------------------------------------------------------- 1 | namespace XPlat.UI 2 | { 3 | /// Provides helper methods to evaluate or set Thickness values. 4 | public class ThicknessHelper 5 | { 6 | /// Creates a Thickness value based on element values. 7 | /// The initial **Left**. 8 | /// The initial **Top**. 9 | /// The initial **Right**. 10 | /// The initial **Bottom**. 11 | /// The created Thickness. 12 | public static Thickness FromLengths(double left, double top, double right, double bottom) 13 | { 14 | return new Thickness(left, top, right, bottom); 15 | } 16 | 17 | /// Creates a new Thickness value using a uniform value for all the element values. 18 | /// The uniform value to apply to all four of the Thickness element values. 19 | /// The created Thickness. 20 | public static Thickness FromUniformLength(double uniformLength) 21 | { 22 | return new Thickness(uniformLength); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/XPlat.UI/XPlat.UI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | uap10.0.17763;MonoAndroid10.0;xamarinios10;netstandard2.0 5 | true 6 | XPlat - Windows.UI APIs 7 | 8 | This package includes Windows.UI like APIs cross-platform such as: 9 | - Color representing a color in terms of alpha, red, green, and blue channels. 10 | - Colors representing a set of predefined colors. 11 | - DispatcherTimer providing a timer that is integrated into the Dispatcher queue, which is processed at a specified interval of time and at a specified priority. 12 | - Thickness representing the thickness of a frame around a rectangle. 13 | 14 | XPlat API UI Windows UWP iOS Android Xamarin Color DispatcherTimer Thickness 15 | XPlat.UI 16 | 17 | 18 | 19 | --------------------------------------------------------------------------------