public void UnlockPinEntered(bool pinCorrect) { MediaCenterEnvironment env = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; if (pinCorrect) { unlockLibrary(); env.Dialog(string.Format(Application.CurrentInstance.StringData("LibraryUnlockedDial"), this.unlockPeriod.ToString()), Application.CurrentInstance.StringData("LibraryUnlockedCapDial"), DialogButtons.Ok, 60, true); Application.CurrentInstance.Back(); //clear PIN screen if (Config.Instance.HideParentalDisAllowed) { if (Application.CurrentInstance.CurrentFolder != null && Application.CurrentInstance.CurrentFolder != Application.CurrentInstance.RootFolderModel) { Application.CurrentInstance.CurrentFolder.RefreshChildren(); } if (Application.CurrentInstance.RootFolderModel != null) { Application.CurrentInstance.RootFolderModel.RefreshChildren(); } } } else { env.Dialog(Application.CurrentInstance.StringData("IncorrectPINDial"), Application.CurrentInstance.StringData("LibraryUnlockedCapDial"), DialogButtons.Ok, 60, true); Application.CurrentInstance.Back(); //clear PIN screen Logger.ReportInfo("PIN Incorrect attempting to unlock library."); } }
public void DeleteMediaItem(Item Item) { // Setup variables MediaCenterEnvironment mce = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; var msg = "Are you sure you wish to delete this media item?"; var caption = "Delete Confirmation"; // Present dialog DialogResult dr = mce.Dialog(msg, caption, DialogButtons.No | DialogButtons.Yes, 0, true); if (dr == DialogResult.Yes) { // Perform itemtype and configuration checks if (Item.ItemType == ItemType.Movie && (this.Config.Advanced_EnableDelete == true && this.Config.EnableAdvancedCmds == true) ) { Item Parent = Item.PhysicalParent; string path = Item.Path; try { if (Directory.Exists(path)) { Directory.Delete(path, true); } else if (File.Exists(path)) { File.Delete(path); } } catch (IOException) { mce.Dialog("The selected media item cannot be deleted due to an invalid path. Or you may not have sufficient access rights to perform this command.", "Delete Failed", DialogButtons.Ok, 0, true); } catch (Exception) { mce.Dialog("The selected media item cannot be deleted due to an unknown error.", "Delete Failed", DialogButtons.Ok, 0, true); } Back(); // Back to the Parent Item; This parent still contains old data. // These tricks are required in order to load the parent item with "fresh" data. if (session.BackPage()) // Double Back to the GrandParent because history still has old parent. { Navigate(Parent); // Navigate forward to Parent } else // No GrandParent to go back to. { Navigate(Parent); // Navigate to the parent again - this will refresh the objects session.BackPage(); // Now safe to go back to previous parent, and keep session history valid } } else { mce.Dialog("The selected media item cannot be deleted due to its Item-Type or you have not enabled this feature in the configuration file.", "Delete Failed", DialogButtons.Ok, 0, true); } } }
public void ResetConfig() { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; DialogResult r = ev.Dialog("Are you sure you wish to reset all configuration to defaults?", "Reset Configuration", DialogButtons.Yes | DialogButtons.No, 60, true); if (r == DialogResult.Yes) { Config.Instance.Reset(); ev.Dialog("Please restart Media Browser", "Configuration Reset", DialogButtons.Ok, 60, true); Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); } }
private bool Load() { try { this.data = ConfigData.FromFile(configFilePath); return(true); } catch (Exception ex) { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; DialogResult r = ev.Dialog(ex.Message + "\nReset to default?", "Error in configuration file", DialogButtons.Yes | DialogButtons.No, 600, true); if (r == DialogResult.Yes) { if (!Directory.Exists(configFolderPath)) { Directory.CreateDirectory(configFolderPath); } this.data = new ConfigData(configFilePath); Save(); return(true); } else { return(false); } } }
public void FinishInitialConfig() { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; ev.Dialog("Initial configuration is complete, please restart Media Browser", "Restart", DialogButtons.Ok, 60, true); Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); }
private static ConfigData GetConfig() { ConfigData config = null; try { config = ConfigData.FromFile(ApplicationPaths.ConfigFile); } catch (Exception ex) { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; DialogResult r = ev.Dialog(ex.Message + "\n" + Application.CurrentInstance.StringData("ConfigErrorDial"), Application.CurrentInstance.StringData("ConfigErrorCapDial"), DialogButtons.Yes | DialogButtons.No, 600, true); if (r == DialogResult.Yes) { config = new ConfigData(ApplicationPaths.ConfigFile); config.Save(); } else { Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); } } return(config); }
public void PlaySecure(bool resume, bool queue) { try { if (this.IsPlayable || this.IsFolder) { if (PlayableItem.PlaybackController != Application.CurrentInstance.PlaybackController && PlayableItem.PlaybackController.RequiresExternalPage) { Application.CurrentInstance.OpenExternalPlaybackPage(this); } this.PlayableItem.QueueItem = queue; this.PlayableItem.PlaybackController.MetaDuration = this.BaseItem is Video && (this.baseItem as Video).RunningTime != null ? (this.baseItem as Video).RunningTime.Value : 0; this.PlayableItem.Play(this.PlayState, resume); if (!this.IsFolder && this.TopParent != null) { this.TopParent.AddNewlyWatched(this); //add to watched list if not a whole folder } } } catch (Exception e) { Logger.ReportException("Error playing item " + this.Name, e); MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; ev.Dialog(Application.CurrentInstance.StringData("ContentErrorDial") + "\n" + baseItem.Path, Application.CurrentInstance.StringData("ContentErrorCapDial"), DialogButtons.Ok, 60, true); } }
public static DialogResult DisplayDialog(string message, string caption, DialogButtons buttons, int timeout) { // We won't be able to take this during a page transition. This is good! // Conversly, no new pages can be navigated while this is present. lock (syncObj) { DialogResult result = MediaCenterEnvironment.Dialog(message, caption, buttons, timeout, true); return(result); } }
public void ClearCache() { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; DialogResult r = ev.Dialog("Are you sure you wish to clear the cache?\nThis will erase all cached and downloaded information and images.", "Clear Cache", DialogButtons.Yes | DialogButtons.No, 60, true); if (r == DialogResult.Yes) { bool ok = Kernel.Instance.ItemRepository.ClearEntireCache(); if (!ok) { ev.Dialog("An error occured during the clearing of the cache, you may wish to manually clear it from " + ApplicationPaths.AppCachePath + " before restarting Media Browser", "Error", DialogButtons.Ok, 60, true); } else { ev.Dialog("Please restart Media Browser", "Cache Cleared", DialogButtons.Ok, 60, true); } Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); } }
public void PlayPinEntered(bool pinCorrect) { Application.CurrentInstance.Back(); //clear the PIN page before playing MediaCenterEnvironment env = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; if (pinCorrect) { Logger.ReportInfo("Playing protected content " + anItem.Name); this.anItem.PlaySecure(resume, queue); } else { env.Dialog(Application.CurrentInstance.StringData("IncorrectPINDial"), Application.CurrentInstance.StringData("ContentProtected"), DialogButtons.Ok, 60, true); Logger.ReportInfo("Pin Incorrect attempting to play " + anItem.Name); } }
public void NewPinEntered(bool pinCorrect) { MediaCenterEnvironment env = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; if (pinCorrect) { Logger.ReportInfo("Entering New PIN"); gettingNewPIN = true; //set flag Application.CurrentInstance.OpenSecurityPage(Application.CurrentInstance.StringData("EnterNewPINDial")); } else { env.Dialog(Application.CurrentInstance.StringData("IncorrectPINDial"), Application.CurrentInstance.StringData("CantChangePINDial"), DialogButtons.Ok, 60, true); Logger.ReportInfo("PIN Incorrect attempting change PIN "); } }
// Entry point for the app public void GoToMenu() { try { if (Config.IsFirstRun) { OpenConfiguration(false); MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; ev.Dialog("As this is the first time you have run Media Browser please setup the inital configuration", "Configure", DialogButtons.Ok, 60, true); } else { // We check config here instead of in the Updater class because the Config class // CANNOT be instantiated outside of the application thread. if (Config.EnableUpdates) { Updater update = new Updater(this); Async.Queue(update.checkUpdate); } Async.Queue(() => { using (new Profiler("Full Library Refresh")) { try { FullRefresh(this.RootFolder); } catch (Exception ex) { Logger.ReportException("Failed to refresh library! ", ex); Debug.Assert(false, "Full refresh thread should never crash!"); } } }); BaseItem initial = this.RootFolder; OpenFolderPage((MediaBrowser.Library.FolderModel)ItemFactory.Instance.Create(initial)); } } catch (Exception e) { Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment.Dialog("Media Browser encountered a critical error and had to shut down: " + e.ToString() + " " + e.StackTrace.ToString(), "Critical Error", DialogButtons.Ok, 60, true); Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); } }
/// <summary> /// Displays a simple "OK" message box, branded with the Z logo. /// </summary> public void MessageBox(string text, string caption, int timeout, bool modal) { if (MediaCenterEnvironment == null) { Debug.WriteLine(String.Format("Dialog {0}: {1}", caption, text)); return; } MediaCenterEnvironment.Dialog( text, caption, new object[] { DialogButtons.Ok }, timeout, modal, "resx://Z,Version=7.0.0.0,PublicKeyToken=2f4e6f203aa84589,Culture=neutral/Z.Resources/ZLogoProgramLibrary", delegate(DialogResult dialogResult) { }); }
public void UnwatchedPinEntered(bool pinCorrect) { Application.CurrentInstance.Back(); //clear the PIN page before playing MediaCenterEnvironment env = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; if (pinCorrect) { Logger.ReportInfo("Playing protected unwatched content " + anItem.Name); //add to list of protected folders we've entered addProtectedFolder(anItem as FolderModel); Application.CurrentInstance.PlayUnwatchedSecure(anItem); } else { env.Dialog(Application.CurrentInstance.StringData("IncorrectPINDial"), Application.CurrentInstance.StringData("ContentProtected"), DialogButtons.Ok, 60, true); Logger.ReportInfo("PIN Incorrect attempting to play unwatched in " + anItem.Name); } }
private void Play(bool resume) { try { if (this.IsPlayable) { if (PlayableItem.PlaybackController != Application.CurrentInstance.PlaybackController) { Application.CurrentInstance.OpenExternalPlaybackPage(this); } this.PlayableItem.Play(this.PlayState, resume); } } catch (Exception) { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; ev.Dialog("There was a problem playing the content. Check location exists\n" + baseItem.Path, "Content Error", DialogButtons.Ok, 60, true); } }
public void DialogTest(string strClickedText) { int timeout = 5; bool modal = true; string caption = Resources.DialogCaption; if (session != null) { MediaCenterEnvironment.Dialog(strClickedText, caption, new object[] { DialogButtons.Ok }, timeout, modal, null, delegate(DialogResult dialogResult) { }); } else { Debug.WriteLine("DialogTest"); } }
public void CustomPINEntered(string aPIN) { //Logger.ReportInfo("Custom PIN entered: " + aPIN); if (gettingNewPIN) { gettingNewPIN = false; Config.Instance.ParentalPIN = aPIN; MediaCenterEnvironment env = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; env.Dialog(Application.CurrentInstance.StringData("PINChangedDial"), Application.CurrentInstance.StringData("PINChangedCapDial"), DialogButtons.Ok, 60, true); Application.CurrentInstance.Back(); //clear PIN entry screen } else { pinCallback(aPIN == customPIN); if (pinCallback != UnlockPinEntered && aPIN == customPIN && aPIN == Config.Instance.ParentalPIN && Config.Instance.UnlockOnPinEntry) { //also unlock the library unlockLibrary(); Application.CurrentInstance.Information.AddInformationString(string.Format(Application.CurrentInstance.StringData("LibraryUnLockedProf"), this.unlockPeriod.ToString())); //and display a message } } }