Clear() public method

public Clear ( ) : void
return void
示例#1
0
    private void ReadRSS(List<string> _URL, GUIListControl _List, string _Username, string _Password)
    {
      try
      {
        int intItemCount = 0;
        _List.Clear();

        foreach (string URL in _URL)
        {
          HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(URL);
          webReq.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip");

          if ((_Username.Length > 0) && (_Password.Length > 0)) { webReq.Credentials = new NetworkCredential(_Username, _Password); }

          HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();
          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.Load(((webResp.ContentEncoding.ToLower().Contains("gzip")) ? new GZipStream(webResp.GetResponseStream(), CompressionMode.Decompress, false) : webResp.GetResponseStream()));
          webResp.Close();

          if (xmlDoc.SelectSingleNode("rss[@version='2.0']") != null)
          {
            XmlNodeList xmlNodes = xmlDoc.SelectNodes("rss/channel/item");
            foreach (XmlNode xmlNode in xmlNodes)
            {
              Site.AddItem(xmlNode, _List);
              intItemCount += 1;
            }
          }
          else
          {
            GUIPropertyManager.SetProperty("#Status", "Error parsing XML");
          }
        }

        _List.ListItems.Sort(delegate(GUIListItem _Item1, GUIListItem _Item2) { return _Item2.FileInfo.CreationTime.CompareTo(_Item1.FileInfo.CreationTime); });
        GUIPropertyManager.SetProperty("#Status", "Found " + intItemCount.ToString() + " Items");
      }
      catch (Exception e) { MP.Error(e); }
      finally
      {
        if (_List.Count > 0)
        {
          this.LooseFocus();
          _List.Focus = true;
        }
      }
    }
示例#2
0
    public void History(GUIListControl _List, GUIWindow _GUI)
    {
      try
      {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(new XmlTextReader(CreateURL("api?mode=history", "output=xml", false)));

        if (xmlDoc.SelectSingleNode("history/slots") != null)
        {
          _List.Clear();

          string strItemInfo = String.Empty;

          foreach (XmlNode nodeItem in xmlDoc.SelectNodes("history/slots/slot"))
          {
            DateTime dtPubDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(double.Parse(nodeItem["completed"].InnerText));

            strItemInfo = String.Empty;

            foreach (XmlNode nodeInfo in nodeItem.SelectNodes("stage_log/slot"))
            {
              strItemInfo += ((strItemInfo.Length > 0) ? Environment.NewLine : String.Empty) + nodeInfo["name"].InnerText + ":" + Environment.NewLine;

              foreach (XmlNode nodeProgress in nodeInfo.SelectNodes("actions/item"))
              {
                strItemInfo += nodeProgress.InnerText + Environment.NewLine;
              }
            }

            MP.ListItem(_List, nodeItem["name"].InnerText, nodeItem["status"].InnerText, strItemInfo, dtPubDate, 0, String.Empty, String.Empty, 4);
          }

          GUIPropertyManager.SetProperty("#Status", "History Loaded");
        }
        else
        {
          GUIPropertyManager.SetProperty("#Status", "Error parsing XML");
        }
      }
      catch (Exception e) { MP.Error(e); }
      finally
      {
        if (_List.Count > 0)
        {
          _GUI.LooseFocus();
          _List.Focus = true;
        }
      }
    }
        private void AddRangeToList(GUIListControl listControl, List<GUIListItem> listItems)
        {
            listControl.Clear();

            foreach (var item in listItems) {
                listControl.Add(item);
            }
        }
示例#4
0
    public void Queue(GUIListControl _List, GUIWindow _GUI, bool refocus)
    {
        int selectedIndex = _List.SelectedListItemIndex;

        try
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(new XmlTextReader(CreateURL("api?mode=queue", "output=xml", false)));

            if (xmlDoc.SelectSingleNode("queue/slots") != null)
            {
                if (refocus)
                {
                    _List.Clear();
                }

                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
                string strJobInfo;

                int i = 0;
                foreach (XmlNode nodeItem in xmlDoc.SelectNodes("queue/slots/slot"))
                {
                    strJobInfo = "Status: " + nodeItem["status"].InnerText + Environment.NewLine + "Filename: " + nodeItem["filename"].InnerText + Environment.NewLine + "Priority: " + nodeItem["priority"].InnerText + Environment.NewLine + "Category: " + nodeItem["cat"].InnerText + Environment.NewLine + "Percentage: " + nodeItem["percentage"].InnerText + "%";

                    double mbdone = double.Parse(nodeItem["mb"].InnerText, nfi) - double.Parse(nodeItem["mbleft"].InnerText, nfi);

                    if (_List.Count > i && !refocus)
                    {
                        MP.UpdateListItem(i, _List, nodeItem["filename"].InnerText, ((nodeItem["status"].InnerText == "Paused") ? "Paused" : mbdone.ToString("N2") + " / " + double.Parse(nodeItem["mb"].InnerText, nfi).ToString("N2") + " MB"), strJobInfo, DateTime.Now, 0, String.Empty, nodeItem["nzo_id"].InnerText, 3);
                    }
                    else
                    {
                        MP.ListItem(_List, nodeItem["filename"].InnerText, ((nodeItem["status"].InnerText == "Paused") ? "Paused" : mbdone.ToString("N2") + " / " + double.Parse(nodeItem["mb"].InnerText, nfi).ToString("N2") + " MB"), strJobInfo, DateTime.Now, 0, String.Empty, nodeItem["nzo_id"].InnerText, 3);
                    }

                    ++i;
                }

                GUIPropertyManager.SetProperty("#Status", "Queue Loaded");
            }
            else
            {
                GUIPropertyManager.SetProperty("#Status", "Error parsing XML");
            }
        }
        catch (Exception e) { MP.Error(e); }
        finally
        {
            if (_List.Count > 0 && refocus)
            {
                _GUI.LooseFocus();
                _List.Focus = true;
            }
            else if (_List.IsFocused && _List.Count > selectedIndex)
            {
                _List.SelectedListItemIndex = selectedIndex;
            }
        }
    }