⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmevaluation.cs

📁 用C#编写的一个款搜索engine的源代码!摘自<Visual c#2005 程序设计>
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SECompare.Forms
{
    public partial class FrmEvaluation : Form
    {
        SECompare.Evaluation.Evaluation SeqEvaluation = null; 

        public FrmEvaluation()
        {
            InitializeComponent();
        }

        private void btnStart_Click(object sender, System.EventArgs e)
        {
            //Ensure Engines have been selected.
            if (this.RefEngineList.SelectedEngine == null)
            {
                MessageBox.Show("Please Select Reference Engine!", "Setting Error");
                return;
            }
            if (this.PeerEngineList.SelectedEngine == null)
            {
                MessageBox.Show("Please Select Peer Engine!", "Setting Error");
                return;
            }

            //Get selected Sequence Evaluation Method
            if (this.cmbSeqMethod.SelectedItem == null)
            {
                MessageBox.Show("Please Select Sequence Evaluation Method!", "Setting Error");
                return;
            }

            Evaluation.Methods SeqMethod;
            switch (this.cmbSeqMethod.SelectedItem.ToString())
            {
                case "Coverage":
                    SeqMethod = Evaluation.Methods.Coverage;
                    break;
                case "P":
                    SeqMethod = Evaluation.Methods.P;
                    break;
                case "MAP":
                    SeqMethod = Evaluation.Methods.MAP;
                    break;
                case "RP":
                    SeqMethod = Evaluation.Methods.RP;
                    break;
                case "Rank1R":
                    SeqMethod = Evaluation.Methods.Rank1R;
                    break;
                case "CI":
                    SeqMethod = Evaluation.Methods.CI;
                    break;
                case "SP":
                    SeqMethod = Evaluation.Methods.SP;
                    break;
                default:
                    MessageBox.Show("Please Select Sequence Evaluation Method!", "Setting Error");
                    return;
            }

            //Choose Folder
            FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
            fbd.SelectedPath = Directory.GetCurrentDirectory();

            //Run Evaluation
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                if (Directory.Exists(fbd.SelectedPath))
                {
                    this.SeqEvaluation = new Evaluation.Evaluation(fbd.SelectedPath,
                        this.RefEngineList.SelectedEngine,
                        this.PeerEngineList.SelectedEngine,
                        SeqMethod,
                        this.StringToIntArray(this.txtCheckPoint_Ref.Text),
                        this.StringToIntArray(this.txtCheckPoint_Peer.Text));
                    this.SeqEvaluation.Start();
                    this.threadMsgMonitor.ThreadStatus = this.SeqEvaluation;
                    this.threadMsgMonitor.Title = SeqMethod.ToString() + " Evaluation";
                    this.threadMsgMonitor.StartButton = this.btnStart;
                    this.threadMsgMonitor.Start();
                }
            }
        }

        /// <summary>
        /// Convert String to integer array.
        /// </summary>
        /// <param name="str">string of integers separated by "," or " ".</param>
        /// <returns></returns>
        private int[] StringToIntArray(String str)
        {
            String[] unit = str.Split(new char[] { ',', ' ' });
            ArrayList integers = new ArrayList();
            int i;
            for (i = 0; i < unit.Length; i++)
            {
                try
                {
                    integers.Add(Convert.ToInt32(unit[i]));
                }
                catch (FormatException)
                {
                    continue;
                }
            }

            int[] retval = new int[integers.Count];
            i = 0;
            foreach (int iunit in integers)
            {
                retval[i++] = iunit;
            }

            return retval;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -