private void button1_Click(object sender, EventArgs e) { int x = Convert.ToInt32(textBox1.Text); int y = Convert.ToInt32(textBox2.Text); myClass area = new myClass(x,y); textBox3.Text = Convert.ToString(area.calc(x, y)); }
static void Main() { var yourchild = new ChildClass(); yourchild.childProp1 = 222; yourchild.childProp2 = "Childstring"; yourchild.childProp6 = new ChildClass() { childProp2 = "ChildChild" }; var yourObject = new myClass(1, "mystring", 5.5, 1.3f); yourObject.prop6 = yourchild; //First Step // create a XAML string string stCopie = System.Windows.Markup.XamlWriter.Save(yourObject); //Secound Step // convert him back to an Object of YourTyp var Copie = System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader.Create(new System.IO.StringReader(stCopie))) as myClass; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
private void button1_Click(object sender, EventArgs e) { int x = Convert.ToInt32(textBox1.Text); int y = Convert.ToInt32(textBox2.Text); myClass area = new myClass(x, y); textBox3.Text = Convert.ToString(area.calc(x, y)); }
//var files = Directory.GetFiles(Path.GetDirectoryName(Application.ExecutablePath), "*.dll", SearchOption.AllDirectories); //List<myClass> commands = new List<myClass>(); //foreach (string file in files) //{ // i++; // Assembly commandAssembly = Assembly.Load(Path.GetFileNameWithoutExtension(file)); // if (commandAssembly != null) // { // foreach (Type type in commandAssembly.GetTypes()) // { // if (type.BaseType != null && type.BaseType.FullName == typeof(myClass).FullName) // { // commands.Add((myClass)Activator.CreateInstance(type)); // } // } // } //} private void abc() { var files = Directory.GetFiles(Path.GetDirectoryName(Application.ExecutablePath), "*.dll", SearchOption.AllDirectories); List <myClass> commands = new List <myClass>(); List <IPlugin> assemblies = new List <IPlugin>(); List <ToolStripItem> mMenu = new List <ToolStripItem>(); foreach (string file in files) { IPlugin plug = null; Assembly commandAssembly = Assembly.Load(Path.GetFileNameWithoutExtension(file)); if (commandAssembly != null) { Type ObjType = null; ObjType = commandAssembly.GetType(Path.GetFileNameWithoutExtension(file) + ".PlugIn"); if (ObjType != null) { plug = (IPlugin)Activator.CreateInstance(ObjType); plug.Host = this; //plug.Menu = "I sent this from main"; Console.WriteLine("ipi.Add(1,2)=" + plug.Add(1, 2)); assemblies.Add(plug); //For classes List <ToolStripItem> sMenu = new List <ToolStripItem>(); foreach (Type type in commandAssembly.GetTypes()) { if (type.BaseType != null && type.BaseType.FullName == typeof(myClass).FullName) { myClass myCls = (myClass)Activator.CreateInstance(type); commands.Add(myCls); sMenu.Add(myCls.Menu); plug.Menu.DropDownItems.Add(myCls.Menu); } } // ToolStripMenuItem ms = new ToolStripMenuItem("ab", null, sMenu.ToArray()); // plug.Menu.DropDownItems.Add(sMenu.ToArray()); mMenu.Add(plug.Menu); } } } this.menuStrip1.Items.AddRange(mMenu.ToArray()); }
private void Form1_Load(object sender, EventArgs e) { myClass my_class = new myClass(); /* for (int i = 0; i < my_class.Nn; i++) my_class.InnerArray[i] = 5 * Math.Sin(2 * Math.PI * i / 100) * Math.Cos(2 * Math.PI * i / my_class.Nn); // задаем форму сигнала */ double[] InnerArray__A = new double[20]; double[] InnerArray__T = new double[20]; InnerArray__A[0] = 10; InnerArray__A[1] = 15; InnerArray__A[2] = 8; InnerArray__A[3] = 13; InnerArray__A[4] = 6; InnerArray__A[5] = 3; InnerArray__A[6] = 1; InnerArray__A[7] = 1; InnerArray__A[8] = 1; InnerArray__A[9] = 1; InnerArray__A[10] = 1; InnerArray__A[11] = 1; InnerArray__A[12] = 1; InnerArray__A[13] = 1; InnerArray__A[14] = 1; InnerArray__A[15] = 1; InnerArray__A[16] = 1; InnerArray__A[17] = 1; InnerArray__A[18] = 1; InnerArray__A[19] = 1; InnerArray__T[0] = 0; InnerArray__T[1] = 1; InnerArray__T[2] = 2; InnerArray__T[3] = 3; InnerArray__T[4] = 4; InnerArray__T[5] = 5; InnerArray__T[6] = 6; InnerArray__T[7] = 7; InnerArray__T[8] = 8; InnerArray__T[9] = 9; InnerArray__T[10] = 10; InnerArray__T[11] = 11; InnerArray__T[12] = 12; InnerArray__T[13] = 13; InnerArray__T[14] = 14; InnerArray__T[15] = 15; InnerArray__T[16] = 16; InnerArray__T[17] = 17; InnerArray__T[18] = 18; InnerArray__T[19] = 19; my_class.DPF(InnerArray__A,InnerArray__T); PD obratochka = new PD(); List<double> obr = new List<double>(); obr = obratochka.FromFourier(my_class.output,20); for (int i = 0; i < my_class.Nn; i++) { listBox1.Items.Add(my_class.Furie[i].Amplitude); listBox2.Items.Add(my_class.Furie[i].Faza); listBox3.Items.Add(my_class.Furie[i].Freq); listBox4.Items.Add(my_class.Furie[i].Re); listBox5.Items.Add(my_class.Furie[i].Im); listBox8.Items.Add(obr[i]); } for(int i = 0; i < InnerArray__A.Length;i++) { listBox6.Items.Add(InnerArray__A[i]); } for (int i = 0; i < InnerArray__T.Length; i++) { listBox7.Items.Add(InnerArray__T[i]); } }