SelElementList Method

Build 1501 on 14/Nov/2017  This topic last edited on: 23/Mar/2016, at 12:16

Description

Selected elements interface.

Syntax

Dim list = Page.SelElementList()

Remarks

Returns list of selection on page.

Example

Private Sub DoTxtToPath(ByVal iMode As Integer, ByVal sDist As Integer, ByVal bSpread As Boolean, ByVal bDelete As Boolean)

    Dim list = Page.SelElementList()

 

    If list.Count <> 2 Then

      MsgBox("To fit text to path, select a single path object and a single frame!", vbCritical, cAppName)

      Exit Sub

    End If

 

    ' find path and frame

    Dim frameId = 0, frameIndex

    Dim curveId = 0, curveIndex

    Dim err = False

    If list(0).Kind <> POK.oFrame Then ' the first one is path

      If list(1).Kind = POK.oFrame Then ' the second one is frame

        frameId = list(1).Id

        frameIndex = 1

        curveId = list(0).Id

        curveIndex = 0

      Else

        err = True

      End If

    Else

      If list(1).Kind <> POK.oFrame Then ' the second one is path

        If list(0).Kind = POK.oFrame Then ' the first one is frame

          frameId = list(0).Id

          frameIndex = 0

          curveId = list(1).Id

          curveIndex = 1

        Else

          err = True

        End If

      End If

    End If

 

    If err Then

      MsgBox("To fit text to path, one object must be path, and other must be frame!", vbCritical, cAppName)

      Exit Sub

    End If

 

    'show clessidra

    Dim bc = New WinUI.Controls.BusyCursor

 

    'stop page redraw 

    FredApp.DisableDraw = True

 

    'select text frame and convert it to curves: all objects are selected 

    Page.ObjSelectId(frameId, False)

    Page.TxtEdit(False)

    Dim objTS = TedApp.ActiveTxtDispatcher.GetTextStatus()

    Dim strTextColor = "K"

    Dim iTextGray = 100

    If objTS.HasColor Then

      strTextColor = objTS.Color      'displays the current color  

    End If

    If objTS.HasGray Then

      iTextGray = objTS.Gray      'displays the current color  

    End If

    objTS = Nothing

    Fred.SelNormal()

    Page.TxtToSgm(-1)

 

    'get the y and height 

    Dim yy = Page.GetSelectionY

    Dim hh = Page.GetSelectionHeight

    Dim ww = Page.GetSelectionWidth

 

    'store objects in letters array 

    Dim letters = Page.SelElementList

    Dim elem As ElementProp

 

    Dim dist = 0

    Dim dLett = 0

    If bSpread Then ' if text should spread horizontally

      Page.ObjSelectId(curveId, False)

      elem = Page.SelElement()

      elem.StoreShape()

      Dim stp = 1000

      While elem.WalkShape(dist)

        dist = dist + 1000 ' move further 

      End While

      Dim iCurveWidth = dist

      dLett = Int((iCurveWidth - ww) / letters.Count)

      elem = Nothing

    End If

 

    'select and delete the text frame

    If (bDelete) Then

      Page.ObjSelectId(frameId, False)

      Page.EditDelete()

    End If

 

    'select the path and initiate walk 

    Page.ObjSelectId(curveId, False)

    elem = Page.SelElement()

    elem.StoreShape()

 

    'loop on all objects stored in the array 

    dist = 0

    Dim distx = 0

    Dim prevx = 0

    For i = 0 To letters.Count - 1

      Dim objId = letters(i).Id

      Dim x = letters(i).X

      Dim y = letters(i).Y

      Dim w = letters(i).W

      Dim h = letters(i).H

 

      'when not on the first object, calculate the distance as  

      '... difference between current x and previous x 

      If i > 0 Then

        distx = Math.Abs(x - prevx) + dLett

      End If

      dist = dist + distx

      prevx = x

      'proceed on the shape 

      elem.WalkShape(dist)

      'select the lettr 

      Page.ObjSelectId(objId, False)

      'calculate the rotation 

 

      Dim rot = elem.WalkA / 10

      'move letter on the shape (using absolute co-ordinates of group to make a distance from the shape

      If iMode = 0 Then

        Page.ObjMove(elem.WalkX - x, elem.WalkY - yy - hh - Units.ToVal(sDist))

      ElseIf iMode = 1 Then

        Page.ObjMove(elem.WalkX - x, elem.WalkY - yy + Units.ToVal(sDist))

      End If

      'rotate letter, using the shape point as rotation centre 

      Page.ObjSetAnglePoint(rot, elem.WalkX, elem.WalkY)

    Next

 

    'enable draw, stop clessidra, redraw 

    Page.ViewRedraw()

    Page.ObjSelectId(letters(0).Id, False)

    For i = 1 To letters.Count - 1

      Page.ObjSelectId(letters(i).Id, True)

    Next

 

    'Page.ObjMerge(0)

    Page.ObjSetPaperColor(strTextColor, iTextGray)

    Page.ObjSetBorderWeight(0)

 

    bc.Dispose()

    FredApp.DisableDraw = False

  End Sub

Context

Page designer