Пример #1
0
    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();
    }
Пример #2
0
        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();
        }