コード例 #1
0
ファイル: Form2.cs プロジェクト: 15831944/tool
        private void simpleButton2_Click_1(object sender, EventArgs e)
        {
            if (this.textEdit1.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("请输入报警界限");
                this.textEdit1.Focus();
                return;
            }
            if (this.textEdit1.Text.Trim().Equals(string.Empty))
            {
                MessageBox.Show("报警界限的格式输入有误");
                this.textEdit1.Focus();
                return;
            }
            if (this.textEdit2.Text.Trim().Equals(string.Empty))
            {
                dropDownButton1.Text = "斗地主";
                textEdit2.Text       = Application.StartupPath + @"\resources\UserMonitorResource\music\斗地主.wav";
            }


            //修改配置文件
            SystemConfig.WriteConfigData("user_warning_count", this.textEdit1.Text.Trim());
            SystemConfig.WriteConfigData("music_url", this.textEdit2.Text);
            myMethodDelegate mydelegate = new myMethodDelegate(Form1.soundplyStop);

            mydelegate += Form1.initialize_warning_count;
            mydelegate.Invoke();
            this.Close();
            //    MessageBox.Show("成功保存到配置文件" + Application.StartupPath + "\\plugin\\SystemConfig.xml \n点击读取按钮进行读取!");
        }
コード例 #2
0
        void ThisIsMain()
        {
            myMethodDelegate myDel = new myMethodDelegate(myMethod);

            myDel.Invoke();

            myMethodDelegate2 myDel2 = new myMethodDelegate2(myMethod);

            myDel2.Invoke("Hello");

            myMethodDelegate3 myDel3 = new myMethodDelegate3(myMethod);

            myDel3.Invoke("Hello", 1);

            Console.WriteLine(myDel3.Method);

            foreach (var item in myDel3.Method.GetParameters())
            {
                Console.WriteLine(item.ParameterType + " " + item.Name);
            }

            myDictiornayDelegate     dicDel = new myDictiornayDelegate(dictionaryMethod);
            Dictionary <int, string> data   = new Dictionary <int, string>();

            for (int i = 0; i < 10; i++)
            {
                data.Add(i, $"val{i}");
            }
            dicDel.Invoke(data);

            sayHiDelegate sayHi = new sayHiDelegate(sayHi1);

            sayHi += sayHi2; // = new sayHiDelegate(sayHi2);
            sayHi += sayHi3;
            sayHi += sayHi4;
        }