Imports Newtonsoft.Json Public Class PaintingObjectLayering ' Private ReadOnly _PaintingObject As PaintingObject Public ReadOnly Property PaintingObject As PaintingObject Get Return _PaintingObject End Get End Property ''' ''' Get the current object list from the painting object. ''' ''' Returns the current object list from the painting object. Public ReadOnly Property ObjectList As PaintingObjectList Get Return PaintingObject.Parent.PaintingObjects End Get End Property ''' ''' Create a new instance of object layer managing. ''' ''' Public Sub New(obj As PaintingObject) _PaintingObject = obj End Sub ''' ''' Moves the object by the given number of indicies. ''' ''' The number how many objects it should be moved. Public Sub MoveObject(count As Integer) Dim oldIndex As Integer = ObjectList.IndexOf(PaintingObject) Dim newIndex As Integer = oldIndex + count MoveObjectTo(newIndex) End Sub ''' ''' Moves the object to the new index. ''' ''' Public Sub MoveObjectTo(newIndex As Integer) Dim list As PaintingObjectList = ObjectList 'Check & make index valid If newIndex >= ObjectList.Count Then newIndex = ObjectList.Count - 1 ElseIf newIndex < 0 Then newIndex = 0 End If 'Remove object list.Remove(PaintingObject) 'Insert object at new index list.Insert(newIndex, PaintingObject) 'Order all objects again list.Layering.OrderAll() End Sub ''' ''' Moves the object to the front. ''' Public Sub BringToTop() MoveObjectTo(ObjectList.Count - 1) End Sub ''' ''' Moves the object to the back. ''' Public Sub SendToBack() MoveObjectTo(0) End Sub ''' ''' Moves the object fordward by one ''' Public Sub OneToTop() MoveObject(+1) End Sub ''' ''' Moves the object backward by one ''' Public Sub OneToBack() MoveObject(-1) End Sub End Class