WPF Layout

The past week , I have been working on Tong Hin’s inventory module layout .

Why is layout important ?
Setting a layout is so important to an application usability . Arranging controls based on explicit coordination may work for one environment , but as soon as we change its screen resolution or with different font sizes it will fail .

Therefore , I realized the best practices when creating any layout is to :-

  1. Avoid fixated sizes of height/width . Use the HorizontalAlignment/VerticalAlignment properties together with Margin to position elements in the layout
  2. Practice using a StackPanel to layout buttons of a dialog
  3. Practice using Grid to layout static data entry form . Create Auto sized columns and Star(Asterisk) sized columns for the elements

Additionally , if the layout is too big to fit the resolution size , we can add a scroll bar by using the ScrollViewer property. The visibility of the ScrollViewer can be set using the ScrollbarVisibility properties .

Any beginners should practice these useful tips before starting a UI layout development in WPF . That is all for this week .

Week 3 in Tong Hin !

For my 3rd week in Tong Hin, I was able to create many more functions in my current task (converting project Windows Form to WPF MVVM prism application). This App is created to add users , hash and salt the password for created users and save them into database.

Currently the App is able to generate new users , update salt , reset password , show data in grid , refresh and delete user . Functions can also work with validation (username & password validations etc) . I am also able to add success / warning dialogs into the App . Most of the functions went smoothly except my entire App was unable to run for 2 times which creates panic sometimes (fixed with the help of my supervisor). The remaining function for me to fix is password (which is the hardest function among all because prism doesn’t allow to password bindings directly in the PasswordBox) and add ComboBox to the FloorsInCharge in the update user function .

Currently , I’m doing a lot of research about using Git , Source Tree (committing code and writing commit messages) generally the basic necessities a software engineer needs throughout their programming life .

My supervisor also suggested me to look up on clean code , single instance vs singleton and two-phase commit transaction which is my goal for the next week since there is only hands-on coding last week and I believe understanding the theories in programming is also equally important than the practical hands-on part .

Finally , quite intense of the first 3 weeks but glad that there is progress better than none . That is all so see you next week ! =D

Second week in Tong Hin!

I was given my first task in Tong Hin and assigned to convert a WPF project to prism MVVM View Model and do some unit tests . As usual , I will note down the things I’ve done my second week .

For my second week , I started to work on the UI of my given task . I have completed most of the UI but without data bindings . I also fixed some minor problem such as connecting the config path to the database, created different checkbox buttons in my project .

Also , I finally did my first unit test (with the help of my supervisor) and learned some things about wrappers . I also managed to complete most of the “Prism MVVM View Model” tutorial and EF core tutorial .

Next , I learned a new delegate such as Func in c# , Func is a delegate that points to a method that accepts one or more arguments and returns a value .

That is all for this week . Will be ready for more challenges , so for next week , my goal is to will try to load the data from database to the data-grid in my UI in the project and tryout more unit testing .

Navigation Concept and More of Errors Solving

Since I have completed the PurchaseInvoice module, I needed to fix errors that are present and check the codes again.

Firstly, I started by checking the property isAllPurchaseInvoiceReceived, by checking from the UI to see if the property gets flagged when all invoices are received, and hence after checking, I had to change the logical property of quantity to ensure that if a quantity more than ordered is received the property, then it will not be flagged or be true in its boolean expression.

Next, another error which was found is that when a user creates a GoodsReceive and PurchaseInvoice from PurchaseOrder, the GoodsReceive can afterwards be used when creating a PurchaseInvoice from GoodsReceive, which will result in having an Invoice with the same quantity number received but different cost which is a conflict. To solve the error, the relationship between GoodsReceive and PurchaseInvoice was adjusted by using the EF Core concept of relationships One-to-One by defining the relationship in the config file.

I have also pulled codes from Git and adjusted few parts, that resulted in the project to be using tabs navigation concept instead of dialogues. Such that a user, can have multiple tabs opened at the same time and each is independent on the other. At the same time, this current navigation is more user friendly.

WPF allows the concept of using a ViewModel without getting access to its View. In other words, it loads the codes and knowledge from a ViewModel without taking the view into consideration.

Another information I learnt from GitHub was when pulling if we are not present in the designated branch then we won’t be able to see the changes that have been to the codes. As pulling without being in the branch does not grant us access to the changes made.

See you all next week 🙂

Introduction to Materials Needed for Development

In this week, I’ve go through the resources that required for the project before getting started with the development. For the first, I’ve learnt the usage of git repository by going through some tutorials. It’s used for tracking changes made on source code during development with multiple programmers. Not only that, I’ve also learnt on how to interact with the git repository by using Bitbucket and Sourcetree such as push and pull.

Furthermore, I’ve also get myself familiar with Test Driven Development (TDD) concept which is the development approach that emphasize on testing and refactoring the functions repeatedly. Instead of just getting familiar with the concepts, I’ve also try on its exercise files in order to learn on how to implement and apply the concepts into the project.

Moreover, I’ve learnt the Prism Library for WPF which is the framework that helps to create application that have loosely coupled components. In the course, I’ve learnt how to implement the features such as delegate command, custom dialogs, event aggregator and others as well.

Lastly, after I’ve went through these materials that required for the project, I had been given the task for developing the user module which is the login and create account page. I’ve started the development from creating the repository, set up the config for the model class and create the database that run by Docker which can connect to the database without it install locally.

Get to Know About Prism Library for WPF

I acknowledged that Prism is great framework that support MVVM (Model View View Model) design pattern. First of all, I am introduced to few terms based on the course I followed on some courses and tutorials (Title : Introduction to Prism for WPF).

Next, I learnt how to perform view injection to allow certain text to be displayed when i run the the program. It is performed simply just by linking instance of region to specific region called as ” NAME” in XAML file. Other than that, I also followed some step to implement View Model Locator and construct property to allow connection between View(XAML file) and View Model(CS file) in prism.

Beside that, I came across to know about delegate command, where it is used to implement ICommand without require an event handler. Delegate command can invoke method defined in ViewModel and let u control the properties on view from ViewModel. Hence, I played around with ICommand provided by prism that bind UI gesture to particular action/event. Along side of that, I also try out composite command, where it is able to invoke multiple view on one touch and IEventAggregator, which is a good implementation when you have lots of objects that are potential event sources.

Lastly, I understood the purpose of Dialog in prism library as it is used to notify user of current system progress or asking for user’s confirmation upon an action. In dialog, it is divided into two type, where one is block interaction with the rest of the application (modal) and one is to allow user to still interact with the other part of application (non-modal).

Conclusion, I do have to admit spend quite some time understanding how prism library works as I am still weak in programming knowledge, but thanks to guidance from my supervisor and going through it several times, I managed to get a grab on my understanding.