示例#1
0
 private void ReloadSources()
 {
     appPicker.Items.Clear();
     packageList = new List<StoreItem>();
     foreach (string pkgSource in packageSources)
     {
         try
         {
             WebClient wc = new WebClient();
             string rpkgList = wc.DownloadString(pkgSource).Replace("\r", "");
             List<string> plines = rpkgList.Split('\n').ToList();
             bool storeIsMarket = plines[0].Contains("[WinBXB Market]"); //Check if store is a market
             if (storeIsMarket) plines.RemoveAt(0); //Remove the market indicator
             if (!storeIsMarket) //Parse through as a basic package directory
             {
                 plines.Sort();
                 foreach (string pkgPath in plines)
                 {
                     StoreItem item;
                     if (!pkgPath.StartsWith("http://") && !pkgPath.StartsWith("https://"))
                     {
                         //download from same directory
                         item = new StoreItem(pkgPath, pkgSource + pkgPath);
                     }
                     else
                     {
                         string itemPath = pkgPath;
                         string itemName = System.IO.Path.GetFileNameWithoutExtension(new Uri(itemPath).AbsolutePath);
                         item = new StoreItem(itemName, itemPath);
                         //download from somewhere else
                     }
                     packageList.Add(item);
                     AddAppPickerItem(item);
                 }
             }
             else //Store is a market, supporting advanced features
             {
                 string marketJson = string.Join("", plines);
                 var sourcePkgList = JsonConvert.DeserializeObject<List<StoreItem>>(marketJson);
                 packageList.AddRange(sourcePkgList);
                 foreach (StoreItem item in sourcePkgList)
                 {
                     AddAppPickerItem(item);
                 }
             }
             var appPickerItems = appPicker.Items.Cast<ListViewItem>().ToList().Select(item => (StoreItem)item.Tag);
             packageList = appPickerItems.ToList().Distinct().ToList();
             appPicker.Items.Clear();
             PopulateAppCatalog(packageList.ToList());
             //string storeJson = JsonConvert.SerializeObject(packageList);
         }
         catch (Exception ex)
         {
             label2.Text = "Could not load packages.";
             MessageBox.Show("An Error occurred retrieving the package list: " + ex.ToString());
         }
     }
 }
示例#2
0
 void AddAppPickerItem(StoreItem storeItem)
 {
     var bxbAppIcon = new ListViewItem()
     {
         Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))),
         Text = storeItem.ToString(),
         Tag = storeItem,
         ImageIndex = 0,
     };
     appPicker.Items.Add(bxbAppIcon);
 }
示例#3
0
 private void DownloadApp(StoreItem app)
 {
     label2.Text = string.Format("Downloading {0}...", app.Name);
     WebClient wc = new WebClient();
     string tempPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+"\\wstr\\"+app.Name+".bxb";
     string dirPath = System.IO.Path.GetDirectoryName(tempPath);
     if (!System.IO.Directory.Exists(dirPath))
         System.IO.Directory.CreateDirectory(dirPath);
     wc.DownloadFile(app.DownloadLink,tempPath);
     MainForm.InstallApp(tempPath);
     System.IO.File.Delete(tempPath);
     ((MainForm)this.Owner).RefreshList();
     label2.Text = string.Format("{0} was installed.",app.Name);
 }