private void button1_Click(object sender, EventArgs e) { ViewPort(50, 50, 650, 500); System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Chocolate); System.Drawing.Graphics formGraphics = this.CreateGraphics(); System.IO.StreamReader Fc = new System.IO.StreamReader("C:/Users/Catalin/source/repos/WindowsFormsApp2/WindowsFormsApp2/FileCorp.txt"); String Line = Fc.ReadLine(); String[] Split = Line.Split(new Char[] { ' ', ',', '\t' }); int n = Convert.ToInt32(Split[0]); varf[] V = new varf[n + 1]; for (int i = 1; i <= n; i++) { Line = Fc.ReadLine(); Split = Line.Split(new Char[] { ' ', ',', '\t' }); int X = Convert.ToInt32(Split[0]); int Z = Convert.ToInt32(Split[1]); int Y = Convert.ToInt32(Split[2]) - 100; // y <--->z V[i] = new varf(X, Y, Z); // V V V !! } Line = Fc.ReadLine(); Split = Line.Split(new Char[] { ' ', ',', '\t' }); int m = Convert.ToInt32(Split[0]); muchie[] M = new muchie[m + 1]; for (int j = 1; j <= m; j++) // Cit. Muchii { Line = Fc.ReadLine(); Split = Line.Split(new Char[] { ' ', ',', '\t' }); M[j] = new muchie(); M[j].st = Convert.ToInt32(Split[0]); M[j].dr = Convert.ToInt32(Split[1]); } Line = Fc.ReadLine(); // Cit. Car. Pr. Tip, r, α Split = Line.Split(new Char[] { ' ', ',', '\t' }); Tip = Convert.ToInt32(Split[0]); Raza = Convert.ToDouble(Split[1]); Alfa = Convert.ToDouble(Split[2]); Fc.Close(); DefPr(Raza, Alfa); // 1=Par(r,α), 2=Persp.(d,q); a = b = Px(V[1]); c = d = Py(V[1]); for (int i = 2; i <= n; i++) { double px = Px(V[i]); if (px < a) { a = px; } else if (px > b) { b = px; } double py = Py(V[i]); if (py < c) { c = py; } else if (py > d) { d = py; } } Window(a, d, b, c); // Fereasta Reală for (int j = 1; j <= m; j++) // Desenare muchii { formGraphics.DrawLine(myPen, u(Px(V[M[j].st])), v(Py(V[M[j].st])), u(Px(V[M[j].dr])), v(Py(V[M[j].dr]))); } myPen.Dispose(); formGraphics.Dispose(); }
public object createMuh(muchie fromMuchie) { object toR = Activator.CreateInstance(muhType, fromMuchie.x, fromMuchie.y, fromMuchie.dist); return toR; }
public void setMembers() { Type listType = typeof(List<>).MakeGenericType(new[] { muhType }); setValue("n", graf.noduri.Count); object debugn = getValue("n"); #region Set Graph Array muhs = Array.CreateInstance(listType, graf.noduri.Count+1); for (int i = 0; i < graf.noduri.Count; i++) { IList muh = (IList)Activator.CreateInstance(listType); for (int j = 0; j < graf.noduri[i].vec.Count; j++) { Muchie vMuchie = graf.noduri[i].vec[j]; muchie crt; if (i + 1 == vMuchie.x.num()) crt = new muchie(vMuchie.x.num(), vMuchie.y.num(), vMuchie.dist); else crt = new muchie(vMuchie.y.num(), vMuchie.x.num(), vMuchie.dist); muh.Add(createMuh(crt)); } muhs.SetValue(Convert.ChangeType(muh, listType), i+1); } setValue("graf", muhs); #endregion watchMuchii = Activator.CreateInstance(listType); setValue("watchMuchii", watchMuchii); watchSelected = Activator.CreateInstance(listType); setValue("watchSelected", watchSelected); int x = 8; Array nodesInfo = Array.CreateInstance(x.GetType(), graf.noduri.Count + 1); for (int i = 1; i <= graf.noduri.Count; i++) nodesInfo.SetValue(i, i); setValue("nodesInfo", nodesInfo); }
public muchie createMuchie(object muhInstance) { muchie toR = new muchie((int)muhType.GetField("x").GetValue(muhInstance), (int)muhType.GetField("y").GetValue(muhInstance), (int)muhType.GetField("dist").GetValue(muhInstance)); return toR; }