private void SaveTrailers() { OMLApplication.ExecuteSafe(delegate { OMLSettings.TrailersDefinition = _trailersDefinition.Chosen as string; }); }
public void AddCurrentTitle() { if (TitleCollectionManager.ContainsDisks(CurrentTitle.Disks)) { OMLApplication.DebugLine("[Setup UI] Skipping title: " + CurrentTitle.Name + " because already in the collection"); AddInHost.Current.MediaCenterEnvironment.Dialog(CurrentTitle.Name + " was found to already exist in your database and has been skipped.", "Skipped Title", DialogButtons.Ok, 2, false); TotalTitlesSkipped++; } else { OMLApplication.DebugLine("[Setup UI] Adding title: " + CurrentTitle.Id); //_titleCollection.Add(CurrentTitle); TotalTitlesAdded++; } CurrentTitleIndex++; if (TotalTitlesFound > CurrentTitleIndex) { CurrentTitle = _titles[CurrentTitleIndex]; } else { AllTitlesProcessed = true; } }
private void SaveUILanguage() { OMLApplication.ExecuteSafe(delegate { OMLSettings.UILanguage = CultureIdFromDisplayName(_uiLanguage.Chosen as string); }); }
public void AddAllCurrentTitles() { OMLApplication.DebugLine("[Setup] Starting deferred all titles import"); Application.DeferredInvokeOnWorkerThread(delegate { OMLApplication.DebugLine("[Setup] AddingAllCurrentTitles Started"); AddingAllStarted = true; for (CurrentTitleIndex = CurrentTitleIndex; TotalTitlesFound > CurrentTitleIndex; CurrentTitleIndex++) { CurrentTitle = _titles[CurrentTitleIndex]; if (TitleCollectionManager.ContainsDisks(CurrentTitle.Disks)) { OMLApplication.DebugLine("[Setup UI] Skipping title: " + CurrentTitle.Name + " because already in the collection"); TotalTitlesSkipped++; } else { OMLApplication.DebugLine("[Setup UI] Adding title: " + CurrentTitle.Id); //_titleCollection.Add(CurrentTitle); TotalTitlesAdded++; } } }, delegate { OMLApplication.DebugLine("[Setup] AddingAllCurrentTitles Completed"); AddingAllComplete = true; AllTitlesProcessed = true; FirePropertyChanged("TotalTitlesAdded"); }, null); }
public Setup() { LoadPlugins(); AllTitlesProcessed = false; CurrentTitle = null; CurrentTitleIndex = 0; current = this; //_titleCollection.loadTitleCollection(); _ImporterSelection = new Choice(); List <string> _Importers = new List <string>(); foreach (OMLPlugin _plugin in availablePlugins) { OMLApplication.DebugLine("[Setup] Adding " + _plugin.Name + " to the list of Importers"); _Importers.Add(_plugin.Description); } _ImporterSelection.Options = _Importers; _ImporterSelection.ChosenChanged += delegate(object sender, EventArgs e) { OMLApplication.ExecuteSafe(delegate { Choice c = (Choice)sender; ImporterDescription = @"Notice: " + GetPlugin().SetupDescription(); OMLApplication.DebugLine("Item Chosed: " + c.Options[c.ChosenIndex]); }); }; }
public void AddCheckedNode(TreeNode node) { OMLApplication.DebugLine("Adding node: " + node.FullPath); TreeView.CheckedNodes.Add(node); FirePropertyChanged("CheckedNodes"); HasCheckedNodes = true; }
public bool PlayMovie() { if (FileScanner.IsDVD(_mediaPath)) { bool isUNC = false; string path = FileScanner.GetPlayStringForPath(_mediaPath); // the unc path requires that it start with // so remove \\ if it exists //http://discuss.mediacentersandbox.com/forums/thread/9307.aspx if (path.StartsWith("\\\\")) { path = path.Substring(2); isUNC = true; } path = path.Replace("\\", "/"); if (OMLApplication.IsWindows7 && isUNC) { path = string.Format("//{0}", path); } else { path = string.Format("DVD://{0}", path); } OMLApplication.DebugLine("[MoviePlayerDVD] Actual play string being passed to PlayMovie: {0}", path); return(PlayMovie(path)); } return(false); }
private void DeleteOldRegistryKey(AddInHost host) { // remove old HKCU key that caused settings to appear on the TV+Movies menu strip if (!host.MediaCenterEnvironment.Capabilities.ContainsKey("Console")) { try { RegistryKey delKeyValue = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\" + @"Media Center\Extensibility\Categories\Services\" + @"Movies\{543d0438-b10d-43d8-a20d-f0c96db4e6bd}", true); if (delKeyValue != null) { OMLApplication.DebugLine("[Launch] Deleting old registry key value"); delKeyValue.DeleteValue(@"UseCount"); } } catch (Exception) { } // we don't really care, just delete it if you find it try { RegistryKey delSubKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\" + @"Media Center\Extensibility\Categories\Services\Movies", true); if (delSubKey != null) { OMLApplication.DebugLine("[Launch] Deleting old registry key"); delSubKey.DeleteSubKey(@"{543d0438-b10d-43d8-a20d-f0c96db4e6bd}"); } } catch (Exception) { } // we don't really care, just delete it if you find it } }
private void Initialize(IEnumerable <Title> titles) { DateTime start = DateTime.Now; _jumpInListText = new EditableText(this); _jumpInListText.Value = String.Empty; //FocusedItem = new GalleryItem(this, "", "", null); _categoryChoice = new Choice(this, "Categories"); //CreateCategories(); _moviesVirtualList = new VirtualList(this, null); //CreateSortLookup(); if (_sortFunctionLookup.ContainsKey(OMLSettings.MovieSort)) { _currentSort = _sortFunctionLookup[OMLSettings.MovieSort]; } else { _currentSort = SortByNameAscending; } //SetupAlphaCharacters(); LoadMovies(titles); OMLApplication.DebugLine("[MovieGallery] Initialize: time: {0}, items: {1}", DateTime.Now - start, this._movies.Count); }
public void PlayMedia() { OMLApplication.DebugLine("Playing trailer: {0}", this.TrailerUrl); AddInHost.Current.MediaCenterEnvironment.PlayMedia(Microsoft.MediaCenter.MediaType.Video, this.TrailerUrl, false); AddInHost.Current.MediaCenterEnvironment.MediaExperience.GoToFullScreen(); AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged += new PropertyChangedEventHandler(Transport_PropertyChanged); }
/// <summary> /// A callback that gets called when the movie is selected /// </summary> /// <param name="sender">The sender is a MovieItem.</param> /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param> //public override void ItemSelected(object sender, EventArgs args) //{ // OMLApplication.ExecuteSafe(delegate // { // MovieItem galleryItem = (MovieItem)sender; // // Navigate to a details page for this item. // MovieDetailsPage page = CreateDetailsPage(galleryItem); // Gallery.JumpInListText.Value = ""; // Gallery.ClearJumpValue = true; // OMLApplication.Current.GoToDetails(page); // }); //} /// <summary> /// Creates the details page for this movie /// </summary> /// <param name="item">The movie item.</param> /// <returns></returns> //public MovieDetailsPage CreateDetailsPage(MovieItem item) //{ // OMLApplication.DebugLine("[MovieItem] Creating a detailspage for {0}", item); // return new MovieDetailsPage(item); //} private void IncrementPlayCount() { OMLApplication.ExecuteSafe(delegate { TitleCollectionManager.IncrementWatchedCount(this.TitleObject); }); }
public void LocateExternalPlayerExecutable(Choice selector, EditableText textBox, Choice localFixedDrive) { string driveLetterToScan = localFixedDrive.Chosen as String; DriveInfo dInfo = new DriveInfo(driveLetterToScan); string startPath = null; switch ((ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), selector.Chosen.ToString())) { case ExternalPlayer.KnownPlayers.WinDVD9: startPath = DefaultWinDVD9Path; break; case ExternalPlayer.KnownPlayers.PowerDVD8: startPath = DefaultPowerDVD8Path; break; case ExternalPlayer.KnownPlayers.TotalMediaTheater: startPath = DefaultTMTPath; break; // don't do anything if there's no mounting tool selected case ExternalPlayer.KnownPlayers.None: case ExternalPlayer.KnownPlayers.Other: default: return; } if (File.Exists(Path.Combine(dInfo.RootDirectory.FullName, startPath))) { textBox.Value = Path.Combine(dInfo.RootDirectory.FullName, startPath); } else { // let's scan all the folders for it OMLApplication.Current.IsBusy = true; Application.DeferredInvokeOnWorkerThread(delegate { exePath = ScanAllFoldersForExecutable(dInfo.RootDirectory.FullName, Path.GetFileName(startPath)); }, delegate { OMLApplication.Current.IsBusy = false; if (exePath.Length > 0) { OMLApplication.DebugLine("[Settings] Found Image Mounter: {0}", exePath); textBox.Value = exePath; } else { AddInHost.Current.MediaCenterEnvironment.Dialog( string.Format("The external player was not" + " found on the [{0}] drive.", driveLetterToScan), "Failed to Find External Player", Microsoft.MediaCenter.DialogButtons.Ok, 5, true); } }, null); } }
private void SaveImpersonationSettings() { OMLApplication.ExecuteSafe(delegate { OMLSettings.ImpersonationUsername = _impersonationUsername.Value; OMLSettings.ImpersonationPassword = _impersonationPassword.Value; }); }
public MoviePlayerWPL(MediaSource source) { _mItem = source; OMLApplication.DebugLine("[MoviePlayerWPL] Loading for playlist: " + _mItem.MediaPath); _wplm = new WindowsPlayListManager(_mItem.MediaPath); _currentItem = 0; }
public void PlayDiskWithOptions() { OMLApplication.ExecuteSafe(delegate { // Play the Selected Disk _movieDetails.PlayMovie(); _playClicked = false; // I use the private variable because I don't want to send an event to the MCML page }); }
public void SearchForTitle(Title t) { UriBuilder uri = new UriBuilder(API_URL_SEARCH); uri.Query = "api_key=" + API_KEY + "&title=" + t.OriginalName; WebRequest req = HttpWebRequest.Create(uri.Uri); WebResponse res = req.GetResponse(); Stream stream = res.GetResponseStream(); XmlDocument xDoc = new XmlDocument(); xDoc.Load(stream); XmlNodeList possibleMovieNodes = xDoc.SelectNodes("//moviematches//movie"); foreach (XmlNode posssibleMovieNode in possibleMovieNodes) { XPathNavigator nav = posssibleMovieNode.CreateNavigator(); string strScore = GetChildNodesValue(nav, "score"); if (!string.IsNullOrEmpty(strScore)) { double score = 0; try { double.TryParse(strScore, out score); if (score == 1.0) { // its a perfect match, take it! IList <string> backDropUrls = GrabBackDropUrls(nav); DownloadBackDropsForTitle(t, backDropUrls); } else if (score >= 8.0) { // ok, its not perfect but its pretty good, take the top one IList <string> backDropUrls = GrabBackDropUrls(nav); DownloadBackDropsForTitle(t, backDropUrls); } } catch (Exception) { OMLApplication.DebugLine("[TheMovieDbBackDropDownloader] Unable to parse a double from a string: {0}", strScore); } } } if (stream != null) { stream.Close(); } if (res != null) { res.Close(); } }
private void SaveExternalPlayers() { OMLApplication.ExecuteSafe(delegate { List <string> mappings = new List <string>(); try { string chosenBluRayPlayer = _externalPlayerSelectionBluRay.Chosen as string; ExternalPlayer.KnownPlayers bluRayPlayer = (ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), chosenBluRayPlayer); if (bluRayPlayer != ExternalPlayer.KnownPlayers.None) { if (!string.IsNullOrEmpty(_externalPlayerPathBluRay.Value) && _externalPlayerPathBluRay.Value.Trim().Length != 0) { mappings.Add(VideoFormat.BLURAY.ToString() + "|" + ((int)bluRayPlayer).ToString() + "|" + _externalPlayerPathBluRay.Value.Trim()); } } string chosenHDDVDPlayer = _externalPlayerSelectionHDDVD.Chosen as string; ExternalPlayer.KnownPlayers hddvdPlayer = (ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), chosenHDDVDPlayer); if (hddvdPlayer != ExternalPlayer.KnownPlayers.None) { if (!string.IsNullOrEmpty(_externalPlayerPathHDDVD.Value) && _externalPlayerPathHDDVD.Value.Trim().Length != 0) { mappings.Add(VideoFormat.HDDVD.ToString() + "|" + ((int)hddvdPlayer).ToString() + "|" + _externalPlayerPathHDDVD.Value.Trim()); } } string chosenAllPlayer = _externalPlayerSelectionAll.Chosen as string; ExternalPlayer.KnownPlayers allPlayer = (ExternalPlayer.KnownPlayers)Enum.Parse(typeof(ExternalPlayer.KnownPlayers), chosenAllPlayer); if (allPlayer != ExternalPlayer.KnownPlayers.None) { if (!string.IsNullOrEmpty(_externalPlayerPathAll.Value) && _externalPlayerPathAll.Value.Trim().Length != 0) { mappings.Add(VideoFormat.ALL.ToString() + "|" + ((int)allPlayer).ToString() + "|" + _externalPlayerPathAll.Value.Trim()); } } OMLSettings.ExternalPlayerMapping = mappings; ExternalPlayer.RefreshExternalPlayerList(); } catch (Exception ex) { Utilities.DebugLine("[Settings] Error saving external player settings", ex); } }); }
public void Reset() { OMLApplication.DebugLine("Resetting the Setup object"); _AllTitlesProcessed = false; _currentTitle = null; _currentTitleIndex = 0; _filename = string.Empty; _loadComplete = false; _loadStarted = false; _titles = null; //_titleCollection.loadTitleCollection(); _treeView.CheckedNodes.Clear(); }
public void Initialize(Dictionary <string, object> appInfo, Dictionary <string, object> entryPointInfo) { if (entryPointInfo.ContainsKey("Context")) { _id = (string)entryPointInfo["Context"]; } OMLApplication.DebugLine("[Launch] Initialize() id: {0}", _id); StartOMLEngineService(); OMLEngine.Utilities.RawSetup(); }
public void Uninitialize() { if (OMLApplication.Current != null) { if (OMLApplication.Current.IsExtender && this.imp != null) { this.imp.Leave(); } OMLApplication.Current.Uninitialize(); OMLApplication.DebugLine("[Launch] Uninitialize"); } }
public void RemoveCheckedNode(TreeNode node) { OMLApplication.DebugLine("Removing node: " + node.Title); if (TreeView.CheckedNodes.Contains(node)) { TreeView.CheckedNodes.Remove(node); FirePropertyChanged("CheckedNodes"); } if (TreeView.CheckedNodes.Count > 0) { HasCheckedNodes = false; } }
public OMLPlugin GetPlugin() { string strChosenImporter = (string)Setup.Current._ImporterSelection.Chosen; OMLApplication.DebugLine("Chosen Importer is: " + strChosenImporter); for (int i = 0; i < availablePlugins.Count; i++) { if (availablePlugins[i].Description.CompareTo(strChosenImporter) == 0) { return(availablePlugins[i]); } } return(null); }
public TreeNode(String title, String fullPath) { Title = title; FullPath = fullPath; Checked.ChosenChanged += delegate(object sender, EventArgs e) { OMLApplication.ExecuteSafe(delegate { // this is the one that works OMLApplication.DebugLine("Changed: " + this.GetType().ToString()); Setup.Current.AddCheckedNode(this); }); }; }
static void MergeFile(FileStream writter, string vob0, string vobx) { byte[] buffer = new byte[128 * 1024 * 1024]; OMLApplication.DebugLine("[MoviePlayerExtenderDVD] Appending '{0}' to '{1}'", vobx, vob0); using (FileStream reader = File.OpenRead(vobx)) for (; ;) { int read = reader.Read(buffer, 0, buffer.Length); if (read == 0) { break; } writter.Write(buffer, 0, read); } }
public void PlayAllDisks() { if (!((bool)_watched.Chosen)) { _watched.Chosen = true; } OMLApplication.ExecuteSafe(delegate { // Play the Selected Disk PlayClicked = true; _movieDetails.PlayAllDisks(); _playClicked = false; // I use the private variable because I don't want to send an event to the MCML page }); }
public void UpdateWatched() { OMLApplication.ExecuteSafe(delegate { bool watched = (bool)_watched.Chosen; if (watched && _movieDetails.TitleObject.WatchedCount == 0) { TitleCollectionManager.IncrementWatchedCount(_movieDetails.TitleObject); } else if (!watched && _movieDetails.TitleObject.WatchedCount != 0) { TitleCollectionManager.ClearWatchedCount(_movieDetails.TitleObject); } }); }
public void NoTitlesFoundNotice() { OMLApplication.Current.MediaCenterEnvironment.Dialog("No titles were found, would you like to try again?", "Notice", new object[] { DialogButtons.Yes, DialogButtons.No, }, 0, true, null, delegate(DialogResult result) { OMLApplication.DebugLine("[Setup UI] _NoTitlesFoundNoticeCallback called"); if (result.CompareTo(DialogButtons.Yes) == 0) { OMLApplication.Current.MediaCenterEnvironment.Dialog("This functionality has not been completed", "Notice", DialogButtons.Ok, 10, false); } }); }
public void SaveSettings() { SaveMountingTools(); SaveMovieSettings(); SaveUILanguage(); SaveTrailers(); SaveFilterSettings(); SaveTranscoding(); SaveImpersonationSettings(); SaveExternalPlayers(); OMLApplication.ExecuteSafe(delegate { OMLApplication.Current.Startup(null); }); }
void Transport_PropertyChanged(IPropertyObject sender, string property) { OMLApplication.ExecuteSafe(delegate { MediaTransport t = (MediaTransport)sender; Utilities.DebugLine("MoviePlayerTranscode.Transport_PropertyChanged: movie {0} property {1} playrate {2} state {3} pos {4}", OMLApplication.Current.NowPlayingMovieName, property, t.PlayRate, t.PlayState.ToString(), t.Position.ToString()); if (property == "PlayState") { if (t.PlayState == PlayState.Finished || t.PlayState == PlayState.Stopped) { transcoder.Stop(false); Utilities.DebugLine("MoviePlayerTranscode.Transport_PropertyChanged: movie {0} Finished", OMLApplication.Current.NowPlayingMovieName); OMLApplication.Current.NowPlayingStatus = PlayState.Finished; } } }); }
private static string ScanAllFoldersForExecutable(string dir, string executable) { if (!Directory.Exists(dir)) { return(string.Empty); } string tmtPath = string.Empty; DirectoryInfo dInfo; FileSystemInfo[] items = new FileSystemInfo[0]; // this just needs to be init'd try { dInfo = new DirectoryInfo(dir); items = dInfo.GetFileSystemInfos(); } catch (Exception e) { OMLApplication.DebugLine("Caught exception trying to scan {0}: {1}", dir, e.Message); } foreach (FileSystemInfo item in items) { if (item is DirectoryInfo) { DirectoryInfo dirInfo = item as DirectoryInfo; OMLApplication.DebugLine("[Settings] Scanning folder [{0}] for TMT", dirInfo.FullName); tmtPath = ScanAllFoldersForExecutable(dirInfo.FullName, executable); if (!string.IsNullOrEmpty(tmtPath)) { return(tmtPath); } } if (item is FileInfo) { FileInfo fInfo = item as FileInfo; if (fInfo.Name.Equals(executable, StringComparison.OrdinalIgnoreCase)) { return(fInfo.FullName); } } } return(string.Empty); }
private void BeginStart(object host) { OMLApplication.DebugLine("[Launch] Launch called"); if (TestDBConnection((AddInHost)host)) { DeleteOldRegistryKey((AddInHost)host); if (app == null) { OMLApplication.DebugLine("[Launch] No Application found, creating..."); app = new OMLApplication(s_session, (AddInHost)host); } try { if (OMLApplication.Current.IsExtender) { this.imp = new Impersonator(); this.imp.Enter(); } } catch (Exception ex) { OMLApplication.DebugLine("Exception during this.imp.Enter(): {0}", ex); } app.Startup(_id); } else { //just going to do a retry for now-need to allow db change later... List<string> buttons = new List<string>(); buttons.Add("Retry"); buttons.Add("Cancel"); Microsoft.MediaCenter.DialogResult res = ((AddInHost)host).MediaCenterEnvironment.Dialog("Unable to communicate with database. Would you like to retry or cancel?", "OPEN MEDIA LIBRARY", buttons, -1, true, null, delegate(Microsoft.MediaCenter.DialogResult dialogResult) { }); if ((int)res == 100) { Microsoft.MediaCenter.UI.Application.DeferredInvoke(new Microsoft.MediaCenter.UI.DeferredHandler(this.BeginStart), (object)host, new TimeSpan(1)); } else { s_session.Close(); } } }
public void LoadGallery(OMLApplication app) { // app.Startup(null); app.GoToBackPage(); }