Matpaint – simple app with simple features – codeproject pln to usd

.

Being electronics engineering students, we are taught programming but not as properly as CS guys learn it binary worksheet. This App implements many of the simple features which are taken as granted in Windows GUI Apps. The primary goal was to make something similar to this app: LED Matrix Studio http://freshney.org/electronics/builder.htm – but with time constraints and finding it is not as easy as it seems we settled with an app which is somewhat useful.

We call our app, MATPaint, which is short for MATrix Paint – the app currently allows for designing and saving of Dot-Matrix patterns for up to 32×32 size matrix.

This article is written as it is a requirement of our C# project – our programming teacher Engr. Sajid Hussain (IIEE-PCSIR, Karachi) asked us to make an application as part of our C# Course and put on CodeProject.com and this application and article are the result of that.


I had worked on LED Dot-Matrix displays as a side project a few months back using AVR and 8×8 LED Displays and had made a quick and dirty app for generation of the hex-code for the display pattern.

So for this C# Project, I along with my group-mate (Maaz Ahmed) decided to make an app which can generate codes for various sizes of dot-matrix displays and also has other features available in regular apps that we use binary converter to text. We did find a similar app [mentioned in the Intro] which did all that during our search for similar work on the Internet but that was written in Delphi and not C#, so we basically have written this app from scratch. How this Article is Written

two parts, the first part describes the application working, features and how it was made plus explanation of some of the tasks (File save/Open etc) the other part details the working of the Matrix/Grid and the relevant functions (Invert/Flip/Roll etc) rs to usd exchange rate. The first part mainly done and written by me [Zaid Pirwani] and the second part by Maaz Ahmed gold background images. Making of MATPaint

We started with a Visual Studio 2010 C# project but half way through we moved over to VS2012 and the files uploaded along this article were last saved/built with VS2012 – (the solutions files can still be opened in VS2010 if it has SP1 update installed). The App does

not use any external libraries other than those provided by Windows and should run on any Windows PC without any additional installation (well maybe .Net Framework).

We used the DataGridView control for the purpose of pattern generation because this control provides flexibility and customization to the user for creating any types of cells. We exploited its properties to design the grid with the desired functionality xpf to usd. With the extensive support to design and adjust the appearance of the cells we find it suitable for our needs.

Now, feature by feature code explanation and snippets are provided, the code below is not verbatim as used in the app. For the sake of explanation we have omitted

The first thing we wanted in the app was to be able to save patterns and open them later on what is the binary system. For the file type and format we decided to simply save the files as text files having row and column data comma separated and divided by lines changes. The files are saved with an extension .maz to differentiate them from other text files.

We used the OpenFileDialog and SaveFileDialog objects available in VS2012 – however simply putting in the Open/Save dialogs was not enough as we wanted proper notepad-like functionality for opening/saving files so that the user is prompted when opening a file when already a file was being edited and so on call option example. This was implemented by putting in 2 flag variables; isChanged (boolean) and currentFile (enum with Opened and New as values), the values of these 2 flag variables is checked whenever a file is opened / closed / new file etc.

The methods used are NewMatrix();, SaveMatrix();, SaveOpenMatrix();, OpenMatrix(); along with click events for New, Open, Save and Save menu items.

// Similar to SAVEMatrix – Code Omitted HERE – will omit from the // app as well and overload the SaveMatrix() method in later revision of app

// Open FILE SPECIFCIATIONS // File should be in simple TXT format, ‘,’ delimited // First Line: ColumnCount, RowCount // Second Line and so on: Each line has data of 8 rows in INT format and commas separate the different Columns try

and the app opens as it was closed. We used the built-in App Settings option in VS2012 (also in VS2010) to store and retrieve app settings like App Size,

Location, State, Matrix Size etc call option price formula. The settings are retried during the Form_Load event and are saved in the Form_Closing event. private void Form1_Load( object sender, EventArgs e)

Exporting the pattern as a HEX File (Binary Code): What good is a Dot-Matrix Pattern generator when it cannot produce hex code for micro-controllers

so we added a very simple hex generator which saves the Row/Column codes as Binary data rather than text. private void binaryCodeHEXToolStripMenuItem_Click( object sender, EventArgs e)

Print preview and Printing of the Pattern: In the end, we just added the PrintDocument, PrintDialog and PrintPreview for one more feature, the print option is very crudely implemented and prints the screenshot capture of the Matrix control but for now, it seems to be working. private void printPreviewToolStripMenuItem_Click( object sender, EventArgs e)

Install Shield Setup Wizard and FileType Association: Last but not the least, to make an installer for the app, we opted to use a InstallShield Setup Project to our app and with some simple steps in a wizard the whole thing was ready, as a bonus we added FileType Association as well for .maz extension and added support for command line arguments so that our app opens the appropriate pattern when a .maz file is double clicked equity meaning in accounting. Task Specific Features

NewMatrix() method, we kept it maximum at 32 cause after that the form repaint on screen was taking quite a lot of time making the app slow. private void NewMatrix()

four different sizes available for designing in addition to the Fill screen mode, where the cells are expanded to the corners of the window. This method is called whenever the user selects a different size type from the list or if Fill Screen is selected whenever the application form size is changed (checked by the

Pattern Resize (change dimensions): Changing of the dimension of the matrix/grid is done by the following code streaming forex rates. This also alerts the user when there

Pattern movement allow us either to shift the data on the grid or to rotate it across its edges in the Up/Down/Left/Right directions if the Roll Grid checkbox is checked.

This is done by this code, only code for UP and Right shifting is provided here as the Down and Left are quite similar to these. UP SHIFT/ROLL // Storing the data of the critical Row 0 – the first row

dataGridView1.Rows[dataGridView1.RowCount – 1].Cells[y].Style.BackColor = Color.White; RIGHT SHIFT/ROLL // Storing the data of the critical Column 0 – the last column

DataGridView control as the base grid for our Matrix paint area and it worked out quite great, though usually DataGridViews are not used for painting purposes and are for data output to user in grid form.

• Simple Features are sometimes NOT very simple: Though we are saying this cause we are beginners but the most time on the app was spent on the simple features we usually take for granted like Open/Save, File Association, etc.

• Goal of this Project was Learning C#: I think working on this app gave us a good practice of making a simple GUI Application and though the app may not seem to do much, much effort was put into it and the main goal was to add regular-app-features not make a complete pattern generator.

• Probably NOT the Best Practices: The code in this project may not be the BEST-PRACTICE code, but this is what gets the work done and doesn’t go into the complexities which a beginner usually runs from as this is made by us who are very new to C# and GUI and VS.

The complete source code is available at GitHub as well and while it is unlikely that I will be updating the app in the coming months but I wish to add a few more things to this app and if time allows will keep on updating it there.


banner