예제 #1
0
        private void LoadPlaylist(ProgressInfo progress)
        {
            JRPlaylist pl = progress.args[0] as JRPlaylist;

            pl.Files            = new List <JRFile>();
            progress.totalItems = pl.Count;
            int i = 0;

            List <string> fields = new List <string>();

            foreach (var f in state.TableFields)
            {
                if (jrAPI.FieldMap.TryGetValue(f.ToLower(), out string name))
                {
                    fields.Add(name);
                }
            }

            foreach (var file in jrAPI.getFiles(pl, fields))
            {
                pl.Files.Add(file);
                progress.currentItem = ++i;
                progress.subtitle    = $"{file.Name} ({file.Year})";
                progress.Update(false);
            }
        }
예제 #2
0
        private void ConnectJRiver(ProgressInfo progress)
        {
            progress.result   = false;
            progress.subtitle = "Starting MediaCenter";
            progress.Update(true);
            if (!jrAPI.Connect())
            {
                return;
            }

            progress.subtitle = "Reading fields";
            progress.Update();
            jrAPI.getFields();

            // syntax highlighter
            foreach (var tab in expressionTabs)
            {
                tab.highlighter = new ELSyntax(jrAPI.FieldsHighlight, settings.ExtraFunctions);
            }

            progress.subtitle = "Reading playlists";
            progress.Update(true);
            var lists = jrAPI.getPlaylists(settings.PlaylistFilter, !settings.FastStart).ToList();

            progress.result = true;
        }
예제 #3
0
 public static void FindLatestRelease(ProgressInfo progress)
 {
     try
     {
         using (var client = new HttpClient())
         {
             client.BaseAddress = new Uri("https://api.github.com");
             client.DefaultRequestHeaders.Add("User-Agent", "Microsoft .Net HttpClient");        // needed for github
             HttpResponseMessage response = client.GetAsync(GitHubReleaseURL).Result;
             if (response.IsSuccessStatusCode)
             {
                 string result = response.Content.ReadAsStringAsync().Result;
                 lastCheck     = DateTime.Now;
                 LatestVersion = VersionInfo.Parse(result);
                 if (progress != null)
                 {
                     progress.result = true;
                 }
                 return;
             }
         }
     }
     catch { }
     if (progress != null)
     {
         progress.result = false;
     }
 }
예제 #4
0
파일: ProgressUI.cs 프로젝트: zybexXL/Zelda
 public ProgressUI(string title, Action <ProgressInfo> action, bool canCancel = true, params object[] args)
 {
     InitializeComponent();
     bgAction      = action;
     this.progress = new ProgressInfo(title)
     {
         args = args, canCancel = canCancel
     };
     init();
 }
예제 #5
0
        public static void DoUpgrade(ProgressInfo progress)
        {
            try
            {
                string tmpFile = Path.Combine(Path.GetTempPath(), $"Zelda.{LatestVersion.version}.tmp");
                if (File.Exists(tmpFile))
                {
                    File.Delete(tmpFile);
                }

                using (var client = new WebClient())
                {
                    progress.subtitle = "downloading new version";
                    progress.Update();
                    client.Headers.Add("User-Agent", "Microsoft .Net HttpClient");
                    client.DownloadFile(LatestVersion.package, tmpFile);

                    progress.subtitle = "upgrading";
                    string currEXE = Assembly.GetEntryAssembly().Location;
                    string bakFile = Path.ChangeExtension(currEXE, ".bak");
                    if (File.Exists(bakFile))
                    {
                        File.Delete(bakFile);
                    }

                    File.Move(currEXE, bakFile);
                    File.Move(tmpFile, currEXE);

                    progress.result   = true;
                    restartNeeded     = true;
                    progress.subtitle = "starting new version";
                    Application.Restart();
                    return;
                }
            }
            catch { }
            progress.result = false;
        }