LooseFocus() public method

This method will remove the focus from the currently focused control
public LooseFocus ( ) : void
return void
Exemplo n.º 1
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;
        }
      }
    }
Exemplo n.º 2
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;
            }
        }
    }