How to set font size and style for each shape file


Author
Message
Kirk Kanjian
Kirk Kanjian
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Hi
I am using Nevron diagram and trying to set Font size and style for each shape.
But it is taking the last shape style for the entire renderings.
Please let me know how to set font styles for each shape

Code used for setting font style for each shape:

For Each s As NShape In document.Descendants(NFilters.Shape2D, -1)
      If Not IsNothing(s.Tag) Then
      Dim roomInfo As RoomInfo = s.Tag
      Dim roomNumber As String = roomInfo.RoomNumber
      Dim customFontSize as Single = roomInfo.CustomFontSize

      Dim textSize As Single
      If Not String.IsNullOrEmpty(customFontSize ) Then
        textSize = Convert.ToSingle(customFontSize )
        Dim textStyle As New NTextStyle
        textStyle = s.ComposeTextStyle()
        textStyle.FontStyle = New NFontStyle("Arial", textSize)
         NStyle.SetTextStyle(s, textStyle)
       End If
    End If
   Next


Replies
Kirk Kanjian
Kirk Kanjian
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)
Group: Forum Members
Posts: 8, Visits: 18
Hi,

I implemented the code and cloned the shapefile style. But still i am seeing no difference in the text size for each shape file.
Please let me know what i am missing.


For Each s As NShape In document.Descendants(NFilters.Shape2D, -1)
  If Not IsNothing(s.Tag) Then
    Dim roomInfo As RoomInfo = s.Tag
    Dim roomNumber As String = roomInfo.RoomNumber
    Dim customFontSize as Single = roomInfo.CustomFontSize
    Dim textSize As Single

    If Not String.IsNullOrEmpty(customFontSize) Then
     textSize = Convert.ToSingle(customFontSize)
     Dim textStyle As NTextStyle = CType(s.ComposeTextStyle().Clone(), NTextStyle)
     textStyle.FontStyle = New NFontStyle("Arial", textSize)
     NStyle.SetTextStyle(s, textStyle)
    End If
  End If
Next


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.3K
Hi Kirk,

A better solution would be to create a custom NShapeCreatedListener and then override its OnPolygonLabelCreated method. This method is called every time a label of a polygon (room in your case) is created. You can use it to modify the style of the created map label.

Please take a look at the following NOV Diagram web example:
http://examplesaspnetdiagram.nevron.com/Frames/NExampleFrame.aspx?ExampleUrl=Examples%2fMaps%2fNWorldPopulationUC.ascx

You will find the custom implementation of the NShapeCreatedListener at the end of the code in the "Source Code" tab.

We hope this helps. Let us know if you have any questions.


Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search