Ejemplo n.º 1
0
            public async Task UploadAsync(Windows.Storage.StorageFile sourceFile,
                string containerName, string blobName)
            {
                var properties = await sourceFile.GetBasicPropertiesAsync();
                if (properties.Size > (1024 * 1024 * 64))
                    throw new Exception("File cannot be larger than 64MB");

                var container = this.Parent.GetContainer(containerName);
                var blob = container.GetBlockBlobReference(blobName);
                await blob.UploadFromFileAsync(sourceFile);
            }
Ejemplo n.º 2
0
            public async Task<Windows.Networking.BackgroundTransfer.UploadOperation> UploadBackgroundAsync(Windows.Storage.StorageFile sourceFile,
                string containerName, string blobName, Action<Windows.Networking.BackgroundTransfer.UploadOperation> progressCallback = null)
            {
                var properties = await sourceFile.GetBasicPropertiesAsync();
                if (properties.Size > (1024 * 1024 * 64))
                    throw new Exception("File cannot be larger than 64MB");

                var permissions = Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions.Write;
                var container = this.Parent.GetContainer(containerName);
                var signature = this.GetSas(permissions, TimeSpan.FromMinutes(5), container.Name, blobName);
                var uploader = new Windows.Networking.BackgroundTransfer.BackgroundUploader
                {
                    TransferGroup = Windows.Networking.BackgroundTransfer.BackgroundTransferGroup.CreateGroup(_groupName)
                };
                uploader.SetRequestHeader("Filename", sourceFile.Name);
                var upload = uploader.CreateUpload(signature, sourceFile);
                if (progressCallback == null)
                    return await upload.StartAsync();
                else
                    return await upload.StartAsync().AsTask(new Progress<Windows.Networking.BackgroundTransfer.UploadOperation>(progressCallback));
            }
Ejemplo n.º 3
0
        //////////////////////////////////////////////////////////////// open pdf and load pdf and calculate pdf size and unload pdf      
        private async void OpenPDFDocument(Windows.Storage.StorageFile file)
        {
            if (file != null)
            {
                Windows.Storage.FileProperties.BasicProperties properties = await file.GetBasicPropertiesAsync();
                m_SDKDocument = new FSDK_Document();
                //Load PDF document
                int result = await m_SDKDocument.OpenDocumentAsync(file, (int)properties.Size);
                if(result != 0)
                {
                    return;
                }
                m_PDFDoc.pointer = m_SDKDocument.m_hDoc.pointer;
                m_iPageCount = m_PDFFunction.My_Doc_CountPages(m_PDFDoc);

                //import wordlist into struct
                string[] testStr = new string[WordNumber];
                testStr = Wordlist;
                wordInfo wInfo;
                for (int count = 0; count < testStr.Length; count++)
                {
                    bool[] testData = new bool[m_iPageCount];
                    for (int count1 = 0; count1 < testData.Length; count1++)
                    {
                        testData[count1] = false;
                    }
                    wInfo.word = testStr[count];
                    wInfo.annotFlag = testData;
                    wordInfoList.Add(wInfo);
                }

                //Load first two PDF page
                result = LoadPage(0);
                if(result != 0)
                {
                    return;
                }
                result = LoadPage(1);
                if (result != 0)
                {
                    return;
                }
                nextInvisibleIndex = 2;
                 
                //get page size and calculate suitable render size
                GetPageInfo();
                m_dbScaleFator = (m_dbCommonFitWidthScale < m_dbCommonFitHeightScale) ? m_dbCommonFitWidthScale : m_dbCommonFitHeightScale;
                CalcRenderSize();

                //Show PDF page to device.
                initPdfGrid(m_iPageCount);
                ShowPage();

                //initial preview page 
                preview_visiblePage = new Dictionary<int, PageHandle>();
                Preview_InitGrid();
            }
            return;

        }