Example #1
0
        /*==============================================================
         * 开始
         *==============================================================*/
        internal void PictureBox_Start_Click(object sender, EventArgs e)
        {
            m_is_updating_database = true;
            m_is_stopping          = false;

            lock_controls(false);

            progressBar_Update.Value = 0;
            label_Log.Text           = "";

            if (radioButton_UseLocalData.Checked)
            {
                append_log(LANGUAGES.txt(54));                  // 执行数据库更新...

                Thread th = new Thread(update_db_thread);
                th.Start();
            }
            else
            {
                append_log(LANGUAGES.txt(55));                  // 正在从远程服务器下载数据库文件...

                WebClient wc = new WebClient();

                wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
                wc.DownloadDataCompleted   += Wc_DownloadDataCompleted;

                m_sw.Restart();

                wc.DownloadDataAsync(new Uri("https://github.com/foxofice/sub_share/raw/master/Subtitles DataBase/Files/db.xml"));
            }
        }
Example #2
0
        /*==============================================================
         * 打开本地文件夹
         *==============================================================*/
        private void ToolStripButton_Folder_Click(object sender, EventArgs e)
        {
            if (dataGridView_Main.SelectedCells.Count == 0)
            {
                return;
            }

            DataTable dt = (DataTable)dataGridView_Main.DataSource;

            if (dt == null)
            {
                return;
            }

            DataRow dr = ((DataRowView)dataGridView_Main.SelectedCells[0].OwningRow.DataBoundItem).Row;

            string dir = string.Format("{0:s}/{1:s}/{2:s}/{3:s}",
                                       CONFIG.m_s_subs_path.Replace("\\", "/"),
                                       (string)dr[DATA.e_ColumnName.path.ToString()],
                                       (string)dr[DATA.e_ColumnName.source.ToString()],
                                       (string)dr[DATA.e_ColumnName.sub_name.ToString()]);

            if (!Directory.Exists(dir))
            {
                MessageBox.Show(string.Format(LANGUAGES.txt(25), dir));                 // 找不到文件夹 {0:s}
                return;
            }

            PATH.open_dir(dir);
        }
Example #3
0
        /*==============================================================
         * 写入配置文件
         *==============================================================*/
        static internal void    write_config()
        {
            List <string> lines = new List <string>();

            lines.Add(LANGUAGES.txt(100));              //「// 字幕路径」
            lines.Add($"{m_k_OPTION__SUBS_PATH}: {m_s_subs_path}");
            lines.Add("");

            lines.Add(LANGUAGES.txt(101));              //「// 最后更新数据库的时间」
            lines.Add($"{m_k_OPTION__LAST_UPDATA_DB_TIME}: {m_s_last_updata_db_time.ToString()}");
            lines.Add("");

            lines.Add(LANGUAGES.txt(102));              //「// 窗口大小」
            lines.Add($"{m_k_OPTION__WINDOW_WIDTH}: {m_s_window_width}");
            lines.Add($"{m_k_OPTION__WINDOW_HEIGHT}: {m_s_window_height}");
            lines.Add("");

            lines.Add(LANGUAGES.txt(103));              //「// 窗口位置」
            lines.Add($"{m_k_OPTION__WINDOW_X}: {m_s_window_x}");
            lines.Add($"{m_k_OPTION__WINDOW_Y}: {m_s_window_y}");
            lines.Add("");

            lines.Add(LANGUAGES.txt(104));              //「// 数据网格的样式(width = 宽度、idx = 显示顺序索引)」
            lines.Add($"{m_k_OPTION__COLUMN__NAME_CHS__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.name_chs]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_CHT__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.name_cht]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_JP__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.name_jp]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_EN__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.name_en]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_ROME__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.name_rome]}");
            lines.Add("");
            lines.Add($"{m_k_OPTION__COLUMN__TIME__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.time]}");
            lines.Add($"{m_k_OPTION__COLUMN__TYPE__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.type]}");
            lines.Add($"{m_k_OPTION__COLUMN__SOURCE__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.source]}");
            lines.Add($"{m_k_OPTION__COLUMN__SUB_NAME__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.sub_name]}");
            lines.Add($"{m_k_OPTION__COLUMN__EXTENSION__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.extension]}");
            lines.Add($"{m_k_OPTION__COLUMN__PROVIDERS__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.providers]}");
            lines.Add($"{m_k_OPTION__COLUMN__DESC__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.desc]}");
            lines.Add($"{m_k_OPTION__COLUMN__PATH__WIDTH}: {m_s_column_width[(int)DATA.e_ColumnName.path]}");
            lines.Add("");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_CHS__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.name_chs]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_CHT__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.name_cht]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_JP__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.name_jp]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_EN__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.name_en]}");
            lines.Add($"{m_k_OPTION__COLUMN__NAME_ROME__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.name_rome]}");
            lines.Add("");
            lines.Add($"{m_k_OPTION__COLUMN__TIME__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.time]}");
            lines.Add($"{m_k_OPTION__COLUMN__TYPE__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.type]}");
            lines.Add($"{m_k_OPTION__COLUMN__SOURCE__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.source]}");
            lines.Add($"{m_k_OPTION__COLUMN__SUB_NAME__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.sub_name]}");
            lines.Add($"{m_k_OPTION__COLUMN__EXTENSION__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.extension]}");
            lines.Add($"{m_k_OPTION__COLUMN__PROVIDERS__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.providers]}");
            lines.Add($"{m_k_OPTION__COLUMN__DESC__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.desc]}");
            lines.Add($"{m_k_OPTION__COLUMN__PATH__IDX}: {m_s_column_idx[(int)DATA.e_ColumnName.path]}");

            File.WriteAllLines(PATH.m_k_CONFIG_FILENAME, lines, Encoding.UTF8);
        }
Example #4
0
 /*==============================================================
  * 窗口关闭时
  *==============================================================*/
 private void frm_Mainform_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (MessageBox.Show(LANGUAGES.txt(1),                       // 是否要退出程序?
                         $"{COMMON.m_k_PROGRAM_NAME} {COMMON.m_k_VERSION}",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question,
                         MessageBoxDefaultButton.Button2) == DialogResult.No)
     {
         e.Cancel = true;
         return;
     }
 }
Example #5
0
        /*==============================================================
         * 异步下载完成时
         *==============================================================*/
        private void Wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            m_sw.Stop();

            if (e.Error != null)
            {
                append_log(LANGUAGES.txt(63));                  // 下载数据库文件失败
                append_log(e.Error.Message);
            }
            else if (!e.Cancelled)
            {
                File.WriteAllBytes(PATH.m_k_DB_FILENAME, e.Result);

                append_log(LANGUAGES.txt(62));                  // 下载数据库文件完成

                CONFIG.m_s_last_updata_db_time = DateTime.Now;
                CONFIG.write_config();

                // 加载数据
                DATA.read_data_from_file();
            }

            lock_controls(true);

            if (m_is_stopping)
            {
                append_log(string.Format(LANGUAGES.txt(57) + LANGUAGES.txt(60),                         // 用户停止更新数据库(合计 {0:d} 条数据,耗时 {1:s})
                                         DATA.m_s_all_subs.Count,
                                         m_sw.Elapsed.ToString()),
                           Color.Blue);
            }
            else
            {
                if (e.Error == null)
                {
                    append_log(string.Format(LANGUAGES.txt(58) + LANGUAGES.txt(60),                             // 更新数据库完成(合计 {0:d} 条数据,耗时 {1:s})
                                             DATA.m_s_all_subs.Count,
                                             m_sw.Elapsed.ToString()),
                               Color.Green);
                }
                else
                {
                    append_log(LANGUAGES.txt(59), Color.Red);                           // 更新数据库失败
                }
            }

            m_is_stopping          = false;
            m_is_updating_database = false;
        }
Example #6
0
        /*==============================================================
         * 窗口加载时
         *==============================================================*/
        private void frm_About_Load(object sender, EventArgs e)
        {
            this.Icon = IMAGE.img2icon(Resource1.Logo);
            this.Text = string.Format("{0:s} {1:s} {2:s}",
                                      LANGUAGES.txt(14),                                                                        // 关于
                                      COMMON.m_k_PROGRAM_NAME,
                                      COMMON.m_k_VERSION);

            pictureBox_Icon.Image = Resource1.Logo;

            if (File.Exists(PATH.m_k_CHANGELOG_FILENAME))
            {
                textBox_ChangeLog.Text = File.ReadAllText(PATH.m_k_CHANGELOG_FILENAME, Encoding.UTF8);
            }
        }
Example #7
0
        /*==============================================================
         * 窗口加载时
         *==============================================================*/
        private void frm_Mainform_Load(object sender, EventArgs e)
        {
            m_s_mainform = this;

            this.Icon = IMAGE.img2icon(Resource1.Logo);
            this.Text = $"{COMMON.m_k_PROGRAM_NAME} {COMMON.m_k_VERSION}";

            // 读取配置文件
            CONFIG.read_config();

            // 加载多语言模板
            LANGUAGES.read_languages_list();
            LANGUAGES.change_language_to_default();

            // 加载数据库文件
            DATA.read_data_from_file();
        }
Example #8
0
        /*==============================================================
         * 更新状态栏
         *==============================================================*/
        internal void   update_status()
        {
            toolStripStatusLabel_ItemsCount.Text = string.Format(LANGUAGES.txt(23),                     // {0:d} 条记录
                                                                 dataGridView_Main.Rows.Count);

            DataTable dt = (DataTable)dataGridView_Main.DataSource;

            if (dt != null)
            {
                HashSet <string> movies = new HashSet <string>();

                foreach (DataRow dr in dt.Rows)
                {
                    movies.Add((string)dr[DATA.e_ColumnName.path.ToString()]);
                }

                toolStripStatusLabel_MovieCount.Text = string.Format(LANGUAGES.txt(24),                         // {0:d} 部影片
                                                                     movies.Count);
            }
        }
Example #9
0
        /*==============================================================
         * 重置搜索条件
         *==============================================================*/
        private void LinkLabel_Reset_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (MessageBox.Show(LANGUAGES.txt(80),                      // 是否重置搜索条件?
                                $"{COMMON.m_k_PROGRAM_NAME} {COMMON.m_k_VERSION}",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }

            textBox_Name.Clear();
            textBox_SubName.Clear();
            textBox_Extension.Clear();
            textBox_Providers.Clear();
            textBox_Desc.Clear();
            comboBox_Type.SelectedIndex          = -1;
            comboBox_Source.Text                 = "";
            checkBox_Time.Checked                = false;
            radioButton_Time_EarlierThan.Checked = true;
            dateTimePicker_Time.Value            = DateTime.Now;
        }
Example #10
0
        /*==============================================================
         * 根据条件查找数据
         *==============================================================*/
        internal void   do_search()
        {
            DATA.m_s_lock.EnterReadLock();

            if (DATA.m_s_all_subs.Count == 0)
            {
                DATA.m_s_lock.ExitReadLock();

                if (!m_UpdateDatabase.m_is_updating_database)
                {
                    if (MessageBox.Show(LANGUAGES.txt(26),                              // 本地没有任何数据,是否要下载最新的字幕索引?
                                        $"{COMMON.m_k_PROGRAM_NAME} {COMMON.m_k_VERSION}",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question,
                                        MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        FORMS.active_form(m_UpdateDatabase);

                        m_UpdateDatabase.radioButton_UseRemoteData.Checked = true;
                        m_UpdateDatabase.PictureBox_Start_Click(null, null);
                    }
                }

                return;
            }

            if (textBox_Filter.TextLength == 0)
            {
                m_DataGridView_event_enable  = false;
                dataGridView_Main.DataSource = DATA.m_s_dt;
                update_columns_style();
                m_DataGridView_event_enable = true;
            }
            else
            {
                string filter_string;

                if (radioButton_SearchByName.Checked)
                {
                    StringBuilder sb = new StringBuilder();

                    string fix_Name_chs = SQL.fix_string(ChineseConverter.Convert(textBox_Filter.Text, ChineseConversionDirection.TraditionalToSimplified));
                    string fix_Name_cht = SQL.fix_string(ChineseConverter.Convert(textBox_Filter.Text, ChineseConversionDirection.SimplifiedToTraditional));

                    sb.Append($"[name_chs] like '%{fix_Name_chs}%' or [name_chs] like '%{fix_Name_cht}%' or ");
                    sb.Append($"[name_cht] like '%{fix_Name_chs}%' or [name_cht] like '%{fix_Name_cht}%' or ");
                    sb.Append($"[name_jp] like '%{fix_Name_chs}%' or [name_jp] like '%{fix_Name_cht}%' or ");
                    sb.Append($"[name_en] like '%{fix_Name_chs}%' or ");
                    sb.Append($"[name_rome] like '%{fix_Name_chs}%'");

                    filter_string = sb.ToString();
                }
                else
                {
                    filter_string = textBox_Filter.Text;
                }

                try
                {
                    DataRow[] dr_list = DATA.m_s_dt.Select(filter_string);

                    DATA.m_s_dt_search.Rows.Clear();
                    foreach (DataRow dr in dr_list)
                    {
                        DataRow dr_tmp = DATA.m_s_dt_search.NewRow();
                        for (int i = 0; i < DATA.m_s_dt_search.Columns.Count; ++i)
                        {
                            dr_tmp[i] = dr[i];
                        }

                        DATA.m_s_dt_search.Rows.Add(dr_tmp);
                    }

                    m_DataGridView_event_enable  = false;
                    dataGridView_Main.DataSource = DATA.m_s_dt_search;
                    update_columns_style();
                    m_DataGridView_event_enable = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            DATA.m_s_lock.ExitReadLock();

            update_status();
        }
Example #11
0
 /*==============================================================
  * 窗口加载时
  *==============================================================*/
 private void frm_UpdateDatabase_Load(object sender, EventArgs e)
 {
     this.Icon = IMAGE.img2icon(Resource1.Logo);
     this.Text = LANGUAGES.txt(10);                      // 更新数据库
 }
Example #12
0
        /*==============================================================
         * 执行更新数据库的线程
         *==============================================================*/
        void update_db_thread()
        {
            if (!Directory.Exists(CONFIG.m_s_subs_path))
            {
                FORMS.invoke(() =>
                {
                    append_log($"{LANGUAGES.txt(56)} {CONFIG.m_s_subs_path}",                           // 找不到本地字幕路径
                               Color.Red);
                    lock_controls(true);
                });

                m_is_updating_database = false;
                return;
            }

            m_sw.Restart();

            long can_refresh_UI_tick = 0;

            DATA.m_s_lock.EnterWriteLock();

            DATA.m_s_all_subs.Clear();

            SortedSet <string> source_list = new SortedSet <string>();

            FORMS.invoke(() =>
            {
                frm_Mainform.m_s_mainform.m_Search.comboBox_Type.Items.Clear();
                frm_Mainform.m_s_mainform.m_Search.comboBox_Type.Items.Add("");

                frm_Mainform.m_s_mainform.m_Search.comboBox_Source.Items.Clear();

                COMMON.SetProgressValue(0);
            });

            string[] dirs_type = Directory.GetDirectories(CONFIG.m_s_subs_path, "*.*", SearchOption.TopDirectoryOnly);
            foreach (string dir_type in dirs_type)
            {
                FORMS.invoke(() =>
                {
                    frm_Mainform.m_s_mainform.m_Search.comboBox_Type.Items.Add(Path.GetFileName(dir_type));
                });

                string[] dirs_year = Directory.GetDirectories(dir_type, "*.*", SearchOption.TopDirectoryOnly);
                for (int i_year = 0; i_year < dirs_year.Length; ++i_year)
                {
                    string dir_year = dirs_year[i_year];

                    string[] dirs_video = Directory.GetDirectories(dir_year, "*.*", SearchOption.TopDirectoryOnly);
                    for (int i_video = 0; i_video < dirs_video.Length; ++i_video)
                    {
                        string dir_video = dirs_video[i_video];

                        // 路径
                        string path = dir_video.Substring(CONFIG.m_s_subs_path.Length + 1).Replace("\\", "/");

                        FORMS.invoke(() =>
                        {
                            label_Log.Text = dir_video;
                        });

                        // 日期
                        string   name_tmp  = Path.GetFileName(dir_video);
                        int      idx       = name_tmp.IndexOf(")");
                        string[] date_vals = name_tmp.Substring(1, idx - 1).Split('.');

                        int year  = int.Parse(date_vals[0]);
                        int month = (date_vals.Length >= 2) ? int.Parse(date_vals[1]) : 1;
                        int day   = (date_vals.Length >= 3) ? int.Parse(date_vals[2]) : 1;

                        DateTime date = new DateTime(year, month, day);

                        // 番名
                        //string name_chs	= name_tmp.Substring(idx + 1);
                        string name_chs  = "";
                        string name_cht  = "";
                        string name_jp   = "";
                        string name_en   = "";
                        string name_rome = "";

                        // 读取 info.txt
                        string info_filename = Path.Combine(dir_video, "info.txt");

                        if (File.Exists(info_filename))
                        {
                            string[] lines = File.ReadAllLines(info_filename, Encoding.UTF8);
                            foreach (string line in lines)
                            {
                                if (line.Length < 2)
                                {
                                    continue;
                                }

                                if (line[0] == '/' && line[1] == '/')
                                {
                                    continue;
                                }

                                idx = line.IndexOf(":");
                                if (idx < 0)
                                {
                                    continue;
                                }

                                string w1 = line.Substring(0, idx).Trim().ToLower();
                                string w2 = line.Substring(idx + 1).Trim();

                                if (w1 == "chs")
                                {
                                    name_chs = w2.Trim();
                                    continue;
                                }

                                if (w1 == "cht")
                                {
                                    name_cht = w2.Trim();
                                    continue;
                                }

                                if (w1 == "jp")
                                {
                                    name_jp = w2.Trim();
                                    continue;
                                }

                                if (w1 == "en")
                                {
                                    name_en = w2.Trim();
                                    continue;
                                }

                                if (w1 == "rome")
                                {
                                    name_rome = w2.Trim();
                                    continue;
                                }
                            }                                   // for
                        }

                        string[] dirs_source = Directory.GetDirectories(dir_video, "*.*", SearchOption.TopDirectoryOnly);
                        foreach (string dir_source in dirs_source)
                        {
                            source_list.Add(Path.GetFileName(dir_source));

                            string[] dirs_sub_name = Directory.GetDirectories(dir_source, "*.*", SearchOption.TopDirectoryOnly);
                            foreach (string dir_sub_name in dirs_sub_name)
                            {
                                if (m_is_stopping)
                                {
                                    return;
                                }

                                string providers = "";                                          // 字幕组/提供者
                                string desc      = "";                                          // 字幕说明

                                // 后缀名
                                SortedSet <string> extension_list = new SortedSet <string>();

                                string[] files = Directory.GetFiles(dir_sub_name, "*.*", SearchOption.TopDirectoryOnly);
                                foreach (string file in files)
                                {
                                    string extension = Path.GetExtension(file).ToLower();
                                    extension_list.Add(extension);
                                }                                       // for files

                                // xxx.txt
                                string desc_filename = dir_sub_name + ".txt";
                                if (File.Exists(desc_filename))
                                {
                                    string file_txt = File.ReadAllText(desc_filename, Encoding.UTF8);
                                    idx = file_txt.IndexOf("desc:", StringComparison.CurrentCultureIgnoreCase);
                                    if (idx > 0)
                                    {
                                        desc = file_txt.Substring(idx + 5).Trim();
                                    }

                                    string[] lines = File.ReadAllLines(desc_filename, Encoding.UTF8);
                                    foreach (string line in lines)
                                    {
                                        if (line.Length < 2)
                                        {
                                            continue;
                                        }

                                        if (line[0] == '/' && line[1] == '/')
                                        {
                                            continue;
                                        }

                                        idx = line.IndexOf(":");
                                        if (idx < 0)
                                        {
                                            continue;
                                        }

                                        string w1 = line.Substring(0, idx).Trim().ToLower();
                                        string w2 = line.Substring(idx + 1).Trim();

                                        if (w1 == "providers")
                                        {
                                            providers = w2.Trim();
                                            break;
                                        }
                                    }                                           // for
                                }

                                DATA.c_SubInfo sub_info = new DATA.c_SubInfo();
                                DATA.m_s_all_subs.Add(sub_info);

                                sub_info.m_name_chs  = name_chs;
                                sub_info.m_name_cht  = name_cht;
                                sub_info.m_name_jp   = name_jp;
                                sub_info.m_name_en   = name_en;
                                sub_info.m_name_rome = name_rome;

                                sub_info.m_time     = date;
                                sub_info.m_type     = Path.GetFileName(dir_type);
                                sub_info.m_source   = Path.GetFileName(dir_source);
                                sub_info.m_sub_name = Path.GetFileName(dir_sub_name);

                                foreach (string extension in extension_list)
                                {
                                    if (sub_info.m_extension.Length > 0)
                                    {
                                        sub_info.m_extension += ";";
                                    }

                                    sub_info.m_extension += extension;
                                }

                                sub_info.m_providers = providers;
                                sub_info.m_desc      = desc;

                                sub_info.m_path = path;
                            }                           // for dirs_sub_name
                        }                               // for dirs_source

                        // 进度条
                        int progress_value = COMMON.m_k_MAX_PROGRESS_VALUE * i_year / dirs_year.Length +
                                             COMMON.m_k_MAX_PROGRESS_VALUE * (i_video + 1) / (dirs_year.Length * dirs_video.Length);
                        COMMON.SetProgressValue(progress_value);
                    }                           // for dirs_video

                    if (can_refresh_UI_tick <= m_sw.ElapsedMilliseconds)
                    {
                        can_refresh_UI_tick = m_sw.ElapsedMilliseconds + 50;                            // 50ms 刷新一次界面
                        Application.DoEvents();
                    }
                }               // for dirs_year
            }                   // for dirs_type

            FORMS.invoke(() =>
            {
                foreach (string source in source_list)
                {
                    frm_Mainform.m_s_mainform.m_Search.comboBox_Source.Items.Add(source);
                }

                COMMON.SetProgressValue(0);
            });

            DATA.m_s_lock.ExitWriteLock();

            FORMS.invoke(() =>
            {
                m_sw.Stop();

                CONFIG.m_s_last_updata_db_time = DateTime.Now;
                CONFIG.write_config();

                lock_controls(true);

                DATA.data2dt();

                append_log(string.Format(LANGUAGES.txt(61),                             // 正在把数据写入到文件 {0:s} ...
                                         PATH.m_k_DB_FILENAME));
                DATA.m_s_dt.WriteXml(PATH.m_k_DB_FILENAME);

                if (m_is_stopping)
                {
                    append_log(string.Format(LANGUAGES.txt(57) + LANGUAGES.txt(60),                             // 用户停止更新数据库(合计 {0:d} 条数据,耗时 {1:s})
                                             DATA.m_s_all_subs.Count,
                                             m_sw.Elapsed.ToString()),
                               Color.Blue);
                }
                else
                {
                    append_log(string.Format(LANGUAGES.txt(58) + LANGUAGES.txt(60),                             // 更新数据库完成(合计 {0:d} 条数据,耗时 {1:s})
                                             DATA.m_s_all_subs.Count,
                                             m_sw.Elapsed.ToString()),
                               Color.Green);
                }

                frm_Mainform.m_s_mainform.m_DataGridView_event_enable  = false;
                frm_Mainform.m_s_mainform.dataGridView_Main.DataSource = DATA.m_s_dt;
                frm_Mainform.m_s_mainform.update_columns_style();
                frm_Mainform.m_s_mainform.m_DataGridView_event_enable = true;

                frm_Mainform.m_s_mainform.update_status();

                m_is_stopping = false;
            });

            m_is_updating_database = false;
        }
Example #13
0
 /*==============================================================
  * 窗口加载时
  *==============================================================*/
 private void frm_Search_Load(object sender, EventArgs e)
 {
     this.Icon = IMAGE.img2icon(Resource1.Logo);
     this.Text = string.Format(LANGUAGES.txt(11));                       // 高级查找
 }