private bool CallLfMergeBridge(string bridgeInput, out string bridgeOutput) { bridgeOutput = string.Empty; using (var tmpFile = new Palaso.IO.TempFile(bridgeInput)) { var options = new Dictionary <string, string> { { "-p", _project.FwDataPath }, { "serializedCommentsFromLfMerge", tmpFile.Path } }; try { if (!LfMergeBridge.LfMergeBridge.Execute("Language_Forge_Write_To_Chorus_Notes", _progress, options, out bridgeOutput)) { _logger.Error("Got an error from Language_Forge_Write_To_Chorus_Notes: {0}", bridgeOutput); return(false); } else { // _logger.Debug("Good output from Language_Forge_Write_To_Chorus_Notes: {0}", bridgeOutput); return(true); } } catch (NullReferenceException) { _logger.Debug("Got an exception. Before rethrowing it, here is what LfMergeBridge sent:"); _logger.Debug("{0}", bridgeOutput); throw; } } }
private bool CallLfMergeBridge(string bridgeInput, out string bridgeOutput) { // Call into LF Bridge to do the work. bridgeOutput = string.Empty; using (var tmpFile = new Palaso.IO.TempFile(bridgeInput)) { var options = new Dictionary <string, string> { { "-p", _project.FwDataPath }, { "serializedCommentsFromLfMerge", tmpFile.Path }, }; if (!LfMergeBridge.LfMergeBridge.Execute("Language_Forge_Get_Chorus_Notes", _progress, options, out bridgeOutput)) { _logger.Error("Got an error from Language_Forge_Get_Chorus_Notes: {0}", bridgeOutput); return(false); } else { // _logger.Debug("Got the JSON from Language_Forge_Get_Chorus_Notes: {0}", bridgeOutput); return(true); } } }
private void OnPasteImage(DomEventArgs ge) { if (!_model.CanChangeImages()) { MessageBox.Show( LocalizationManager.GetString("EditTab.CantPasteImageLocked", "Sorry, this book is locked down so that images cannot be changed.")); return; } Image clipboardImage = null; try { clipboardImage = GetImageFromClipboard(); if (clipboardImage == null) { MessageBox.Show( LocalizationManager.GetString("EditTab.NoImageFoundOnClipboard", "Before you can paste an image, copy one onto your 'clipboard', from another program.")); return; } var target = (GeckoHtmlElement)ge.Target.CastToGeckoElement(); if (target.ClassName.Contains("licenseImage")) { return; } var imageElement = GetImageNode(ge); if (imageElement == null) { return; } Cursor = Cursors.WaitCursor; //nb: later, code closer to the the actual book folder will //improve this file name. Taglib# requires an extension that matches the file content type, however. using (var temp = TempFile.WithExtension("png")) { clipboardImage.Save(temp.Path, ImageFormat.Png); // using (var progressDialog = new ProgressDialogBackground()) // { // progressDialog.ShowAndDoWork((progress, args) => // { // ImageUpdater.CompressImage(temp.Path, progress); // }); // } using (var palasoImage = PalasoImage.FromFile(temp.Path)) { _model.ChangePicture(imageElement, palasoImage, new NullProgress()); } } } catch (Exception error) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "The program had trouble getting an image from the clipboard."); } finally { if (clipboardImage != null) { clipboardImage.Dispose(); } } Cursor = Cursors.Default; }
private void OnPasteImage(GeckoDomEventArgs ge) { if (!_model.CanChangeImages()) { MessageBox.Show( LocalizationManager.GetString("EditTab.CantPasteImageLocked","Sorry, this book is locked down so that images cannot be changed.")); return; } Image clipboardImage = null; try { clipboardImage = GetImageFromClipboard(); if (clipboardImage == null) { MessageBox.Show( LocalizationManager.GetString("EditTab.NoImageFoundOnClipboard","Before you can paste an image, copy one onto your 'clipboard', from another program.")); return; } if (ge.Target.ClassName.Contains("licenseImage")) return; var imageElement = GetImageNode(ge); if (imageElement == null) return; Cursor = Cursors.WaitCursor; //nb: later, code closer to the the actual book folder will //improve this file name using (var temp = new TempFile()) { clipboardImage.Save(temp.Path, ImageFormat.Png); // using (var progressDialog = new ProgressDialogBackground()) // { // progressDialog.ShowAndDoWork((progress, args) => // { // ImageUpdater.CompressImage(temp.Path, progress); // }); // } using (var palasoImage = PalasoImage.FromFile(temp.Path)) { _model.ChangePicture(imageElement, palasoImage, new NullProgress()); } } } catch (Exception error) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "The program had trouble getting an image from the clipboard."); } finally { if (clipboardImage != null) clipboardImage.Dispose(); } Cursor = Cursors.Default; }