Tag Archives: WINFORMS

DESIGN A TRAINER/KEYGEN

#85 Designing a trainer/keygen in C#

When I think about trainers 3 things come to mind.. original chiptunes, nostalgic games on windows and imaginative unique art styles. funny enough there was a decent amount of programming hacks and tricks used but people rarely think of that nowadays.

I have created an example template application with just the chiptunes and a little bit of art included. I will not include any logic for cracking games or programs etc. this article is just focusing on the visual and music design for nostalgic and educational purposes.

Please se the GitHub link to the source code here.

FREETAKSERVER MANAGER

#70 FreeTAKServer Windows Manager Concept

FreeTAKServer manager control panel concept.

Just a quick C# working example of a FreeTAKServer Manager application for the Windows OS.

WinForms & WPF versions are supported.


The FreeTAKServer Manager C# application was created to make using the current v1.7 of FreeTAKServer more user friendly.

FreeTAKServer Manager has the ability to Start, Stop, Restart, Install and Uninstall the FreeTAKServer & FreeTAKServer-UI.

It can also start on startup, send alert emails, let the user test the API (localhost & custom), allow quick MainConfig.py & config.py edits, Open a portforward testing page.

The App requires Admin privilege in order to run cmd commands effectively.

Remove all previous Python environment variables (if you have them) because they mess up the paths.

N.B the application has been created with the microsoft Visual Studio 2019 Community IDE. (https://visualstudio.microsoft.com/vs/)

API testing form

https://github.com/Cale-Torino/FreeTAKServer_Manager

7ZIP EXAMPLE AUTOMATION

#67 7zipExample Automation Application In C#

Example Video

While creating a download page for a website I came across the problem where the browser would open a .PDF file instead of downloading it to the desktop of my PC when using the JavaScript window.location.href = "url/path/file.pdf"; function. A quick easy solution is to archive the .PDF document as a .ZIP file or .7z etc. Now when the function is called the file will be downloaded.

Using a quick C# WinForms application I was able to automate the process. Here I have included a small demo project which may be useful on windows machines.

The Main function is as below:

Example code of the main function.

A new process is started and Arguments are sent to the 7za.exe console application.

7za.exe can also be used in the CMD console as well as with scripting languages such as PowerShell or Batch.

C# WINDOWS FORMS EMAIL

#54 C# WINDOWS FORMS EMAIL TEST

Form C# Email Example

A simple C# WinForms desktop application to send a text email/send an attachment email.

This application uses no special class. The default mail classes are used namely:

using System.Net.Mail;

using System.Net.Mime;

The email text is sent in HTML format:

var mailMessage = new MailMessage{                     From = new MailAddress(Vars._mailFrom),//email            Subject = "C# WinForms Test Mail",                     Body = "<h1>Hello</h1>" + "<h2>C# WinForms Test Mail</h2>",                     IsBodyHtml = true,};

INI READER/WRITER C#

#23 INI READER/WRITER C#

Simple INI Reader/Writer

INI files are mostly used in C++ and Delphi programming these days. Microsoft’s .Net framework focuses on XML-based config files not INI files. However it is still possible to read and write to INI files using C#. In this example I have created a very simple INI reader. It allows you to read/write to the config file ini_reader_writer_20xx-xx-xx.ini .

There are plenty  NuGet packages, such as INI Parser. Which allow easy implementation into our projects. You could also write your own class which gives us more control but is overkill for an example. Example an INI file handling class using C#, P/Invoke and Win32.

USING A DLL IN C#

#21 USING A DLL IN C#

A very simple example of how a DLL can be used.

In this simple example I create a very simple DLL(Dynamic-link library) in C#. the library has to functions the first function is the Calculate method which allows us initiate a simple addition of the numbers in each numerical box.The second function is a logger to keep track of the addition problems we solve. The WriteLine method also shows us how we can write to and delete files in by calling methods from the dll_example_class_library.dll we compiled.

A simple method called Calculate just adds two numbers together using the dll_example_class_library.dll DLL’s help to keep code more organised and also allow us to change functionality of programs without recompiling the EXE .

After the DLL is compiled we can add it to our project by: right clicking Refrences, clicking add reference, clicking browse and selecting our DLL

In order for us to use the methods in our class it has to first be initiated. Once initiated we can start using the methods in our logic.

C# EVENT LOGGER

#20 C# EVENT LOGGER

Event Logger Example

A simple logger to write all the occurring events to a file in the root directory \ Logs folder of the application.

The logger class LoggerClass.cs processes the data and writes it to a .log file. the Class can also delete the current log file which is being written to.

WINFORMS C# DARKUI

#11 WINFORMS C# DARKUI

DarkUI

Dark themed control and docking library for .NET WinForms.

DarkUI is an attempt to create a simple, extensible control library which emulates the look and feel of popular tabbed document interfaces such as Visual Studio, Photoshop, WebStorm, and XCode. Originally just a collection of bug fixes and enhancements built on top of WinForms, it has now evolved in to a fully working docking and control library.

It’s an inspiring library displaying the power of Windows Forms.

The best way to learn how to use DarkUI is to check out the Example project included with the source code. It’ll show you how to use the majority of the forms, controls, and docking components.

The example source code by RobinPerris can be found here.