.NET programming basic course

Hi!
As I had mentioned in one of my previous posts I attended a programming course dedicated for C#/.NET beginners. The course was organised by polish IT leader Comarch (at the end of this post you will find a link to the course on their website).
I have to say that most of the topics presented during the course were nothing new to me. But, it’s completely different than learning on your own no matter if it’s from a book or YouTube course or lecture. Having that possibility to ask questions and get instant answer is the biggest advantage. Sometimes, you think that you might have not understood something you ask a question to clarify and you get an affirmative answer –  that’s a confidence boost. That gives you that feeling that you’re on the right track. You can’t get that any other way than face-to-face learning experience.
What’s more that improves the quality of the course is the fact that it was mostly all time practice. The theory part was more of a brief introduction to the topic than a lecture. All important things were presented with an example and tested by students ourselves.
After completing the course I have one advice for anyone who wants to get into programming: be extremely careful when learning online. Some of the learning materials are not prepared with that mindset that someone who’s going to learn is absolute beginner. They tend to go shortcuts, don’t pay attention to details which denies learners to fully comprehend the knowledge. And sometimes they teach bad habits (for instance I have not heard before the course about the ‘private field, public property’ convention).
What I learnt during the course and I find most important for me at this stage is deeper insight into class inheritance and polymorphism.
I am pretty happy with the course but still there were some disappointments. I was really hoping to get some more details about such aspects as interfaces, data-binding and MVVM model. We talked a bit about interfaces, the tutor showed us an example of data-binding and he said few words about MVVM. But I was simply hoping for more.
Generally, I find the course much beneficial for me and I will surely continue with courses from Comarch. The course ended with issuing a certificate. That’s my first 🙂
Thanks, Michal

Programowanie .NET – kurs podstawowy (Comarch)

RomanDecimalConverter

Greetings,
I have finished another quick project. The plan for this was to introduce myself to WPF and XAML. My general thoughts are that despite that WinForms seems to be easier and quicker way to design a Windows application I find WPF more organised and more controllable that WinForms. I designed all windows for this application using only XAML editor (not the visual one) in Visual Studio. That gives better understanding what is happening with the window.

The application itself is quite simple: it converts Roman numbers to Decimal, and the other way around. Algorithms of conversion are quite simple so I won’t describe them here (they can be found in readme file, or by analysing the code).

That was quite a nice way to leap into WPF. Next week, I’m going to three-day basics of .NET programming course which I hope will give me more insight to WPF and MVVM model (which, I’ve deducted from some of the YouTube lectures about WPF, is essential for writing a well-organised and maintainable applications).

Stay tuned!

ClickOnce installer (*.zip)
Source code (*.zip)
Readme file (*.txt)

Localising your application

Hello!
Some time ago, while working on an abandoned project (which, I have to admit honestly, turned out to be too laborious and complicated for me at that point) I had worked out a method to localise the program using XML files. That worked perfectly okay but only recently I have that there are way easiest methods to achieve that.
Let’s start with XML method. Available languages have a unique file with all strings stored in. The file is organised as follows:

As you can see each window has a specific section in XML file, and only this section will be loaded when a window is displayed. Every window has a method which loads all related strings:

Drawbacks of this method are clearly visible: you have to write a method which will load all strings from XML file. And you have to be extremely careful not to omit any text you want to display. It worked but not effectively at all.

There is other much simpler method which I found at AltControlDelete.pl. It uses resource files and System.Globalization. General idea is that you create individual *.resx file for each language: Lang.resx for default (English) language and Lang.xx-XX.resx, where xx-XX is the name of a culture (for instance, pl-PL for Polish). What’s important is that access modifier for those files must be set as public as shown below.

lang_resx
These files must be stored in one folder (let say “Languages”). Now, you need to include them in your source code and you’re ready to use these strings in your code:

To use it with XAML you need to add appropriate namespace to Window element in XAML file:

Now, to switch between languages you need to change Culture in your process:

Of course, you need to build your app in a way that user has the possibility to switch between languages as he intends.

That’s about it. The method with *.resx files is much simpler and most of all quicker and to some point less prone to omissions and mistakes. Of course, there are other methods (for instance, Mulitilingual app toolkit  from Microsoft) but this one seems to me that is easy enough and does not require any add-on or third-party software other than Visual Studio).

This post is based on articles available at www.altcontroldelete.pl by Jerzy Piechowiak.

WPF TUTORIAL – APLIKACJE WIELOJĘZYCZNE
TWORZENIE APLIKACJI WIELOJĘZYCZNYCH Z C# I ASP.NET W VISUAL STUDIO

 

MakeNoMistakes 1.1

Greetings!

I have just finished the application introduced in previous post. To remind what the application is about: it is an implementation of a classic game Minesweeper. My addition to the idea is that once you click on a mine you have one chance to disarm the mine by solving small equation (addition or subtraction).

Here are links to ClickOnce installer and source code. As usual the code was written in MS Visual Studio.

ClickOnce installer (*.ZIP)
Source code (*.ZIP)

One note before you try it out – don’t mind the graphics. I am hopeless at drawings.

Enjoy!

MakeNoMistakes – my implementation of a classic

Hello All,
It has been a while since my last post in which I announced ‘another small app’. It is now time to publish its first version. Generally, it is another version of small game which is distributed with MS Windows and it is about finding mines. The app I have written is slightly different. It gives a player a possibility to disarm a mine if it is found by right clicking. In classic minesweeper it is possible to click with both mouse buttons to uncover all adjacent tiles. In my app it can be done by hovering a tile for a short moment. In this case uncovering the mine will result in an explosion and therefore the game ends.
This is the first version. It is not finished, but I would say it is 95% complete. What is missing is possibility to play a game on custom tile-board and a hall of fame (and nice graphics, but I am not an artist at all). Right now I am publishing only an EXE file (in a ZIP archive). Source code will be published when the application is completed.
Thanks, Michal

MakeNoMistakes (*.ZIP)

Dynamically generated buttons

Aloha!
Currently, I am working on another small app which I will present here shortly. Its function will be disclosed later as that fact is of no importance to this post. What is important is that some buttons the app will create automatically depending on some user settings. The buttons will be arranged in, let’s call it excel-style, in a table with equal size cells. So, the buttons need to be generated in a loop. That seems to be an easy task, but it becomes a bit trickier if you want them to perform different action. Here’s how to do that.

The code above shows how to generate the buttons with individual action performed by each button. But the solution above requires you to know how many buttons your program will create and still manually write separate switch/case instructions for each but. Tricky, but in some cases might be enough.

If it isn’t enough C# gives you opportunity to create actions delegates and store them in a dictionary.

These are two approaches to dynamically created buttons with individual actions for each button.

This post has been compiled from:
http://stackoverflow.com/questions/1434282/how-do-i-create-5-buttons-and-assign-individual-click-events-dynamically
http://stackoverflow.com/questions/33107026/dynamic-switch-cases
http://stackoverflow.com/questions/8414930/is-it-possible-to-declare-generic-delegate-with-no-parameters