Exemple #1
0
 private void cbbTheme_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbbTheme.Text != null)
     {
         SysSetting.GetInstance().ThemeModel = new ThemeModel(cbbTheme.Text);
     }
 }
Exemple #2
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                var novel    = BH.GetNovel(novelId);
                var menuList = BH.GetNovelContents(novelId).ToList <NovelContent>();

                var theme               = SysSetting.GetInstance().ThemeModel;
                var dirInfo             = new DirectoryInfo(string.Format(BookHelper.DIR_PATH_NOVEL, novel.NovelID));
                var fileInfos           = dirInfo.GetFiles();
                var listModelContent    = CommonHelper.LoadHtmlFile(theme.ListModelPath);
                var chapterModelContent = CommonHelper.LoadHtmlFile(theme.ChapterModelPath);
                int i = 0;
                btnAccept.Enabled    = false;
                progressBar1.Minimum = 0;
                progressBar1.Maximum = fileInfos.Length;
                progressBar1.Visible = true;


                var _ManualEvents = new MutipleThreadResetEvent(fileInfos.Length);
                ThreadPool.SetMinThreads(1, 1);
                ThreadPool.SetMaxThreads(5, 10);

                foreach (var fileInfo in fileInfos)
                {
                    if (fileInfo.Name.Contains("List.htm"))
                    {
                        ThreadPool.QueueUserWorkItem(state => BH.SaveNovelListToHtml(novel, menuList, listModelContent));
                        _ManualEvents.SetOne();
                        //BH.SaveNovelListToHtml(novel, menuList, listModelContent);
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(state => ChangeModel(fileInfo, chapterModelContent, _ManualEvents));
                        //BH.ChangeThemeModel(fileInfo, chapterModelContent);
                    }
                    i++;
                    //this.Invoke(new RefreshUI(refreshUI), i);
                    //this.Invoke(new Action<int>((value) =>
                    //{
                    //    progressBar1.Value = value;
                    //    if (progressBar1.Maximum == value)
                    //    {
                    //        progressBar1.Visible = false;
                    //        btnAccept.Enabled = true;
                    //    }
                    //}), i);
                }
                //_ManualEvents.WaitAll();
                //MessageBox.Show("应用完成!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                progressBar1.Visible = false;
                btnAccept.Enabled    = true;
            }
        }