Skip to footer content
.NET HELP

NativeUI C# (How It Works For Developers)

NativeUI is an essential framework for C# developers in the Grand Theft Auto (GTA) modding community. It simplifies the creation of an easy, painless nested menu system and custom banners, making it a favorite among GTA modders for its user-friendly approach and adaptability to various screen resolutions. NativeUI MOD is designed to create fast, Rockstar-like menus, echoing the style and responsiveness of nested menus found in GTA games. In this tutorial, we'll understand what NativeUI is and how we can integrate IronPDF with it.

Basics of NativeUI

NativeUI excels in creating nested menus easily, a boon for modders who wish to build sophisticated interfaces without having complex code for event-based callbacks and item descriptions. It's also adaptable to various screen resolutions, ensuring that menus are visually appealing across different displays. One of NativeUI's strengths is its painless nested menu system, allowing developers to create complex menu structures with custom instructional buttons effortlessly. For beginners, NativeUI's documentation on its wiki is a valuable resource, providing step-by-step guidance in menu creation.

Setting Up NativeUI in Visual Studio

Initial setup in Visual Studio involves downloading the NativeUI library and incorporating the .dll file into your mod project. The NativeUI library is a published package available through popular C# repositories, making it easily accessible for integration into your project. The installation is straightforward. When setting up NativeUI, ensure you have compatible versions between your development environment and the NativeUI library for optimal performance.

NativeUI C# (How It Works For Developers): Figure 1 - NativeUI

Creating Your First Menu

Creating your first menu with NativeUI is an exciting step. The library's design caters to ease of use, allowing you to add item descriptions, simple buttons, and even custom banners without much hassle. For those starting, it's advisable to begin with a basic script and gradually add more complex features as you become more comfortable with the framework. Here’s a simple example of creating a basic menu with its own textures:

using System;
using System.Windows.Forms;
using NativeUI;

public class YourFirstMenu : Script
{
    private MenuPool _menuPool;
    private UIMenu mainMenu;

    public YourFirstMenu()
    {
        _menuPool = new MenuPool();
        mainMenu = new UIMenu("NativeUI", "SELECT AN OPTION");
        _menuPool.Add(mainMenu);
        AddMenuItems(mainMenu);
        _menuPool.RefreshIndex();

        // Subscribe to event handlers for updating and input control
        Tick += OnTick;
        KeyDown += OnKeyDown;
    }

    private void AddMenuItems(UIMenu menu)
    {
        var item1 = new UIMenuItem("Item 1", "Description for Item 1");
        menu.AddItem(item1);

        // Set up an event for when an item is selected
        menu.OnItemSelect += (sender, item, index) =>
        {
            if (item == item1)
            {
                // Do something when Item 1 is selected
            }
        };
    }

    private void OnTick(object sender, EventArgs e)
    {
        // Process the pool to handle drawing and interactions
        _menuPool.ProcessMenus();
    }

    private void OnKeyDown(object sender, KeyEventArgs e)
    {
        // Toggle the visibility of the menu with F5 key
        if (e.KeyCode == Keys.F5 && !_menuPool.IsAnyMenuOpen())
            mainMenu.Visible = !mainMenu.Visible;
    }
}
using System;
using System.Windows.Forms;
using NativeUI;

public class YourFirstMenu : Script
{
    private MenuPool _menuPool;
    private UIMenu mainMenu;

    public YourFirstMenu()
    {
        _menuPool = new MenuPool();
        mainMenu = new UIMenu("NativeUI", "SELECT AN OPTION");
        _menuPool.Add(mainMenu);
        AddMenuItems(mainMenu);
        _menuPool.RefreshIndex();

        // Subscribe to event handlers for updating and input control
        Tick += OnTick;
        KeyDown += OnKeyDown;
    }

    private void AddMenuItems(UIMenu menu)
    {
        var item1 = new UIMenuItem("Item 1", "Description for Item 1");
        menu.AddItem(item1);

        // Set up an event for when an item is selected
        menu.OnItemSelect += (sender, item, index) =>
        {
            if (item == item1)
            {
                // Do something when Item 1 is selected
            }
        };
    }

    private void OnTick(object sender, EventArgs e)
    {
        // Process the pool to handle drawing and interactions
        _menuPool.ProcessMenus();
    }

    private void OnKeyDown(object sender, KeyEventArgs e)
    {
        // Toggle the visibility of the menu with F5 key
        if (e.KeyCode == Keys.F5 && !_menuPool.IsAnyMenuOpen())
            mainMenu.Visible = !mainMenu.Visible;
    }
}
Imports System
Imports System.Windows.Forms
Imports NativeUI

Public Class YourFirstMenu
	Inherits Script

	Private _menuPool As MenuPool
	Private mainMenu As UIMenu

	Public Sub New()
		_menuPool = New MenuPool()
		mainMenu = New UIMenu("NativeUI", "SELECT AN OPTION")
		_menuPool.Add(mainMenu)
		AddMenuItems(mainMenu)
		_menuPool.RefreshIndex()

		' Subscribe to event handlers for updating and input control
		AddHandler Me.Tick, AddressOf OnTick
		AddHandler Me.KeyDown, AddressOf OnKeyDown
	End Sub

	Private Sub AddMenuItems(ByVal menu As UIMenu)
		Dim item1 = New UIMenuItem("Item 1", "Description for Item 1")
		menu.AddItem(item1)

		' Set up an event for when an item is selected
		AddHandler menu.OnItemSelect, Sub(sender, item, index)
			If item = item1 Then
				' Do something when Item 1 is selected
			End If
		End Sub
	End Sub

	Private Sub OnTick(ByVal sender As Object, ByVal e As EventArgs)
		' Process the pool to handle drawing and interactions
		_menuPool.ProcessMenus()
	End Sub

	Private Sub OnKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
		' Toggle the visibility of the menu with F5 key
		If e.KeyCode = Keys.F5 AndAlso Not _menuPool.IsAnyMenuOpen() Then
			mainMenu.Visible = Not mainMenu.Visible
		End If
	End Sub
End Class
$vbLabelText   $csharpLabel

This script sets up a basic menu with one item and handles its selection. NativeUI utilizes event-based callbacks, which means actions in your menus will trigger specific events, making your UI interactive and responsive.

Enhancing User Interaction

A key aspect of NativeUI is its ability to create menus that are both functional and user-friendly. The library supports mouse controls. In addition to mouse controls, NativeUI boasts comprehensive controller support, ensuring that menus are easily navigable with game controllers. You can further enhance user interaction by adding custom instructional buttons, which guide users through the menu options.

Customizing Menus

NativeUI allows for a high degree of customization. You can decorate your menus with your own textures and custom banners, giving them a unique look that stands out. Adding these personal touches not only makes your menus more visually appealing but also creates a more immersive experience for users.

private void CustomizeMenu(UIMenu menu)
{
    // Set a custom banner texture for the menu
    menu.SetBannerType("texture.png");

    // Change the color of a specific menu item to red
    menu.ChangeItemColour("Item 1", System.Drawing.Color.FromArgb(255, 0, 0));
}
private void CustomizeMenu(UIMenu menu)
{
    // Set a custom banner texture for the menu
    menu.SetBannerType("texture.png");

    // Change the color of a specific menu item to red
    menu.ChangeItemColour("Item 1", System.Drawing.Color.FromArgb(255, 0, 0));
}
Private Sub CustomizeMenu(ByVal menu As UIMenu)
	' Set a custom banner texture for the menu
	menu.SetBannerType("texture.png")

	' Change the color of a specific menu item to red
	menu.ChangeItemColour("Item 1", System.Drawing.Color.FromArgb(255, 0, 0))
End Sub
$vbLabelText   $csharpLabel

IronPDF: C# PDF Library

NativeUI C# (How It Works For Developers): Figure 2 - IronPDF

IronPDF is a comprehensive library in .NET for working with PDF files. It enables developers to create new PDFs, edit existing ones, and convert HTML to PDF, making it a necessary library for any C# application that needs to handle PDF documents.

Implementing IronPDF in a NativeUI Application

Integrating IronPDF in a C# project with NativeUI requires adding the IronPDF package to your Visual Studio project. This can be done easily via NuGet Package Manager in Visual Studio. Once set up, you can use IronPDF's features alongside the UI elements created with NativeUI.

Consider an application where you need to generate a report based on user input from a NativeUI interface. Here’s how you can achieve this using IronPDF:

using IronPdf;
using NativeUI;
using System;

public class ReportGenerator : Script
{
    private MenuPool _menuPool;
    private UIMenu mainMenu;

    public ReportGenerator()
    {
        _menuPool = new MenuPool();
        mainMenu = new UIMenu("Report Generator", "SELECT AN OPTION");
        _menuPool.Add(mainMenu);
        AddPdfGenerationOption(mainMenu);
        _menuPool.RefreshIndex();

        // Subscribe to event handlers for updating and input control
        Tick += OnTick;
        KeyDown += OnKeyDown;
    }

    private void AddPdfGenerationOption(UIMenu menu)
    {
        var generateReportItem = new UIMenuItem("Generate Report", "Create a PDF report");
        menu.AddItem(generateReportItem);

        // Set up an event for when an item is selected
        menu.OnItemSelect += (sender, item, index) =>
        {
            if (item == generateReportItem)
            {
                CreatePdfReport();
            }
        };
    }

    private void CreatePdfReport()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1><p>Report details...</p>");
        pdf.SaveAs("Report.pdf");

        // Notification to the user that the PDF report has been generated
        Console.WriteLine("PDF report generated and saved as Report.pdf");
    }

    private void OnTick(object sender, EventArgs e)
    {
        // Process the pool to handle drawing and interactions
        _menuPool.ProcessMenus();
    }

    private void OnKeyDown(object sender, KeyEventArgs e)
    {
        // Toggle the visibility of the menu with F5 key
        if (e.KeyCode == Keys.F5 && !_menuPool.IsAnyMenuOpen())
            mainMenu.Visible = !mainMenu.Visible;
    }
}
using IronPdf;
using NativeUI;
using System;

public class ReportGenerator : Script
{
    private MenuPool _menuPool;
    private UIMenu mainMenu;

    public ReportGenerator()
    {
        _menuPool = new MenuPool();
        mainMenu = new UIMenu("Report Generator", "SELECT AN OPTION");
        _menuPool.Add(mainMenu);
        AddPdfGenerationOption(mainMenu);
        _menuPool.RefreshIndex();

        // Subscribe to event handlers for updating and input control
        Tick += OnTick;
        KeyDown += OnKeyDown;
    }

    private void AddPdfGenerationOption(UIMenu menu)
    {
        var generateReportItem = new UIMenuItem("Generate Report", "Create a PDF report");
        menu.AddItem(generateReportItem);

        // Set up an event for when an item is selected
        menu.OnItemSelect += (sender, item, index) =>
        {
            if (item == generateReportItem)
            {
                CreatePdfReport();
            }
        };
    }

    private void CreatePdfReport()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1><p>Report details...</p>");
        pdf.SaveAs("Report.pdf");

        // Notification to the user that the PDF report has been generated
        Console.WriteLine("PDF report generated and saved as Report.pdf");
    }

    private void OnTick(object sender, EventArgs e)
    {
        // Process the pool to handle drawing and interactions
        _menuPool.ProcessMenus();
    }

    private void OnKeyDown(object sender, KeyEventArgs e)
    {
        // Toggle the visibility of the menu with F5 key
        if (e.KeyCode == Keys.F5 && !_menuPool.IsAnyMenuOpen())
            mainMenu.Visible = !mainMenu.Visible;
    }
}
Imports IronPdf
Imports NativeUI
Imports System

Public Class ReportGenerator
	Inherits Script

	Private _menuPool As MenuPool
	Private mainMenu As UIMenu

	Public Sub New()
		_menuPool = New MenuPool()
		mainMenu = New UIMenu("Report Generator", "SELECT AN OPTION")
		_menuPool.Add(mainMenu)
		AddPdfGenerationOption(mainMenu)
		_menuPool.RefreshIndex()

		' Subscribe to event handlers for updating and input control
		AddHandler Me.Tick, AddressOf OnTick
		AddHandler Me.KeyDown, AddressOf OnKeyDown
	End Sub

	Private Sub AddPdfGenerationOption(ByVal menu As UIMenu)
		Dim generateReportItem = New UIMenuItem("Generate Report", "Create a PDF report")
		menu.AddItem(generateReportItem)

		' Set up an event for when an item is selected
		AddHandler menu.OnItemSelect, Sub(sender, item, index)
			If item = generateReportItem Then
				CreatePdfReport()
			End If
		End Sub
	End Sub

	Private Sub CreatePdfReport()
		Dim renderer = New ChromePdfRenderer()
		Dim pdf = renderer.RenderHtmlAsPdf("<h1>Report</h1><p>Report details...</p>")
		pdf.SaveAs("Report.pdf")

		' Notification to the user that the PDF report has been generated
		Console.WriteLine("PDF report generated and saved as Report.pdf")
	End Sub

	Private Sub OnTick(ByVal sender As Object, ByVal e As EventArgs)
		' Process the pool to handle drawing and interactions
		_menuPool.ProcessMenus()
	End Sub

	Private Sub OnKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
		' Toggle the visibility of the menu with F5 key
		If e.KeyCode = Keys.F5 AndAlso Not _menuPool.IsAnyMenuOpen() Then
			mainMenu.Visible = Not mainMenu.Visible
		End If
	End Sub
End Class
$vbLabelText   $csharpLabel

Conclusion

NativeUI C# (How It Works For Developers): Figure 3 - License

The integration of IronPDF with NativeUI in C# applications is a powerful combination that can significantly enhance functionality and user experience. Whether it's for creating business reports, educational tools, or comprehensive data forms, this combination provides a robust platform for developers to build sophisticated and high-quality applications. With creativity and thoughtful implementation, the potential applications of this integration are vast and diverse.

Get started with IronPDF's free trial and explore its full potential. When you're ready to commit, licenses begin at just $749 - a small price for such powerful capabilities!

Frequently Asked Questions

What is the framework used for creating menus in C# development related to Grand Theft Auto modding?

NativeUI is a framework for C# developers primarily used in the Grand Theft Auto modding community. It simplifies the creation of nested menu systems and custom banners, making it a popular choice for its user-friendly design and adaptability to various screen resolutions.

How does the menu framework enhance user interaction in applications?

NativeUI enhances user interaction by supporting both mouse controls and comprehensive controller support, making menus easily navigable. It also allows for the addition of custom instructional buttons to guide users through menu options.

What are the steps to set up the menu framework in Visual Studio?

To set up NativeUI in Visual Studio, download the NativeUI library and incorporate the .dll file into your mod project. The library is accessible through popular C# repositories, and it’s important to ensure compatibility between your development environment and the NativeUI library for optimal performance.

What customization options does the menu framework offer for menus?

NativeUI allows for extensive customization, including decorating menus with custom textures and banners. This personalization makes menus more visually appealing and enhances the immersive experience for users.

How can a PDF library be integrated into an application using the menu framework?

IronPDF can be integrated into a NativeUI application by adding the IronPDF package via NuGet Package Manager in Visual Studio. Once set up, developers can use IronPDF features alongside NativeUI elements, such as generating PDF reports based on user input from a NativeUI interface.

What is a basic example of creating a menu using the framework?

A basic menu can be created using the NativeUI framework by setting up a MenuPool and a UIMenu, adding items to the menu, and subscribing to event handlers for item selection and menu visibility toggling. This involves writing a script that manages these elements and interactions.

What are the benefits of using a PDF library with the menu framework?

Using IronPDF with NativeUI allows developers to create and manipulate PDF documents within applications, adding functionality such as generating reports from user inputs. This integration provides a powerful toolset for developing sophisticated applications with comprehensive document handling capabilities.

Where can developers find resources to learn more about the menu framework?

Developers can find resources and documentation on the NativeUI GitHub wiki, which offers step-by-step guidance for creating menus and using the framework effectively in C# applications.

What is the significance of event-based callbacks in the menu framework?

Event-based callbacks in NativeUI allow for interactive and responsive user interfaces by triggering specific events in response to user actions within menus. This mechanism simplifies the management of menu interactions and enhances user experience.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.
Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?

Nuget Passed