0

我有一个方法可以找到两个对象之间的关系,如果它存在,我想在链接上绘制两个 Lineshapes。我已经开始实现第一个线形,但是每当我测试代码时,这些线都会持续存在。我尝试了多种方法(如您所见),这些方法不会刷新画布以绘制新线。

private void DrawRelationshipLines()
            {
                _canvas = new ShapeContainer {Parent = panelCredentialsVisualisation};
                //These methods below do not redraw the canvas
                _canvas.Shapes.Remove(_tableinfoLine);
                _canvas.Shapes.Clear();
                _canvas.Refresh();
                _canvas.Update();
                //

                List<string> relationships = lvSelectedTableInfoCredentialsIntersection.GetAllRelationships();

                if (relationships.Capacity == 0)
                    return;

                foreach (string context in relationships)
                {
                    Label contextLabelName = GetLabelByName(context);
                    _tableinfoLine = new LineShape
                    {
                        Parent = _canvas,
                        BorderWidth = 2,
                        BorderColor = Color.BlueViolet,
                        StartPoint = new Point(lblselectedTableinfo.Right, lblselectedTableinfo.Top + 10),
                        EndPoint = new Point(contextLabelName.Left, contextLabelName.Top + 10)
                    };
    }

该代码在搜索关系和绘制它们时工作正常,但是我希望能够在绘制不同的关系之前清除画布,这可能吗?

谢谢,如果有人可以提供帮助。

4

1 回答 1

0

移动 _canvas = new ShapeContainer {Parent = panelCredentialsVisualisation}; 该方法之外的方法使这项工作。似乎每次初始化一个新的 ShapeContainer 都会导致问题。

于 2015-08-25T13:55:51.823 回答