void addLink(link newLink) { try { con.Open(); OleDbCommand command = new OleDbCommand(); command.Connection = con; command.CommandText = "INSERT INTO linksTbl VALUES (@ID, @parentNode, @childNode, @timeStamp);"; command.Parameters.AddWithValue("@ID", newLink.id); command.Parameters.AddWithValue("@parentNode", newLink.parentNode); command.Parameters.AddWithValue("@childNode", newLink.childNode); command.Parameters.AddWithValue("@timeStamp", newLink.timeStamp.ToString()); command.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("Error" + ex); } con.Close(); }
undoState cloneState(List <node> oldNodes, List <link> oldLinks) { List <node> clonedNodes = new List <node>(); List <link> clonedLinks = new List <link>(); node nodeBuffer; link linkBuffer; for (int i = 0; i < oldNodes.Count; i++) { nodeBuffer = new node(); nodeBuffer.id = oldNodes[i].id; nodeBuffer.fileLocation = oldNodes[i].fileLocation; nodeBuffer.name = oldNodes[i].name; nodeBuffer.projectId = oldNodes[i].projectId; nodeBuffer.rank = oldNodes[i].rank; nodeBuffer.timeStamp = oldNodes[i].timeStamp; nodeBuffer.type = oldNodes[i].type; nodeBuffer.x = oldNodes[i].x; nodeBuffer.y = oldNodes[i].y; clonedNodes.Add(nodeBuffer); } for (int i = 0; i < oldLinks.Count; i++) { linkBuffer = new link(); linkBuffer.childNode = oldLinks[i].childNode; linkBuffer.id = oldLinks[i].id; linkBuffer.parentNode = oldLinks[i].parentNode; linkBuffer.timeStamp = oldLinks[i].timeStamp; clonedLinks.Add(linkBuffer); } undoState clonedState = new undoState(); clonedState.set(clonedNodes, clonedLinks); return(clonedState); }
private void replayBtn_Click(object sender, EventArgs e) { node nextNode = new node(); link nextLink = new link(); List <node> tempNodes = new List <node>(); List <link> tempLinks = new List <link>(); int delay; int pause = 700; bool moreNodes = true; bool moreLinks = true; bool loop = true; bool writeNode = false; int nodeIterator = 0; int linkIterator = 0; sortNodesLinks(); delay = (int)((nodes.Count + links.Count) * 700) % 5600; player2 = new System.Media.SoundPlayer(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Tacitus\\memoryMusic.wav"); player2.PlayLooping(); string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); path += "\\Tacitus\\lift.wav"; player = new System.Media.SoundPlayer(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Tacitus\\memoryMusicEnd.wav"); while (loop) { System.Threading.Thread.Sleep(pause); //player.Play(); if (nodes.Count() == nodeIterator) { moreNodes = false; } if (links.Count() == linkIterator) { moreLinks = false; } if (!moreNodes && !moreLinks) { loop = false; } if (loop) { if (moreNodes) { nextNode = nodes[nodeIterator]; } if (moreLinks) { nextLink = links[linkIterator]; } if (nextNode.timeStamp < nextLink.timeStamp) { writeNode = true; } if (!moreLinks) { writeNode = true; } if (!moreNodes) { writeNode = false; } if (writeNode) { int relativeX = nextNode.x - translateX; int relativeY = nextNode.y - translateY; for (int i = 0; i < frameRate; i++) { translateX += (relativeX - mapPicBx.Width / 2) / frameRate; translateY += (relativeY - mapPicBx.Height / 2) / frameRate; drawMap(tempLinks, tempNodes); } tempNodes.Add(nextNode); writeNode = false; drawMap(tempLinks, tempNodes); nodeIterator++; } else if (moreLinks) { tempLinks.Add(nextLink); drawMap(tempLinks, tempNodes); linkIterator++; } } } System.Threading.Thread.Sleep(delay); player2.Stop(); player.Play(); }
public void addLink(link newLink) { links.Add(newLink); }