Mtf.Controls
                             
                            
                                1.1.54
                            
                        
                    dotnet add package Mtf.Controls --version 1.1.54
NuGet\Install-Package Mtf.Controls -Version 1.1.54
<PackageReference Include="Mtf.Controls" Version="1.1.54" />
<PackageVersion Include="Mtf.Controls" Version="1.1.54" />
<PackageReference Include="Mtf.Controls" />
paket add Mtf.Controls --version 1.1.54
#r "nuget: Mtf.Controls, 1.1.54"
#:package Mtf.Controls@1.1.54
#addin nuget:?package=Mtf.Controls&version=1.1.54
#tool nuget:?package=Mtf.Controls&version=1.1.54
Mtf.Controls Documentation
Overview
This documentation provides guidance on using the Mtf.Controls library in your project, which includes customizable controls like ListView, TreeView, and Panel elements.
To install the Mtf.Controls package, follow these steps:
- Add Package: - Open the terminal in your project directory. 
- Run the following command: - dotnet add package Mtf.Controls
 - This will automatically download and reference the - Mtf.Controlslibrary in your project.
- Include the Namespace: At the top of your code file, include the - Mtf.Controlsnamespace:- using Mtf.Controls;
Dependencies and Licensing
This package uses the following dependencies, each under their respective licenses:
- Mtf.MessageBoxes: Version 6.0.2 (MIT License)
- System.Net.Http: Version 4.3.4 (MIT License)
Each dependency's license applies independently to their respective code. This package complies with their license terms. If you use this package, ensure that you meet the requirements of each dependency's license.
Using Custom Controls
AnsiColoringRichTextBox
The AnsiColoringRichTextBox is a custom control that extends RichTextBox to display text with ANSI color codes, allowing for text formatting with color, bold, and underline styles based on ANSI escape sequences.
Properties
- DisplayAnsiColors (bool):- Specifies whether ANSI color codes should be processed and displayed.
- When set to true, the control will automatically format text with ANSI colors.
 
Usage Example
var ansiTextBox = new AnsiColoringRichTextBox();
ansiTextBox.AppendText("\x1B[0;31mThis is red text\x1B[0;32m and this is green text.");
ansiTextBox.AppendText("Hello, World!", ansiTextBox.ColorToAnsiColoringMode(Color.Blue), ansiTextBox.ColorToAnsiColoringMode(Color.Yellow, true), Enums.AnsiColoringMode.BoldFont);
Controls.Add(ansiTextBox);
ANSI Color Codes Supported
The AnsiColoringRichTextBox recognizes a wide range of ANSI color codes, including:
- Regular Colors: Black, Red, Green, Yellow, Blue, Purple, Cyan, White.
- Bold Colors: Enhanced versions of regular colors.
- High Intensity Colors: Lighter or more intense shades.
- Bold High Intensity Colors: Bolder shades of high intensity colors.
Methods
- ClearColoring: Resets the text formatting to default colors and styles.
Events
- OnTextChanged: Automatically applies ANSI coloring if DisplayAnsiColorsis enabled when the text changes.
PasswordBox Control
The PasswordBox control in Mtf.Controls extends the standard TextBox to provide a secure way to handle password input. Unlike a regular TextBox with PasswordChar, the PasswordBox stores the password as a SecureString and handles input securely, preventing sensitive data from being stored in plain text.
Attributes
- [ToolboxItem(true)]� Ensures that the control is available in the Toolbox.
- [ToolboxBitmap(typeof(PasswordBox), "Resources.PasswordBox.png")]� Associates an icon for the control in the Toolbox.
Constructor
- PasswordBox(): Initializes a new PasswordBoxwith a defaultPasswordChar(*).
Properties
| Property | Type | Description | 
|---|---|---|
| PasswordChar | char | The character to display in place of the actual password characters. Default is *. | 
| UseSystemPasswordChar | bool | If true, the system-defined password character is used. Default isfalse. | 
Methods
- OnKeyPress(KeyPressEventArgs e): Handles key press events to update the SecureString(password) instead of storing characters in plain text. Prevents the actual character from being displayed.
- OnTextChanged(EventArgs e): Clears the SecureStringwhen theTextproperty is cleared.
- OnKeyDown(KeyEventArgs e): Manages additional key events such as backspace or delete to ensure passwordremains consistent with displayed text.
- Dispose(): Overrides Dispose()to securely clear and release theSecureStringwhen the control is disposed of.
SecureString Handling
The PasswordBox uses a SecureString to store the password securely. This ensures that sensitive data isn't held in memory in plain text, reducing the risk of exposure.
Example Usage
using System;
using System.Security;
using System.Windows.Forms;
using Mtf.Controls;
public class LoginForm : Form
{
    private PasswordBox passwordBox;
    public LoginForm()
    {
        passwordBox = new PasswordBox
        {
            Location = new System.Drawing.Point(10, 10),
            Width = 200
        };
        Controls.Add(passwordBox);
    }
    public SecureString GetPassword()
    {
        return passwordBox.Password;  // Use this to retrieve the secure password input
    }
}
In this example, LoginForm creates a PasswordBox control to securely capture a password. The password can be retrieved as a SecureString by calling GetPassword().
ListView Control
MtfListView Class Documentation
The MtfListView class is a custom ListView control that enhances the standard functionality with additional features such as alternating colors, compact view, and integrated thread safe behaviour. It is designed to improve the visual appearance and usability of list views in applications.
Attributes
- ToolboxItem: Indicates that the control is a toolbox item.
- ToolboxBitmap: Provides a bitmap for the control in the toolbox.
Constructor
MtfListView()
Initializes a new instance of the MtfListView class, setting default values for its properties.
Properties
| Property | Type | Description | 
|---|---|---|
| ReadonlyCheckboxes | bool | Indicates if the item checkboxes are readonly. | 
| EnsureLastItemIsVisible | bool | Ensures that the last item is visible. | 
| AlternatingColorEven | Color | Specifies color for even rows. | 
| AlternatingColorOdd | Color | Specifies color for odd rows. | 
| AlternatingPairColorEven | Color | Specifies color for paired even rows. | 
| AlternatingPairColorOdd | Color | Specifies color for paired odd rows. | 
| SameItemsColorEven | Color | Specifies color for same even rows. | 
| SameItemsColorOdd | Color | Specifies color for same odd rows. | 
| CompactView | bool | If true, identical items are displayed only once. | 
| AlternatingColorsAreInUse | bool | Enables/disables alternating colors. | 
| FirstItemIsGray | bool | If true, the first item will be gray. | 
| AlwaysDifferentColumnIndexes | ReadOnlyCollection<int> | Specifies columns to ignore for compact view creation, defaulting to an empty list. | 
Example Usage
[ToolboxItem(true)]
[ToolboxBitmap(typeof(MtfListView), "Resources.MtfListView.png")]
public class MtfListView : ListView
{
    private readonly List<int> alwaysDifferentColumnIndexes = new List<int>();
    public MtfListView()
    {
        EnsureLastItemIsVisible = false;
        AlternatingColorsAreInUse = true;
        FirstItemIsGray = false;
        OwnerDraw = AlternatingColorsAreInUse;
        SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.EnableNotifyMessage | ControlStyles.UserPaint, true);
        UpdateStyles();
        View = View.Details;
        FullRowSelect = true;
        AlternatingColorEven = Color.LightBlue;
        AlternatingColorOdd = BackColor;
        AlternatingPairColorEven = Color.LightSeaGreen;
        AlternatingPairColorOdd = Color.CadetBlue;
        SameItemsColorEven = Color.DarkOrange;
        SameItemsColorOdd = Color.LightSalmon;
        CompactView = false;
    }
    // Properties
    [Browsable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    [Description("Indicates that the item checkboxes are readonly or not.")]
    public bool ReadonlyCheckboxes { get; set; }
    [Browsable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    [Description("Ensures that the last item is visible.")]
    public bool EnsureLastItemIsVisible { get; set; }
    // Additional properties...
}
FileBrowserView class
Properties
| Property | Type | Description | 
|---|---|---|
| WorkingDirectory | string | The current working directory. | 
| SelectedElements | IEnumerable<FileSystemInfo> | Gets the seleted files and folders. | 
MtfTreeView Class
The MtfTreeView class extends TreeView with features like custom line styles, multiple selection support, custom checkbox appearance, and tick color.
Constants
| Constant | Type | Description | 
|---|---|---|
| CheckboxSize | short | Specifies the size of the checkbox. | 
| BigShift | byte | Specifies the large shift value. | 
| SmallShift | byte | Specifies the small shift value. | 
| MinShift | byte | Specifies the minimum shift value. | 
Properties
| Property | Type | Description | 
|---|---|---|
| StateImageOrCheckBoxOnLeft | bool | If true, displays the state image on the left side. | 
| LineStyle | DashStyle | Sets the style of lines between nodes. | 
| ShowPlusMinusOnRootNodes | bool | If true, displays a plus-minus icon on root nodes. | 
| DrawDefaultImageToNodes | bool | Uses ImageIndexof ListView to set node images. | 
| TickColor | Color | Sets the color of checkbox ticks. | 
| CheckBoxBackground | Color | Sets the background color for checkboxes. | 
| MultiSelect | bool | Enables/disables multiple node selection. | 
| SelectedNodes | TreeNode[] | Array of currently selected nodes. | 
Usage Example
var treeView = new MtfTreeView
{
    MultiSelect = true,
    TickColor = Color.Green,
    LineStyle = DashStyle.Dot
};
SourceCodeViewerRichTextBox
SourceCodeViewerRichTextBox is a custom control derived from the RichTextBox class. It provides functionality for displaying source code with customizable syntax coloring and improved control over text rendering and updates.
Features
- Syntax Highlighting: Supports multiple coloring methods, such as C++/CLI, C#, Java, Object Pascal, Visual Basic, and Visual C++.
- Thread-Safe Text Manipulation: Safe methods for appending and setting text in multithreaded applications.
- Efficient Updates: Supports batch updates without flickering, with options to begin and end updates manually.
- Customizable Tab Size: Dynamically calculates tab width based on font size.
- Optional Auto-Scrolling: Ensures the last line of text is visible on updates if configured.
Constructors
SourceCodeViewerRichTextBox()
Initializes the control, setting default options for:
- Disabling URL detection
- Accepting tabs
- No initial coloring
Properties
ColoringMethod (ColoringMethod)
Defines the syntax coloring mode.
- Type: ColoringMethod
- Default: ColoringMethod.No_Coloring
- Usage: Set to any of the supported programming languages to enable syntax highlighting for that language.
ScroolToLastLine (bool)
Determines whether the control automatically scrolls to the last line on each update.
- Type: bool
- Default: false
- Description: Set to trueto enable auto-scrolling to the last line.
Methods
GetTextThreadSafe()
Returns the control�s text safely in a multithreaded environment.
SetTextThreadSafe(string text)
Sets the control�s text safely in a multithreaded environment.
AppendTextThreadSafe(string text, Color? textColor = null)
Appends text to the control safely in a multithreaded environment, with an optional text color.
BeginUpdate()
Disables control updates to prevent flickering during batch operations.
EndUpdate()
Re-enables control updates after a batch operation and redraws the control.
StartUpdate(ref int scrollTo, ref int pos, ref int len)
Starts a safe update process by caching the current scroll and cursor positions.
StopUpdate(int scrollTo, int pos, int len)
Ends the update process, restoring the control's scroll and cursor positions.
ClearColoring()
Resets all text colors to the default font color.
ClearBackgroundColoring()
Resets the background color of all text to the control�s background color.
ApplyColoring()
Applies syntax coloring based on the configured ColoringMethod.
Supported Coloring Methods
- No_Coloring - Disables all syntax highlighting.
- CPP_CLI - Syntax highlighting for C++/CLI.
- C_Sharp - Syntax highlighting for C#.
- Java - Syntax highlighting for Java.
- Object_Pascal - Syntax highlighting for Object Pascal.
- Visual_Basic - Syntax highlighting for Visual Basic.
- Visual_CPP - Syntax highlighting for Visual C++.
Example Usage
var codeViewer = new SourceCodeViewerRichTextBox
{
    ColoringMethod = ColoringMethod.C_Sharp,
    ScroolToLastLine = true
};
codeViewer.SetTextThreadSafe("public class HelloWorld { }");
MovablePanel
MovablePanel is a transparent panel that can be moved by dragging it with the mouse. It is useful in scenarios where dynamic relocation of a window or panel is needed. The following attributes and events are available:
Attributes
- [ToolboxItem(true)]� Ensures the control is available in the Toolbox.
- [ToolboxBitmap(typeof(MovablePanel), "Resources.MovablePanel.bmp")]� Associates a custom icon for the panel in the Toolbox.
Properties
- CanMove(bool): Determines if the panel is movable. Default is- true.
Methods
- OnMouseDown(MouseEventArgs e): Initiates the panel's movement when the mouse button is pressed, if- CanMoveis set to- true.
- OnMouseUp(MouseEventArgs e): Stops moving the panel when the mouse button is released.
- OnMouseMove(MouseEventArgs e): Updates the panel's position as the mouse is moved, as long as movement is allowed.
Usage Example
var panel = new MovablePanel
{
    CanMove = true
};
MovableSizablePanel
MovableSizablePanel extends MovablePanel, adding the capability to resize the panel in the East (right), South (bottom), and South-East (bottom-right) directions.
Attributes
- [Browsable(true)],- [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)],- [Description("Can change the size of the panel")]� Allows the- CanSizeproperty to be visible and modifiable in the designer.
Properties
- CanSize(bool): Determines if the panel is resizable. Default is- true.
Methods
- InitializeResizeHandles(): Creates resize handles on the panel's right, bottom, and bottom-right sides.
- CheckSize(): Ensures the panel does not shrink below a predefined minimum size (- Constants.MinSize).
- PbEast_MouseMove,- PbSouth_MouseMove,- PbSouthEast_MouseMove: Logic for resizing in specific directions.
Usage Example
var sizablePanel = new MovableSizablePanel
{
    CanMove = true,
    CanSize = true
};
MtfPictureBox
MtfPictureBox is a custom PictureBox control that supports resizable and repositionable inner controls during resizing. It is particularly useful for displaying elements with relative positions that need to adapt dynamically to changes in size.
Attributes
- [ToolboxItem(true)]� Ensures the control is available in the Toolbox.
- [ToolboxBitmap(typeof(MtfPictureBox), "Resources.MtfPictureBox.png")]� Associates a custom icon for the PictureBox in the Toolbox.
Properties
- RepositioningAndResizingControlsOnResize(bool): Specifies whether controls added to the PictureBox should resize and reposition automatically.
- OriginalSize(Size): Stores the original size for scaling calculations.
Methods
- OnControlAdded(ControlEventArgs e): Stores the position and size of a new control added to the PictureBox.
- OnControlRemoved(ControlEventArgs e): Deletes position and size information of a control when it�s removed.
- RefreshLocation(Control control): Updates the position of a given control.
- RefreshSize(Control control): Updates the size of a given control.
- RelocateControls(): Relocates all controls based on the new scaling ratio.
Usage Example
var pictureBox = new MtfPictureBox
{
    RepositioningAndResizingControlsOnResize = true,
    OriginalSize = new Size(800, 600)
};
Constants
This project uses a Constants class to store shared values such as:
- MinSize(Size): Minimum size allowed for resizable panels, ensuring they do not shrink below this threshold.
- Border(int): Defines the size of the resize borders on the- MovableSizablePanel.
Ensure the Constants class is defined appropriately for the panels to function as expected.
Notes
- MovablePaneland- MovableSizablePanelrely on the- Constantsclass for settings like- MinSizeand- Border.
- MtfPictureBoxshould be initialized with the- OriginalSizeproperty set to the initial dimensions, so it can calculate scaling accurately.
- The methods handling resizing (PbEast_MouseMove,PbSouth_MouseMove, andPbSouthEast_MouseMove) require careful handling of mouse events to avoid conflicts with other mouse-based controls on the form.
Important Notes
- Ensure your project has .NET dependencies to support Mtf.Controls.
- For more details on using specific methods or properties, refer to the Mtf.ControlsGitHub Repository.
- If you have problems with the Visual Studio Toolbox, remove all files from C:\Users\morte\AppData\Local\Microsoft\VisualStudio[vs_version_]\ComponentModelCache. After a rebuild, the toolbox should include these controls.
Feel free to reach out if further clarification is needed!
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net9.0-windows7.0 is compatible. net10.0-windows was computed. | 
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 is compatible. | 
- 
                                                    .NETFramework 4.6.2- Mtf.MessageBoxes (>= 6.0.13)
- Mtf.Windows.Forms.Extensions (>= 1.0.16)
- System.Net.Http (>= 4.3.4)
 
- 
                                                    .NETFramework 4.8.1- Mtf.MessageBoxes (>= 6.0.13)
- Mtf.Windows.Forms.Extensions (>= 1.0.16)
- System.Net.Http (>= 4.3.4)
 
- 
                                                    net8.0-windows7.0- Mtf.MessageBoxes (>= 6.0.13)
- Mtf.Windows.Forms.Extensions (>= 1.0.16)
- System.Net.Http (>= 4.3.4)
 
- 
                                                    net9.0-windows7.0- Mtf.MessageBoxes (>= 6.0.13)
- Mtf.Windows.Forms.Extensions (>= 1.0.16)
- System.Net.Http (>= 4.3.4)
 
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Mtf.Controls:
| Package | Downloads | 
|---|---|
| Mtf.Controls.Video Custom Windows Forms Controls. The library includes various controls, such as: - MortoGraphyWindow (Show JPEG and MJPEG streams) | 
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | 
|---|---|---|
| 1.1.54 | 117 | 8/15/2025 | 
| 1.1.50 | 170 | 6/6/2025 | 
| 1.1.47 | 206 | 5/26/2025 | 
| 1.1.20 | 179 | 5/22/2025 | 
| 1.1.15 | 218 | 5/20/2025 | 
| 1.1.14 | 208 | 5/20/2025 | 
| 1.1.13 | 193 | 5/18/2025 | 
| 1.1.12 | 186 | 5/17/2025 | 
| 1.1.11 | 277 | 5/14/2025 | 
| 1.1.9 | 290 | 5/13/2025 | 
| 1.1.2 | 203 | 5/8/2025 | 
| 1.1.1 | 201 | 5/8/2025 | 
| 1.0.93 | 195 | 4/11/2025 | 
| 1.0.89 | 207 | 4/9/2025 | 
| 1.0.75 | 174 | 4/6/2025 | 
| 1.0.70 | 226 | 4/3/2025 | 
| 1.0.65 | 225 | 4/2/2025 | 
| 1.0.56 | 189 | 3/27/2025 | 
| 1.0.48 | 182 | 3/11/2025 | 
| 1.0.45 | 222 | 3/9/2025 | 
| 1.0.44 | 206 | 3/9/2025 | 
| 1.0.15 | 173 | 11/28/2024 | 
| 1.0.14 | 165 | 11/14/2024 | 
| 1.0.13 | 145 | 11/14/2024 | 
| 1.0.4 | 164 | 11/12/2024 | 
| 1.0.3 | 159 | 11/12/2024 | 
| 1.0.2 | 160 | 11/12/2024 | 
| 1.0.1 | 142 | 10/30/2024 |