/// <summary> /// Adds a node to the current node so that it is linked to it. /// </summary> /// <param name="node">The node to link this one to</param> /// <returns> /// True if successfully added to the list that this node links to. /// False if this node already links to that node. /// </returns> public bool AddLinkedNode(Node node) { if (!LinksTo.Contains(node)) { LinksTo.Add(node); Parents.Add(node); return(true); } return(false); }
private String BuildInsertCommandLinksTo(LinksTo lt) { String command; StringBuilder sb = new StringBuilder(); // use a string builder to create the dynamic string sb.AppendFormat("Values('{0}' , '{1}' , '{2}')", lt.BranchCode.ToString(), lt.LinkName, lt.LinkCode.ToString()); String prefix = "INSERT INTO SM_LinksTo" + "(BranchCode , Link , LinkCode) "; command = prefix + sb.ToString(); return(command); }
public void DrawLinks(SpriteBatch spriteBatch) { // Draw all nodes that this node points to foreach (var linksToNodeLocation in LinksTo.Select(i => i.Center)) { var vectorDiff = Center - linksToNodeLocation; vectorDiff.Normalize(); var rotationAngle = (float)Math.Atan2(vectorDiff.Y, vectorDiff.X); var boxRadius = Radius - (_arrow.Height / 2f); var drawArrowLocation = new Vector2( (float)(Center.X + (boxRadius) * Math.Cos(Math.PI - rotationAngle)), (float)(Center.Y + (boxRadius) * Math.Sin(-rotationAngle))); spriteBatch.Draw(_arrow, drawArrowLocation, null, Color.White, rotationAngle, new Vector2(_arrow.Width, _arrow.Height) / 2, 1f, SpriteEffects.None, 1f); } }
public int InsertLinksTo(LinksTo lt) { int numEffected = 0; SqlConnection con; SqlCommand cmd; try { con = connect("DB7"); // create the connection } catch (Exception ex) { // write to log throw (ex); } String cStr = BuildInsertCommandLinksTo(lt); // helper method to build the insert string cmd = CreateCommand(cStr, con); // create the command try { numEffected = cmd.ExecuteNonQuery(); // execute the command } catch (Exception ex) { //return 0; // write to log throw (ex); } finally { if (con != null) { // close the db connection con.Close(); } } return(numEffected); }
public BranchNode(NodeDiagram parent, ILInstruction instruction) : base(parent) { this.Instruction = instruction; string operand = instruction.GetOperandString(); Text = instruction.Offset.ToString("x4") + Environment.NewLine + instruction.Code.ToString() + (string.IsNullOrEmpty(operand) ? "" : Environment.NewLine + operand); using (System.Drawing.Graphics g = parent.CreateGraphics()) { SizeF s = g.MeasureString(Text, parent.Font); nodeSize = base.NodeSize; if (s.Width > base.NodeSize.Width) { nodeSize = new Size((int)s.Width, nodeSize.Height); } if (s.Height > base.NodeSize.Height) { nodeSize = new Size((int)nodeSize.Width, (int)s.Height); } } if (instruction.Code == OpCodes.Beq || instruction.Code == OpCodes.Beq_S) { jumpExpression = "=="; continueExpression = "!="; } else if (instruction.Code == OpCodes.Bge || instruction.Code == OpCodes.Bge_S || instruction.Code == OpCodes.Bge_Un || instruction.Code == OpCodes.Bge_Un_S) { jumpExpression = ">="; continueExpression = "<"; } else if (instruction.Code == OpCodes.Bgt || instruction.Code == OpCodes.Bgt_S || instruction.Code == OpCodes.Bgt_Un || instruction.Code == OpCodes.Bgt_Un_S) { jumpExpression = ">"; continueExpression = "<="; } else if (instruction.Code == OpCodes.Ble || instruction.Code == OpCodes.Ble_S || instruction.Code == OpCodes.Ble_Un || instruction.Code == OpCodes.Ble_Un_S) { jumpExpression = "<="; continueExpression = ">"; } else if (instruction.Code == OpCodes.Blt || instruction.Code == OpCodes.Blt_S || instruction.Code == OpCodes.Blt_Un || instruction.Code == OpCodes.Blt_Un_S) { jumpExpression = "<"; continueExpression = ">="; } else if (instruction.Code == OpCodes.Bne_Un || instruction.Code == OpCodes.Bne_Un_S) { jumpExpression = "!="; continueExpression = "=="; } else if (instruction.Code == OpCodes.Brfalse || instruction.Code == OpCodes.Brfalse_S) { jumpExpression = "false"; continueExpression = "true"; } else if (instruction.Code == OpCodes.Brtrue || instruction.Code == OpCodes.Brtrue_S) { jumpExpression = "true"; continueExpression = "false"; } LinksTo.Add(new Condition() { Text = continueExpression }); LinksTo.Add(new Condition() { Text = jumpExpression }); }
public bool RemoveNode(Node node) { return(LinksTo.Remove(node)); }
public bool ContainsNode(Node node) { return(LinksTo.Contains(node)); }
// POST: api/LinksTo public int PostLinksTo([FromBody] LinksTo lt) { return(lt.InsertLinksTo()); }
// POST: api/LinksTo public int Post([FromBody] LinksTo[] LT) { LinksTo l = new LinksTo(); return(l.InsertLinksTo(LT)); }
public int UpdateLinksBranch([FromBody] LinksTo[] t) { LinksTo lt = new LinksTo(); return(lt.UpdateLinksBranch(t)); }
public List <LinksTo> getLinks(string branchCode) { LinksTo lt = new LinksTo(); return(lt.GetLinks(branchCode)); }