TXDrawingControl Class
- Namespace
TXTextControl.Drawing
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WinForms. SDK
- Assembly
TXDrawing.Windows. Forms. dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WinForms. SDK TXDrawing.from the setup.Windows. Forms. dll
- Inherits
- Control
- TXDrawing
Control
- Implements
- INotify
Property Changed
Description
The TXDrawingControl class implements a Windows Forms control with features to draw custom or predefined shapes. It can be added to a document with the TextControl.Drawings property. The TXDrawingControl class is inherited from the System.Windows.Forms.Control class and implements the System.ComponentModel.INotifyPropertyChanged interface. The following describes only the properties, methods and events defined through the TXDrawingControl class. For a list of properties, methods and events inherited from the System.Windows.Forms.Control class and the System.ComponentModel.INotifyPropertyChanged interface see the .NET Framework reference.
Syntax
public class TXDrawingControl : Control, INotifyPropertyChangedPublic Class TXDrawingControl
Inherits Control
Implements INotifyPropertyChangedExamples
The following example creates a TXDrawing Control instance and configures its back color setting for a document workflow.
using TXTextControl.Drawing.TXDrawingControl tXDrawingControl = new();
tXDrawingControl.BackColor = System.Drawing.Color.LightSteelBlue;Dim tXDrawingControl As New TXTextControl.Drawing.TXDrawingControl()
tXDrawingControl.BackColor = System.Drawing.Color.LightSteelBlueMembers
Constructors
| Constructor | Description |
|---|---|
| TXDrawingControl | Initializes a new instance of the TXDrawingControl class. |
Properties
| Property | Description |
|---|---|
| BackColor | Gets or sets the TX Drawing Control's back color. The default value is System.Drawing.Transparent. |
| BorderColor | Gets or sets the TX Drawing Control's border line color. The default value is System.Drawing.SystemColors.WindowText. |
| BorderWidth | Gets or sets the TX Drawing Control's border line width. The value is given in twips. The default value is 0. |
| CanCopy | Informs whether shapes are selected which can be copied to the internal clipboard. |
| CanPaste | Informs whether the internal clipboard contains shapes that can be pasted into the TX Drawing Control. |
| CanRedo | Informs whether an operation can be re-done using the Redo method. |
| CanUndo | Gets a value indicating whether the user can undo the previous operation in the TX Drawing Control. |
| Cursor | Not described in the reference. public Cursor Cursor { get; set; } |
| IsCanvasVisible | Gets a value whether the TX Drawing Control is interpreted as canvas or not. The control is not interpreted as canvas if it contains only one shape, the shape's CanFitToCanvas property is set to false, its AutoSize property is set to true and the control's BorderWidth property is 0. If the property's value is false the control can be thought of as a representation of the containing shape where bounds changes of the control lead to considering changes of the shape and vise versa. |
| Selection | Gets an object of type Drawing.Selection that represents the current selected shapes inside the TX Drawing Control. |
| Shapes | Gets an object of type ShapeCollection that represents those shapes which are displayed inside the TX Drawing Control. |
| ZoomFactor | Gets or sets the zoom factor, in percent, for the TX Drawing Control. When the value is changed both all drawn shapes and the control itself are resized considering to the specified zoom factor. To change the property value the control's Dock property has been set to DockStyle.None. Otherwise an exception is thrown. The default value is 100. |
Methods
| Method | Description |
|---|---|
| ClearUndo | Clears the undo buffer of the TX Drawing Control. |
| Copy | Copies the current selected shapes of the TX Drawing Control to the Clipboard. |
| Cut | Moves the current selected shapes of the TX Drawing Control to the Clipboard. |
| FormatShapesDialog | Opens a dialog to format selected shapes. |
| GetSVG | Not described in the reference. public string GetSVG(Size size, bool showHandles); |
| Load | Loads shapes data into the TX Drawing Control from a specified object of type System.IO.Stream. |
| Paste | Pastes the content of the clipboard into the TX Drawing Control |
| PrintPaint | Renders the displayed shapes on the specified System.Drawing.Graphics object. |
| Redo | Redoes the last TX Drawing Control operation. |
| Save | Saves the shapes data to the given object of type System.IO.Stream. |
| SaveImage | Saves the displayed shapes as an image. |
| SelectAll | Selects all shapes in the TX Drawing Control. |
| SetCanvasSize | Not described in the reference. public void SetCanvasSize(double dNewWidth, double dNewHeight); |
| SizeToContent | If any changes of the the displayed shapes' visible bounds require an adaption of the TX Drawing Control bounds, the size and/or location of the control is expanded respectively decreased by the considering value of the considering shape's side(s). The method returns an array of doubles which represent the effected alteration for each control's side (left, top, right, bottom) in Twips. |
| Undo | Undoes the last edit operation in the TX Drawing Control. |
Events
| Event | Description |
|---|---|
| AdaptBounds | Indicates that the visible bounds of the displayed shapes have been changed (by changing the shape's angle, outline width, yellow adjust rectangles or the control's border width) in so far that the control requires an update of its bounds. The event always raises if the visible bounds exceed the control's bounds. If IsCanvasVisible is false, AdaptBounds is also raised if considering changes lead to a decreasing of the visible shape bounds. The event handler receives an argument of type EventArgs containing data related to this event. |
| Changed | Indicates that the number or formatting of the displayed shapes has been changed. The event handler receives an argument of type EventArgs containing data related to this event. |
| PropertyChanged | Not described in the reference. public event PropertyChangedEventHandler PropertyChanged; |
| ShapeAdjusted | Occurs when a shape has been adjusted by using its yellow adjust rectangle. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeClicked | Occurs when a shape has been clicked on. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeCreated | Occurs when a new shape has been created. It occurs, when a shape has been inserted in TX Drawing Control's shapes collection by pasting or using the shape collection's Add method. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeDeleted | Occurs when a shape has been deleted from the TX Drawing Control's shapes collection. It occurs by cutting or using the shape collection's Remove, RemoveAt or Clear method. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeDeselected | Occurs when a shape has been deselected. It occurs by removing a shape from the TXDrawingControl.Selection.Shapes property or, if the number of selected shapes is greater than 0, clicking on a location inside the TX Drawing Control where no shape is located. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeFlipped | Occurs when a shape has been flipped. It occurs by using the shape's Flip property or sizing a shape manually by mouse in so far as the shape is flipped horizontally or vertically. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeFormatChanged | Occurs when shape formatting attributes which cannot be handled with the built-in mouse interface have been changed. The corresponding attributes are the shape's ShapeFill, ShapeOutline are Type properties. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeMoved | Occurs when a shape has been moved with the built-in mouse interface. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeSelected | Occurs when a shape has been selected. It occurs by using the select all method, changing the TXDrawingControl.Selection.Shapes property or selecting shapes manually by the built-in mouse interface . The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ShapeSized | Occurs when a shape has been sized with the built-in mouse interface. The event handler receives an argument of type ShapeEventArgs containing data related to this event. |
| ViewChanged | Occurs when UI manipulations such as shape moving or selection changing have caused the view to change. The event handler receives an argument of type ViewChangedEventArgs containing data related to this event. |