Samples of Assignments: Drawing in Xamarin Using Ncontrol

In the process of development, sometimes there’s a need to draw some interface elements manually. The Ncontrol component was created exactly for these purposes.

The library uses the NGraphics library to perform custom drawings to make it easy to build complex controls. The project is hosted on Github and is distributed under the MIT license. NControlView can be used both to do custom drawings and to create complex custom controls.

To make a long story short, it’s a rendering visualization mechanism on top of the standard mechanisms in iOS, Android, and Windows Phone.

First, you need to initialize the component: add the string NControlViewRenderer.Init() after the string Forms.Init() in classes AppDelegate for iOS or MainActivity for Android.

Then, you can directly add the needed element in C# code:

var myView = new NControlView {
      DrawingFunction = (canvas, rect) => {
          canvas.DrawLine(rect.Left, rect.Top, rect.Width, rect.Height, NGraphics.Colors.Red);
          canvas.DrawLine(rect.Width, rect.Top, rect.Left, rect.Height, NGraphics.Colors.Yellow);
      }
  };

However, it’s better to create an inheritor of the NcontrolView class and use it in Xaml:

public class MyControl: NControlView
{
  public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect)
  {
    canvas.DrawLine(rect.Left, rect.Top, rect.Width, rect.Height, NGraphics.Colors.Red);
    canvas.DrawLine(rect.Width, rect.Top, rect.Left, rect.Height, NGraphics.Colors.Yellow);
  }
}

Two examples of the usage of NControl from the official Xamarin forum are attached to the word file.

Thanks for your attention!

This page features one of the samples of assignments that you can view to help you deal with your own assignment. Our samples include information that you can’t use in your own homework. Many students get help from Assignment.EssayShark.com if they like our samples of assignments. Our service provides the information technology assignments and other types of projects done by academic staff. On our site, you can get help with any discipline. We work 24/7 so that you can contact us any time you want. Each assignment will be done with individual approach and according to your instructions. Get out help if you want to forget about your homework problems.

Leave a Reply

Your email address will not be published. Required fields are marked *

Customer testimonials

Submit your instructions to the experts without charge.