/// <summary> /// Converts a native language structure to a Language object. /// </summary> /// <param name="language"> /// The structure to convert. /// </param> /// <returns> /// The converted structure. /// </returns> public static Language NativeToLanguage(iso639_lang_t language) { string englishName = InteropUtilities.ToStringFromUtf8Ptr(language.eng_name); string nativeName = InteropUtilities.ToStringFromUtf8Ptr(language.native_name); return(new Language { Code = language.iso639_2, EnglishName = englishName, NativeName = nativeName }); }
/// <summary> /// Checks the status of the ongoing scan. /// </summary> private void PollScanProgress() { IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle); string statusJson = Marshal.PtrToStringAnsi(json); JsonState state = JsonConvert.DeserializeObject <JsonState>(statusJson); if (state.State == NativeConstants.HB_STATE_SCANNING) { if (this.ScanProgress != null) { this.ScanProgress(this, new ScanProgressEventArgs { Progress = state.Scanning.Progress, CurrentPreview = state.Scanning.Preview, Previews = state.Scanning.PreviewCount, CurrentTitle = state.Scanning.Title, Titles = state.Scanning.TitleCount }); } } else if (state.State == NativeConstants.HB_STATE_SCANDONE) { this.titles = new List <Title>(); var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle); string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg); JsonScanObject scanObject = JsonConvert.DeserializeObject <JsonScanObject>(scanJson); foreach (Title title in ScanFactory.CreateTitleSet(scanObject)) { // Set the Main Title. this.featureTitle = title.IsMainFeature ? title.TitleNumber : 0; this.titles.Add(title); } this.scanPollTimer.Stop(); if (this.ScanCompleted != null) { this.ScanCompleted(this, new System.EventArgs()); } } }