public HttpResponseMessage GetDocumentPage(PostedDataEntity postedData) { string password = string.Empty; try { string documentGuid = postedData.guid; int pageNumber = postedData.page; password = string.IsNullOrEmpty(postedData.password) ? null : postedData.password; var fileFolderName = Path.GetFileName(documentGuid).Replace(".", "_"); string fileCacheSubFolder = Path.Combine(cachePath, fileFolderName); IViewerCache cache = new FileViewerCache(cachePath, fileCacheSubFolder); PageDescriptionEntity page; if (globalConfiguration.GetViewerConfiguration().GetIsHtmlMode()) { using (HtmlViewer htmlViewer = new HtmlViewer(documentGuid, cache, GetLoadOptions(password))) { page = this.GetPageDescritpionEntity(htmlViewer, documentGuid, pageNumber, fileCacheSubFolder); } } else { using (PngViewer pngViewer = new PngViewer(documentGuid, cache, GetLoadOptions(password))) { page = this.GetPageDescritpionEntity(pngViewer, documentGuid, pageNumber, fileCacheSubFolder); } } return(this.Request.CreateResponse(HttpStatusCode.OK, page)); } catch (Exception ex) { // set exception message return(this.Request.CreateResponse(HttpStatusCode.Forbidden, new Resources().GenerateException(ex, password))); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { await TitleBarHelper.SetVisibilityAsync(Visibility.Collapsed); TitleBarHelper.SetButtonBackgroundColor(Colors.Transparent); TitleBarHelper.SetButtonForegroundColor(ForegroundBrush.Color); Messenger.Default.Register <LoadContentMessage>(this, message => { HtmlViewer.NavigateToString(ViewModel.FormattedHtml); }); Messenger.Default.Register <TagsEditedMessage>(this, async message => { if (message.Item.Id == ViewModel.Item.Model.Id) { await HtmlViewer.InvokeScriptAsync("updateTagsElement", new List <string>() { ViewModel.BuildTagsHtml(message.Item) }); } }); }
protected override void OnNavigatedFrom(NavigationEventArgs e) { HtmlViewer.NavigateToString("<p></p>"); Messenger.Default.Unregister(this); }
/// <summary> /// Requires a language object /// </summary> /// <param name="lang"></param> public WebPageInteractor(Language lang, HtmlViewer viewer, WebBrowser browser) { m_lang = lang; m_viewer = viewer; m_browser = browser; }
public Form NewMainWindow(bool fTesting) { try { ImageHolder holder = new ImageHolder(); // TODO: may want to add following to xml at some point or put it in configuration Path using Cabhab.ico as name // We are putting the configuration files in the common app directory string sAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string sCabhabDirectory = Path.Combine(sAppData, Path.Combine("SIL", "Cabhab")); string sConfigPath = Path.Combine(sCabhabDirectory, "Configurations"); string sConfig = Path.Combine(sConfigPath, ConfigurationFile); ConfigurationFileFullPath = sConfig; string sConfigSettings = Path.Combine(sCabhabDirectory, "ConfigurationSettings"); if (!Directory.Exists(sConfigSettings)) { Directory.CreateDirectory(sConfigSettings); } Mediator.PropertyTable.UserSettingDirectory = sConfigSettings; //MessageBox.Show("Before LoadUi(). sConfig = " + sConfig); LoadUI(sConfig); //Argument("x")); //MessageBox.Show("Before getting icon file"); string sIconFile = Mediator.PropertyTable.GetStringProperty("CabhabAppIcon", null); //MessageBox.Show("Before changing icon: sIconFile = " + sIconFile); sIconFile = Path.Combine(sConfigPath, sIconFile); //MessageBox.Show("Before setting icon: sIconFile = " + sIconFile); Icon = new System.Drawing.Icon(sIconFile); if (!fTesting) { //m_mainSplitterContainer.Panel1Collapsed = true; GetToolAndStatusBars(); m_viewer = (HtmlViewer) Mediator.PropertyTable.GetValue("currentContentControlObject"); m_viewer.ChangeShowToolbar += new EventHandler(OnChangeShowToolbar); m_viewer.ChangeShowStatusBar += new EventHandler(OnChangeShowStatusBar); Language m_lang = m_viewer.m_lang; m_lang.ChangeLanguageName += new EventHandler(OnChangeLanguageName); string sLangName = (m_lang != null) ? sLangName = m_lang.Name : ""; Mediator.PropertyTable.SetProperty("DocumentName", sLangName); UpdateCaptionBar(); if (m_sAnswerFile != null && File.Exists(m_sAnswerFile)) { m_lang.LoadAnswerFile(m_sAnswerFile); m_lang.LanguageNameChanged(); } Show(); } return this; } catch(Exception e) { MessageBox.Show("Exception caught: message =" + e.Message); MessageBox.Show("Inner exception = " + e.InnerException); return this; } }