我正在编写dijkstra算法,我不知道如何防止删除document.getElementById ("textWidget") value = "<NewVal>";
$scope.widget.title = "<NewVal>";
上的图形,我在这里放了一点代码。另外,我把图片理解为更好。但是正如你在图片中看到的那样,圆形图片的一部分被删除了,这就是我拖动窗体的原因。
picturebox
我把这段代码放在 private List<Node> listNode = new List<Node>();
private int counter = 0;
private void DrawCircles(int nodeId)
{
Graphics g = picBoard.CreateGraphics();
g.SmoothingMode = SmoothingMode.AntiAlias;
Rectangle rect = new Rectangle(listNode[nodeId].Location.X - 12, listNode[nodeId].Location.Y - 12, 25, 25);
Pen myPen = new Pen(Brushes.Black, 2);
g.FillEllipse((listNode[nodeId].Selected ? listNode[nodeId].SelectedColor
: listNode[nodeId].NormalColor), rect);
g.DrawEllipse(myPen, rect);
TextRenderer.DrawText(g, nodeId.ToString(), new Font("Tahoma", 8),
rect, Color.Black,
TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
g.Dispose();
}
private void picBoard_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Node node = new Node(counter, e.Location);
listNode.Add(node);
DrawCircles(counter);
counter++;
InitializeNodeList();
}
}
方法中
此代码导致不再删除DrawCircle()
上的圆形图形,但此代码存在每次picturebox
在节点之前删除的问题。
doubleClick