public ShareRequestAdapter(DataRequest dataRequest, Guid id)
 {
     _dataRequest = dataRequest;
     _data = _dataRequest.Data;
     _properties = _data.Properties;
     _properties.ApplicationName = "ExampleApplication.WinRT";
     Id = id;
 }
Beispiel #2
0
 public ShareRequestAdapter(DataRequest dataRequest, Guid id)
 {
     _dataRequest = dataRequest;
     _data        = _dataRequest.Data;
     _properties  = _data.Properties;
     _properties.ApplicationName = "ExampleApplication.WinRT";
     Id = id;
 }
        private async Task ShareFileAsync(DashboardViewModel vm, DataPackage dataPackage, DataPackagePropertySet propertySet)
        {
            var cleanFileName = vm.SelectedItem.ImagePath.Replace(@"../Images/", "");

            var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var imagesFolder = await packageLocation.GetFolderAsync("Images");
            var imageToShare = await imagesFolder.GetFileAsync(cleanFileName);

            dataPackage.SetStorageItems(new List<IStorageItem>{imageToShare});

            var imageStreamRef = RandomAccessStreamReference.CreateFromFile(imageToShare);
            propertySet.Thumbnail = imageStreamRef;

        }
Beispiel #4
0
        private void TextSharingHandler(DataPackagePropertySet properties, DataRequest request)
        {
            properties.Title = "Compartiendo texto desde el Share Charm";
            properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm";

            request.Data.SetText("Hola Mundo desde Share Charm");
        }
Beispiel #5
0
        private void LinkSharingHandler(DataPackagePropertySet properties, DataRequest request)
        {
            properties.Title = "Compartiendo un link desde el Share Charm";
            properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm";

            request.Data.SetUri(new Uri("http://www.google.com"));
        }
Beispiel #6
0
        private async void ImageSharingHandler(DataPackagePropertySet properties, DataRequest request)
        {

            properties.Title = "Compartiendo una imagen desde el Share Charm";
            properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm";

            // TODO Deferral espera abierta en el sistema 

            // TODO Cuando se esten cargando cosas de manera asincrona debemos llamar el deferrel
            // TODO para que el sistema espere a la carga de los archivos antes de disparar el proceso completo.

            var deferral = request.GetDeferral();

            // Ctrl + k + s, genera el envoltorio de try
            try
            {
                var thumbFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logo.png");
                properties.Thumbnail = RandomAccessStreamReference.CreateFromFile(thumbFile);

                var imageFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logo.png");
                request.Data.SetBitmap(RandomAccessStreamReference.CreateFromFile(imageFile));
            }
            finally
            {
                deferral.Complete();
            }
        }
Beispiel #7
0
        private async void FileSharingHandler(DataPackagePropertySet properties, DataRequest request)
        {
            properties.Title = "Compartiendo un conjunto de archivos desde el Share Charm";
            properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm";

            var deferral = request.GetDeferral();

            try
            {
                var sampleFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\casilleros.xlsx"); // Archivo no existe

                var sampleFile2 = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logo.png");

                var storageFilesList = new List<IStorageItem>();
                storageFilesList.Add(sampleFile);
                request.Data.SetStorageItems(storageFilesList);
            }
            finally
            {
                deferral.Complete();
            }
        }
Beispiel #8
0
        private void HtmlSharingHandler(DataPackagePropertySet properties, DataRequest request)
        {
            properties.Title = "Compartiendo un documento de html5 desde el Share Charm";
            properties.Description = "Se supone que estoy compartiendo la descirpcion con el Share Charm";

            var localImagePath = "ms-appx:///Assets/Logo.png";
            string htmlContent = @"<p> hola esto es un <strong> parrafo de HTML </strong> :) </p>
<p>Y esto es una imagen: <img source='"+ localImagePath +"'/></p>";
            var htmlFormatString = HtmlFormatHelper.CreateHtmlFormat(htmlContent);

            request.Data.ResourceMap[localImagePath] = RandomAccessStreamReference.CreateFromUri(new Uri(localImagePath));
            request.Data.SetHtmlFormat(htmlFormatString);
        }
        private async Task ShareImageAsFileAsync(DashboardViewModel vm, DataPackage dataPackage, DataPackagePropertySet propertySet)
        {
            var cleanFileName = vm.SelectedItem.ImagePath.Replace(@"../Images/", "");

            var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var imagesFolder    = await packageLocation.GetFolderAsync("Images");

            var imageToShare = await imagesFolder.GetFileAsync(cleanFileName);

            var imageStreamRef = RandomAccessStreamReference.CreateFromFile(imageToShare);

            dataPackage.SetStorageItems(new List <IStorageItem> {
                imageToShare
            });
            propertySet.Thumbnail = imageStreamRef;
        }
Beispiel #10
0
 /// <include file="../../../docs/Microsoft.Maui.Controls/DataPackage.xml" path="//Member[@MemberName='.ctor']/Docs" />
 public DataPackage()
 {
     Properties         = new DataPackagePropertySet();
     PropertiesInternal = new DataPackagePropertySet();
 }
 internal DataPackagePropertySetAdapter( DataPackagePropertySet propertySet )
 {
     Contract.Requires( propertySet != null );
     adapted = propertySet;
 }