/// ------------------------------------------------------------------------------------ public static Dictionary <double, double> SegmentAudioFile(string audioFile, int silenceThreshold, float clusterDuration, int clusterThreshold, float[] onsetDetectionValues) { var rubyScript = FileLocator.GetFileDistributedWithApplication("AutoSegmenter", "rubyscripts", "segmenter.rb"); var libAubioFolder = Path.GetDirectoryName( FileLocator.GetFileDistributedWithApplication("AutoSegmenter", "libaudio", "aubioonset.exe")); if (!libAubioFolder.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))) { libAubioFolder += Path.DirectorySeparatorChar; } var runtime = Ruby.CreateRuntime(); var engine = runtime.GetEngine("rb"); var paths = engine.GetSearchPaths().ToList(); paths.Add(Path.GetDirectoryName(rubyScript)); engine.SetSearchPaths(paths); engine.Runtime.ExecuteFile(rubyScript); var segmenterObj = engine.Runtime.Globals.GetVariable("Segmenter"); var segmenterInst = engine.Operations.CreateInstance(segmenterObj); engine.Operations.InvokeMember(segmenterInst, "initFromCSharp", silenceThreshold, clusterDuration, clusterThreshold, onsetDetectionValues); IronRuby.Builtins.Hash returnValues = engine.Operations.InvokeMember(segmenterInst, "processFromCSharp", libAubioFolder, audioFile); return(returnValues.ToDictionary(kvp => (double)kvp.Key, kvp => (double)kvp.Value)); }
/// ------------------------------------------------------------------------------------ private void LoadToolbarAndContextMenus() { if (App.DesignMode) { return; } if (_tmAdapter != null) { _tmAdapter.Dispose(); } _tmAdapter = AdapterHelper.CreateTMAdapter(); if (_tmAdapter != null) { var defs = new[] { FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName, "CVChartsTMDefinition.xml") }; _tmAdapter.Initialize(this, App.MsgMediator, App.ApplicationRegKeyPath, defs); _tmAdapter.AllowUpdates = true; } // Give the chart Phone search toolbar button a default image. var childItemProps = _tmAdapter.GetItemProperties("tbbChartPhoneSearchAnywhere"); var parentItemProps = _tmAdapter.GetItemProperties("tbbChartPhoneSearch"); if (parentItemProps != null && childItemProps != null) { parentItemProps.Image = childItemProps.Image; parentItemProps.Visible = true; parentItemProps.Update = true; _tmAdapter.SetItemProperties("tbbChartPhoneSearch", parentItemProps); } }
private void About_Click(object sender, EventArgs e) { using (var dlg = new SILAboutBox(FileLocator.GetFileDistributedWithApplication("aboutbox.htm"))) { dlg.ShowDialog(this); } }
public bool ShowPdf(string pdfFile) { #if !__MonoCS__ if (Settings.Default.UseAdobePdfViewer) { return(((AdobeReaderControl)_pdfViewerControl).ShowPdf(pdfFile)); } #endif var url = string.Format("{0}{1}?file=/bloom/{2}", Bloom.web.ServerBase.PathEndingInSlash, FileLocator.GetFileDistributedWithApplication("pdf/web/viewer.html"), pdfFile); var browser = ((GeckoWebBrowser)_pdfViewerControl); browser.Navigate(url); browser.DocumentCompleted += (sender, args) => { // We want to suppress several of the buttons that the control normally shows. // It's nice if we don't have to modify the html and related files, because they are unzipped from a package we install // from a source I'm not sure we control, and installed into a directory we can't modify at runtime. // A workaround is to tweak the stylesheet to hide them. The actual buttons (and two menu items) are easily // hidden by ID. // Unfortunately we're getting rid of a complete group in the pull-down menu, which leaves an ugly pair of // adjacent separators. And the separators don't have IDs so we can't easily select just one to hide. // Fortunately there are no other divs in the parent (besides the separator) so we just hide the second one. // This is unfortunately rather fragile and may not do exactly what we want if the viewer.html file // defining the pdfjs viewer changes. GeckoStyleSheet stylesheet = browser.Document.StyleSheets.First(); stylesheet.CssRules.Add("#openFile, #print, #download, #viewBookmark, #pageRotateCw, #pageRotateCcw, #secondaryToolbarButtonContainer div:nth-of-type(2) {display: none}"); }; return(true); }
private void InfoWindow_Load(object sender, EventArgs e) { Activate(); //bring to front var path = FileLocator.GetFileDistributedWithApplication("about.htm"); _webBrowser.Navigate(path); }
/// ------------------------------------------------------------------------------------ private static AnnotationFileHelper GetOrCreateFile(string eafFile, string mediaFileName) { if (string.IsNullOrEmpty(eafFile)) { eafFile = ComputeEafFileNameFromOralAnnotationFile(mediaFileName); } var fileExisted = File.Exists(eafFile); if (!fileExisted) { File.Copy(FileLocator.GetFileDistributedWithApplication("annotationTemplate.etf"), eafFile, true); ChangeMediaFileName(eafFile, mediaFileName); } var helper = Load(eafFile); helper.SetMediaFile(mediaFileName); if (!fileExisted) { helper.GetOrCreateHeader(); helper.GetOrCreateTranscriptionTierElement(); helper.GetOrCreateFreeTranslationTierElement(); } helper.Save(); return(helper); }
public static void CompressImage(string path, IProgress progress) { progress.WriteStatus("Compressing image: " + Path.GetFileName(path)); var pngoutPath = FileLocator.GetFileDistributedWithApplication("optipng.exe"); var result = CommandLineRunner.Run(pngoutPath, "\"" + path + "\"", Encoding.UTF8, Path.GetDirectoryName(path), 300, progress, (s) => progress.WriteMessage(s)); }
//Factory public static AccessKeys GetAccessKeys(string bucket) { var connectionsPath = FileLocator.GetFileDistributedWithApplication("connections.dll"); var lines = RobustFile.ReadAllLines(connectionsPath); switch (bucket) { case BloomS3Client.SandboxBucketName: // S3 'uploaderDev' user, who has permission to use the BloomLibraryBooks-Sandbox bucket. //parse.com silbloomlibrarysandbox return(new AccessKeys(lines[2], lines[3], lines[6], lines[7])); case BloomS3Client.UnitTestBucketName: return(new AccessKeys(lines[2], lines[3], lines[8], lines[9])); case BloomS3Client.ProductionBucketName: //S3 'uploader' user, who has permission to use the BloomLibraryBooks bucket //parse.com silbloomlibrary return(new AccessKeys(lines[0], lines[1], lines[4], lines[5])); case BloomS3Client.ProblemBookUploadsBucketName: return(new AccessKeys(lines[2], lines[3], null, null)); case BloomS3Client.BloomDesktopFiles: // For now, this is public read, and no one needs to write. return(new AccessKeys(null, null, null, null)); default: throw new ApplicationException("Bucket name not recognized: " + bucket); } }
/// ------------------------------------------------------------------------------------ private static FwQueries Load(string filename) { // Find the file that contains the queries. var queryFile = FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName, filename); var fwqueries = XmlSerializationHelper.DeserializeFromFile <FwQueries>(queryFile); if (fwqueries != null) { fwqueries.QueryFile = queryFile; } else if (ShowMsgOnFileLoadFailure) { string filePath = Utils.PrepFilePathForMsgBox(queryFile); var msg = LocalizationManager.GetString("Miscellaneous.Messages.DataSourceReading.LoadingSQLQueriesErrorMsg", "The file that contains FieldWorks queries '{0}' is either missing or corrupt. " + "Until this problem is corrected, FieldWorks data sources cannot be accessed or " + "added as data sources."); App.NotifyUserOfProblem(msg, filePath); fwqueries = new FwQueries(true); } return(fwqueries); }
private static string GetReferenceTextProjectFileLocation(ReferenceTextType referenceTextType) { Debug.Assert(IsStandardReferenceText(referenceTextType)); string projectFileName = referenceTextType.ToString().ToLowerInvariant() + ProjectBase.kProjectFileExtension; return(FileLocator.GetFileDistributedWithApplication(kDistFilesReferenceTextDirectoryName, referenceTextType.ToString(), projectFileName)); }
private void OnAboutBoxClick(object sender, EventArgs e) { using (var dlg = new Palaso.UI.WindowsForms.SIL.SILAboutBox(FileLocator.GetFileDistributedWithApplication(false, "infoPages", "aboutBox.htm"))) { dlg.ShowDialog(); } }
static KeyManager() { var connectionsPath = FileLocator.GetFileDistributedWithApplication("connections.dll"); var lines = File.ReadAllLines(connectionsPath); if (BookTransfer.UseSandbox) { // These lines contain the S3 keys for the 'uploaderDev' user, who has permission to use the BloomLibraryBooks-Sandbox bucket. S3AccessKey = lines[2]; S3SecretAccessKey = lines[3]; // These lines contain the Parse.com keys for the 'application' silbloomlibrarysandbox ParseApiKey = lines[6]; ParseApplicationKey = lines[7]; } else { // These lines contain the S3 keys for the 'uploader' user, who has permission to use the BloomLibraryBooks bucket. S3AccessKey = lines[0]; S3SecretAccessKey = lines[1]; // These lines contain the Parse.com keys for the 'application' silbloomlibrary ParseApiKey = lines[4]; ParseApplicationKey = lines[5]; } ParseUnitTestApiKey = lines[8]; ParseUnitTextApplicationKey = lines[9]; }
/// <summary> /// Return the top-level document that should be displayed in the browser for the current page. /// Enhance JohnT: Since EditViewFrame.htm does not change, it should be possible to modify /// the caller so that it just loads that file directly, rather than making a temp file out of /// the DOM we make out of the file. However, we probably soon want to make the accordion optional, /// at which point we may just return _domForCurrentPage when it is turned off, or more likely, /// return a modified DOM which hides it. /// </summary> /// <returns></returns> public HtmlDom GetXmlDocumentForEditScreenWebPage() { var path = FileLocator.GetFileDistributedWithApplication("BloomBrowserUI/bookEdit", "EditViewFrame.htm"); var dom = new HtmlDom(XmlHtmlConverter.GetXmlDomFromHtmlFile(path)); // only show the accordion when the template enables it var css_class = dom.Body.GetAttributeNode("class"); if (css_class == null) { css_class = dom.Body.OwnerDocument.CreateAttribute("class"); dom.Body.Attributes.Append(css_class); } if (_currentlyDisplayedBook.BookInfo.ReaderToolsAvailable) { css_class.Value = "accordion"; } else { css_class.Value = "no-accordion"; } return(dom); }
private static void AddRequisiteJsFiles(string path) { const string bloomPlayerFileName = "bloomPlayer.js"; var bloomLibraryJsPath = FileLocator.GetFileDistributedWithApplication(bloomPlayerFileName); RobustFile.Copy(bloomLibraryJsPath, Path.Combine(path, bloomPlayerFileName), true); }
/// <summary> /// This is designed to be easily unit testable by not taking actual HttpContext, but doing everything through this IRequestInfo object /// </summary> /// <param name="info"></param> public void MakeReply(IRequestInfo info) { var r = info.LocalPathWithoutQuery.Replace("/bloom/", ""); r = r.Replace("library/", ""); if (r.Contains("libraryContents")) { GetLibraryBooks(info); } else if (r == "libraryName") { info.WriteCompleteOutput(_collectionSettings.CollectionName + " Library"); } else if (r.Contains("SourceCollectionsList")) { GetStoreBooks(info); } else if (r.StartsWith("thumbnails/")) { r = r.Replace("thumbnails/", ""); r = r.Replace("%5C", "/"); r = r.Replace("%20", " "); if (File.Exists(r)) { info.ReplyWithImage(r); } } else if (r.EndsWith(".png")) { info.ContentType = "image/png"; r = r.Replace("thumbnail", ""); //if (r.Contains("thumb")) { if (File.Exists(r)) { info.ReplyWithImage(r); } else { var imgPath = FileLocator.GetFileDistributedWithApplication("BloomBrowserUI", "book.png"); info.ReplyWithImage(imgPath); //book.GetThumbNailOfBookCoverAsync(book.Type != Book.Book.BookType.Publication,image => RefreshOneThumbnail(book, image)); } } // else // { // var imgPath = FileLocator.GetFileDistributedWithApplication("root", "ui", "book.png"); // info.ReplyWithImage(imgPath); // } } else { string path = FileLocator.GetFileDistributedWithApplication("BloomBrowserUI", r); //request.QueryString.GetValues() info.WriteCompleteOutput(File.ReadAllText(path)); } }
public void CreateGroups_GroupsInDistFiles_CanReadAll() { var path = FileLocator.GetFileDistributedWithApplication("myWorkSafe.ini"); var reader = new GroupIniFileReader(path); var groups = reader.CreateGroups().ToArray(); Assert.That(groups.Count(), Is.GreaterThan(5)); }
/// ------------------------------------------------------------------------------------ public static IEnumerable <FFmpegConversionInfo> GetConversions(string fileToConvert) { var iniFile = FileLocator.GetFileDistributedWithApplication("FFmpegConversions.ini"); var ffmpegConversions = new IniDocument(iniFile); var typeToShow = string.Empty; if (FileUtils.AudioFileExtensions.Contains(Path.GetExtension(fileToConvert))) { typeToShow = "audio"; } else if (FileUtils.VideoFileExtensions.Contains(Path.GetExtension(fileToConvert))) { typeToShow = "video"; } for (int i = 0; i < ffmpegConversions.Sections.Count; i++) { var applicableFileType = ffmpegConversions.Sections[i].GetValue("applicableFileType"); if (applicableFileType != null && applicableFileType.Contains(typeToShow)) { yield return(new FFmpegConversionInfo { Name = ffmpegConversions.Sections[i].Name, OutputExtension = ffmpegConversions.Sections[i].GetValue("outputFileExtension"), CommandLine = ffmpegConversions.Sections[i].GetValue("commandLine"), Comments = ffmpegConversions.Sections[i].GetValue("comments"), ApplicableFileType = ffmpegConversions.Sections[i].GetValue("applicableFileType") }); } } if (typeToShow == "video") { yield return(new FFmpegConversionInfo { Name = ConvertMediaDlg.GetFactoryConvertToH263Mp4ConversionName(), OutputExtension = "mp4", CommandLine = "-vb {vb} -codec:v mpeg4 -ab {ab} -codec:a aac -strict -2", ApplicableFileType = "video" }); } yield return(new FFmpegConversionInfo { Name = ConvertMediaDlg.GetFactoryExtractToStandardPcmConversionName(), OutputExtension = "wav", CommandLine = "-vn -codec:a {pcm}", ApplicableFileType = "audio/video" }); yield return(new FFmpegConversionInfo { Name = ConvertMediaDlg.GetFactoryExtractToMp3AudioConversionName(), OutputExtension = "mp3", CommandLine = "-vn -codec:a libmp3lame -ac 1", ApplicableFileType = "audio/video" }); }
public static void Main(string[] rgArgs) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ErrorReport.AddProperty("EmailAddress", "*****@*****.**"); ErrorReport.AddStandardProperties(); ExceptionHandler.Init(); s_loadingWnd = new SmallFadingWnd(Properties.Resources.kstidLoadingProgramMsg); PortableSettingsProvider.SettingsFileFolder = App.ProjectFolder; PortableSettingsProvider.SettingsFileName = "PCIEditor.settings"; string inventoryFilePath = FileLocator.GetDirectoryDistributedWithApplication(App.ConfigFolderName); // This is the poor man's way of determining whether or not the user has // write access to the folder in which the phonetic inventory // is stored. I'm sure there is a great class in .Net to use for such a // thing, but I couldn't find it in the little bit of digging I did. Sigh! string tmpFile = Path.Combine(inventoryFilePath, "!~tmpaccesstest~!"); try { File.WriteAllText(tmpFile, string.Empty); } catch { string msg = string.Format(Properties.Resources.kstidWriteAccessErrorMsg, inventoryFilePath); Utils.MsgBox(msg); return; } File.Delete(tmpFile); string inventoryPath = null; try { // Make sure the phonetic inventory file exists. inventoryPath = FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName, App.kDefaultInventoryFileName); } catch { string filePath = Utils.PrepFilePathForMsgBox(inventoryPath); string msg = string.Format(Properties.Resources.kstidInventoryFileMissing, filePath); Utils.MsgBox(msg); return; } var editor = new PCIEditor(); editor.OpenFile(inventoryPath); Application.Run(editor); }
private void _releaseNotesMenuItem_Click(object sender, EventArgs e) { var path = FileLocator.GetFileDistributedWithApplication("ReleaseNotes.md"); using (var dlg = new ShowReleaseNotesDialog(global::Bloom.Properties.Resources.BloomIcon, path)) { dlg.ShowDialog(); } }
public override void Execute() { var path = FileLocator.GetFileDistributedWithApplication("ReleaseNotes.md"); using (var dlg = new ShowReleaseNotesDialog(System.Windows.Forms.Application.OpenForms.Count > 0 ? System.Windows.Forms.Application.OpenForms[0].Icon : null, path)) { dlg.ShowDialog(); } }
private void _releaseNotesMenuItem_Click(object sender, EventArgs e) { var path = FileLocator.GetFileDistributedWithApplication("ReleaseNotes.md"); using (var dlg = new ShowReleaseNotesDialog(this.FindForm().Icon, path)) { dlg.ShowDialog(); } }
private void OnAboutLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string path = FileLocator.GetFileDistributedWithApplication(true, "about.htm"); using (var dlg = new SIL.Windows.Forms.Miscellaneous.SILAboutBox(path)) { dlg.ShowDialog(); } }
private bool ProcessCssFile(IRequestInfo info, string localPath) { // BL-2219: "OriginalImages" means we're generating a pdf and want full images, // but it has nothing to do with css files and defeats the following 'if' localPath = localPath.Replace(OriginalImageMarker + "/", ""); // is this request the full path to a real file? if (RobustFile.Exists(localPath) && Path.IsPathRooted(localPath)) { // Typically this will be files in the book or collection directory, since the browser // is supplying the path. // currently this only applies to settingsCollectionStyles.css, and customCollectionStyles.css var cssFile = Path.GetFileName(localPath); if ((cssFile == "settingsCollectionStyles.css") || (cssFile == "customCollectionStyles.css")) { info.ContentType = "text/css"; info.ReplyWithFileContent(localPath); return(true); } } // if not a full path, try to find the correct file var fileName = Path.GetFileName(localPath); // try to find the css file in the xmatter and templates if (_fileLocator == null) { _fileLocator = Program.OptimizedFileLocator; } var path = _fileLocator.LocateFile(fileName); // if still not found, and localPath is an actual file path, use it if (string.IsNullOrEmpty(path) && RobustFile.Exists(localPath)) { path = localPath; } if (string.IsNullOrEmpty(path)) { // it's just possible we need to add BloomBrowserUI to the path (in the case of the AddPage dialog) var lastTry = FileLocator.GetFileDistributedWithApplication(true, BloomFileLocator.BrowserRoot, localPath); if (RobustFile.Exists(lastTry)) { path = lastTry; } } // return false if the file was not found if (string.IsNullOrEmpty(path)) { return(false); } info.ContentType = "text/css"; info.ReplyWithFileContent(path); return(true); }
/// ------------------------------------------------------------------------------------ public static void ShowHelpTopic(string topicLink) { var path = FileLocator.GetFileDistributedWithApplication("SayMore.chm"); Help.ShowHelp(new Label(), path, topicLink); Analytics.Track("Show Help Topic", new Dictionary <string, string> { { "topicLink", topicLink } }); }
public static ScrStylesheet GetUsfmScrStylesheet() { if (s_usfmStyleSheet != null) { return(s_usfmStyleSheet); } string usfmStylesheetPath = FileLocator.GetFileDistributedWithApplication("sfm", "usfm.sty"); return(s_usfmStyleSheet = new ScrStylesheet(usfmStylesheetPath)); }
/// <summary> /// This can be used to find the best localized file when there is only one file with the given name, /// and the file is part of the files distributed with Bloom (i.e., not something in a downloaded template). /// </summary> public static string GetBestLocalizableFileDistributedWithApplication(bool existenceOfEnglishVersionIsOptional, params string[] partsOfEnglishFilePath) { var englishPath = FileLocator.GetFileDistributedWithApplication(existenceOfEnglishVersionIsOptional, partsOfEnglishFilePath); if (!RobustFile.Exists(englishPath)) { return(englishPath); // just return whatever the original GetFileDistributedWithApplication gave. "", null, whatever it is. } return(BloomFileLocator.GetBestLocalizedFile(englishPath)); }
private static string GetPathToBundledFFmpeg() { try { return(FileLocator.GetFileDistributedWithApplication("ffmpeg", "ffmpeg.exe")); } catch (Exception) { return(string.Empty); } }
private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { //we delay making one of these until we have to if (tabControl1.SelectedIndex == 1 && _aboutPage.Controls.Count == 0) { var webBrowser = new WebBrowser(); webBrowser.Dock = DockStyle.Fill; _aboutPage.Controls.Add(webBrowser); var path = FileLocator.GetFileDistributedWithApplication("distfiles", "about.htm"); webBrowser.Navigate(path); } }
public string Encode(string sourcePath, string destPathWithoutExtension) { string args = string.Format("\"{0}\" \"{1}.{2}\"", sourcePath, destPathWithoutExtension, FormatName); string exePath = FileLocator.GetFileDistributedWithApplication("sox", "sox.exe"); var result = CommandLineRunner.Run(exePath, args, "", 60, new ConsoleProgress()); if (result.StandardError.Contains("FAIL")) { return(null); } return(destPathWithoutExtension + "." + FormatName); }
/// ------------------------------------------------------------------------------------ private static void Load() { s_loadAttempted = true; try { var filename = FileLocator.GetFileDistributedWithApplication(App.ConfigFolderName, "NormalizationExceptions.xml"); s_exceptionsList = XmlSerializationHelper.DeserializeFromFile <List <NormalizationException> >(filename); } catch { } }