Beispiel #1
0
        /// <summary>
        /// 运行按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnYunXing_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }
            Assembly asbly;

            try
            {
                asbly = Assembly.LoadFile((ClassPaths[listBox1.SelectedIndex])[1]);
            }
            catch
            {
                MessageBox.Show("系统找不到指定文件或者非有效的dll文件");
                //将文件内无效的项目移除
                ClassPaths.RemoveAt(listBox1.SelectedIndex);
                listBox1.Items.RemoveAt(listBox1.SelectedIndex);
                Changge = true;
                return;
            }
            Object oo = asbly.CreateInstance((ClassPaths[listBox1.SelectedIndex])[0]);

            MyInterfaces.WinFormInterface ooshow = (MyInterfaces.WinFormInterface)oo;
            (ClassPaths[listBox1.SelectedIndex])[2] = ooshow.GetDirectons;
            ooshow.ShowIt();
        }
Beispiel #2
0
        /// <summary>
        /// listBox1的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }
            if ((ClassPaths[listBox1.SelectedIndex])[2] != "")
            {
                textBox1.Text = (ClassPaths[listBox1.SelectedIndex])[2];
                return;
            }
            Assembly asbly = Assembly.LoadFile((ClassPaths[listBox1.SelectedIndex])[1]);
            Object   oo    = asbly.CreateInstance((ClassPaths[listBox1.SelectedIndex])[0]);

            MyInterfaces.WinFormInterface ooshow = (MyInterfaces.WinFormInterface)oo;
            (ClassPaths[listBox1.SelectedIndex])[2] = ooshow.GetDirectons;
            textBox1.Text = ooshow.GetDirectons;
            Changge       = true;
        }