public static void CreateSpring(SpringModel model) { List <SpringModel> allSprings = Spring_GetAll(); if (allSprings.Count > 0) { model.Id = allSprings.OrderByDescending(x => x.Id).First().Id + 1; } else { model.Id = 1; } allSprings.Add(model); allSprings.SaveSpringsToFile(); }
private void addNewSpringButton_Click(object sender, EventArgs e) { if (!ValidateData()) { return; } SpringModel model = new SpringModel() { Number = springNumberTextBox.Text, Force = double.Parse(springForceTextBox.Text), ForceTolerance = double.Parse(springForceToleranceTextBox.Text), Length = double.Parse(springLenghTextBox.Text), Rate = double.Parse(springRateTextBox.Text) }; TextConnector.CreateSpring(model); allSprings.Add(model); UpdateData(); }
public static List <SpringModel> ConvertTextToSpring(this List <string> lines) { // Id|^|Number|^|Rate|^|Length|^|Force|^|ForceTolerance List <SpringModel> output = new List <SpringModel>(); SpringModel curr = new SpringModel(); foreach (string line in lines) { string[] cols = line.Split(new string[] { "|^|" }, StringSplitOptions.None); curr.Id = int.Parse(cols[0]); curr.Number = cols[1]; curr.Rate = double.Parse(cols[2]); curr.Length = double.Parse(cols[3]); curr.Force = double.Parse(cols[4]); curr.ForceTolerance = double.Parse(cols[5]); output.Add(curr); curr = new SpringModel(); } return(output); }
private void allSpringsComboBox_SelectionChangeCommitted(object sender, EventArgs e) { selectedSpring = (SpringModel)allSpringsComboBox.SelectedItem; WireUpLists(); }
public void BuildAutomaticLayoutedGraph(bool initOnly) { ClearData(); int index = 0; foreach (NounFrame NF in _TMR.Nounframes) { NounFrameEntity nfe = new NounFrameEntity(0, 0, NF, _TMR, GImSearch, SizeMode, _conceptCombination); this.Add(nfe); _dicNounFrame.Add(NF, nfe); _nodes.Add(new Node(0, 0, index)); index++; } foreach (NounFrame NF in _TMR.Nounframes) { foreach (CaseRole cr in NF.Ownerof.Keys) { foreach (NounFrame NF2 in NF.Ownerof[cr]) { if (_dicNounFrame.ContainsKey(NF2) == true) { NounFrameEntity nfe2; nfe2 = _dicNounFrame[NF2]; if (ShowEdgeText) { Add(new MM_LineWithText(_dicNounFrame[NF], nfe2, cr.ToString())); } else { Add(new MM_LineWithText(_dicNounFrame[NF], nfe2, "")); } _edges.Add(new GraphTest.Edge(_nodes[this._TMR.Nounframes.IndexOf(NF)], _nodes[this._TMR.Nounframes.IndexOf(NF2)])); _nodes[this._TMR.Nounframes.IndexOf(NF)].Neighbours.Add(_nodes[this._TMR.Nounframes.IndexOf(NF2)]); _nodes[this._TMR.Nounframes.IndexOf(NF2)].Neighbours.Add(_nodes[this._TMR.Nounframes.IndexOf(NF)]); } } } } foreach (VerbFrame VF in _TMR.VerbFrames) { VerbFrameEntity VF_entity = new VerbFrameEntity(0, 0, VF, _TMR, GImSearch, SizeMode); Add(VF_entity); _dicVerbFrame.Add(VF, VF_entity); _nodes.Add(new Node(0, 0, index)); //if (VF.Aspect.Duration.ActionTime != null) //{ // index++; // _nodes.Add(new Node(0, 0, index)); //} foreach (CaseRole cr in VF.CaseRoles.Keys) { List <NounFrame> nfs = VF.CaseRoles[cr]; foreach (NounFrame NF in nfs) { if (_dicNounFrame.ContainsKey(NF) == true) { NounFrameEntity nfe = _dicNounFrame[NF]; if (cr == CaseRole.Agent) { if (ShowEdgeText) { Add(new MM_LineWithText(nfe, VF_entity, cr.ToString())); } else { Add(new MM_LineWithText(nfe, VF_entity, "")); } } else { if (ShowEdgeText) { Add(new MM_LineWithText(VF_entity, nfe, cr.ToString())); } else { Add(new MM_LineWithText(VF_entity, nfe, "")); } } //Add(new MM_Line(VF_entity, nfe)); _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[this._TMR.Nounframes.IndexOf(NF)])); _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.Nounframes.IndexOf(NF)]); _nodes[this._TMR.Nounframes.IndexOf(NF)].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); } } } index++; } foreach (VerbFrame VF in _TMR.VerbFrames) { VerbFrameEntity VF_entity = _dicVerbFrame[VF]; foreach (DomainRelationType drt in VF.DomainRelations.Keys) { List <VerbFrame> vfl = VF.DomainRelations[drt]; foreach (VerbFrame vf in vfl) { if (_dicVerbFrame.ContainsKey(vf) == true) { VerbFrameEntity vfe = _dicVerbFrame[vf]; if (ShowEdgeText) { Add(new MM_LineWithText(VF_entity, vfe, drt.ToString())); } else { Add(new MM_LineWithText(VF_entity, vfe, "")); } //Add(new MM_Line(VF_entity, vfe)); _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[this._TMR.VerbFrames.IndexOf(vf) + this._TMR.Nounframes.Count])); _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(vf) + this._TMR.Nounframes.Count]); _nodes[this._TMR.VerbFrames.IndexOf(vf) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); } } } foreach (DomainRelationType drt in VF.DomainRelations_n.Keys) { List <NounFrame> nfl = VF.DomainRelations_n[drt]; foreach (NounFrame nf in nfl) { if (_dicNounFrame.ContainsKey(nf) == true) { NounFrameEntity nfe = _dicNounFrame[nf]; if (ShowEdgeText) { Add(new MM_LineWithText(VF_entity, nfe, drt.ToString())); } else { Add(new MM_LineWithText(VF_entity, nfe, "")); } //Add(new MM_Line(VF_entity, nfe)); _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[this._TMR.Nounframes.IndexOf(nf)])); _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.Nounframes.IndexOf(nf)]); _nodes[this._TMR.Nounframes.IndexOf(nf)].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); } } } foreach (TemporalRelationType trt in VF.TemporalRelations.Keys) { List <VerbFrame> vfl = VF.TemporalRelations[trt]; foreach (VerbFrame vf in vfl) { if (_dicVerbFrame.ContainsKey(vf) == true) { VerbFrameEntity vfe = _dicVerbFrame[vf]; if (ShowEdgeText) { Add(new MM_LineWithText(VF_entity, vfe, trt.ToString())); } else { Add(new MM_LineWithText(VF_entity, vfe, "")); } //Add(new MM_Line(VF_entity, vfe)); _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[this._TMR.VerbFrames.IndexOf(vf) + this._TMR.Nounframes.Count])); _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(vf) + this._TMR.Nounframes.Count]); _nodes[this._TMR.VerbFrames.IndexOf(vf) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); } } } foreach (TemporalRelationType trt in VF.TemporalRelations_n.Keys) { List <NounFrame> nfl = VF.TemporalRelations_n[trt]; foreach (NounFrame nf in nfl) { if (_dicNounFrame.ContainsKey(nf) == true) { NounFrameEntity nfe = _dicNounFrame[nf]; if (ShowEdgeText) { Add(new MM_LineWithText(VF_entity, nfe, trt.ToString())); } else { Add(new MM_LineWithText(VF_entity, nfe, "")); } //Add(new MM_Line(VF_entity, nfe)); _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[this._TMR.Nounframes.IndexOf(nf)])); _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[this._TMR.Nounframes.IndexOf(nf)]); _nodes[this._TMR.Nounframes.IndexOf(nf)].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); } } } //aspects if (VF.Aspect.Duration.ActionTime != null) { string time = VF.Aspect.Duration.ActionTime; VerbFrameEntity vfe = _dicVerbFrame[VF]; MM_RectangleWithText timeEntity = new MM_RectangleWithText(0, 0, 30, 25, time, ""); Add(timeEntity); otherEntities.Add(timeEntity); _nodes.Add(new Node(0, 0, _nodes.Count)); if (ShowEdgeText) { Add(new MM_LineWithText(VF_entity, timeEntity, "Time")); } else { Add(new MM_LineWithText(VF_entity, timeEntity, "")); } //Add(new MM_Line(VF_entity, timeEntity)); _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[_nodes.Count - 1])); _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[_nodes.Count - 1]); _nodes[_nodes.Count - 1].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); } //adverbs //if (VF.AdverbsInfo != null) //{ // foreach (MyWordInfo mwi in VF.AdverbsInfo) // { // MM_RectangleWithText entity = new MM_RectangleWithText(0, 0, 30, 25, mwi.Word, ""); // Add(entity); // otherEntities.Add(entity); // _nodes.Add(new Node(0, 0, _nodes.Count)); // Add(new MM_LineWithText(VF_entity, entity, "Adverb")); // _edges.Add(new GraphTest.Edge(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count], _nodes[_nodes.Count - 1])); // _nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count].Neighbours.Add(_nodes[_nodes.Count - 1]); // _nodes[_nodes.Count - 1].Neighbours.Add(_nodes[this._TMR.VerbFrames.IndexOf(VF) + this._TMR.Nounframes.Count]); // } //} //adjectives //foreach (NounFrame nounframe in _TMR.Nounframes) //{ // if (nounframe.AdjectivesInfo != null) // { // foreach (MyWordInfo mwi in nounframe.AdjectivesInfo) // { // MM_RectangleWithText entity = new MM_RectangleWithText(0, 0, 30, 25, mwi.Word, ""); // Add(entity); // otherEntities.Add(entity); // _nodes.Add(new Node(0, 0, _nodes.Count)); // Add(new MM_LineWithText(VF_entity, entity, "Adjective")); // _edges.Add(new GraphTest.Edge(_nodes[this._TMR.Nounframes.IndexOf(nounframe)], _nodes[_nodes.Count - 1])); // _nodes[this._TMR.Nounframes.IndexOf(nounframe)].Neighbours.Add(_nodes[_nodes.Count - 1]); // _nodes[_nodes.Count - 1].Neighbours.Add(_nodes[this._TMR.Nounframes.IndexOf(nounframe)]); // } // } //} } _spModel = new SpringModel(_nodes, _edges, 800, 200, Mode.CIRCULAR); //this._spModel._getOriginDistance = new GetOriginDistance(getOriginDistance); this._spModel.StepDoneEvent += new SingleStepUpdateEventHandler(_spModel_StepDoneEvent); if (LayoutiingThread != null) { if (LayoutiingThread.ThreadState != ThreadState.Stopped) { LayoutiingThread.Abort(); } } if (initOnly) { _spModel.InitializeSpringModel(); _spModel.AdjustNodes(new Rectangle(0, 0, 800, 600)); _spModel_StepDoneEvent(); } else { LayoutiingThread = new System.Threading.Thread(new System.Threading.ThreadStart(_spModel.Run)); LayoutiingThread.Start(); } }