Tuesday, 12 June 2018

My First Project on Github - WPF C# Drawing App

I had a Github account but I only used it a few times. I decided to change that. I created a plan for myself (see my Github Page here - https://hassan-theitguy.github.io/). One of the first projects I decided to add to my Github was a C# drawing app. Recently someone had made use of my code from a long past blog post. So I decided to create an update to that. This was my experience.

  • Download and Install Visual Studio Community Edition.
  • Take a look at the Graphics library (which I ended up not using because I opted to use InkCanvas)
  • Install the Visual Studio GitHub extension
  • Search for tutorials through Google like "c# canvas mouse drawing tutorial"
  • Decided on WPF app because I wanted to see what it is like. (From wikipedia - WPF attempts to provide a consistent programming model for building applications and separates the user interface from business logic. It resembles similar XML-oriented object models, such as those implemented in XUL and SVG.)
  • My canvas events were not firing and found the cause here - https://stackoverflow.com/questions/2507165/wpf-canvas-events-not-working
  • Came across the term GDI+ (graphics device interface that allows programmers to write device-independent applications.)
  • Found out that WPF uses 8 digit hex colour codes. First two is alpha.
  • I was surprised to learn that WPF has no color dialog. Ended up using the one from the WPF Extended Toolkit which can be easily installed through NuGet in Visual Studio)
  • I like the Issue Tracking and Wiki tabs on Github.
  • Useful guide Understanding the GitHub Flow
  • Found out that if I try to render to bmp the InkCanvas directly that it starts from top of the Window grid. This means that I end up with an empty bar on the left of my image. This would be where I have the menu using a dock panel). To fix this, I found out that I needed to use DrawingVisual and then render that. (see here)
  • Github Gists allows us to share and embed code snippets (example above).
  • The "git" name and what it stands for (depending on your mood) - https://github.com/git/git/blob/master/README.md. Like this one, "Goddamn Idiotic Truckload of sh*t".
  • So far I have pen color, pen size, undo and save. What feature should I add to the app next?

Thanks for following and share your experience with us in the comments below.

No comments: