예제 #1
0
 private Boolean saveConfigToClass()
 {
     try
     {
         VOA.ClassConfig.configSavePath       = this.textBoxSavePath.Text;
         VOA.ClassConfig.configIsHtmlDownload = this.checkBoxFileTypeHTML.Checked;
         VOA.ClassConfig.configIsTXTDownload  = this.checkBoxFileTypeTXT.Checked;
         VOA.ClassConfig.configIsMP3Download  = this.checkBoxFileTypeMP3.Checked;
         for (int i = 0; i < VOA.ClassConfig.configVOATypeList.Count; i++)
         {
             VOA.ClassConfigVOAType configType = (VOA.ClassConfigVOAType)VOA.ClassConfig.configVOATypeList[i];
             for (int j = 0; j < this.checkBoxConfigList.Count; j++)
             {
                 System.Windows.Forms.CheckBox checkBox = (System.Windows.Forms.CheckBox) this.checkBoxConfigList[j];
                 if (checkBox.Text == configType.TypeName)
                 {
                     configType.TpyeIsDownload = checkBox.Checked;
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #2
0
        public Boolean getVoaList()
        {
            try
            {
                int TypeIsDownloadNum = 0;
                VOAItemList = new ArrayList();
                ////进度条操作
                //this.toolStripProgressBar.Value = 1;
                //this.toolStripProgressBar.Maximum = VOA.ClassConfig.configVOATypeList.Count;
                ////操作结束
                for (int i = 0; i < VOA.ClassConfig.configVOATypeList.Count; i++)
                {
                    VOA.ClassConfigVOAType config = (VOA.ClassConfigVOAType)VOA.ClassConfig.configVOATypeList[i];
                    if (config.TpyeIsDownload)
                    {
                        TypeIsDownloadNum++;
                    }
                }
                for (int i = 0; i < VOA.ClassConfig.configVOATypeList.Count; i++)
                {
                    VOA.ClassConfigVOAType config = (VOA.ClassConfigVOAType)VOA.ClassConfig.configVOATypeList[i];
                    if (config.TpyeIsDownload)
                    {
                        VOA.ClassHTML classHtml = new VOA.ClassHTML();
                        classHtml.Url = config.TypeURL;
                        classHtml.GetHTML();
                        ArrayList temp = classHtml.GetVOAList(60 / TypeIsDownloadNum, config.TypeName);
                        for (int j = 0; j < temp.Count; j++)
                        {
                            VOAItemList.Add(temp[j]);
                        }
                    }
                    this.backWorkerGetVoaList.ReportProgress(i + 1);
                    ////进度条操作
                    //this.toolStripProgressBar.Value = i + 1;
                    ////操作结束
                }

                this.checkedListBoxMain.Items.Clear();
                if (VOAItemList.Count == 0)
                {
                    return(false);
                }
                for (int i = 0; i < VOAItemList.Count; i++)
                {
                    ClassVOA voa = (ClassVOA)VOAItemList[i];
                    CheckBox cb  = new CheckBox();
                    this.checkedListBoxMain.Items.Add(voa.Type + "-" + voa.Name + " (" + voa.Date.ToString("yyyy-MM-dd") + ")");
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #3
0
        public static Boolean SaveConfigFile()
        {
            try
            {
                XmlTextWriter writer = new XmlTextWriter("VOA.inf", null);

                writer.Formatting  = Formatting.Indented; //缩进格式
                writer.Indentation = 4;
                writer.WriteStartDocument();

                writer.WriteStartElement("Config");
                writer.WriteStartAttribute("Name", null);
                writer.WriteString("VOADownloader");
                writer.WriteEndAttribute();
                //写入configSavePath
                writer.WriteStartElement("ConfigItem");
                writer.WriteStartAttribute("Name", null);
                writer.WriteString("configSavePath");
                writer.WriteEndAttribute();
                writer.WriteStartAttribute("Value", null);
                writer.WriteString(configSavePath);
                writer.WriteEndAttribute();
                writer.WriteEndElement();

                //写入configIsHtmlDownload
                writer.WriteStartElement("ConfigItem");
                writer.WriteStartAttribute("Name", null);
                writer.WriteString("configIsHtmlDownload");
                writer.WriteEndAttribute();
                writer.WriteStartAttribute("Value", null);
                writer.WriteString(configIsHtmlDownload.ToString());
                writer.WriteEndAttribute();
                writer.WriteEndElement();

                //写入configIsTXTDownload
                writer.WriteStartElement("ConfigItem");
                writer.WriteStartAttribute("Name", null);
                writer.WriteString("configIsTXTDownload");
                writer.WriteEndAttribute();
                writer.WriteStartAttribute("Value", null);
                writer.WriteString(configIsTXTDownload.ToString());
                writer.WriteEndAttribute();
                writer.WriteEndElement();

                //写入configIsMP3Download
                writer.WriteStartElement("ConfigItem");
                writer.WriteStartAttribute("Name", null);
                writer.WriteString("configIsMP3Download");
                writer.WriteEndAttribute();
                writer.WriteStartAttribute("Value", null);
                writer.WriteString(configIsMP3Download.ToString());
                writer.WriteEndAttribute();
                writer.WriteEndElement();

                //写入configVOATypeList
                for (int i = 0; i < configVOATypeList.Count; i++)
                {
                    VOA.ClassConfigVOAType voaType = (VOA.ClassConfigVOAType)configVOATypeList[i];
                    writer.WriteStartElement("ConfigItem");
                    writer.WriteStartAttribute("Name", null);
                    writer.WriteString(voaType.TypeName);
                    writer.WriteEndAttribute();
                    writer.WriteStartAttribute("Value", null);
                    writer.WriteString(voaType.TpyeIsDownload.ToString());
                    writer.WriteEndAttribute();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.Flush();
                writer.Close();

                //FileInfo fi = new FileInfo("VOA.inf");
                //fi.Attributes = fi.Attributes | FileAttributes.Hidden;

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }