由于不会c#,就把代码转换成vb.net。在线转的。但转化后总出问题。以下是一个类代码。请大家帮我看看。- class SR : SelectionReactor
- {
- ObjectIdCollection selected;
- ObjectId spaceId;
- public SR(ObjectIdCollection s, ObjectId id)
- {
- spaceId = id;
- selected = s;
- }
- public override bool Selected(DrawableDesc pDrawableDesc)
- {
- DrawableDesc pDesc = pDrawableDesc;
- if (pDesc.Parent != null)
- {
- // we walk up the GS node path to the root container primitive
- // to avoid e.g. selection of individual lines in a dimension
- while (((DrawableDesc)pDesc.Parent).Parent != null)
- pDesc = (DrawableDesc)pDesc.Parent;
- if (pDesc.PersistId != IntPtr.Zero && ((DrawableDesc)pDesc.Parent).PersistId == spaceId.OldIdPtr)
- {
- pDesc.MarkedToSkip = true; // regen abort for selected drawable, to avoid duplicates
- selected.Add(new ObjectId(pDesc.PersistId));
- }
- return true;
- }
- return false;
- }
- // this more informative callback may be used to implement subentities selection
- public override SelectionReactorResult Selected(PathNode pthNode, Teigha.GraphicsInterface.Viewport viewInfo)
- {
- return SelectionReactorResult.NotImplemented;
- }
- };
复制代码 转成vb.net的代码- Class SR
- Inherits SelectionReactor
- Private <font color="#ff0000">Shadows</font> selected As ObjectIdCollection
- Private spaceId As ObjectId
- Public Sub New(s As ObjectIdCollection, id As ObjectId)
- spaceId = id
- Selected = s
- End Sub
- 'Public Overrides Function Selected(pDrawableDesc As DrawableDesc) As Boolean
- Public Overloads Function Selected(ByVal pDrawableDesc As DrawableDesc) As Boolean
- Dim pDesc As DrawableDesc = pDrawableDesc
- If pDesc.Parent IsNot Nothing Then
- ' we walk up the GS node path to the root container primitive
- ' to avoid e.g. selection of individual lines in a dimension
- While DirectCast(pDesc.Parent, DrawableDesc).Parent IsNot Nothing
- pDesc = DirectCast(pDesc.Parent, DrawableDesc)
- End While
- If pDesc.PersistId <> IntPtr.Zero AndAlso DirectCast(pDesc.Parent, DrawableDesc).PersistId = spaceId.OldIdPtr Then
- pDesc.MarkedToSkip = True
- ' regen abort for selected drawable, to avoid duplicates
- selectedc.Add(New ObjectId(pDesc.PersistId))
- End If
- Return True
- End If
- Return False
- End Function
- ' this more informative callback may be used to implement subentities selection
- Public Overrides Function Selected(ByVal pthNode As PathNode, ByVal viewInfo As Teigha.GraphicsInterface.Viewport) As SelectionReactorResult
- Return SelectionReactorResult.NotImplemented
- End Function
- End Class
shodows本来是没有的。建议我加。我加上还是不行。提示如下
错误 1 “Selected”已声明为此 class 中的“Private Shadows selected As Teigha.DatabaseServices.ObjectIdCollection”。 H:\source code\dmdraw\dmdraw\SelectionReactor.vb 114 35 dmdraw
错误 2 “Selected”已声明为此 class 中的“Private Shadows selected As Teigha.DatabaseServices.ObjectIdCollection”。 H:\source code\dmdraw\dmdraw\SelectionReactor.vb 132 35 dmdraw
有哪位熟悉两种代码的吗。应该怎么处理呢。
|