//добавление соотношения public void AddRelation(string RelCB1, int RelTB_1, int RelTB_2) { var SegmentF = db.segments.Where(s => s.Name == RelCB1).First <segments>(); Relations NewRel = new Relations() { relation1 = Convert.ToInt32(RelTB_1), relation2 = Convert.ToInt32(RelTB_2), segment_ID = Convert.ToInt32(SegmentF.id) }; db.Relations.Add(NewRel); db.SaveChanges(); }
//точка соотношения public double Reletion(Relations rel, string k) { var seg = db.segments.Where(w => w.id == rel.segment_ID).FirstOrDefault <segments>(); double relation = Convert.ToDouble(Convert.ToDouble(rel.relation1) / Convert.ToDouble(rel.relation2)); double XM = Convert.ToDouble(Convert.ToDouble(seg.x1) + relation * Convert.ToDouble(seg.x2)) / (1 + relation); double YM = Convert.ToDouble(Convert.ToDouble(seg.y1) + relation * Convert.ToDouble(seg.y2)) / (1 + relation); if (k == "x") { return(XM); } else if (k == "y") { return(YM); } else { return(0); } }