当前位置: 首页>>代码示例>>C#>>正文


C# Settings.Dispose方法代码示例

本文整理汇总了C#中Settings.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.Dispose方法的具体用法?C# Settings.Dispose怎么用?C# Settings.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings的用法示例。


在下文中一共展示了Settings.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Sites

        public Sites(string strType)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Plugins) + @"\Windows\Sites.xml");
                if (xmlDoc.SelectSingleNode("sites/site") != null)
                {
                    List<GUIListItem> _Items = new List<GUIListItem>();

                    foreach (XmlNode nodeItem in xmlDoc.SelectNodes("sites/site"))
                    {
                        switch (strType)
                        {
                            case "Feeds":
                                if (nodeItem.SelectNodes("feeds").Count != 0)
                                {
                                    if (nodeItem.SelectSingleNode("login") != null)
                                    {
                                        if ((nodeItem["login"].Attributes["username"].InnerText.Length != 0) && (nodeItem["login"].Attributes["password"].InnerText.Length != 0))
                                        {
                                            _Items.Add(new GUIListItem(nodeItem.Attributes["name"].InnerText));
                                        }
                                    }
                                    else
                                    {
                                        _Items.Add(new GUIListItem(nodeItem.Attributes["name"].InnerText));
                                    }
                                }
                                break;
                            case "Search":
                                if (nodeItem.SelectNodes("searches").Count != 0)
                                {
                                    if (nodeItem.SelectSingleNode("login") != null)
                                    {
                                        if ((nodeItem["login"].Attributes["username"].InnerText.Length != 0) && (nodeItem["login"].Attributes["password"].InnerText.Length != 0))
                                        {
                                            _Items.Add(new GUIListItem(nodeItem.Attributes["name"].InnerText));
                                        }
                                    }
                                    else
                                    {
                                        _Items.Add(new GUIListItem(nodeItem.Attributes["name"].InnerText));
                                    }
                                }
                                break;
                            case "Groups":
                                if (nodeItem.SelectSingleNode("groups") != null)
                                {
                                    if (nodeItem.SelectSingleNode("login") != null)
                                    {
                                        if ((nodeItem["login"].Attributes["username"].InnerText.Length != 0) && (nodeItem["login"].Attributes["password"].InnerText.Length != 0))
                                        {
                                            _Items.Add(new GUIListItem(nodeItem.Attributes["name"].InnerText));
                                        }
                                    }
                                    else
                                    {
                                        _Items.Add(new GUIListItem(nodeItem.Attributes["name"].InnerText));
                                    }
                                }
                                break;
                        }
                    }

                    if (_Items.Count > 0)
                    {
                        GUIListItem _Item = MP.Menu(_Items, "Select Site");
                        if (_Item != null)
                        {
                            SiteName = _Item.Label;

                            if (xmlDoc.SelectSingleNode("sites/site[@name='" + SiteName + "']/login") != null)
                            {
                                Username = xmlDoc.SelectSingleNode("sites/site[@name='" + SiteName + "']/login").Attributes["username"].InnerText;
                                Password = xmlDoc.SelectSingleNode("sites/site[@name='" + SiteName + "']/login").Attributes["password"].InnerText;
                            }
                        }
                    }
                }
                else
                {
                    GUIPropertyManager.SetProperty("#Status", "Error parsing XML");
                }

                Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");
                MaxResults = mpSettings.GetValueAsInt("#Sites", "MaxResults", 50);
                if (MaxResults == 0) { MaxResults = 50; }
                MPTVSeries = mpSettings.GetValueAsBool("#Sites", "MPTVSeries", false);
                mpSettings.Dispose();
            }
            catch (Exception e) { MP.Error(e); }
        }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:93,代码来源:Sites.cs

示例2: OnPageLoad

    protected override void OnPageLoad()
    {
      try
      {
        // Set "Status" label
        GUIPropertyManager.SetProperty("#Status", "Idle");

        // Disable "Refresh Feed" button
        btnRefresh.Disabled = true;

        // Load Settings
        Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");

        // Setup Page Title
        // ##################################################
        string strPageTitle = mpSettings.GetValue("#Plugin", "DisplayName");
        GUIPropertyManager.SetProperty("#PageTitle", ((strPageTitle.Length == 0) ? "mpNZB" : strPageTitle));
        // ##################################################

        // Setup Client
        // ##################################################
        switch (mpSettings.GetValue("#Client", "Grabber"))
        {
          case "SABnzbd":
            {
              Client = new Clients.SABnzbd(mpSettings.GetValue("#Client", "Host"), mpSettings.GetValue("#Client", "Port"), mpSettings.GetValueAsBool("#Client", "CatSelect", false), mpSettings.GetValueAsBool("#Client", "Auth", false), mpSettings.GetValue("#Client", "Username"), mpSettings.GetValue("#Client", "Password"), mpSettings.GetValue("#Client", "APIKey"), mpSettings.GetValueAsInt("#Plugin", "UpdateFrequency", 1), mpSettings.GetValueAsBool("#Plugin", "Notifications", false), mpSettings.GetValueAsInt("#Plugin", "AutoHideSeconds", 0), mpSettings.GetValueAsBool("#Client", "Https", false));

              string strVersion = Client.Version();

              if (strVersion.Length != 0)
              {
                GUIPropertyManager.SetProperty("#Status", "Idle (" + strVersion + ")");
              }
              else
              {
                GUIPropertyManager.SetProperty("#Status", "SABnzbd connection failed");
                return;
              }

              break;
            }
        }

        
        tmrStatus = new Timer();
        tmrStatus.Elapsed += new System.Timers.ElapsedEventHandler(OnTimer);
        tmrStatus.Interval = (mpSettings.GetValueAsInt("#Plugin", "UpdateFrequency", 1) * 1000);
        tmrStatus.Enabled = true;
        
        // ##################################################

        // Unload Settings
        mpSettings.Dispose();
          

        // Update Status
        Client.Visible = true;
        Client.Status();
        if (Client.Paused) { btnPause.Selected = true; }

        // Load queue
        Client.Queue(lstItems, this, true); 
        Client.ActiveView = (int)ClientView.Queue;

        // Start with parameter
        // Working at the moment:
        // "search:string to search"
        string loadParam = null;

        // check if running version of mediaportal supports loading with parameter and handle _loadParameter
        System.Reflection.FieldInfo fi = typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        if (fi != null)
        {
            loadParam = (string)fi.GetValue(this);
        }

        if (!string.IsNullOrEmpty(loadParam)) 
        {
            Log.Debug("[MPNZB] Loading with param: " + loadParam);
            string search = Regex.Match(loadParam, "search:([^|]*)").Groups[1].Value;
            if (!string.IsNullOrEmpty(search))
            {
                SelectSite("Search", search);
            }
        }

      }
      catch (Exception e) { MP.Error(e); }
    }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:89,代码来源:mpNZB.cs

示例3: fncSaveConfig

    private void fncSaveConfig()
    {
      Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");
      
      // Plugin Settings
      // ##################################################
      int intUpdateFreq = 1;
      int.TryParse(txtUpdateFreq.Text, out intUpdateFreq);
      if (intUpdateFreq < 1) { intUpdateFreq = 1; }
      mpSettings.SetValue("#Plugin", "UpdateFrequency", intUpdateFreq);
      mpSettings.SetValue("#Plugin", "DisplayName", txtDisplayName.Text);
      mpSettings.SetValueAsBool("#Plugin", "Notifications", chkNotifications.Checked);

      int intAutohide  = (int)numericUpDownAutoHide.Value;
      mpSettings.SetValue("#Plugin", "AutoHideSeconds", intAutohide);
      // ##################################################

      // Client Settings
      // ##################################################
      mpSettings.SetValue("#Client", "Grabber", cmbGrabber.Text);

      mpSettings.SetValue("#Client", "Host", txtHost.Text);
      mpSettings.SetValue("#Client", "Port", txtPort.Text);
      mpSettings.SetValueAsBool("#Client", "Https", checkBoxHttps.Checked);

      mpSettings.SetValueAsBool("#Client", "CatSelect", chkCatSelect.Checked);
      
      mpSettings.SetValueAsBool("#Client", "Auth", chkAuth.Checked);
      mpSettings.SetValue("#Client", "Username", txtUsername.Text);
      mpSettings.SetValue("#Client", "Password", txtPassword.Text);
      mpSettings.SetValue("#Client", "APIKey", txtAPIKey.Text);
      // ##################################################

      // Site Settings
      // ##################################################
      int intMaxResults = 50;
      int.TryParse(txtMaxResults.Text, out intMaxResults);
      mpSettings.SetValue("#Sites", "MaxResults", intMaxResults);
      mpSettings.SetValueAsBool("#Sites", "MPTVSeries", chkMPTVSeries.Checked);
      // ##################################################

      // Searches
      // ##################################################
      foreach (ListViewItem Item in lvSearches.Items)
      {
        mpSettings.SetValue("#Searches", Item.SubItems[0].Text, Item.SubItems[1].Text);
      }
      // ##################################################

      // Groups
      // ##################################################
      foreach (ListViewItem Item in lvGroups.Items)
      {
        mpSettings.SetValue("#Groups", Item.Text, String.Empty);
      }
      // ##################################################

      mpSettings.Dispose();
    }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:59,代码来源:frmSetup.cs

示例4: GetHome

    /// <summary>
    /// If the plugin should have it's own button on the main menu of MediaPortal then it
    /// should return true to this method, otherwise if it should not be on home
    /// it should return false
    /// </summary>
    /// <param name="strButtonText">text the button should have</param>
    /// <param name="strButtonImage">image for the button, or empty for default</param>
    /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
    /// <param name="strPictureImage">subpicture for the button or empty for none</param>
    /// <returns>true : plugin needs it's own button on home
    /// false : plugin does not need it's own button on home</returns>

    public bool GetHome(out string strButtonText, out string strButtonImage,
      out string strButtonImageFocus, out string strPictureImage)
    {
      // ##################################################
      // Load button text
      // ##################################################
      Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");
      strButtonText = mpSettings.GetValue("#Plugin", "DisplayName");
      if (strButtonText.Length == 0) { strButtonText = "mpNZB"; }
      mpSettings.Dispose();
      // ##################################################

      strButtonImage = String.Empty;
      strButtonImageFocus = String.Empty;
      strPictureImage = String.Empty;
      return true;
    }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:29,代码来源:mpNZB.cs

示例5: frmSetup_Load

    private void frmSetup_Load(object sender, EventArgs e)
    {
      // Set Defaults
      cmbGrabber.Text = "SABnzbd";
      chkCatSelect.Enabled = true;
      txtHost.Text = "127.0.0.1";
      txtPort.Text = "8080";
      txtUpdateFreq.Text = "1";
      numericUpDownAutoHide.Value = 0;
      

      if (File.Exists(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml"))
      {
        Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");

        // Plugin Settings
        // ##################################################
        int intUpdate = mpSettings.GetValueAsInt("#Plugin", "UpdateFrequency", 1);
        if (intUpdate > 0) { txtUpdateFreq.Text = intUpdate.ToString(); }
        txtDisplayName.Text = mpSettings.GetValue("#Plugin", "DisplayName");
        chkNotifications.Checked = mpSettings.GetValueAsBool("#Plugin", "Notifications", false);

        int intAutohide = mpSettings.GetValueAsInt("#Plugin", "AutoHideSeconds", 0);
        if (intUpdate > 0) { numericUpDownAutoHide.Value = intAutohide; }
        // ##################################################

        // Client Settings
        // ##################################################
        string strGrabber = mpSettings.GetValue("#Client", "Grabber");
        if (strGrabber.Length > 0) { cmbGrabber.Text = strGrabber; }

        string strHost = mpSettings.GetValue("#Client", "Host");
        if (strHost.Length > 0) { txtHost.Text = strHost; }
        string strPort = mpSettings.GetValue("#Client", "Port");
        if (strPort.Length > 0) { txtPort.Text = strPort; }

        checkBoxHttps.Checked = mpSettings.GetValueAsBool("#Client", "Https", false);

        chkCatSelect.Enabled = (cmbGrabber.Text == "SABnzbd");
        chkCatSelect.Checked = mpSettings.GetValueAsBool("#Client", "CatSelect", false);

        chkAuth.Checked = mpSettings.GetValueAsBool("#Client", "Auth", false);
        txtUsername.Enabled = chkAuth.Checked;
        txtPassword.Enabled = chkAuth.Checked;
        txtUsername.Text = mpSettings.GetValue("#Client", "Username");
        txtPassword.Text = mpSettings.GetValue("#Client", "Password");
        txtAPIKey.Text = mpSettings.GetValue("#Client", "APIKey");
        // ##################################################

        // Site Settings
        // ##################################################
        txtMaxResults.Text = mpSettings.GetValueAsInt("#Sites", "MaxResults", 50).ToString();
        chkMPTVSeries.Checked = mpSettings.GetValueAsBool("#Sites", "MPTVSeries", false);
        // ##################################################

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");

        // Searches
        // ##################################################
        foreach (XmlNode nodeItem in xmlDoc.SelectNodes("profile/section[@name='#Searches']/entry"))
        {
          lvSearches.Items.Add(nodeItem.Attributes["name"].InnerText).SubItems.Add(nodeItem.InnerText);
          mpSettings.RemoveEntry("#Searches", nodeItem.Attributes["name"].InnerText);
        }
        // ##################################################

        // Groups
        // ##################################################
        foreach (XmlNode nodeItem in xmlDoc.SelectNodes("profile/section[@name='#Groups']/entry"))
        {
          lvGroups.Items.Add(nodeItem.Attributes["name"].InnerText);
          mpSettings.RemoveEntry("#Groups", nodeItem.Attributes["name"].InnerText);
        }
        // ##################################################

        mpSettings.Dispose();
      }
    }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:79,代码来源:frmSetup.cs


注:本文中的Settings.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。