コード例 #1
0
 public void ShowDialog()
 {
     if (handler == null)
     {
         return;
     }
     handler.OnTaskProgress += new BackgroundTaskProgress(setProgress);
     closeProgDialog();
     dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
     if (dlgPrgrs != null)
     {
         dlgPrgrs.Reset();
         dlgPrgrs.DisplayProgressBar = true;
         dlgPrgrs.ShowWaitCursor     = false;
         dlgPrgrs.DisableCancel(true);
         dlgPrgrs.SetHeading("");
         dlgPrgrs.SetLine(1, "");
         dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
     }
     else
     {
         GUIWaitCursor.Init(); GUIWaitCursor.Show();
     }
     if (!handler.Start())
     {
         closeProgDialog();
         return;
     }
 }
コード例 #2
0
ファイル: GUIRSSFeed.cs プロジェクト: c3333/MediaPortal-1
        private void UpdateNews(bool bShowWarning)
        {
            GUIDialogProgress dlgProgress =
                (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);

            try
            {
                if (m_strSiteURL.ToLowerInvariant().StartsWith("http://") == false &&
                    m_strSiteURL.ToLowerInvariant().StartsWith("file://") == false)
                {
                    m_strSiteURL = "http://" + m_strSiteURL;
                }

                long startTime = Environment.TickCount;
                dlgProgress.SetHeading(704);
                dlgProgress.SetLine(1, GUILocalizeStrings.Get(705) + " " + m_strSiteName);
                dlgProgress.SetLine(2, "");
                dlgProgress.SetLine(3, "");
                dlgProgress.ShowProgressBar(false);
                dlgProgress.StartModal(GetID);
                dlgProgress.Progress();

                Uri newURL = new Uri(m_strSiteURL);
                Download(newURL);
                UpdateButtons();

                // Leave dialog on screen for minimum of 1 seconds
                // to eliminate the horrible flash of dialog before user can reed it
                long endTime = Environment.TickCount;
                if (endTime - startTime < 1000)
                {
                    Thread.Sleep((int)(1000 - (endTime - startTime)));
                }
                dlgProgress.Close();
            }
            catch (Exception e)
            {
                dlgProgress.Close();
                if (bShowWarning)
                {
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_WARNING, 0, 0, 0, 0, 0, 0);
                    msg.Param1 = 9;   //my news
                    msg.Param2 = 912; //Unable to download latest news
                    msg.Param3 = 0;
                    msg.Label3 = m_strSiteURL;
                    GUIWindowManager.SendMessage(msg);
                    Log.Error(e);
                }
            }
        }
コード例 #3
0
        public bool OnActorsStarting(IMDBFetcher fetcher)
        {
            GUIDialogProgress pDlgProgress =
                (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);

            // show dialog that we're downloading the actor info
            pDlgProgress.Reset();
            pDlgProgress.SetHeading(986);
            pDlgProgress.SetLine(1, fetcher.MovieName);
            pDlgProgress.SetLine(2, string.Empty);
            pDlgProgress.SetObject(fetcher);
            pDlgProgress.StartModal(GUIWindowManager.ActiveWindow);
            return(true);
        }
コード例 #4
0
        public bool OnSearchStarting(IMDBFetcher fetcher)
        {
            GUIDialogProgress pDlgProgress =
                (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);

            // show dialog that we're busy querying www.imdb.com
            pDlgProgress.Reset();
            pDlgProgress.SetHeading(197);
            pDlgProgress.SetLine(1, fetcher.MovieName);
            pDlgProgress.SetLine(2, string.Empty);
            pDlgProgress.SetObject(fetcher);
            pDlgProgress.StartModal(GUIWindowManager.ActiveWindow);
            return(true);
        }
コード例 #5
0
        static GUIDialogProgress PrepareProgressDialog(string header)
        {
            GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);

            if (dlgPrgrs != null)
            {
                dlgPrgrs.Reset();
                dlgPrgrs.DisplayProgressBar = true;
                dlgPrgrs.ShowWaitCursor     = false;
                dlgPrgrs.DisableCancel(true);
                dlgPrgrs.SetHeading(string.Format("{0} - {1}", PluginConfiguration.Instance.BasicHomeScreenName, header));
                dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
            }
            return(dlgPrgrs);
        }
コード例 #6
0
        public void UpdateSearchResults(string sortOrder)
        {
            GUIDialogProgress dlg = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);

            dlg.Reset();
            dlg.SetHeading("Torrents");
            dlg.SetLine(1, "Fetching torrents...");
            dlg.SetPercentage(0);
            dlg.ShowProgressBar(true);
            dlg.StartModal(GUIWindowManager.ActiveWindow);

            _progressDlg = new ProgressUpdater();
            _progressDlg.SetAutoUpdate(1000, 20);

            TorrentEngine.Instance().SearchTorrent(_searchEngine.Name, _searchString, sortOrder, dlg);
        }
コード例 #7
0
        void filtersCreator_DoWork(object sender, DoWorkEventArgs e)
        {
            GUIDialogProgress progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);

            progressDialog.Reset();
            progressDialog.ShowWaitCursor = true;
            progressDialog.SetHeading(Translation.CreatingFilters);
            progressDialog.Percentage = 0;
            progressDialog.SetLine(1, string.Empty);
            progressDialog.SetLine(2, string.Empty);
            progressDialog.StartModal(this.GetID);

            GUIWindowManager.Process();

            TraktHandlers.MovingPictures.CreateMovingPicturesFilters();

            progressDialog.SetHeading(Translation.UpdatingFilters);
            GUIWindowManager.Process();

            TraktHandlers.MovingPictures.UpdateMovingPicturesFilters();
            progressDialog.ShowWaitCursor = false;
            progressDialog.Close();
            GUIWindowManager.Process();
        }
コード例 #8
0
        public List <string> deleteSeason(TVSeriesPlugin.DeleteMenuItems type)
        {
            List <string> resultMsg = new List <string>();

            // Always delete from Local episode table if deleting from disk or database
            SQLCondition condition = new SQLCondition();

            condition.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
            condition.Add(new DBEpisode(), DBEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal);

            /* TODO will include hidden episodes as hidden attribute is only in onlineepisodes. maybe we should include it in localepisodes also..
             * if hidden episodes are excluded then the if (resultMsg.Count is wrong and should do another select to get proper count
             * if (!DBOption.GetOptions(DBOption.cShowHiddenItems))
             * {
             *  //don't include hidden seasons unless the ShowHiddenItems option is set
             *  condition.Add(new DBEpisode(), idden, 0, SQLConditionType.Equal);
             * }
             */

            List <DBEpisode> episodes = DBEpisode.Get(condition, false);

            if (episodes != null)
            {
                bool hasLocalEpisodesToDelete = episodes.Exists(e => !string.IsNullOrEmpty(e[DBEpisode.cFilename]));
                hasLocalEpisodesToDelete &= (type == TVSeriesPlugin.DeleteMenuItems.disk || type == TVSeriesPlugin.DeleteMenuItems.diskdatabase);

                DBSeries series     = Helper.getCorrespondingSeries(this[DBSeason.cSeriesID]);
                string   seriesName = series == null ? this[DBSeason.cSeriesID].ToString() : series.ToString();

                // show progress dialog as this can be a long process esp for network drives
                // will show new progress for each season if deleting from the series level
                GUIDialogProgress progressDialog = null;
                if (!Settings.isConfig)
                {
                    progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
                    progressDialog.Reset();
                    progressDialog.DisplayProgressBar = true;
                    progressDialog.ShowWaitCursor     = false;
                    progressDialog.DisableCancel(true);
                    progressDialog.SetHeading(Translation.Delete);
                    progressDialog.Percentage = 0;
                    progressDialog.SetLine(1, string.Format("{0} {1} {2}", seriesName, Translation.Season, this[DBSeason.cIndex]));
                    progressDialog.SetLine(2, string.Empty);

                    // only show progress dialog if we have local files in season
                    if (hasLocalEpisodesToDelete)
                    {
                        progressDialog.StartModal(GUIWindowManager.ActiveWindow);
                    }
                }

                int counter = 0;

                foreach (DBEpisode episode in episodes)
                {
                    string episodeName = string.Format("{0}x{1} - {2}", episode[DBOnlineEpisode.cSeasonIndex], episode[DBOnlineEpisode.cEpisodeIndex], episode[DBOnlineEpisode.cEpisodeName]);
                    if (!Settings.isConfig)
                    {
                        progressDialog.SetLine(2, episodeName);
                    }
                    if (!Settings.isConfig)
                    {
                        GUIWindowManager.Process();
                    }

                    resultMsg.AddRange(episode.deleteEpisode(type, true));

                    if (!Settings.isConfig)
                    {
                        progressDialog.Percentage = Convert.ToInt32(((double)++counter / (double)episodes.Count) * 100.0);
                    }
                    if (!Settings.isConfig)
                    {
                        GUIWindowManager.Process();
                    }
                }

                // close progress dialog
                if (!Settings.isConfig)
                {
                    progressDialog.Close();
                }

                // if we have removed all episodes in season without error, cleanup the online table
                if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk)
                {
                    condition = new SQLCondition();
                    condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                    condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal);
                    DBOnlineEpisode.Clear(condition);
                }
            }

            #region Facade Remote Color
            // if we were successful at deleting all episodes of season from disk, set HasLocalFiles to false
            // note: we only do this if the database entries still exist
            if (resultMsg.Count == 0 && type == TVSeriesPlugin.DeleteMenuItems.disk)
            {
                this[cHasLocalFiles] = false;
                this.Commit();
            }

            // if we were successful at deleting all episodes of season from disk,
            // also check if any local episodes exist on disk for series and set HasLocalFiles to false
            if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.database)
            {
                // Check Series for Local Files
                SQLCondition episodeConditions = new SQLCondition();
                episodeConditions.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                List <DBEpisode> localEpisodes = DBEpisode.Get(episodeConditions);
                if (localEpisodes.Count == 0 && !DBSeries.IsSeriesRemoved)
                {
                    DBSeries series = DBSeries.Get(this[DBSeason.cSeriesID]);
                    if (series != null)
                    {
                        series[DBOnlineSeries.cHasLocalFiles] = false;
                        series.Commit();
                    }
                }
            }
            #endregion

            #region Cleanup

            // if there are no error messages and if we need to delete from db
            if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk)
            {
                condition = new SQLCondition();
                condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                condition.Add(new DBSeason(), DBSeason.cIndex, this[DBSeason.cIndex], SQLConditionType.Equal);
                DBSeason.Clear(condition);
            }

            DBSeries.IsSeriesRemoved = false;
            if (type != TVSeriesPlugin.DeleteMenuItems.disk)
            {
                // If local/online episode count is zero then delete the series and all seasons
                condition = new SQLCondition();
                condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                episodes = DBEpisode.Get(condition, false);
                if (episodes.Count == 0)
                {
                    // Delete Seasons
                    condition = new SQLCondition();
                    condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                    DBSeason.Clear(condition);

                    // Delete Local Series
                    condition = new SQLCondition();
                    condition.Add(new DBSeries(), DBSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                    DBSeries.Clear(condition);

                    // Delete Online Series
                    condition = new SQLCondition();
                    condition.Add(new DBOnlineSeries(), DBOnlineSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal);
                    DBOnlineSeries.Clear(condition);

                    DBSeries.IsSeriesRemoved = true;
                }
            }
            #endregion

            return(resultMsg);
        }
コード例 #9
0
        protected override void OnShowContextMenu()
        {
            if (listControl == null || listControl.SelectedListItem == null)
            {
                return;
            }
            GUIListItem   selectedItem = listControl.SelectedListItem;
            YouTubeEntry  videoEntry   = selectedItem.MusicTag as YouTubeEntry;
            GUIDialogMenu dlg          = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }
            dlg.Reset();
            dlg.SetHeading(498); // menu
            if (Youtube2MP.player.CurrentSong > -1 || Youtube2MP.temp_player.CurrentSong > -1)
            {
                dlg.Add(Translation.PlayNext);
            }
            dlg.Add(Translation.ShowPreviousWindow);
            dlg.Add(Translation.Fullscreen);
            if (videoEntry != null)
            {
                dlg.Add(Translation.AddPlaylist);
                dlg.Add(Translation.AddAllPlaylist);
                dlg.Add(Translation.Info);
                if (Youtube2MP.service.Credentials != null)
                {
                    dlg.Add(Translation.AddFavorites);
                    dlg.Add(Translation.AddWatchLater);
                }
            }
            dlg.DoModal(GetID);
            if (dlg.SelectedId == -1)
            {
                return;
            }
            if (dlg.SelectedLabelText == Translation.ShowPreviousWindow)
            {
                GUIWindowManager.ShowPreviousWindow();
            }
            else if (dlg.SelectedLabelText == Translation.Fullscreen)
            {
                g_Player.ShowFullScreenWindow();
            }
            else if (dlg.SelectedLabelText == Translation.AddPlaylist)
            {
                VideoInfo inf = SelectQuality(videoEntry);
                if (inf.Quality != VideoQuality.Unknow)
                {
                    AddItemToPlayList(selectedItem, inf);
                }
            }
            else if (dlg.SelectedLabelText == Translation.AddAllPlaylist)
            {
                VideoInfo inf = SelectQuality(videoEntry);
                inf.Items = new Dictionary <string, string>();
                if (inf.Quality != VideoQuality.Unknow)
                {
                    GUIDialogProgress dlgProgress =
                        (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
                    if (dlgProgress != null)
                    {
                        dlgProgress.Reset();
                        dlgProgress.SetHeading(Translation.AddAllPlaylist);
                        dlgProgress.SetLine(1, "");
                        dlgProgress.SetLine(2, "");
                        dlgProgress.SetPercentage(0);
                        dlgProgress.Progress();
                        dlgProgress.ShowProgressBar(true);
                        dlgProgress.StartModal(GetID);
                    }
                    int i = 0;
                    for (int j = 0; j < listControl.Count; j++)
                    {
                        GUIListItem item = listControl[j];
                        if (dlgProgress != null)
                        {
                            double pr = ((double)i / (double)listControl.Count) * 100;
                            dlgProgress.SetLine(1, item.Label);
                            dlgProgress.SetLine(2, i.ToString() + "/" + listControl.Count.ToString());
                            dlgProgress.SetPercentage((int)pr);
                            dlgProgress.Progress();
                            if (dlgProgress.IsCanceled)
                            {
                                break;
                            }
                        }
                        i++;
                        AddItemToPlayList(item, new VideoInfo(inf));
                    }
                    if (dlgProgress != null)
                    {
                        dlgProgress.Close();
                    }
                }
            }
            else if (dlg.SelectedLabelText == Translation.AddFavorites)
            {
                try
                {
                    Youtube2MP.service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry);
                }
                catch (Exception)
                {
                    Err_message(Translation.WrongRequestWrongUser);
                }
            }
            else if (dlg.SelectedLabelText == Translation.AddWatchLater)
            {
                PlayListMember pm = new PlayListMember();
                pm.Id = videoEntry.VideoId;
                Youtube2MP.request.Insert(new Uri("https://gdata.youtube.com/feeds/api/users/default/watch_later"), pm);
            }
            else if (dlg.SelectedLabelText == Translation.Info)
            {
                YoutubeGuiInfoEx scr = (YoutubeGuiInfoEx)GUIWindowManager.GetWindow(29053);
                scr.YouTubeEntry = videoEntry;
                //if (entry!=null)
                //{
                //  ArtistItem artistItem=ent
                //}
                GUIWindowManager.ActivateWindow(29053);
            }
            else if (dlg.SelectedLabelText == Translation.PlayNext)
            {
                PlayNext(videoEntry);
            }
        }
コード例 #10
0
ファイル: MusicImport.cs プロジェクト: thomasr3/MediaPortal-1
        private static void ThreadEncodeTrack()
        {
            m_Ripping = true;

            try
            {
                CreateTempFolder();
                if (mp3Background)
                {
                    GUIWaitCursor.Show();
                }
                else if (dlgProgress != null)
                {
                    dlgProgress.Reset();
                    dlgProgress.SetPercentage(0);
                    dlgProgress.StartModal(GetID);
                    dlgProgress.Progress();
                    dlgProgress.ShowProgressBar(true);
                }

                while (importQueue.Count > 0)
                {
                    TrackInfo trackInfo = (TrackInfo)importQueue.Dequeue();
                    if ((dlgProgress != null) && !mp3Background)
                    {
                        if (importQueue.Count > 0)
                        {
                            dlgProgress.SetHeading(
                                string.Format(GUILocalizeStrings.Get(1105) + " ({0} " + GUILocalizeStrings.Get(1104) + ")",
                                              importQueue.Count + 1));
                        }
                        else
                        {
                            dlgProgress.SetHeading(GUILocalizeStrings.Get(1103));
                        }

                        dlgProgress.SetLine(2,
                                            string.Format("{0:00}. {1} - {2}", trackInfo.MusicTag.Track, trackInfo.MusicTag.Artist,
                                                          trackInfo.MusicTag.Title));
                        //dlgProgress.SetLine(2, trackInfo.TempFileName);
                        if (dlgProgress.IsCanceled)
                        {
                            m_CancelRipping = true;
                        }
                    }

                    if (!m_CancelRipping)
                    {
                        m_Drive = new CDDrive();
                        SaveTrack(trackInfo);
                        if (File.Exists(trackInfo.TempFileName) && !m_CancelRipping)
                        {
                            #region Tagging

                            try
                            {
                                Tags tags = Tags.FromFile(trackInfo.TempFileName);
                                tags["TRCK"] = trackInfo.MusicTag.Track.ToString() + "/" + trackInfo.TrackCount.ToString();
                                tags["TALB"] = trackInfo.MusicTag.Album;
                                tags["TPE1"] = trackInfo.MusicTag.Artist;
                                tags["TIT2"] = trackInfo.MusicTag.Title;
                                tags["TCON"] = trackInfo.MusicTag.Genre;
                                if (trackInfo.MusicTag.Year > 0)
                                {
                                    tags["TYER"] = trackInfo.MusicTag.Year.ToString();
                                }
                                tags["TENC"] = "MediaPortal / Lame";
                                tags.Save(trackInfo.TempFileName);
                            }
                            catch
                            {
                            }

                            #endregion

                            #region Database

                            try
                            {
                                if (!Directory.Exists(trackInfo.TargetDir))
                                {
                                    Directory.CreateDirectory(trackInfo.TargetDir);
                                }

                                if (File.Exists(trackInfo.TargetFileName))
                                {
                                    if (mp3ReplaceExisting)
                                    {
                                        File.Delete(trackInfo.TargetFileName);
                                    }
                                }

                                if (!File.Exists(trackInfo.TargetFileName))
                                {
                                    File.Move(trackInfo.TempFileName, trackInfo.TargetFileName);
                                }

                                if (File.Exists(trackInfo.TargetFileName) && mp3Database)
                                {
                                    if (importUnknown || (trackInfo.MusicTag.Artist != "Unknown Artist") ||
                                        (trackInfo.MusicTag.Album != "Unknown Album"))
                                    {
                                        MusicDatabase dbs = MusicDatabase.Instance;
                                        dbs.AddSong(trackInfo.TargetFileName);
                                    }
                                }
                            }
                            catch
                            {
                                Log.Info("CDIMP: Error moving encoded file {0} to new location {1}", trackInfo.TempFileName,
                                         trackInfo.TargetFileName);
                            }

                            #endregion
                        }
                    }
                }
                if (mp3Background)
                {
                    GUIWaitCursor.Hide();
                }
                else
                {
                    dlgProgress.Close();
                }
            }
            finally
            {
                CleanupTempFolder();
            }
            m_CancelRipping = false;
            m_Ripping       = false;
        }
コード例 #11
0
 void DoSubsequentLoad()
 {
     if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO &&
         PluginConfiguration.Instance.updateOnStart != false &&
         PluginConfiguration.Instance.lastFirstRun.AddHours(PluginConfiguration.Instance.updatePeriod) < DateTime.Now)
     {
         bool?doUpdate = PluginConfiguration.Instance.updateOnStart;
         if (!PluginConfiguration.Instance.updateOnStart.HasValue && !preventDialogOnLoad)
         {
             GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
             if (dlg != null)
             {
                 dlg.Reset();
                 dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                 dlg.SetLine(1, Translation.Instance.PerformAutomaticUpdate);
                 dlg.SetLine(2, Translation.Instance.UpdateAllYourSites);
                 dlg.DoModal(GUIWindowManager.ActiveWindow);
                 doUpdate = dlg.IsConfirmed;
             }
         }
         PluginConfiguration.Instance.lastFirstRun = DateTime.Now;
         if (doUpdate == true || PluginConfiguration.Instance.ThumbsAge >= 0)
         {
             GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
             if (dlgPrgrs != null)
             {
                 dlgPrgrs.Reset();
                 dlgPrgrs.DisplayProgressBar = true;
                 dlgPrgrs.ShowWaitCursor     = false;
                 dlgPrgrs.DisableCancel(true);
                 dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                 dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
             }
             else
             {
                 GUIWaitCursor.Init(); GUIWaitCursor.Show();
             }
             new System.Threading.Thread(delegate()
             {
                 if (doUpdate == true)
                 {
                     if (dlgPrgrs != null)
                     {
                         dlgPrgrs.SetHeading(string.Format("{0} - {1}", PluginConfiguration.Instance.BasicHomeScreenName, Translation.Instance.AutomaticUpdate));
                     }
                     var onlineVersion = Sites.Updater.VersionOnline;
                     if (OnlineVideos.Sites.Updater.VersionCompatible)
                     {
                         bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) =>
                         {
                             if (dlgPrgrs != null)
                             {
                                 if (!string.IsNullOrEmpty(m))
                                 {
                                     dlgPrgrs.SetLine(1, m);
                                 }
                                 if (p != null)
                                 {
                                     dlgPrgrs.SetPercentage(p.Value);
                                 }
                                 return(dlgPrgrs.ShouldRenderLayer());
                             }
                             else
                             {
                                 return(true);
                             }
                         }
                                                                                    );
                         if (updateResult == true && OnlineVideoSettings.Instance.SiteUtilsList.Count > 0)
                         {
                             GUISiteUpdater.ReloadDownloadedDlls();
                         }
                         else if (updateResult == null || OnlineVideoSettings.Instance.SiteUtilsList.Count > 0)
                         {
                             OnlineVideoSettings.Instance.BuildSiteUtilsList();
                         }
                         if (updateResult != false)
                         {
                             PluginConfiguration.Instance.BuildAutomaticSitesGroups();
                             SiteImageExistenceCache.ClearCache();
                         }
                     }
                     else
                     {
                         // inform the user that autoupdate is disabled due to outdated version!
                         dlgPrgrs.SetLine(1, Translation.Instance.AutomaticUpdateDisabled);
                         dlgPrgrs.SetLine(2, onlineVersion != null ? string.Format(Translation.Instance.LatestVersionRequired, onlineVersion) : "Check your Internet Connection!");
                         Thread.Sleep(5000);
                         dlgPrgrs.SetLine(2, string.Empty);
                     }
                 }
                 if (PluginConfiguration.Instance.ThumbsAge >= 0)
                 {
                     if (dlgPrgrs != null)
                     {
                         dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                         dlgPrgrs.SetLine(1, Translation.Instance.DeletingOldThumbs);
                         dlgPrgrs.Percentage = 0;
                     }
                     ImageDownloader.DeleteOldThumbs(PluginConfiguration.Instance.ThumbsAge, r =>
                     {
                         if (dlgPrgrs != null)
                         {
                             dlgPrgrs.Percentage = r;
                         }
                         return(dlgPrgrs != null ? dlgPrgrs.ShouldRenderLayer() : true);
                     });
                 }
                 if (dlgPrgrs != null)
                 {
                     dlgPrgrs.Percentage = 100; dlgPrgrs.SetLine(1, Translation.Instance.Done); dlgPrgrs.Close();
                 }
                 else
                 {
                     GUIWaitCursor.Hide();
                 }
                 GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
                 {
                     DoPageLoad();
                     return(0);
                 }, 0, 0, null);
             })
             {
                 Name = "OVLoad", IsBackground = true
             }.Start();
             return;
         }
     }
     DoPageLoad();
 }
コード例 #12
0
        private static bool WakeupSystem(byte[] hwAddress, string wakeupTarget, int timeout)
        {
            int waited = 0;

            WakeOnLanManager wakeOnLanManager = new WakeOnLanManager();

            Log.Debug("WOLMgr: Ping {0}", wakeupTarget);
            if (wakeOnLanManager.Ping(wakeupTarget, 200))
            {
                Log.Debug("WOLMgr: {0} already started", wakeupTarget);
                return(true);
            }

            GUIDialogProgress progressDialog =
                (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS

            progressDialog.Reset();
            progressDialog.SetHeading(GUILocalizeStrings.Get(1990));
            progressDialog.ShowProgressBar(true);
            progressDialog.SetLine(1, GUILocalizeStrings.Get(1991));
            progressDialog.StartModal(GUIWindowManager.ActiveWindow);

            // First, try to send WOL Packet
            if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast))
            {
                Log.Debug("WOLMgr: FAILED to send the first wake-on-lan packet!");
            }

            while (waited < timeout)
            {
                int percentange = (waited * 100) / timeout;

                progressDialog.SetPercentage(percentange);
                progressDialog.Progress();

                Log.Debug("WOLMgr: Ping {0}", wakeupTarget);
                if (wakeOnLanManager.Ping(wakeupTarget, 200))
                {
                    progressDialog.SetPercentage(100);
                    progressDialog.Progress();
                    progressDialog.Close();

                    int waittime;
                    using (Settings xmlreader = new MPSettings())
                    {
                        waittime = xmlreader.GetValueAsInt("WOL", "WaitTimeAfterWOL", 0);
                    }

                    if (waittime > 0)
                    {
                        GUIDialogProgress progressDialog2 =
                            (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS
                        progressDialog2.Reset();
                        progressDialog2.SetHeading(string.Empty);
                        progressDialog2.ShowProgressBar(true);
                        progressDialog2.SetLine(1, GUILocalizeStrings.Get(1994));
                        progressDialog2.StartModal(GUIWindowManager.ActiveWindow);

                        waited = waittime;

                        for (int i = waited; waited != 0; waited--)
                        {
                            percentange = (waited * 100) / waittime;

                            progressDialog2.SetPercentage(percentange);
                            progressDialog2.Progress();

                            System.Threading.Thread.Sleep(1000);
                        }

                        progressDialog2.SetPercentage(0);
                        progressDialog2.Progress();
                        progressDialog2.Close();
                    }
                    return(true);
                }
                // Send WOL Packet
                if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast))
                {
                    Log.Debug("WOLMgr: Sending the wake-on-lan packet failed (local network maybe not ready)! {0}s", waited);
                }
                Log.Debug("WOLMgr: System {0} still not reachable, waiting... {1}s", wakeupTarget, waited);

                System.Threading.Thread.Sleep(1000);
                waited++;
            }

            // Timeout was reached and WOL packet can't be send (we stop here)
            Log.Debug("WOLMgr: FAILED to send wake-on-lan packet after the timeout {0}, try increase the value!", timeout);

            progressDialog.SetPercentage(100);
            progressDialog.Progress();
            progressDialog.Close();

            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);

            dlgOk.SetHeading(GUILocalizeStrings.Get(1992)); // Not available
            dlgOk.SetLine(1, GUILocalizeStrings.Get(1993));
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);

            return(false);
        }