Inheritance: System.ComponentModel.BackgroundWorker
Exemplo n.º 1
0
        public XbmcHandler(XbmcJsonRpcConnection xbmc, DisplayHandler display)
        {
            if (xbmc == null)
            {
                throw new ArgumentNullException("xbmc");
            }
            if (display == null)
            {
                throw new ArgumentNullException("display");
            }

            this.xbmc = xbmc;
            this.display = display;

            this.xbmc.Connected                     +=  this.xbmcConnected;
            this.xbmc.Aborted                       +=  this.xbmcAborted;
            this.xbmc.Player.PlaybackStarted        +=  this.xbmcPlaybackStarted;
            this.xbmc.Player.PlaybackPaused         +=  this.xbmcPlaybackPaused;
            //this.xbmc.Player.PlaybackResumed        +=  this.xbmcPlaybackResumed;
            this.xbmc.Player.PlaybackStopped        +=  this.xbmcPlaybackStopped;
            //this.xbmc.Player.PlaybackEnded          +=  this.xbmcPlaybackEnded;
            this.xbmc.Player.PlaybackSeek           +=  this.xbmcPlaybackSeek;
            this.xbmc.Player.PlaybackSeekChapter    +=  this.xbmcPlaybackSeek;
            this.xbmc.Player.PlaybackSpeedChanged   +=  this.xbmcPlaybackSpeedChanged;

            this.progressTimer = new System.Timers.Timer();
            this.progressTimer.Interval = ProgressUpdateInterval;
            this.progressTimer.Elapsed += progressTimerUpdate;
            this.progressTimer.AutoReset = true;

            this.systemTimeTimer = new System.Timers.Timer();
            this.systemTimeTimer.Interval = SystemTimeUpdateInterval;
            this.systemTimeTimer.Elapsed += systemTimeTimerUpdate;
            this.systemTimeTimer.AutoReset = true;

            this.WorkerReportsProgress = false;
            this.WorkerSupportsCancellation = true;

            this.controlModeState = new ControlState();
            this.controlModeTimer = new System.Timers.Timer();
            this.controlModeTimer.Interval = ControlModeUpdateInterval;
            this.controlModeTimer.Elapsed += controlModeTimerUpdate;
            this.controlModeTimer.AutoReset = true;

            this.semReady = new Semaphore(0, 1);
            this.semWork = new Semaphore(0, 1);
        }
Exemplo n.º 2
0
        private void controlModeTimerUpdate(object sender, ElapsedEventArgs e)
        {
            this.controlModeTimer.Stop();

            lock (connectionLocking)
            {
                if (!Settings.Default.XbmcControlModeEnable || !this.connected)
                {
                    this.controlModeTimer.Stop();

                    if (this.connected)
                    {
                        this.updateCurrentlyPlaying();
                    }

                    return;
                }
            }

            if (this.controlModeUnchanged >= 0)
            {
                this.controlModeUnchanged += Convert.ToInt32(this.controlModeTimer.Interval);
            }

            if (this.playerState != PlayerState.Stopped && Settings.Default.XbmcControlModeDisableDuringPlayback)
            {
                this.checkControlModeUnchanged();
                //return;
            }
            else
            {
                IDictionary<string, string> info = xbmc.System.GetInfoLabels("System.CurrentWindow", "System.CurrentControl");
                if (info.Count != 2 || string.IsNullOrEmpty(info["System.CurrentControl"]))
                {
                    this.checkControlModeUnchanged();
                    //return;
                }
                else
                {
                    string display = string.Empty;
                    if (Settings.Default.XbmcControlModeDisplayWindowName && !string.IsNullOrEmpty(info["System.CurrentWindow"]))
                    {
                        display = info["System.CurrentWindow"] + ": ";
                    }

                    string control = info["System.CurrentControl"];
                    if (Settings.Default.XbmcControlModeRemoveBrackets && control.StartsWith("[") && control.EndsWith("]"))
                    {
                        control = control.Remove(0, 1);
                        control = control.Remove(control.Length - 1, 1);
                    }

                    if (this.controlModeState.Window == info["System.CurrentWindow"] && this.controlModeState.Control == control)
                    {
                        this.checkControlModeUnchanged();
                        //return;
                    }
                    else
                    {
                        this.display.SetText(display + control);

                        this.controlModeState.Window = info["System.CurrentWindow"];
                        this.controlModeState.Control = control;
                        this.controlModeUnchanged = 0;
                    }
                }
            }

            this.controlModeTimer.Start();
        }
Exemplo n.º 3
0
        private void constructor()
        {
            try
            {
                if (File.Exists(Logging.ErrorLog))
                {
                    if (File.Exists(Logging.ErrorLog + Logging.OldLog))
                    {
                        File.Delete(Logging.ErrorLog + Logging.OldLog);
                    }
                    File.Move(Logging.ErrorLog, Logging.ErrorLog + Logging.OldLog);
                }
                if (File.Exists(Logging.DebugLog))
                {
                    if (File.Exists(Logging.DebugLog + Logging.OldLog))
                    {
                        File.Delete(Logging.DebugLog + Logging.OldLog);
                    }
                    File.Move(Logging.DebugLog, Logging.DebugLog + Logging.OldLog);
                }
            }
            catch (Exception)
            { }

            this.xbmcConnectionTimer = new System.Windows.Forms.Timer();
            this.xbmcConnectionTimer.Tick += xbmcTryConnect;

            this.settingsUpdate();
            this.setupSettingsChanges(this.tabOptions);

            // Setting up iMON
            Logging.Log("Setting up iMON");
            this.imon = new iMonWrapperApi();
            this.imon.StateChanged += wrapperApi_StateChanged;
            this.imon.Error += wrapperApi_Error;
            this.imon.LogError += wrapperApi_iMon_LogError;
            if (Settings.Default.GeneralDebugEnable)
            {
                this.imon.Log += wrapperApi_iMon_Log;
            }

            this.displayHandler = new DisplayHandler(this.imon);
            this.displayHandler.RunWorkerAsync();

            // Setting up XBMC
            this.xbmcConnectingDeletage = new XbmcConnectingDelegate(xbmcConnecting);
            this.xbmcSetup();
        }
Exemplo n.º 4
0
        private void constructor()
        {
            // GUI initialization
            this.tbXbmcMovieSingleText.Suggestions.Add("%title%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%year%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%rating%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%genre%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%duration%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%mpaa%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%tagline%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%studio%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%director%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%writer%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%outline%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%plot%");

            this.tbXbmcTvSingleText.Suggestions.Add("%title%");
            this.tbXbmcTvSingleText.Suggestions.Add("%episode%");
            this.tbXbmcTvSingleText.Suggestions.Add("%season%");
            this.tbXbmcTvSingleText.Suggestions.Add("%show%");
            this.tbXbmcTvSingleText.Suggestions.Add("%year%");
            this.tbXbmcTvSingleText.Suggestions.Add("%rating%");
            this.tbXbmcTvSingleText.Suggestions.Add("%duration%");
            this.tbXbmcTvSingleText.Suggestions.Add("%mpaa%");
            this.tbXbmcTvSingleText.Suggestions.Add("%studio%");
            this.tbXbmcTvSingleText.Suggestions.Add("%director%");
            this.tbXbmcTvSingleText.Suggestions.Add("%writer%");
            this.tbXbmcTvSingleText.Suggestions.Add("%plot%");

            this.tbXbmcMusicSingleText.Suggestions.Add("%title%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%artist%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%album%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%track%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%year%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%rating%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%genre%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%duration%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%disc%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%lyrics%");

            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%title%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%artist%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%album%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%year%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%rating%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%genre%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%duration%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%studio%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%director%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%plot%");

            try
            {
                //if (File.Exists(Logging.ErrorLog))
                //{
                //    if (File.Exists(Logging.ErrorLog + Logging.OldLog))
                //    {
                //        File.Delete(Logging.ErrorLog + Logging.OldLog);
                //    }
                //    File.Move(Logging.ErrorLog, Logging.ErrorLog + Logging.OldLog);
                //}
                if (File.Exists(Logging.DebugLog))
                {
                    if (File.Exists(Logging.DebugLog + Logging.OldLog))
                    {
                        File.Delete(Logging.DebugLog + Logging.OldLog);
                    }
                    File.Move(Logging.DebugLog, Logging.DebugLog + Logging.OldLog);
                }
            }
            catch (Exception)
            { }

            Logging.Log("Current version of XbmcOniMon: " + Assembly.GetExecutingAssembly().GetName().Version.ToString());

            this.xbmcConnectionTimer = new Timer();
            this.xbmcConnectionTimer.Tick += xbmcTryConnect;

            // Check for update
            if (Settings.Default.GeneralCheckForUpdateOnStart)
                Updating.update(true);

            // Check if this is a newer version. If so, do settings update
            if (Settings.Default.CallUpgrade)
            {
                Logging.Log("Trying to upgrade settings");
                Settings.Default.Upgrade();
                Settings.Default.CallUpgrade = false;
                Settings.Default.Save();
                Settings.Default.Reload();
                //this.settingsUpdate();
                Logging.Log("Settings upgraded");
                MessageBox.Show("Settings upgraded from the previous version");
            }

            this.settingsUpdate();
            this.setupSettingsChanges(this.tabOptions);

            // Setting up iMON
            Logging.Log("Setting up iMON");
            this.imon = new iMonWrapperApi();
            this.imon.StateChanged += wrapperApi_StateChanged;
            this.imon.Error += wrapperApi_Error;
            this.imon.LogError += wrapperApiIMonLogError;
            if (Settings.Default.GeneralDebugEnable)
            {
                this.imon.Log += wrapperApiIMonLog;
            }

            this.displayHandler = new DisplayHandler(this.imon);
            this.displayHandler.RunWorkerAsync();

            // Setting up XBMC
            this.xbmcConnectingDeletage = new XbmcConnectingDelegate(xbmcConnecting);
            this.xbmcSetup();
        }
Exemplo n.º 5
0
        private void constructor()
        {
            // GUI initialization
            this.tbXbmcMovieSingleText.Suggestions.Add("%title%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%year%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%rating%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%genre%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%duration%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%mpaa%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%tagline%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%studio%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%director%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%writer%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%outline%");
            this.tbXbmcMovieSingleText.Suggestions.Add("%plot%");

            this.tbXbmcTvSingleText.Suggestions.Add("%title%");
            this.tbXbmcTvSingleText.Suggestions.Add("%episode%");
            this.tbXbmcTvSingleText.Suggestions.Add("%season%");
            this.tbXbmcTvSingleText.Suggestions.Add("%show%");
            this.tbXbmcTvSingleText.Suggestions.Add("%year%");
            this.tbXbmcTvSingleText.Suggestions.Add("%rating%");
            this.tbXbmcTvSingleText.Suggestions.Add("%duration%");
            this.tbXbmcTvSingleText.Suggestions.Add("%mpaa%");
            this.tbXbmcTvSingleText.Suggestions.Add("%studio%");
            this.tbXbmcTvSingleText.Suggestions.Add("%director%");
            this.tbXbmcTvSingleText.Suggestions.Add("%writer%");
            this.tbXbmcTvSingleText.Suggestions.Add("%plot%");

            this.tbXbmcMusicSingleText.Suggestions.Add("%title%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%artist%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%album%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%track%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%year%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%rating%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%genre%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%duration%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%disc%");
            this.tbXbmcMusicSingleText.Suggestions.Add("%lyrics%");

            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%title%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%artist%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%album%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%year%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%rating%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%genre%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%duration%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%studio%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%director%");
            this.tbXbmcMusicVideoSingleText.Suggestions.Add("%plot%");

            try
            {
                //if (File.Exists(Logging.ErrorLog))
                //{
                //    if (File.Exists(Logging.ErrorLog + Logging.OldLog))
                //    {
                //        File.Delete(Logging.ErrorLog + Logging.OldLog);
                //    }
                //    File.Move(Logging.ErrorLog, Logging.ErrorLog + Logging.OldLog);
                //}
                if (File.Exists(Logging.DebugLog))
                {
                    if (File.Exists(Logging.DebugLog + Logging.OldLog))
                    {
                        File.Delete(Logging.DebugLog + Logging.OldLog);
                    }
                    File.Move(Logging.DebugLog, Logging.DebugLog + Logging.OldLog);
                }
            }
            catch (Exception)
            { }

            Logging.Log("Current version of XbmcOniMon: " + Assembly.GetExecutingAssembly().GetName().Version.ToString());

            this.xbmcConnectionTimer       = new Timer();
            this.xbmcConnectionTimer.Tick += xbmcTryConnect;


            // Check for update
            if (Settings.Default.GeneralCheckForUpdateOnStart)
            {
                Updating.update(true);
            }

            // Check if this is a newer version. If so, do settings update
            if (Settings.Default.CallUpgrade)
            {
                Logging.Log("Trying to upgrade settings");
                Settings.Default.Upgrade();
                Settings.Default.CallUpgrade = false;
                Settings.Default.Save();
                Settings.Default.Reload();
                //this.settingsUpdate();
                Logging.Log("Settings upgraded");
                MessageBox.Show("Settings upgraded from the previous version");
            }

            this.settingsUpdate();
            this.setupSettingsChanges(this.tabOptions);

            // Setting up iMON
            Logging.Log("Setting up iMON");
            this.imon = new iMonWrapperApi();
            this.imon.StateChanged += wrapperApi_StateChanged;
            this.imon.Error        += wrapperApi_Error;
            this.imon.LogError     += wrapperApiIMonLogError;
            if (Settings.Default.GeneralDebugEnable)
            {
                this.imon.Log += wrapperApiIMonLog;
            }

            this.displayHandler = new DisplayHandler(this.imon);
            this.displayHandler.RunWorkerAsync();

            // Setting up XBMC
            this.xbmcConnectingDeletage = new XbmcConnectingDelegate(xbmcConnecting);
            this.xbmcSetup();
        }