|
|
|
|
|
- Overview
- Manipulating the Diagram Editor control programmatically
- Overview
- Export a diagram as an image
- Managing shape libraries
- Programming tips
- How do I retrieve selection characteristics from a Diagram Editor control?
- Using the Note property of the different shapes
- How do you know the type of a shape?
- WEBDEV specific features
- Programming the Diagram Editor control in WEBDEV
- Example: Getting and modifying the selected shape
- Example: Getting the index of a shape added in a Diagram Editor control
- Associated WLanguage properties
- Properties specific to Diagram Editor controls
Manipulating Diagram Editor controls programmatically
WINDEV and WEBDEV allow you to programmatically manipulate Diagram Editor controls. To do so, use the control variable in the code. Diagram Editor controls can also be manipulated programmatically using Diagram functions. This help page explains how to programmatically manipulate Diagram Editor controls. Manipulating the Diagram Editor control programmatically Overview Diagram Editor controls allow you to programmatically create and display diagrams. To do so, WLanguage provides you with: Export a diagram as an image To export a diagram as an image, you can use DiagramToImage. This function exports the diagram as a variable of type Image. Then, simply call one of the following functions to get the image of the diagram in the desired format:
Managing shape libraries Multiple shape libraries are included with the Diagram Editor control. You can create your own shape library. A shape library is a diagram loaded as a library. This diagram can be created: - via the Diagram Editor control:
- Create a diagram.
- Import the images that correspond to the desired shapes.
- Save the diagram as a ".wddiag" file.
- programmatically:
- Create a variable of type Diagram. This variable will hold the shape library.
- Create the different custom shapes.
- Add the shapes to the "Library" diagram.
- Save the "Library" diagram as a ".wddiag" file.
Once the "Library" diagram has been created: - Load the diagram as a library (DiagramLoadLibrary).
- Add the library to the array of libraries of the final diagram.
Example of a library created programmatically: sFichier is string = fTempDir() + [ fSep ] + "bibli_perso.wddiag"
BibliTemp is Diagram
D1 is diagOval
D1.Width = 50
D1.Height = 50
D1.Background.Color = DarkRed
Add(BibliTemp.Shape, D1)
D2 is diagOval
D2.Width = 50
D2.Height = 70
D2.Background.Color = DarkGreen
Add(BibliTemp.Shape, D2)
DiagramSave(BibliTemp, sFichier)
MaBibli is diagLibrary
DiagramLoadLibrary(MaBibli, sFichier)
MaBibli.Name = "Perso"
Add(EDIAG_Diagramme.Bibliothèque, MaBibli)
ToastDisplay("La bibliothèque personnelle a été ajoutée dans la liste.")
Note: If you wish to use only your own libraries, remember to delete the default libraries proposed by PC SOFT.. To do so, use ArrayDeleteAll on the array of libraries of the diagram. How do I retrieve selection characteristics from a Diagram Editor control? You can retrieve the characteristics of a selection in a Diagram Editor control using the Selection property. If the selection includes more than one shape, you can loop through the array of shapes. Example:
MaSélection is diagSelection <- EDIAG_MonDiagramme.Sélection
IF MaSélection.Shape.Count > 0 THEN
FOR EACH stForme OF MaSélection.Shape
LIB_INFO_SELECTION = "Sélection de " + stForme.Nom +
" [ " + stForme.X + ", " + stForme.Y + " - " + stForme.Largeur +
"x" + stForme.Hauteur + " ]"
END
ELSE
LIB_INFO_SELECTION = "Cliquez sur une forme dans le diagramme pour connaître la sélection"
END
Using the Note property of the different shapes diagShape variables ( diagOval, diagRectangle, etc.) have a Note property. This property can be used to record any type of information: shape number, shape type, business information, etc. If the diagram is saved as a "wddiag" file, the information specified using the Note property is also saved.. This information can then be read and processed when looping through the different shapes of a diagram. How do you know the type of a shape? To determine the type of a shape, simply assign the shape to the different available variables. Example: FOR EACH shape OF DIAGEDT_MyDiagram.Shape ImageShape is diagImage <- shape IF ImageShape <> Null THEN // The shape is an image END END Associated WLanguage properties Properties specific to Diagram Editor controls The following properties are used to manage the characteristics of a Diagram Editor control programmatically: | | EditMode | The EditMode property gets and sets the editing mode of the Diagram Editor control: selection or freehand drawing. | GridlinesVisible | The GridlinesVisible property is used to: - Determine whether or not gridlines are visible in a control.
- Show or hide gridlines in a control.
| Library | The Library property allows you to handle the different preset libraries associated with a Diagram Editor control. This property accesses the array of libraries of the Diagram Editor control. | LibraryPanelVisible | The property LibraryPanelVisible property: - determine if the "Library" panel is displayed in a Diagram Editor control.
- show or hide the "Library" panel in a Diagram Editor control.
| ModifierPanelVisible | The property ModifierVisiblePanel property allows you to: - determine if the "Modifier" panel is displayed in a Diagram Editor control.
- show or hide the "Modifier" panel in a Diagram Editor control.
| PageBorderVisible | The property VisiblePageFrame property allows you to:- determine if the page borders are displayed in a Diagram Editor control.
- show or hide the page borders in a Diagram Editor control.
| Selection | The property Selection property displays the characteristics of the selection (or cursor): - in a Word Processing control.
Note: This selection is located in the part being edited (body, header or footer). - in a Spreadsheet control.
- in an HTML Editor control.
- in a Diagram Editor control.
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|