/// <summary> /// Start point of the plugin. /// This method gets called by MediaPortal. /// </summary> public void Start() { // Log Handler Log.OnNewLog += new Log.NewLogHandler(OnNewLog); var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).LastWriteTime; Log.Info("Version {0}.{1}.{2}.{3}, build on {4} at {5}.", version.Major, version.Minor, version.Build, version.Revision, buildDate.ToShortDateString(), buildDate.ToLongTimeString()); Log.Debug("Loading settings."); Settings.LoadSettings(); Settings.SaveSettings(); Log.Debug("Initialising event handler."); // PowerModeChanged Handler SystemEvents.PowerModeChanged += PowerModeChanged; // Screensaver Handler if (Settings.monitorScreensaverState) { Thread screensaverMonitorThread = new Thread(monitorScreensaverState); screensaverMonitorThread.IsBackground = true; screensaverMonitorThread.Start(); } // g_Player Handler g_Player.PlayBackStarted += new g_Player.StartedHandler(g_Player_PlayBackStarted); g_Player.PlayBackStopped += new g_Player.StoppedHandler(g_Player_PlayBackStopped); g_Player.PlayBackEnded += new g_Player.EndedHandler(g_Player_PlayBackEnded); // FrameGrabber Handler MediaPortal.FrameGrabber.GetInstance().OnNewFrame += new MediaPortal.FrameGrabber.NewFrameHandler(AtmolightPlugin_OnNewFrame); // Button Handler GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); // Connection Lost Handler Core.OnNewConnectionLost += new Core.NewConnectionLostHandler(OnNewConnectionLost); // VU Meter Handler Core.OnNewVUMeter += new Core.NewVUMeterHander(OnNewVUMeter); staticColorTemp[0] = Settings.staticColorRed; staticColorTemp[1] = Settings.staticColorGreen; staticColorTemp[2] = Settings.staticColorBlue; Log.Debug("Generating new AtmoLight.Core instance."); coreObject = Core.GetInstance(); // General settings coreObject.SetDelay(Settings.delayReferenceTime); if (Settings.delay) { coreObject.EnableDelay(); } coreObject.SetGIFPath(Settings.gifFile); coreObject.SetReInitOnError(Settings.restartOnError); coreObject.SetStaticColor(Settings.staticColorRed, Settings.staticColorGreen, Settings.staticColorBlue); coreObject.SetCaptureDimensions(Settings.captureWidth, Settings.captureHeight); coreObject.blackbarDetection = Settings.blackbarDetection; coreObject.blackbarDetectionTime = Settings.blackbarDetectionTime; coreObject.blackbarDetectionThreshold = Settings.blackbarDetectionThreshold; coreObject.powerModeChangedDelay = Settings.powerModeChangedDelay; coreObject.vuMeterMindB = Settings.vuMeterMindB; coreObject.vuMeterMinHue = Settings.vuMeterMinHue; coreObject.vuMeterMaxHue = Settings.vuMeterMaxHue; coreObject.blackbarDetectionHorizontal = Settings.blackbarDetectionHorizontal; coreObject.blackbarDetectionVertical = Settings.blackbarDetectionVertical; coreObject.blackbarDetectionLinkAreas = Settings.blackbarDetectionLinkAreas; // AmbiBox coreObject.ambiBoxIP = Settings.ambiBoxIP; coreObject.ambiBoxPort = Settings.ambiBoxPort; coreObject.ambiBoxMaxReconnectAttempts = Settings.ambiBoxMaxReconnectAttempts; coreObject.ambiBoxReconnectDelay = Settings.ambiBoxReconnectDelay; coreObject.ambiBoxMediaPortalProfile = Settings.ambiBoxMediaPortalProfile; coreObject.ambiBoxExternalProfile = Settings.ambiBoxExternalProfile; coreObject.ambiBoxPath = Settings.ambiBoxPath; coreObject.ambiBoxAutoStart = Settings.ambiBoxAutoStart; coreObject.ambiBoxAutoStop = Settings.ambiBoxAutoStop; if (Settings.ambiBoxTarget) { coreObject.AddTarget(Target.AmbiBox); } // AtmoOrb coreObject.atmoOrbBlackThreshold = Settings.atmoOrbBlackThreshold; coreObject.atmoOrbBroadcastPort = Settings.atmoOrbBroadcastPort; coreObject.atmoOrbGamma = Settings.atmoOrbGamma; coreObject.atmoOrbLamps = Settings.atmoOrbLamps; coreObject.atmoOrbMinDiversion = Settings.atmoOrbMinDiversion; coreObject.atmoOrbSaturation = Settings.atmoOrbSaturation; coreObject.atmoOrbThreshold = Settings.atmoOrbThreshold; coreObject.atmoOrbUseOverallLightness = Settings.atmoOrbUseOverallLightness; if (Settings.atmoOrbTarget) { coreObject.AddTarget(Target.AtmoOrb); } // AtmoWin coreObject.atmoWinPath = Settings.atmowinExe; coreObject.atmoWinAutoStart = Settings.startAtmoWin; coreObject.atmoWinAutoStop = Settings.exitAtmoWin; if (Settings.atmoWinTarget) { coreObject.AddTarget(Target.AtmoWin); } // Boblight coreObject.boblightIP = Settings.boblightIP; coreObject.boblightPort = Settings.boblightPort; coreObject.boblightMaxFPS = Settings.boblightMaxFPS; coreObject.boblightMaxReconnectAttempts = Settings.boblightMaxReconnectAttempts; coreObject.boblightReconnectDelay = Settings.boblightReconnectDelay; coreObject.boblightSpeed = Settings.boblightSpeed; coreObject.boblightAutospeed = Settings.boblightAutospeed; coreObject.boblightInterpolation = Settings.boblightInterpolation; coreObject.boblightSaturation = Settings.boblightSaturation; coreObject.boblightValue = Settings.boblightValue; coreObject.boblightThreshold = Settings.boblightThreshold; coreObject.boblightGamma = Settings.boblightGamma; if (Settings.boblightTarget) { coreObject.AddTarget(Target.Boblight); } // Hyperion coreObject.hyperionIP = Settings.hyperionIP; coreObject.hyperionPort = Settings.hyperionPort; coreObject.hyperionPriority = Settings.hyperionPriority; coreObject.hyperionReconnectDelay = Settings.hyperionReconnectDelay; coreObject.hyperionReconnectAttempts = Settings.hyperionReconnectAttempts; coreObject.hyperionPriorityStaticColor = Settings.hyperionPriorityStaticColor; coreObject.hyperionLiveReconnect = Settings.hyperionLiveReconnect; if (Settings.hyperionTarget) { coreObject.AddTarget(Target.Hyperion); } // Hue coreObject.huePath = Settings.hueExe; coreObject.hueStart = Settings.hueStart; coreObject.hueIsRemoteMachine = Settings.hueIsRemoteMachine; coreObject.hueIP = Settings.hueIP; coreObject.huePort = Settings.huePort; coreObject.hueReconnectDelay = Settings.hueReconnectDelay; coreObject.hueReconnectAttempts = Settings.hueReconnectAttempts; coreObject.hueBridgeEnableOnResume = Settings.hueBridgeEnableOnResume; coreObject.hueBridgeDisableOnSuspend = Settings.hueBridgeDisableOnSuspend; coreObject.hueMinDiversion = Settings.hueMinDiversion; coreObject.hueThreshold = Settings.hueThreshold; coreObject.hueBlackThreshold = Settings.hueBlackThreshold; coreObject.hueSaturation = Settings.hueSaturation; coreObject.hueUseOverallLightness = Settings.hueUseOverallLightness; if (Settings.hueTarget) { coreObject.AddTarget(Target.Hue); } // Get the effects that are supported by at least one target supportedEffects = coreObject.GetSupportedEffects(); menuEffect = Settings.effectMenu; if (CheckForStartRequirements()) { coreObject.ChangeEffect(menuEffect, true); CalculateDelay(); } else { coreObject.ChangeEffect(ContentEffect.LEDsDisabled, true); } coreObject.Initialise(); }
private void Initialise() { // Log Handler Log.OnNewLog += new Log.NewLogHandler(OnNewLog); // Version Infos var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; DateTime buildDate = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).LastWriteTime; Log.Info("Version {0}.{1}.{2}.{3}, build on {4} at {5}.", version.Major, version.Minor, version.Build, version.Revision, buildDate.ToShortDateString(), buildDate.ToLongTimeString()); // Settings Log.Debug("Loading settings."); settings = new AtmoLight.Settings(); settings.LoadAll(); settings.SaveAll(); // AtmoLight object creation Log.Debug("Generating new AtmoLight.Core instance."); coreObject = Core.GetInstance(); // General settings coreObject.SetDelay(settings.DelayTime); if (settings.Delay) { coreObject.EnableDelay(); } coreObject.SetGIFPath(settings.GIFFile); coreObject.SetReInitOnError(settings.RestartAtmoWinOnError); coreObject.SetStaticColor(settings.StaticColorRed, settings.StaticColorGreen, settings.StaticColorBlue); coreObject.SetCaptureDimensions(settings.CaptureWidth, settings.CaptureHeight); coreObject.blackbarDetection = settings.BlackbarDetection; coreObject.blackbarDetectionTime = settings.BlackbarDetectionTime; coreObject.blackbarDetectionThreshold = settings.BlackbarDetectionThreshold; coreObject.powerModeChangedDelay = settings.PowerModeChangedDelay; coreObject.blackbarDetectionLinkAreas = settings.BlackbarDetectionLinkAreas; coreObject.blackbarDetectionHorizontal = settings.BlackbarDetectionHorizontal; coreObject.blackbarDetectionVertical = settings.BlackbarDetectionVertical; // API coreObject.apiServerEnabled = settings.RemoteApiServer; // AmbiBox coreObject.ambiBoxAutoStart = settings.AmbiBoxAutoStart; coreObject.ambiBoxAutoStop = settings.AmbiBoxAutoStop; coreObject.ambiBoxExternalProfile = settings.AmbiBoxExternalProfile; coreObject.ambiBoxIP = settings.AmbiBoxIP; coreObject.ambiBoxMaxReconnectAttempts = settings.AmbiBoxMaxReconnectAttempts; coreObject.ambiBoxMediaPortalProfile = settings.AmbiBoxMediaPortalProfile; coreObject.ambiBoxPath = settings.AmbiBoxPath; coreObject.ambiBoxPort = settings.AmbiBoxPort; coreObject.ambiBoxReconnectDelay = settings.AmbiBoxReconnectDelay; if (settings.AmbiBoxTarget) { coreObject.AddTarget(Target.AmbiBox); } // AtmoWin coreObject.atmoWinPath = settings.AtmoWinExe; coreObject.atmoWinAutoStart = settings.StartAtmoWinOnStart; coreObject.atmoWinAutoStop = settings.StopAtmoWinOnExit; coreObject.atmoWakeHelperEnabled = settings.AtmoWakeHelperEnabled; coreObject.atmoWakeHelperComPort = settings.AtmoWakeHelperComPort; coreObject.atmoWakeHelperResumeDelay = settings.AtmoWakeHelperResumeDelay; coreObject.atmoWakeHelperDisconnectDelay = settings.AtmoWakeHelperDisconnectDelay; coreObject.atmoWakeHelperConnectDelay = settings.AtmoWakeHelperConnectDelay; coreObject.atmoWakeHelperReinitializationDelay = settings.AtmoWakeHelperReinitializationDelay; if (settings.AtmoWinTarget) { coreObject.AddTarget(Target.AtmoWin); } // Boblight coreObject.boblightIP = settings.BoblightIP; coreObject.boblightPort = settings.BoblightPort; coreObject.boblightMaxFPS = settings.BoblightMaxFPS; coreObject.boblightMaxReconnectAttempts = settings.BoblightMaxReconnectAttempts; coreObject.boblightReconnectDelay = settings.BoblightReconnectDelay; coreObject.boblightSpeed = settings.BoblightSpeed; coreObject.boblightAutospeed = settings.BoblightAutospeed; coreObject.boblightInterpolation = settings.BoblightInterpolation; coreObject.boblightSaturation = settings.BoblightSaturation; coreObject.boblightValue = settings.BoblightValue; coreObject.boblightThreshold = settings.BoblightThreshold; coreObject.boblightGamma = settings.BoblightGamma; if (settings.BoblightTarget) { coreObject.AddTarget(Target.Boblight); } // Hyperion coreObject.hyperionIP = settings.HyperionIP; coreObject.hyperionPort = settings.HyperionPort; coreObject.hyperionPriority = settings.HyperionPriority; coreObject.hyperionReconnectDelay = settings.HyperionReconnectDelay; coreObject.hyperionReconnectAttempts = settings.HyperionReconnectAttempts; coreObject.hyperionPriorityStaticColor = settings.HyperionPriorityStaticColor; coreObject.hyperionLiveReconnect = settings.HyperionLiveReconnect; if (settings.HyperionTarget) { coreObject.AddTarget(Target.Hyperion); } //Hue coreObject.huePath = settings.hueExe; coreObject.hueStart = settings.hueStart; coreObject.hueIsRemoteMachine = settings.hueIsRemoteMachine; coreObject.hueIP = settings.HueIP; coreObject.huePort = settings.HuePort; coreObject.hueReconnectDelay = settings.HueReconnectDelay; coreObject.hueReconnectAttempts = settings.HueReconnectAttempts; coreObject.hueBridgeEnableOnResume = settings.HueBridgeEnableOnResume; coreObject.hueBridgeDisableOnSuspend = settings.HueBridgeDisableOnSuspend; coreObject.hueThreshold = settings.HueThreshold; coreObject.hueBlackThreshold = settings.HueBlackThreshold; coreObject.hueMinDiversion = settings.HueMinDiversion; coreObject.hueSaturation = settings.HueSaturation; coreObject.hueUseOverallLightness = settings.HueUseOverallLightness; coreObject.hueTheaterEnabled = settings.HueTheaterEnabled; coreObject.hueTheaterRestoreLights = settings.HueTheaterRestoreLights; if (settings.HueTarget) { coreObject.AddTarget(Target.Hue); } if (CheckForStartRequirements()) { coreObject.ChangeEffect(settings.MenuEffect, true, true); CalculateDelay(); } else { coreObject.ChangeEffect(ContentEffect.LEDsDisabled, true, true); } coreObject.Initialise(); // Handlers Core.OnNewConnectionLost += new Core.NewConnectionLostHandler(OnNewConnectionLost); Core.OnNewVUMeter += new Core.NewVUMeterHander(OnNewVUMeter); AtmoLight.Configuration.OnOffButton.ButtonsChanged += new Configuration.OnOffButton.ButtonsChangedHandler(ReregisterKeyBindings); AtmoLight.Configuration.ProfileButton.ButtonsChanged += new Configuration.ProfileButton.ButtonsChangedHandler(ReregisterKeyBindings); SkinContext.DeviceSceneEnd += UICapture; SystemEvents.PowerModeChanged += PowerModeChanged; if (settings.MonitorScreensaverState) { Thread screensaverMonitorThread = new Thread(monitorScreensaverState); screensaverMonitorThread.IsBackground = true; screensaverMonitorThread.Start(); } RegisterSettingsChangedHandler(); RegisterKeyBindings(); }