如何在c#中更新/重新绘制Microsoft Powerpacks画布?

本文关键字:绘制 Microsoft Powerpacks 画布 新绘制 更新 | 更新日期: 2023-09-27 18:09:55

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

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)
                    };
    }

在搜索关系和绘制它们的代码工作得很好,但是我想能够在绘制不同的关系之前清除画布,这是可能的吗?

如果有人能帮忙的话,谢谢。

如何在c#中更新/重新绘制Microsoft Powerpacks画布?

Moving _canvas = new ShapeContainer {Parent = panelCredentialsVisualisation};外部的方法使这个工作。似乎每次初始化一个新的ShapeContainer都会引起问题。