public bool ChangeEffect(ContentEffect effect) { switch (effect) { case ContentEffect.MediaPortalLiveMode: case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: return true; case ContentEffect.StaticColor: // Send command 3 times to make sure it arrives ChangeColor((int)gammaCurve[coreObject.staticColor[0]], (int)gammaCurve[coreObject.staticColor[1]], (int)gammaCurve[coreObject.staticColor[2]]); System.Threading.Thread.Sleep(50); ChangeColor((int)gammaCurve[coreObject.staticColor[0]], (int)gammaCurve[coreObject.staticColor[1]], (int)gammaCurve[coreObject.staticColor[2]]); System.Threading.Thread.Sleep(50); ChangeColor((int)gammaCurve[coreObject.staticColor[0]], (int)gammaCurve[coreObject.staticColor[1]], (int)gammaCurve[coreObject.staticColor[2]]); return true; case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: // Send command 3 times to make sure it arrives ChangeColor(0, 0, 0); System.Threading.Thread.Sleep(50); ChangeColor(0, 0, 0); System.Threading.Thread.Sleep(50); ChangeColor(0, 0, 0); return true; } }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return(false); } try { switch (effect) { case ContentEffect.MediaPortalLiveMode: case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: return(true); case ContentEffect.StaticColor: ChangeStaticColor(coreObject.staticColor); return(true); case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: ChangeStaticColor(new int[] { 0, 0, 0 }); return(true); } } catch (Exception ex) { Log.Error("BoblightHandler - Error changing effect to {0}", effect.ToString()); Log.Error("BoblightHandler - Exception: {0}", ex.Message); ReInitialise(); return(false); } }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return(false); } switch (effect) { case ContentEffect.StaticColor: if (!_priorityCleared) { //Clear live priority channel ClearPriority(coreObject.hyperionPriority); } if (coreObject.targetResendCommand) { ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); Thread.Sleep(50); ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); } else { ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); } break; case ContentEffect.MediaPortalLiveMode: _priorityCleared = false; break; case ContentEffect.LEDsDisabled: ClearPrioritiesAtmoLight(250); break; case ContentEffect.Undefined: default: ClearPrioritiesAtmoLight(250); break; } return(true); }
public bool ChangeEffect(ContentEffect effect) { switch (effect) { case ContentEffect.MediaPortalLiveMode: case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: return(true); case ContentEffect.StaticColor: ChangeColor((byte)gammaCurve[coreObject.staticColor[0]], (byte)gammaCurve[coreObject.staticColor[1]], (byte)gammaCurve[coreObject.staticColor[2]]); return(true); case ContentEffect.Undefined: case ContentEffect.LEDsDisabled: default: ChangeColor(0, 0, 0, true); return(true); } }
/// <summary> /// Change effect. /// </summary> /// <param name="effect">Effect to change to</param> /// <param name="force">Force the effect change</param> /// <returns></returns> public bool ChangeEffect(ContentEffect effect, bool force = false) { if (!IsConnected() && !force) { return false; } // Static color gets excluded so we can actually change it. if ((effect == currentEffect) && (!force)) { Log.Debug("Effect \"{0}\" is already active. Nothing to do.", effect); return false; } currentEffect = effect; Log.Info("Changing AtmoLight effect to: {0}", effect.ToString()); StopAllThreads(); lock (targetsLock) { foreach (var target in targets) { if (target.IsConnected()) { target.ChangeEffect(effect); } } } if (effect == ContentEffect.MediaPortalLiveMode) { blackbarDetectionRect = new Rectangle(0, 0, GetCaptureWidth(), GetCaptureHeight()); if (delayEnabled) { Log.Debug("Adding {0}ms delay to the LEDs.", delayTime); StartSetPixelDataThread(); } } else if (effect == ContentEffect.GIFReader) { StartGIFReaderThread(); } else if (effect == ContentEffect.VUMeter || effect == ContentEffect.VUMeterRainbow) { StartVUMeterThread(); } return true; }
private void monitorScreensaverState() { Log.Debug("Started monitoring screensaver state"); Boolean LEDsDisabledByScreensaver = false; IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>(); while (settings.MonitorScreensaverState) { try { Boolean IsScreenSaverActive = screenControl.IsScreenSaverActive; // Check for screensaver window if (IsScreenSaverActive) { ContentEffect currenContentEffect = coreObject.GetCurrentEffect(); if (currenContentEffect == ContentEffect.MediaPortalLiveMode || currenContentEffect == ContentEffect.ExternalLiveMode || currenContentEffect == ContentEffect.Undefined) { coreObject.ChangeEffect(ContentEffect.LEDsDisabled); LEDsDisabledByScreensaver = true; Log.Debug("LEDs should be deactivated. (Screensaver detected)"); } } // Restore last known effect when coming back from screensaver else if (LEDsDisabledByScreensaver) { LEDsDisabledByScreensaver = false; ContentEffect effect; if (ServiceRegistration.Get <IPlayerContextManager>().IsVideoContextActive) { effect = settings.VideoEffect; } else if (ServiceRegistration.Get <IPlayerContextManager>().IsAudioContextActive) { effect = settings.AudioEffect; } else { effect = settings.MenuEffect; } coreObject.ChangeEffect(effect); CalculateDelay(); Log.Debug("LEDs should be activated again. (Screensaver no longer active)"); } // Sleep for 5 seconds int sleepTime = (int)TimeSpan.FromSeconds(5).TotalMilliseconds; Thread.Sleep(sleepTime); } catch (Exception ex) { // No logging as it could spam the logs //Log.Error("Error in AtmolightPlugin_monitorScreensaverState."); //Log.Error("Exception: {0}", ex.Message); // Sleep for 5 seconds int sleepTime = (int)TimeSpan.FromSeconds(5).TotalMilliseconds; Thread.Sleep(sleepTime); } } }
/// <summary> /// Changes to desired effect. /// </summary> /// <param name="effect"></param> /// <returns></returns> public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return(false); } if (effect != ContentEffect.StaticColor) { staticColorSentDisabledEffect = false; } StopGetAtmoLiveViewSourceThread(); switch (effect) { case ContentEffect.ExternalLiveMode: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) { return(false); } if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsGDI)) { return(false); } break; case ContentEffect.AtmoWinColorchanger: if (!SetAtmoEffect(ComEffectMode.cemColorChange)) { return(false); } break; case ContentEffect.AtmoWinColorchangerLR: if (!SetAtmoEffect(ComEffectMode.cemLrColorChange)) { return(false); } break; case ContentEffect.MediaPortalLiveMode: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) { return(false); } if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsExternal)) { return(false); } StartGetAtmoLiveViewSourceThread(); break; case ContentEffect.StaticColor: if (!staticColorSentDisabledEffect) { if (!SetAtmoEffect(ComEffectMode.cemDisabled)) { return(false); } staticColorSentDisabledEffect = true; } if (!SetAtmoColor((byte)coreObject.staticColor[0], (byte)coreObject.staticColor[1], (byte)coreObject.staticColor[2])) { return(false); } // Workaround for SEDU. // Without the sleep it would not change to color. System.Threading.Thread.Sleep(delaySetStaticColor); if (!SetAtmoColor((byte)coreObject.staticColor[0], (byte)coreObject.staticColor[1], (byte)coreObject.staticColor[2])) { return(false); } break; case ContentEffect.GIFReader: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) { return(false); } if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsExternal)) { return(false); } StartGetAtmoLiveViewSourceThread(); break; case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) { return(false); } if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsExternal)) { return(false); } StartGetAtmoLiveViewSourceThread(); break; case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: if (!SetAtmoEffect(ComEffectMode.cemDisabled)) { return(false); } // Workaround for SEDU. // Without the sleep it would not change to color. System.Threading.Thread.Sleep(delaySetStaticColor); if (!SetAtmoColor(0, 0, 0)) { return(false); } break; } return(true); }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return false; } switch (effect) { case ContentEffect.StaticColor: ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2], 10, 0); break; case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: ChangeColor(0, 0, 0, 1, 0); break; } return true; }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return false; } switch (effect) { case ContentEffect.StaticColor: ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); break; case ContentEffect.LEDsDisabled: ClearPrioritiesAtmoLight(250); break; case ContentEffect.Undefined: default: ClearPrioritiesAtmoLight(250); break; } return true; }
/// <summary> /// Playback started event handler. /// This event handler gets called when playback starts. /// </summary> /// <param name="type">Media type</param> /// <param name="filename">Media filename</param> private void g_Player_PlayBackStarted(g_Player.MediaType type, string filename) { try { if (type == g_Player.MediaType.Video || type == g_Player.MediaType.TV || type == g_Player.MediaType.Recording || type == g_Player.MediaType.Unknown || (type == g_Player.MediaType.Music && filename.Contains(".mkv"))) { Log.Debug("Video detected."); playbackEffect = Settings.effectVideo; } else if (type == g_Player.MediaType.Music) { playbackEffect = Settings.effectMusic; Log.Debug("Music detected."); } else if (type == g_Player.MediaType.Radio) { playbackEffect = Settings.effectRadio; Log.Debug("Radio detected."); } if (CheckForStartRequirements()) { coreObject.ChangeEffect(playbackEffect); CalculateDelay(); } else { coreObject.ChangeEffect(ContentEffect.LEDsDisabled); } } catch (Exception ex) { Log.Error("g_Player_PlayBackStarted failed."); Log.Error("Exception= {0}", ex.Message); } }
/// <summary> /// Prompts the user with the context menu. /// </summary> private void DialogContextMenu() { Log.Info("Opening AtmoLight context menu."); // Showing context menu GUIDialogMenu dlg = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); dlg.Reset(); dlg.SetHeading(Localization.Translate("Common", "AtmoLight")); // Toggle On/Off if (!coreObject.IsAtmoLightOn()) { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "LEDsOn"))); } else { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "LEDsOff"))); } // Change Effect dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "ChangeEffect"))); // Change Profile dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "ChangeProfile"))); // Toggle 3D Mode if (Settings.sbs3dOn) { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "3DOff"))); } else { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "3DOn"))); } // Toggle Blackbar Detection dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetection"))); // Delay if (coreObject.GetCurrentEffect() == ContentEffect.MediaPortalLiveMode) { // Toggle Delay and Change Delay if (coreObject.IsDelayEnabled()) { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "DelayOff"))); dlg.Add( new GUIListItem(Localization.Translate("ContextMenu", "ChangeDelay") + " (" + coreObject.GetDelayTime() + Localization.Translate("Common", "MS") + ")")); } else { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "DelayOn"))); } } // Change Static Color if (coreObject.GetCurrentEffect() == ContentEffect.StaticColor) { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "ChangeStaticColor"))); } // ReInit if (!coreObject.AreAllConnected()) { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "Reinitialise"))); } // Hue set active liveview group if (coreObject.GetTarget(Target.Hue) != null) { dlg.Add(new GUIListItem(Localization.Translate("Hue", "LiveviewGroup"))); } // Hue set active liveview group if (coreObject.GetTarget(Target.Hue) != null) { dlg.Add(new GUIListItem(Localization.Translate("Hue", "StaticColorGroup"))); } // Toggle On/Off AtmoLight if (AtmoLightDisabledByUser) { // Clear all other items if AtmoLight leds is manually disabled by yser dlg.Reset(); dlg.SetHeading(Localization.Translate("ContextMenu", "AtmoLightDisabled")); dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "AtmoLightOn"))); } else if (!AtmoLightDisabledByUser) { dlg.Add(new GUIListItem(Localization.Translate("ContextMenu", "AtmoLightOff"))); } dlg.SelectedLabel = 0; dlg.DoModal(GUIWindowManager.ActiveWindow); // Do stuff // Toggle LEDs if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "LEDsOn") || dlg.SelectedLabelText == Localization.Translate("ContextMenu", "LEDsOff")) { if (!coreObject.IsAtmoLightOn()) { if (g_Player.Playing) { coreObject.ChangeEffect(playbackEffect); CalculateDelay(); } else { coreObject.ChangeEffect(menuEffect); CalculateDelay(); } } else { coreObject.ChangeEffect(ContentEffect.LEDsDisabled); } } // Toggle LEDs for duration of Mediaportal runtime else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "AtmoLightOn")) { AtmoLightDisabledByUser = false; if (g_Player.Playing) { coreObject.ChangeEffect(playbackEffect); } else { coreObject.ChangeEffect(menuEffect); } CalculateDelay(); } else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "AtmoLightOff")) { AtmoLightDisabledByUser = true; coreObject.ChangeEffect(ContentEffect.LEDsDisabled); } // Change Effect else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "ChangeEffect")) { GUIDialogMenu dlgEffect = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); dlgEffect.Reset(); dlgEffect.SetHeading(Localization.Translate("ContextMenu", "ChangeEffect")); // Only show effects that are support by at least one target foreach (ContentEffect effect in Enum.GetValues(typeof (ContentEffect))) { if (supportedEffects.Contains(effect) && effect != ContentEffect.Undefined) { if (effect == ContentEffect.VUMeter || effect == ContentEffect.VUMeterRainbow) { if (g_Player.Playing && (g_Player.currentMedia == g_Player.MediaType.Music || g_Player.currentMedia == g_Player.MediaType.Radio)) { dlgEffect.Add(new GUIListItem(Localization.Translate("ContentEffect", effect.ToString()))); } } else { dlgEffect.Add(new GUIListItem(Localization.Translate("ContentEffect", effect.ToString()))); } } } dlgEffect.SelectedLabel = 0; dlgEffect.DoModal(GUIWindowManager.ActiveWindow); if (!String.IsNullOrEmpty(dlgEffect.SelectedLabelText)) { ContentEffect temp = (ContentEffect) Enum.Parse(typeof (ContentEffect), Localization.ReverseTranslate("ContentEffect", dlgEffect.SelectedLabelText)); if (g_Player.Playing) { playbackEffect = temp; } else { menuEffect = temp; } coreObject.ChangeEffect(temp); CalculateDelay(); } } // Change Profile else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "ChangeProfile")) { coreObject.ChangeProfile(); } // Toggle 3D else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "3DOn") || dlg.SelectedLabelText == Localization.Translate("ContextMenu", "3DOff")) { if (Settings.sbs3dOn) { Log.Info("Switching SBS 3D mode off."); Settings.sbs3dOn = false; } else { Log.Info("Switching SBS 3D mode on."); Settings.sbs3dOn = true; } } // Blackbar detection else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetection")) { GUIDialogMenu dlgBlackbarDetection = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlgBlackbarDetection.Reset(); dlgBlackbarDetection.SetHeading(Localization.Translate("ContextMenu", "BlackbarDetection")); if (Settings.blackbarDetection) { dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetectionOff"))); } else { dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetectionOn"))); } if (coreObject.blackbarDetectionManual) { dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetectionDisableManual"))); } dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetection1.33:1"))); dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetection1.78:1"))); dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetection1.85:1"))); dlgBlackbarDetection.Add(new GUIListItem(Localization.Translate("ContextMenu", "BlackbarDetection2.35:1"))); dlgBlackbarDetection.SelectedLabel = 0; dlgBlackbarDetection.DoModal(GUIWindowManager.ActiveWindow); if (dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetectionOn") || dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetectionOff")) { if (Settings.blackbarDetection) { Log.Info("Switching blackbar detection off."); Settings.blackbarDetection = false; coreObject.blackbarDetection = false; } else { Log.Info("Switching blackbar detection on."); Settings.blackbarDetection = true; coreObject.blackbarDetection = true; } } else if (dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetectionDisableManual")) { coreObject.blackbarDetectionManual = false; } else if (dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetection1.33:1")) { coreObject.blackbarDetectionManual = true; coreObject.blackbarDetectionAR = BlackbarDetectionAR._1_33x1; } else if (dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetection1.78:1")) { coreObject.blackbarDetectionManual = true; coreObject.blackbarDetectionAR = BlackbarDetectionAR._1_78x1; } else if (dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetection1.85:1")) { coreObject.blackbarDetectionManual = true; coreObject.blackbarDetectionAR = BlackbarDetectionAR._1_85x1; } else if (dlgBlackbarDetection.SelectedLabelText == Localization.Translate("ContextMenu", "BlackbarDetection2.35:1")) { coreObject.blackbarDetectionManual = true; coreObject.blackbarDetectionAR = BlackbarDetectionAR._2_35x1; } } // Toggle Delay else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "DelayOn") || dlg.SelectedLabelText == Localization.Translate("ContextMenu", "DelayOff")) { if (coreObject.IsDelayEnabled()) { Log.Info("Switching LED delay off."); coreObject.DisableDelay(); } else { coreObject.EnableDelay( (int) (((float)Settings.delayReferenceRefreshRate / (float)GetRefreshRate()) * (float)Settings.delayReferenceTime)); } } // Change Delay else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "ChangeDelay") + " (" + coreObject.GetDelayTime() + Localization.Translate("Common", "MS") + ")") { if ((int.TryParse(GetKeyboardString(""), out delayTimeHelper)) && (delayTimeHelper >= 0) && (delayTimeHelper <= 1000)) { coreObject.SetDelay(delayTimeHelper); Settings.delayReferenceTime = (int)(((float)delayTimeHelper * (float)GetRefreshRate()) / Settings.delayReferenceRefreshRate); } else { DialogError(Localization.Translate("ContextMenu", "DelayError1"), Localization.Translate("ContextMenu", "DelayError2")); } } // Change Static Color else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "ChangeStaticColor")) { GUIDialogMenu dlgStaticColor = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlgStaticColor.Reset(); dlgStaticColor.SetHeading(Localization.Translate("ContextMenu", "ChangeStaticColor")); dlgStaticColor.Add(new GUIListItem(Localization.Translate("ContextMenu", "Manual"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("ContextMenu", "SaveColor"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("ContextMenu", "LoadColor"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("ContextMenu", "White"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("Common", "Red"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("Common", "Green"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("Common", "Blue"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("ContextMenu", "Cyan"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("ContextMenu", "Magenta"))); dlgStaticColor.Add(new GUIListItem(Localization.Translate("Common", "Yellow"))); dlgStaticColor.SelectedLabel = 0; dlgStaticColor.DoModal(GUIWindowManager.ActiveWindow); switch (dlgStaticColor.SelectedLabel) { case -1: return; case 0: DialogRGBManualStaticColorChanger(); break; case 1: Settings.SaveSpecificSetting("StaticColorRed", coreObject.GetStaticColor()[0].ToString()); Settings.staticColorRed = coreObject.GetStaticColor()[0]; Settings.SaveSpecificSetting("StaticColorGreen", coreObject.GetStaticColor()[1].ToString()); Settings.staticColorGreen = coreObject.GetStaticColor()[1]; Settings.SaveSpecificSetting("StaticColorBlue", coreObject.GetStaticColor()[2].ToString()); Settings.staticColorBlue = coreObject.GetStaticColor()[2]; break; case 2: coreObject.SetStaticColor(Settings.staticColorRed, Settings.staticColorGreen, Settings.staticColorBlue); break; case 3: coreObject.SetStaticColor(255, 255, 255); break; case 4: coreObject.SetStaticColor(255, 0, 0); break; case 5: coreObject.SetStaticColor(0, 255, 0); break; case 6: coreObject.SetStaticColor(0, 0, 255); break; case 7: coreObject.SetStaticColor(0, 255, 255); break; case 8: coreObject.SetStaticColor(255, 0, 255); break; case 9: coreObject.SetStaticColor(255, 255, 0); break; } coreObject.ChangeEffect(ContentEffect.StaticColor, true); } else if (dlg.SelectedLabelText == Localization.Translate("ContextMenu", "Reinitialise")) { coreObject.ReInitialise(); } // Hue set active liveview group if (dlg.SelectedLabelText == Localization.Translate("Hue", "LiveviewGroup")) { GUIDialogMenu dlgHueSetActiveGroup = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); dlgHueSetActiveGroup.Reset(); dlgHueSetActiveGroup.SetHeading(Localization.Translate("Hue", "LiveviewGroup")); dlgHueSetActiveGroup.Add(Localization.Translate("Hue", "All")); var hueTarget = coreObject.GetTarget(Target.Hue) as AtmoLight.Targets.HueHandler; List<string> groups = hueTarget.Loadgroups(); foreach (string group in groups) { dlgHueSetActiveGroup.Add(new GUIListItem(group)); } dlgHueSetActiveGroup.Add(Localization.Translate("Hue", "DisableAllGroups")); dlgHueSetActiveGroup.SelectedLabel = 0; dlgHueSetActiveGroup.DoModal(GUIWindowManager.ActiveWindow); if (dlgHueSetActiveGroup.SelectedLabel == 0) { hueTarget.setActiveGroup(Localization.Translate("Hue", "All")); } else if (dlgHueSetActiveGroup.SelectedLabel > 0) { hueTarget.setActiveGroup(dlgHueSetActiveGroup.SelectedLabelText); } } // Hue set static color for group if (dlg.SelectedLabelText == Localization.Translate("Hue", "StaticColorGroup")) { GUIDialogMenu dlgHueSetActiveGroup = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); dlgHueSetActiveGroup.Reset(); dlgHueSetActiveGroup.SetHeading(Localization.Translate("Hue", "StaticColorGroup")); dlgHueSetActiveGroup.Add(Localization.Translate("Hue", "All")); var hueTarget = coreObject.GetTarget(Target.Hue) as AtmoLight.Targets.HueHandler; List<string> groups = hueTarget.Loadgroups(); foreach (string group in groups) { dlgHueSetActiveGroup.Add(new GUIListItem(group)); } dlgHueSetActiveGroup.SelectedLabel = 0; dlgHueSetActiveGroup.DoModal(GUIWindowManager.ActiveWindow); if (dlgHueSetActiveGroup.SelectedLabel >= 0) { string groupName = dlgHueSetActiveGroup.SelectedLabelText; GUIDialogMenu dlgHueSetStaticColorGroup = (GUIDialogMenu) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_MENU); dlgHueSetStaticColorGroup.Reset(); dlgHueSetStaticColorGroup.SetHeading(Localization.Translate("Hue", "SelectStaticColorGroup")); dlgHueSetStaticColorGroup.Add(Localization.Translate("Hue", "Off")); List<string> staticColors = hueTarget.LoadStaticColors(); foreach (string staticColor in staticColors) { dlgHueSetStaticColorGroup.Add(new GUIListItem(staticColor)); } dlgHueSetStaticColorGroup.SelectedLabel = 0; dlgHueSetStaticColorGroup.DoModal(GUIWindowManager.ActiveWindow); if (dlgHueSetStaticColorGroup.SelectedLabel >= 0) { string colorName = dlgHueSetStaticColorGroup.SelectedLabelText; hueTarget.setGroupStaticColor(groupName, colorName); } } } }
/// <summary> /// Changes to desired effect. /// </summary> /// <param name="effect"></param> /// <returns></returns> public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return false; } StopGetAtmoLiveViewSourceThread(); switch (effect) { case ContentEffect.ExternalLiveMode: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) return false; if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsGDI)) return false; break; case ContentEffect.AtmoWinColorchanger: if (!SetAtmoEffect(ComEffectMode.cemColorChange)) return false; break; case ContentEffect.AtmoWinColorchangerLR: if (!SetAtmoEffect(ComEffectMode.cemLrColorChange)) return false; break; case ContentEffect.MediaPortalLiveMode: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) return false; if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsExternal)) return false; StartGetAtmoLiveViewSourceThread(); break; case ContentEffect.StaticColor: if (!SetAtmoEffect(ComEffectMode.cemDisabled)) return false; if (!SetAtmoColor((byte)coreObject.staticColor[0], (byte)coreObject.staticColor[1], (byte)coreObject.staticColor[2])) return false; // Workaround for SEDU. // Without the sleep it would not change to color. System.Threading.Thread.Sleep(delaySetStaticColor); if (!SetAtmoColor((byte)coreObject.staticColor[0], (byte)coreObject.staticColor[1], (byte)coreObject.staticColor[2])) return false; break; case ContentEffect.GIFReader: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) return false; if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsExternal)) return false; StartGetAtmoLiveViewSourceThread(); break; case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: if (!SetAtmoEffect(ComEffectMode.cemLivePicture)) return false; if (!SetAtmoLiveViewSource(ComLiveViewSource.lvsExternal)) return false; StartGetAtmoLiveViewSourceThread(); break; case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: if (!SetAtmoEffect(ComEffectMode.cemDisabled)) return false; // Workaround for SEDU. // Without the sleep it would not change to color. System.Threading.Thread.Sleep(delaySetStaticColor); if (!SetAtmoColor(0, 0, 0)) return false; break; } return true; }
public bool ChangeEffect(ContentEffect effect) { switch (effect) { case ContentEffect.MediaPortalLiveMode: return true; case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: return true; case ContentEffect.StaticColor: if (coreObject.targetResendCommand) { // Send command 3 times to make sure it arrives ChangeColor((byte) gammaCurve[coreObject.staticColor[0]], (byte) gammaCurve[coreObject.staticColor[1]], (byte) gammaCurve[coreObject.staticColor[2]]); Thread.Sleep(50); ChangeColor((byte) gammaCurve[coreObject.staticColor[0]], (byte) gammaCurve[coreObject.staticColor[1]], (byte) gammaCurve[coreObject.staticColor[2]]); Thread.Sleep(50); } else { ChangeColor((byte)gammaCurve[coreObject.staticColor[0]], (byte)gammaCurve[coreObject.staticColor[1]], (byte)gammaCurve[coreObject.staticColor[2]]); } return true; case ContentEffect.LEDsDisabled: if (coreObject.targetResendCommand) { // Send command 3 times to make sure it arrives ChangeColor(0, 0, 0, true); Thread.Sleep(50); ChangeColor(0, 0, 0, true); Thread.Sleep(50); ChangeColor(0, 0, 0, true); } else { ChangeColor(0, 0, 0, true); } return true; case ContentEffect.Undefined: default: if (coreObject.targetResendCommand) { // Send command 3 times to make sure it arrives ChangeColor(0, 0, 0, true); Thread.Sleep(50); ChangeColor(0, 0, 0, true); Thread.Sleep(50); ChangeColor(0, 0, 0, true); } else { ChangeColor(0, 0, 0, true); } return true; } }
/// <summary> /// Change effect. /// </summary> /// <param name="effect">Effect to change to</param> /// <param name="force">Force the effect change</param> /// <returns></returns> public bool ChangeEffect(ContentEffect effect, bool force = false, bool skipTargetsAndThreads = false, bool apiCommand = false) { if (!IsConnected() && !force) { return false; } if ((effect == currentEffect) && (!force)) { Log.Debug("Effect \"{0}\" is already active. Nothing to do.", effect); return false; } currentEffect = effect; StopAllThreads(); if (skipTargetsAndThreads) { Log.Debug("Setting internal AtmoLight effect (skipping targets and threads) to: {0}", effect.ToString()); return true; } // Only log if it isn't a API command (would flood it otherwise) if (!apiCommand) { Log.Info("Changing AtmoLight effect to: {0}", effect.ToString()); } lock (targetsLock) { foreach (var target in targets) { if (target.IsConnected()) { target.ChangeEffect(effect); } } } if (effect == ContentEffect.MediaPortalLiveMode) { blackbarDetectionRect = new Rectangle(0, 0, GetCaptureWidth(), GetCaptureHeight()); if (delayEnabled) { Log.Debug("Adding {0}ms delay to the LEDs.", delayTime); StartSetPixelDataThread(); } } else if (effect == ContentEffect.GIFReader) { StartGIFReaderThread(); } else if (effect == ContentEffect.VUMeter || effect == ContentEffect.VUMeterRainbow) { StartVUMeterThread(); } return true; }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return false; } switch (effect) { case ContentEffect.StaticColor: if (!priorityCleared) { //Clear live priority channel ClearPriority(coreObject.hyperionPriority); } priorityStaticColorCleared = false; if (coreObject.targetResendCommand) { ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); Thread.Sleep(50); ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); } else { ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2]); } break; case ContentEffect.MediaPortalLiveMode: priorityCleared = false; break; case ContentEffect.LEDsDisabled: ClearPrioritiesAtmoLight(250); break; case ContentEffect.Undefined: default: ClearPrioritiesAtmoLight(250); break; } return true; }
public bool LoadAll() { settings = settingsManager.Load<Settings>(); AtmoWinExe = settings.AtmoWinExe; VideoEffect = settings.VideoEffect; AudioEffect = settings.AudioEffect; MenuEffect = settings.MenuEffect; OnOffButton = settings.OnOffButton; ProfileButton = settings.ProfileButton; ExcludeTimeStart = settings.ExcludeTimeStart; ExcludeTimeEnd = settings.ExcludeTimeEnd; ManualMode = settings.ManualMode; SBS3D = settings.SBS3D; LowCPU = settings.LowCPU; LowCPUTime = settings.LowCPUTime; Delay = settings.Delay; DelayTime = settings.DelayTime; DelayRefreshRate = settings.DelayRefreshRate; StopAtmoWinOnExit = settings.StopAtmoWinOnExit; StartAtmoWinOnStart = settings.StartAtmoWinOnStart; RestartAtmoWinOnError = settings.RestartAtmoWinOnError; MonitorScreensaverState = settings.MonitorScreensaverState; StaticColorBlue = settings.StaticColorBlue; StaticColorGreen = settings.StaticColorGreen; StaticColorRed = settings.StaticColorRed; GIFFile = settings.GIFFile; MPExitEffect = settings.MPExitEffect; AtmoWinTarget = settings.AtmoWinTarget; HyperionTarget = settings.HyperionTarget; HueTarget = settings.HueTarget; HyperionIP = settings.HyperionIP; HyperionLiveReconnect = settings.HyperionLiveReconnect; HyperionPort = settings.HyperionPort; HyperionPriority = settings.HyperionPriority; HyperionPriorityStaticColor = settings.HyperionPriorityStaticColor; HyperionReconnectAttempts = settings.HyperionReconnectAttempts; HyperionReconnectDelay = settings.HyperionReconnectDelay; hueExe = settings.hueExe; hueStart = settings.hueStart; hueIsRemoteMachine = settings.hueIsRemoteMachine; HueIP = settings.HueIP; HuePort = settings.HuePort; HueReconnectDelay = settings.HueReconnectDelay; HueReconnectAttempts = settings.HueReconnectAttempts; HueBridgeEnableOnResume = settings.HueBridgeEnableOnResume; CaptureHeight = settings.CaptureHeight; CaptureWidth = settings.CaptureWidth; BoblightTarget = settings.BoblightTarget; BoblightIP = settings.BoblightIP; BoblightPort = settings.BoblightPort; BoblightMaxFPS = settings.BoblightMaxFPS; BoblightMaxReconnectAttempts = settings.BoblightMaxReconnectAttempts; BoblightReconnectDelay = settings.BoblightReconnectDelay; BoblightSpeed = settings.BoblightSpeed; BoblightAutospeed = settings.BoblightAutospeed; BoblightInterpolation = settings.BoblightInterpolation; BoblightSaturation = settings.BoblightSaturation; BoblightValue = settings.BoblightValue; BoblightThreshold = settings.BoblightThreshold; BoblightGamma = settings.BoblightGamma; BlackbarDetection = settings.BlackbarDetection; BlackbarDetectionTime = settings.BlackbarDetectionTime; BlackbarDetectionThreshold = settings.BlackbarDetectionThreshold; PowerModeChangedDelay = settings.PowerModeChangedDelay; AmbiBoxAutoStart = settings.AmbiBoxAutoStart; AmbiBoxAutoStop = settings.AmbiBoxAutoStop; AmbiBoxExternalProfile = settings.AmbiBoxExternalProfile; AmbiBoxIP = settings.AmbiBoxIP; AmbiBoxMaxReconnectAttempts = settings.AmbiBoxMaxReconnectAttempts; AmbiBoxMediaPortalProfile = settings.AmbiBoxMediaPortalProfile; AmbiBoxPath = settings.AmbiBoxPath; AmbiBoxPort = settings.AmbiBoxPort; AmbiBoxReconnectDelay = settings.AmbiBoxReconnectDelay; AmbiBoxTarget = settings.AmbiBoxTarget; HueThreshold = settings.HueThreshold; HueBlackThreshold = settings.HueBlackThreshold; HueMinDiversion = settings.HueMinDiversion; HueSaturation = settings.HueSaturation; HueUseOverallLightness = settings.HueUseOverallLightness; BlackbarDetectionLinkAreas = settings.BlackbarDetectionLinkAreas; BlackbarDetectionHorizontal = settings.BlackbarDetectionHorizontal; BlackbarDetectionVertical = settings.BlackbarDetectionVertical; return true; }
public static void LoadSettings() { using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { // Legacy support // The effect settings were integers in the past, but now are strings. // In order to avoid a lot of people loosing their effect settings during an update, // we convert the old settings to the new ones. int effectVideoInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode"), out effectVideoInt)) { effectVideo = OldIntToNewContentEffect(effectVideoInt); SaveSpecificSetting("effectVideo", effectVideo.ToString()); } else { effectVideo = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode")); } int effectMusicInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled"), out effectMusicInt)) { effectMusic = OldIntToNewContentEffect(effectMusicInt); SaveSpecificSetting("effectMusic", effectMusic.ToString()); } else { effectMusic = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled")); } int effecRadioInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled"), out effecRadioInt)) { effectRadio = OldIntToNewContentEffect(effecRadioInt); SaveSpecificSetting("effectRadio", effectRadio.ToString()); } else { effectRadio = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled")); } int effectMenuInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled"), out effectMenuInt)) { effectMenu = OldIntToNewContentEffect(effectMenuInt); SaveSpecificSetting("effectMenu", effectMenu.ToString()); } else { effectMenu = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled")); } int effectMPExitInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled"), out effectMPExitInt)) { effectMPExit = OldIntToNewContentEffect(effectMPExitInt == 4 ? 5 : effectMPExitInt); SaveSpecificSetting("effectMPExit", effectMPExit.ToString()); } else { effectMPExit = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled")); } currentLanguage = reader.GetValueAsString("atmolight", "currentLanguage", "English"); // Check for presence of legacy file location (1.7.0.5 or lower) currentLanguageFileLegacy = reader.GetValueAsString("atmolight", "currentLanguageFile", ""); if (!string.IsNullOrEmpty(currentLanguageFileLegacy)) { if (currentLanguageFileLegacy.Contains("nl.xml")) { currentLanguage = "Dutch"; } else if (currentLanguageFileLegacy.Contains("en.xml")) { currentLanguage = "English"; } else if (currentLanguageFileLegacy.Contains("fr.xml")) { currentLanguage = "French"; } else if (currentLanguageFileLegacy.Contains("de.xml")) { ; currentLanguage = "German"; } } string mediaportalLanguageDir = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Language) + "\\"; if (string.IsNullOrEmpty(mediaportalLanguageDir) || !Directory.Exists(mediaportalLanguageDir)) { mediaportalLanguageDir = @"C:\ProgramData\Team MediaPortal\MediaPortal\Language\"; } try { switch (currentLanguage) { case "Dutch": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\nl.xml"; break; case "English": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\en.xml"; break; case "French": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\fr.xml"; break; case "German": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\de.xml"; break; } } catch (Exception ex) { Log.Error("Error during LoadSettings"); Log.Error(ex.Message); throw; } // Normal settings loading atmowinExe = reader.GetValueAsString("atmolight", "atmowinexe", ""); killButton = reader.GetValueAsInt("atmolight", "killbutton", 4); profileButton = reader.GetValueAsInt("atmolight", "cmbutton", 4); menuButton = reader.GetValueAsInt("atmolight", "menubutton", 4); excludeTimeStart = LoadTimeSetting(reader, "excludeTimeStart", "00:00"); excludeTimeEnd = LoadTimeSetting(reader, "excludeTimeEnd", "00:00"); manualMode = reader.GetValueAsBool("atmolight", "OffOnStart", false); sbs3dOn = reader.GetValueAsBool("atmolight", "SBS_3D_ON", false); lowCPU = reader.GetValueAsBool("atmolight", "lowCPU", false); lowCPUTime = reader.GetValueAsInt("atmolight", "lowCPUTime", 0); delay = reader.GetValueAsBool("atmolight", "Delay", false); delayReferenceRefreshRate = reader.GetValueAsInt("atmolight", "DelayRefreshRate", 0); // Legacy reference time delayReferenceTime = reader.GetValueAsInt("atmolight", "DelayTime", 0); // New reference times delayReferenceTime23 = reader.GetValueAsInt("atmolight", "DelayTime23", 0); delayReferenceTime24 = reader.GetValueAsInt("atmolight", "DelayTime24", 0); delayReferenceTime50 = reader.GetValueAsInt("atmolight", "DelayTime50", 0); delayReferenceTime59 = reader.GetValueAsInt("atmolight", "DelayTime59", 0); // If all of the specific refresh values are 0, assume upgrade setting from single rate if (delayReferenceTime23 == 0 && delayReferenceTime24 == 0 && delayReferenceTime50 == 0 && delayReferenceTime59 == 0) { switch (delayReferenceRefreshRate) { case 23: delayReferenceTime23 = delayReferenceTime; break; case 24: delayReferenceTime24 = delayReferenceTime; break; case 50: delayReferenceTime50 = delayReferenceTime; break; case 59: delayReferenceTime59 = delayReferenceTime; break; } } exitAtmoWin = reader.GetValueAsBool("atmolight", "ExitAtmoWin", true); startAtmoWin = reader.GetValueAsBool("atmolight", "StartAtmoWin", true); atmoWakeHelperEnabled = reader.GetValueAsBool("atmolight", "atmoWakeHelperEnabled", false); atmoWakeHelperComPort = reader.GetValueAsString("atmolight", "atmoWakeHelperComPort", ""); atmoWakeHelperResumeDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperResumeDelay", 2500); atmoWakeHelperDisconnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperDisconnectDelay", 1500); atmoWakeHelperConnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperConnectDelay", 1500); atmoWakeHelperReinitializationDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperReinitializationDelay", 0); staticColorRed = reader.GetValueAsInt("atmolight", "StaticColorRed", 0); staticColorGreen = reader.GetValueAsInt("atmolight", "StaticColorGreen", 0); staticColorBlue = reader.GetValueAsInt("atmolight", "StaticColorBlue", 0); restartOnError = reader.GetValueAsBool("atmolight", "RestartOnError", true); trueGrabbing = reader.GetValueAsBool("atmolight", "TrueGrabbing", true); blackbarDetection = reader.GetValueAsBool("atmolight", "BlackbarDetection", false); blackbarDetectionTime = reader.GetValueAsInt("atmolight", "BlackbarDetectionTime", 1000); gifFile = reader.GetValueAsString("atmolight", "GIFFile", ""); captureWidth = reader.GetValueAsInt("atmolight", "captureWidth", 64); captureHeight = reader.GetValueAsInt("atmolight", "captureHeight", 64); monitorScreensaverState = reader.GetValueAsBool("atmolight", "monitorScreensaverState", true); monitorWindowState = reader.GetValueAsBool("atmolight", "monitorWindowState", true); hyperionIP = reader.GetValueAsString("atmolight", "hyperionIP", "127.0.0.1"); hyperionPort = reader.GetValueAsInt("atmolight", "hyperionPort", 19445); hyperionReconnectDelay = reader.GetValueAsInt("atmolight", "hyperionReconnectDelay", 10000); hyperionReconnectAttempts = reader.GetValueAsInt("atmolight", "hyperionReconnectAttempts", 5); hyperionPriority = reader.GetValueAsInt("atmolight", "hyperionPriority", 1); hyperionPriorityStaticColor = reader.GetValueAsInt("atmolight", "hyperionStaticColorPriority", 1); hyperionLiveReconnect = reader.GetValueAsBool("atmolight", "hyperionLiveReconnect", false); hueExe = reader.GetValueAsString("atmolight", "hueExe", ""); hueStart = reader.GetValueAsBool("atmolight", "hueStart", true); hueIsRemoteMachine = reader.GetValueAsBool("atmolight", "hueIsRemoteMachine", false); hueIP = reader.GetValueAsString("atmolight", "hueIP", "127.0.0.1"); huePort = reader.GetValueAsInt("atmolight", "huePort", 20123); hueReconnectDelay = reader.GetValueAsInt("atmolight", "hueReconnectDelay", 10000); hueReconnectAttempts = reader.GetValueAsInt("atmolight", "hueReconnectAttempts", 5); hueBridgeEnableOnResume = reader.GetValueAsBool("atmolight", "hueBridgeEnableOnResume", false); hueBridgeDisableOnSuspend = reader.GetValueAsBool("atmolight", "hueBridgeDisableOnSuspend", false); hueTheaterEnabled = reader.GetValueAsBool("atmolight", "hueTheaterEnabled", false); hueTheaterRestoreLights = reader.GetValueAsBool("atmolight", "hueTheaterRestoreLights", false); hueTheaterEnabledVU = reader.GetValueAsBool("atmolight", "hueTheaterEnabledVU", false); boblightIP = reader.GetValueAsString("atmolight", "boblightIP", "127.0.0.1"); boblightPort = reader.GetValueAsInt("atmolight", "boblightPort", 19333); boblightMaxFPS = reader.GetValueAsInt("atmolight", "boblightMaxFPS", 10); boblightMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "boblightMaxReconnectAttempts", 5); boblightReconnectDelay = reader.GetValueAsInt("atmolight", "boblightReconnectDelay", 5000); boblightSpeed = reader.GetValueAsInt("atmolight", "boblightSpeed", 100); boblightAutospeed = reader.GetValueAsInt("atmolight", "boblightAutospeed", 0); boblightInterpolation = reader.GetValueAsBool("atmolight", "boblightInterpolation", true); boblightSaturation = reader.GetValueAsInt("atmolight", "boblightSaturation", 1); boblightValue = reader.GetValueAsInt("atmolight", "boblightValue", 1); boblightThreshold = reader.GetValueAsInt("atmolight", "boblightThreshold", 20); boblightGamma = Double.Parse(reader.GetValueAsString("atmolight", "boblightGamma", "2.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoWinTarget = reader.GetValueAsBool("atmolight", "atmoWinTarget", true); boblightTarget = reader.GetValueAsBool("atmolight", "boblightTarget", false); hueTarget = reader.GetValueAsBool("atmolight", "hueTarget", false); hyperionTarget = reader.GetValueAsBool("atmolight", "hyperionTarget", false); blackbarDetectionThreshold = reader.GetValueAsInt("atmolight", "blackbarDetectionThreshold", 20); powerModeChangedDelay = reader.GetValueAsInt("atmolight", "powerModeChangedDelay", 5000); ambiBoxTarget = reader.GetValueAsBool("atmolight", "ambiBoxTarget", false); ambiBoxIP = reader.GetValueAsString("atmolight", "ambiBoxIP", "127.0.0.1"); ambiBoxPort = reader.GetValueAsInt("atmolight", "ambiBoxPort", 3636); ambiBoxMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "ambiBoxMaxReconnectAttempts", 5); ambiBoxReconnectDelay = reader.GetValueAsInt("atmolight", "ambiBoxReconnectDelay", 5000); ambiBoxChangeImageDelay = reader.GetValueAsInt("atmolight", "ambiBoxChangeImageDelay", 10); ambiBoxMediaPortalProfile = reader.GetValueAsString("atmolight", "ambiBoxMediaPortalProfile", "MediaPortal"); ambiBoxExternalProfile = reader.GetValueAsString("atmolight", "ambiBoxExternalProfile", "External"); ambiBoxPath = reader.GetValueAsString("atmolight", "ambiBoxPath", "C:\\Program Files (x86)\\AmbiBox\\AmbiBox.exe"); ambiBoxAutoStart = reader.GetValueAsBool("atmolight", "ambiBoxAutoStart", false); ambiBoxAutoStop = reader.GetValueAsBool("atmolight", "ambiBoxAutoStop", false); atmoOrbTarget = reader.GetValueAsBool("atmolight", "atmoOrbTarget", false); atmoOrbBlackThreshold = reader.GetValueAsInt("atmolight", "atmoOrbBlackThreshold", 16); atmoOrbBroadcastPort = reader.GetValueAsInt("atmolight", "atmoOrbBroadcastPort", 49692); atmoOrbGamma = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbGamma", "1").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbMinDiversion = reader.GetValueAsInt("atmolight", "atmoOrbMinDiversion", 16); atmoOrbSaturation = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbThreshold = reader.GetValueAsInt("atmolight", "atmoOrbThreshold", 0); atmoOrbUseOverallLightness = reader.GetValueAsBool("atmolight", "atmoOrbUseOverallLightness", true); atmoOrbUseSmoothing = reader.GetValueAsBool("atmolight", "atmoOrbUseSmoothing", true); atmoOrbSmoothingThreshold = reader.GetValueAsInt("atmolight", "atmoOrbSmoothingThreshold", 200); string atmoOrbLampTemp = reader.GetValueAsString("atmolight", "atmoOrbLamps", ""); string[] atmoOrbLampTempSplit = atmoOrbLampTemp.Split('|'); for (int i = 0; i < atmoOrbLampTempSplit.Length; i++) { if (!string.IsNullOrEmpty(atmoOrbLampTempSplit[i])) { atmoOrbLamps.Add(atmoOrbLampTempSplit[i]); } } vuMeterMindB = reader.GetValueAsInt("atmolight", "vuMeterMindB", -24); vuMeterMinHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMinHue", "0,74999").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); vuMeterMaxHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMaxHue", "0,95833").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueThreshold = reader.GetValueAsInt("atmolight", "hueThreshold", 16); hueBlackThreshold = reader.GetValueAsInt("atmolight", "hueBlackThreshold", 16); hueMinDiversion = reader.GetValueAsInt("atmolight", "hueMinDiversion", 16); hueSaturation = Double.Parse(reader.GetValueAsString("atmolight", "hueSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueUseOverallLightness = reader.GetValueAsBool("atmolight", "hueUseOverallLightness", true); blackbarDetectionHorizontal = reader.GetValueAsBool("atmolight", "blackbarDetectionHorizontal", true); blackbarDetectionVertical = reader.GetValueAsBool("atmolight", "blackbarDetectionVertical", true); blackbarDetectionLinkAreas = reader.GetValueAsBool("atmolight", "blackbarDetectionLinkAreas", true); remoteApiServer = reader.GetValueAsBool("atmolight", "remoteApiServer", false); doNotShowConnectionErrorsDuringPlayback = reader.GetValueAsBool("atmolight", "doNotShowConnectionErrorsDuringPlayback", false); } }
public static void LoadSettings() { using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { // Legacy support // The effect settings were integers in the past, but now are strings. // In order to avoid a lot of people loosing their effect settings during an update, // we convert the old settings to the new ones. int effectVideoInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode"), out effectVideoInt)) { effectVideo = OldIntToNewContentEffect(effectVideoInt); SaveSpecificSetting("effectVideo", effectVideo.ToString()); } else { effectVideo = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode")); } int effectMusicInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled"), out effectMusicInt)) { effectMusic = OldIntToNewContentEffect(effectMusicInt); SaveSpecificSetting("effectMusic", effectMusic.ToString()); } else { effectMusic = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled")); } int effecRadioInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled"), out effecRadioInt)) { effectRadio = OldIntToNewContentEffect(effecRadioInt); SaveSpecificSetting("effectRadio", effectRadio.ToString()); } else { effectRadio = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled")); } int effectMenuInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled"), out effectMenuInt)) { effectMenu = OldIntToNewContentEffect(effectMenuInt); SaveSpecificSetting("effectMenu", effectMenu.ToString()); } else { effectMenu = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled")); } int effectMPExitInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled"), out effectMPExitInt)) { effectMPExit = OldIntToNewContentEffect(effectMPExitInt == 4 ? 5 : effectMPExitInt); SaveSpecificSetting("effectMPExit", effectMPExit.ToString()); } else { effectMPExit = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled")); } currentLanguageFile = reader.GetValueAsString("atmolight", "CurrentLanguageFile", Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\en.xml"); if (currentLanguageFile.Substring(currentLanguageFile.Length - 3, 3).ToLower() == "lng") { int lastBackslash = currentLanguageFile.LastIndexOf("\\") + 1; int lastDot = currentLanguageFile.LastIndexOf("."); switch (currentLanguageFile.Substring(lastBackslash, lastDot - lastBackslash)) { case "GermanDE": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\de.xml"; break; case "DutchNL": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\nl.xml"; break; case "FrenchFR": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\fr.xml"; break; default: case "EnglishUS": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\en.xml"; break; } } // Normal settings loading atmowinExe = reader.GetValueAsString("atmolight", "atmowinexe", ""); killButton = reader.GetValueAsInt("atmolight", "killbutton", 4); profileButton = reader.GetValueAsInt("atmolight", "cmbutton", 4); menuButton = reader.GetValueAsInt("atmolight", "menubutton", 4); excludeTimeStart = LoadTimeSetting(reader, "excludeTimeStart", "00:00"); excludeTimeEnd = LoadTimeSetting(reader, "excludeTimeEnd", "00:00"); manualMode = reader.GetValueAsBool("atmolight", "OffOnStart", false); sbs3dOn = reader.GetValueAsBool("atmolight", "SBS_3D_ON", false); lowCPU = reader.GetValueAsBool("atmolight", "lowCPU", false); lowCPUTime = reader.GetValueAsInt("atmolight", "lowCPUTime", 0); delay = reader.GetValueAsBool("atmolight", "Delay", false); delayReferenceTime = reader.GetValueAsInt("atmolight", "DelayTime", 0); exitAtmoWin = reader.GetValueAsBool("atmolight", "ExitAtmoWin", true); startAtmoWin = reader.GetValueAsBool("atmolight", "StartAtmoWin", true); atmoWakeHelperEnabled = reader.GetValueAsBool("atmolight", "atmoWakeHelperEnabled", false); atmoWakeHelperComPort = reader.GetValueAsString("atmolight", "atmoWakeHelperComPort", ""); atmoWakeHelperResumeDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperResumeDelay", 2500); atmoWakeHelperDisconnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperDisconnectDelay", 1500); atmoWakeHelperConnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperConnectDelay", 1500); atmoWakeHelperReinitializationDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperReinitializationDelay", 0); staticColorRed = reader.GetValueAsInt("atmolight", "StaticColorRed", 0); staticColorGreen = reader.GetValueAsInt("atmolight", "StaticColorGreen", 0); staticColorBlue = reader.GetValueAsInt("atmolight", "StaticColorBlue", 0); restartOnError = reader.GetValueAsBool("atmolight", "RestartOnError", true); trueGrabbing = reader.GetValueAsBool("atmolight", "TrueGrabbing", true); delayReferenceRefreshRate = reader.GetValueAsInt("atmolight", "DelayRefreshRate", 50); blackbarDetection = reader.GetValueAsBool("atmolight", "BlackbarDetection", false); blackbarDetectionTime = reader.GetValueAsInt("atmolight", "BlackbarDetectionTime", 1000); gifFile = reader.GetValueAsString("atmolight", "GIFFile", ""); captureWidth = reader.GetValueAsInt("atmolight", "captureWidth", 64); captureHeight = reader.GetValueAsInt("atmolight", "captureHeight", 64); monitorScreensaverState = reader.GetValueAsBool("atmolight", "monitorScreensaverState", true); monitorWindowState = reader.GetValueAsBool("atmolight", "monitorWindowState", true); hyperionIP = reader.GetValueAsString("atmolight", "hyperionIP", "127.0.0.1"); hyperionPort = reader.GetValueAsInt("atmolight", "hyperionPort", 19445); hyperionReconnectDelay = reader.GetValueAsInt("atmolight", "hyperionReconnectDelay", 10000); hyperionReconnectAttempts = reader.GetValueAsInt("atmolight", "hyperionReconnectAttempts", 5); hyperionPriority = reader.GetValueAsInt("atmolight", "hyperionPriority", 1); hyperionPriorityStaticColor = reader.GetValueAsInt("atmolight", "hyperionStaticColorPriority", 1); hyperionLiveReconnect = reader.GetValueAsBool("atmolight", "hyperionLiveReconnect", false); hueExe = reader.GetValueAsString("atmolight", "hueExe", ""); hueStart = reader.GetValueAsBool("atmolight", "hueStart", true); hueIsRemoteMachine = reader.GetValueAsBool("atmolight", "hueIsRemoteMachine", false); hueIP = reader.GetValueAsString("atmolight", "hueIP", "127.0.0.1"); huePort = reader.GetValueAsInt("atmolight", "huePort", 20123); hueReconnectDelay = reader.GetValueAsInt("atmolight", "hueReconnectDelay", 10000); hueReconnectAttempts = reader.GetValueAsInt("atmolight", "hueReconnectAttempts", 5); hueBridgeEnableOnResume = reader.GetValueAsBool("atmolight", "hueBridgeEnableOnResume", false); hueBridgeDisableOnSuspend = reader.GetValueAsBool("atmolight", "hueBridgeDisableOnSuspend", false); hueTheaterEnabled = reader.GetValueAsBool("atmolight", "hueTheaterEnabled", false); hueTheaterRestoreLights = reader.GetValueAsBool("atmolight", "hueTheaterRestoreLights", false); boblightIP = reader.GetValueAsString("atmolight", "boblightIP", "127.0.0.1"); boblightPort = reader.GetValueAsInt("atmolight", "boblightPort", 19333); boblightMaxFPS = reader.GetValueAsInt("atmolight", "boblightMaxFPS", 10); boblightMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "boblightMaxReconnectAttempts", 5); boblightReconnectDelay = reader.GetValueAsInt("atmolight", "boblightReconnectDelay", 5000); boblightSpeed = reader.GetValueAsInt("atmolight", "boblightSpeed", 100); boblightAutospeed = reader.GetValueAsInt("atmolight", "boblightAutospeed", 0); boblightInterpolation = reader.GetValueAsBool("atmolight", "boblightInterpolation", true); boblightSaturation = reader.GetValueAsInt("atmolight", "boblightSaturation", 1); boblightValue = reader.GetValueAsInt("atmolight", "boblightValue", 1); boblightThreshold = reader.GetValueAsInt("atmolight", "boblightThreshold", 20); boblightGamma = Double.Parse(reader.GetValueAsString("atmolight", "boblightGamma", "2.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoWinTarget = reader.GetValueAsBool("atmolight", "atmoWinTarget", true); boblightTarget = reader.GetValueAsBool("atmolight", "boblightTarget", false); hueTarget = reader.GetValueAsBool("atmolight", "hueTarget", false); hyperionTarget = reader.GetValueAsBool("atmolight", "hyperionTarget", false); blackbarDetectionThreshold = reader.GetValueAsInt("atmolight", "blackbarDetectionThreshold", 20); powerModeChangedDelay = reader.GetValueAsInt("atmolight", "powerModeChangedDelay", 5000); ambiBoxTarget = reader.GetValueAsBool("atmolight", "ambiBoxTarget", false); ambiBoxIP = reader.GetValueAsString("atmolight", "ambiBoxIP", "127.0.0.1"); ambiBoxPort = reader.GetValueAsInt("atmolight", "ambiBoxPort", 3636); ambiBoxMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "ambiBoxMaxReconnectAttempts", 5); ambiBoxReconnectDelay = reader.GetValueAsInt("atmolight", "ambiBoxReconnectDelay", 5000); ambiBoxMediaPortalProfile = reader.GetValueAsString("atmolight", "ambiBoxMediaPortalProfile", "MediaPortal"); ambiBoxExternalProfile = reader.GetValueAsString("atmolight", "ambiBoxExternalProfile", "External"); ambiBoxPath = reader.GetValueAsString("atmolight", "ambiBoxPath", "C:\\Program Files (x86)\\AmbiBox\\AmbiBox.exe"); ambiBoxAutoStart = reader.GetValueAsBool("atmolight", "ambiBoxAutoStart", false); ambiBoxAutoStop = reader.GetValueAsBool("atmolight", "ambiBoxAutoStop", false); atmoOrbTarget = reader.GetValueAsBool("atmolight", "atmoOrbTarget", false); atmoOrbBlackThreshold = reader.GetValueAsInt("atmolight", "atmoOrbBlackThreshold", 16); atmoOrbBroadcastPort = reader.GetValueAsInt("atmolight", "atmoOrbBroadcastPort", 49692); atmoOrbGamma = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbGamma", "1").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbMinDiversion = reader.GetValueAsInt("atmolight", "atmoOrbMinDiversion", 16); atmoOrbSaturation = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbThreshold = reader.GetValueAsInt("atmolight", "atmoOrbThreshold", 0); atmoOrbUseOverallLightness = reader.GetValueAsBool("atmolight", "atmoOrbUseOverallLightness", true); string atmoOrbLampTemp = reader.GetValueAsString("atmolight", "atmoOrbLamps", ""); string[] atmoOrbLampTempSplit = atmoOrbLampTemp.Split('|'); for (int i = 0; i < atmoOrbLampTempSplit.Length; i++) { if (!string.IsNullOrEmpty(atmoOrbLampTempSplit[i])) { atmoOrbLamps.Add(atmoOrbLampTempSplit[i]); } } vuMeterMindB = reader.GetValueAsInt("atmolight", "vuMeterMindB", -24); vuMeterMinHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMinHue", "0,74999").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); vuMeterMaxHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMaxHue", "0,95833").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueThreshold = reader.GetValueAsInt("atmolight", "hueThreshold", 16); hueBlackThreshold = reader.GetValueAsInt("atmolight", "hueBlackThreshold", 16); hueMinDiversion = reader.GetValueAsInt("atmolight", "hueMinDiversion", 16); hueSaturation = Double.Parse(reader.GetValueAsString("atmolight", "hueSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueUseOverallLightness = reader.GetValueAsBool("atmolight", "hueUseOverallLightness", true); blackbarDetectionHorizontal = reader.GetValueAsBool("atmolight", "blackbarDetectionHorizontal", true); blackbarDetectionVertical = reader.GetValueAsBool("atmolight", "blackbarDetectionVertical", true); blackbarDetectionLinkAreas = reader.GetValueAsBool("atmolight", "blackbarDetectionLinkAreas", true); remoteApiServer = reader.GetValueAsBool("atmolight", "remoteApiServer", false); } }
public bool ChangeEffect(ContentEffect effect) { switch (effect) { case ContentEffect.ExternalLiveMode: ChangeEffect(ContentEffect.LEDsDisabled); if (profileList.Contains(coreObject.ambiBoxExternalProfile)) { SendCommand("lock"); SendCommand("setprofile:" + coreObject.ambiBoxExternalProfile); currentProfile = coreObject.ambiBoxExternalProfile; SendCommand("setstatus:on"); SendCommand("unlock"); } return true; case ContentEffect.MediaPortalLiveMode: case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: ChangeEffect(ContentEffect.LEDsDisabled); SendCommand("lock"); System.Threading.Thread.Sleep(50); if (profileList.Contains(coreObject.ambiBoxMediaPortalProfile)) { SendCommand("setprofile:" + coreObject.ambiBoxMediaPortalProfile); currentProfile = coreObject.ambiBoxMediaPortalProfile; } SendCommand("setstatus:on"); SendCommand("unlock"); return true; case ContentEffect.StaticColor: SendCommand("lock"); string staticColorString = "setcolor:"; for (int i = 1; i <= ledCount; i++) { staticColorString += i + "-" + coreObject.staticColor[0] + "," + coreObject.staticColor[1] + "," + coreObject.staticColor[2] + ";"; } SendCommand(staticColorString); System.Threading.Thread.Sleep(50); SendCommand(staticColorString); System.Threading.Thread.Sleep(50); SendCommand(staticColorString); SendCommand("setstatus:off"); return true; case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: SendCommand("lock"); string disableString = "setcolor:"; for (int i = 1; i <= ledCount; i++) { disableString += i + "-" + 0 + "," + 0 + "," + 0 + ";"; } SendCommand(disableString); System.Threading.Thread.Sleep(50); SendCommand(disableString); System.Threading.Thread.Sleep(50); SendCommand(disableString); SendCommand("setstatus:off"); return true; } }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return(false); } switch (effect) { case ContentEffect.StaticColor: ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2], 10, 0); break; case ContentEffect.LEDsDisabled: if (coreObject.hueTheaterEnabled && coreObject.hueTheaterRestoreLights && !TheaterModeFirstStart && TheaterModeIsActivated) { // Send theater command TheaterMode("DISABLE"); TheaterModeIsActivated = false; Array.Clear(changeColorBuffer, 0, changeColorBuffer.Length); StartChangeColorThread(); } else if (coreObject.hueTheaterEnabled && TheaterModeFirstStart) { // Do nothing TheaterModeFirstStart = false; } else { ChangeColor(0, 0, 0, 1, 0); } break; case ContentEffect.MediaPortalLiveMode: if (coreObject.hueTheaterEnabled) { // Send theater command TheaterModeIsActivated = true; StopChangeColorThread(); TheaterMode("ENABLE"); } break; case ContentEffect.VUMeter: if (coreObject.hueTheaterEnabled && coreObject.hueTheaterEnabledVU) { // Send theater command TheaterModeIsActivated = true; StopChangeColorThread(); TheaterMode("ENABLE"); } break; case ContentEffect.VUMeterRainbow: if (coreObject.hueTheaterEnabled && coreObject.hueTheaterEnabledVU) { // Send theater command TheaterModeIsActivated = true; StopChangeColorThread(); TheaterMode("ENABLE"); } break; case ContentEffect.Undefined: default: if (coreObject.hueTheaterEnabled && coreObject.hueTheaterRestoreLights && !TheaterModeFirstStart && TheaterModeIsActivated) { // Send theater command TheaterMode("DISABLE"); Array.Clear(changeColorBuffer, 0, changeColorBuffer.Length); StartChangeColorThread(); TheaterModeIsActivated = false; } else if (coreObject.hueTheaterEnabled && TheaterModeFirstStart) { // Do nothing TheaterModeFirstStart = false; } else { ChangeColor(0, 0, 0, 1, 0); } break; } return(true); }
public bool ChangeEffect(ContentEffect effect) { switch (effect) { case ContentEffect.ExternalLiveMode: ChangeEffect(ContentEffect.LEDsDisabled); if (profileList.Contains(coreObject.ambiBoxExternalProfile)) { SendCommand("lock"); SendCommand("setprofile:" + coreObject.ambiBoxExternalProfile); currentProfile = coreObject.ambiBoxExternalProfile; SendCommand("setstatus:on"); SendCommand("unlock"); } return(true); case ContentEffect.MediaPortalLiveMode: case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: ChangeEffect(ContentEffect.LEDsDisabled); SendCommand("lock"); System.Threading.Thread.Sleep(50); if (profileList.Contains(coreObject.ambiBoxMediaPortalProfile)) { SendCommand("setprofile:" + coreObject.ambiBoxMediaPortalProfile); currentProfile = coreObject.ambiBoxMediaPortalProfile; } SendCommand("setstatus:on"); SendCommand("unlock"); return(true); case ContentEffect.StaticColor: SendCommand("lock"); string staticColorString = "setcolor:"; for (int i = 1; i <= ledCount; i++) { staticColorString += i + "-" + coreObject.staticColor[0] + "," + coreObject.staticColor[1] + "," + coreObject.staticColor[2] + ";"; } SendCommand(staticColorString); System.Threading.Thread.Sleep(50); SendCommand(staticColorString); System.Threading.Thread.Sleep(50); SendCommand(staticColorString); SendCommand("setstatus:off"); return(true); case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: SendCommand("lock"); string disableString = "setcolor:"; for (int i = 1; i <= ledCount; i++) { disableString += i + "-" + 0 + "," + 0 + "," + 0 + ";"; } SendCommand(disableString); System.Threading.Thread.Sleep(50); SendCommand(disableString); System.Threading.Thread.Sleep(50); SendCommand(disableString); SendCommand("setstatus:off"); return(true); } }
public bool ChangeEffect(ContentEffect effect) { // Change the effect on your target }
/// <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(); }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return false; } switch (effect) { case ContentEffect.StaticColor: ChangeColor(coreObject.staticColor[0], coreObject.staticColor[1], coreObject.staticColor[2], 10, 0); break; case ContentEffect.LEDsDisabled: if (coreObject.hueTheaterEnabled && coreObject.hueTheaterRestoreLights && !TheaterModeFirstStart && TheaterModeIsActivated) { // Send theater command TheaterMode("DISABLE"); TheaterModeIsActivated = false; Array.Clear(changeColorBuffer, 0, changeColorBuffer.Length); StartChangeColorThread(); } else if (coreObject.hueTheaterEnabled && TheaterModeFirstStart) { // Do nothing TheaterModeFirstStart = false; } else { ChangeColor(0, 0, 0, 1, 0); } break; case ContentEffect.MediaPortalLiveMode: if (coreObject.hueTheaterEnabled) { // Send theater command TheaterModeIsActivated = true; StopChangeColorThread(); TheaterMode("ENABLE"); } break; case ContentEffect.VUMeter: if (coreObject.hueTheaterEnabled) { // Send theater command TheaterModeIsActivated = true; StopChangeColorThread(); TheaterMode("ENABLE"); } break; case ContentEffect.VUMeterRainbow: if (coreObject.hueTheaterEnabled) { // Send theater command TheaterModeIsActivated = true; StopChangeColorThread(); TheaterMode("ENABLE"); } break; case ContentEffect.Undefined: default: if (coreObject.hueTheaterEnabled && coreObject.hueTheaterRestoreLights && !TheaterModeFirstStart && TheaterModeIsActivated) { // Send theater command TheaterMode("DISABLE"); Array.Clear(changeColorBuffer, 0, changeColorBuffer.Length); StartChangeColorThread(); TheaterModeIsActivated = false; } else if (coreObject.hueTheaterEnabled && TheaterModeFirstStart) { // Do nothing TheaterModeFirstStart = false; } else { ChangeColor(0, 0, 0, 1, 0); } break; } return true; }
public bool ChangeEffect(ContentEffect effect) { if (!IsConnected()) { return false; } try { switch (effect) { case ContentEffect.MediaPortalLiveMode: case ContentEffect.GIFReader: case ContentEffect.VUMeter: case ContentEffect.VUMeterRainbow: return true; case ContentEffect.StaticColor: ChangeStaticColor(coreObject.staticColor); return true; case ContentEffect.LEDsDisabled: case ContentEffect.Undefined: default: ChangeStaticColor(new int[] { 0, 0, 0 }); return true; } } catch (Exception ex) { Log.Error("BoblightHandler - Error changing effect to {0}", effect.ToString()); Log.Error("BoblightHandler - Exception: {0}", ex.Message); ReInitialise(); return false; } }