internal class GettingStartedViewModel: INotifyPropertyChanged
{
private Stream m_pdfDocumentStream;
private string m_documentName;
string filePath = string.Empty;
public event PropertyChangedEventHandler PropertyChanged;
public string DocumentName
{
get
{
return m_documentName;
}
set
{
m_documentName = value;
//Getdata();
//////PdfDocumentStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream(filePath + "Assets.57a3e4dd-3b40-4665-b55a-4b7419d08db6.pdf");
}
}
private async Task<Stream> DownloadPdfStream(string URL)
{
HttpClient httpClient = new HttpClient();
HttpResponseMessage response = await httpClient.GetAsync(URL);
//Check whether redirection is needed
if ((int)response.StatusCode == 302)
{
//The URL to redirect is in the header location of the response message
HttpResponseMessage redirectedResponse = await httpClient.GetAsync(response.Headers.Location.AbsoluteUri);
return await redirectedResponse.Content.ReadAsStreamAsync();
}
return await response.Content.ReadAsStreamAsync();
}
public async void Getdata()
{
PdfDocumentStream= await DownloadPdfStream("http://10.1.3.202/EofficeFileAPI/FIleDownload/57a3e4dd-3b40-4665-b55a-4b7419d08db6.pdf");
}
public GettingStartedViewModel()
{
Getdata();
#if COMMONSB
filePath = "SampleBrowser.Samples.PdfViewer.Samples.";
#else
filePath = "SampleBrowser.SfPdfViewer.";
#endif
}
public Stream PdfDocumentStream
{
get
{
return m_pdfDocumentStream;
}
set
{
m_pdfDocumentStream = value;
NotifyPropertyChanged("PdfDocumentStream");
}
}
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private bool CanExecute(object parameter)
{
return true;
}
}