Entry with Custom Border in Xamarin Forms

Introduction:

In Xamarin Forms Entry control allows a single line of text to be edited. This article demonstrates how to create a custom renderer for the Entry control, enabling developers to override the default native rendering with their own platform-specific customization.

Custom Renderer:

  1. This sample demonstrates a custom renderer for the Entry control, “Enabling developers to override the default native rendering” with their own platform-specific customization.
  2. Custom renderers provide a powerful approach for customizing the appearance and behavior of Xamarin Forms controls. They can be used for small styling changes or sophisticated platform-specific layout and behavior customization.

 

Step1: Create the Mobile App (Xamarin Forms) Project

Open VisualStudio 2017 à File à New à Project à Choose Cross-Platform Template à Choose MobileApp (Xamarin.Forms )à Name it as EntryLineWithanyColorà Click on OKà Chose .NetStanderdà Click OK

 

Step2: Creating CustomEntry.cs

Go to Project EntryLineWithanyColorà Right Click àAdd Class CustomEntry.cs

File Name: CustomEntry.cs

A custom Entry can be created by subclassing the Entry control, as shown in the following code

The CustomEntry control is created in the .NET Standard library project and is simply  ENTRY control. Customization of the control will be carried out in the custom renderer, so no additional implementation is required in the CustomEntry control.

 

Step 3:  Create a class in the Android directory and name it as CustomRenderer.cs

Go to EntryLineWithanyColor.Android à Right Click àAdd Class CustomRenderer.cs

 

File Name: CustomRenderer.cs

Brief Explanation of the above Code:

Here Added the ASSEMBLY attribute it means like declarations

  • CustomEntry is the name of the placeholder class in your common (PCL or Shared) Forms library.
  • ExportRenderer is the name of the actual platform specific implementation class in your iOS/Android/WP project.

Essentially, telling Forms, “when you need to render CustomEntry on Platform X, use the class CustomRenderer.”

  1. Create a subclass of the EntryRenderer class that renders the native control.
  2. Override the OnElementChangedmethod that renders the native control and write logic to customize the control. This method is called when the corresponding Xamarin Forms control is created.
  3. Added an ExportRendererattribute to the custom renderer class to specify that it will be used to render the Xamarin Forms control. This attribute is used to register the custom renderer with Xamarin Forms.

 

 

Step 4: Create UI for Border less Entry 

File Name: MainPage.xaml

Here for Example I have taken Login Form for better Understand

Here we have to declare the Local Refernce nameSpace in MainPage.xaml

 

 

Output: Run the program Ctrl+F5

 

Deploy ASP.NET MVC + Angular 4 + PostgreSQL into AWS

Hello guys hope you are doing good 🙂

From the past few days I was suffering to deploying my ASP.NET MVC application integrated with Angular 4 + PostgreSQL DB into AWS. After my serious deliberation I’ve goto know the procedure and wanted my friends to know about this. That might help you in future.

Step1: Create Elastic Beanstalk web application in AWS

  • Once you login into your account you can find the “Build a solution” section below
  • Choose on Build a web app

  • To create a new Application click on Create New Application, and fill the following required fields Application Name & Platform (.Net). And click on “Create application” button which will start creating the application

 

  • Once application is created with Environments, then you must be able to see HealthGreen

  • Now make sure that the user which is going to be used has the following permissions.

 

Step2: Create RDS (Postgres) in AWS

  • Go to RDS service, and choose PostgreSQL from Step1

 

  • Click on Next, in Step2 choose your case Production (or) Dev / Test
  • Provide the required details
    1. DB instance Class (1GB/ 2GB/…..)
    2. DB Instance Name
    3. Master Username & Password
  • Now make sure that your instance is publicly accessible – Yes, if not click on Modify in Details Section. And choose Public accessible – Yes. If it is not public accessible we will be not able to access this Database in PgAdmin.

 

Step3: Deploy the application into AWS

  • Firstly we need to install “AWS toolkit for Visual Studio 2017”. Once installed you can see the option “Publish to AWS Elastic Beanstalk” on right click the project.
  • Select “Publish to AWS Elastic Beanstalk”, it ask you to create Account Profile.
  • To get the Access Key Id & Secret Access Key, Go to IAM in AWS Console.
  • Select the user, then go to “Security Credentials”, where we can create the Access Key.

 

  • Once you create a new Access key, it gives you Access Key ID & Secret Access Key. Make sure to store your Secret Access Key in a secured place.
  • Now go back to VS 2017 and enter your credentials.
  • Now you can see the Web App we have created in AWS Console.
  • Now Go to View  Open AWS Explorer  Amazon EC2  Key Pairs  Create key pair

 

  • Creating a new Key Pair, will give you a <Key Pair Name>.pem
  • Select “Publish to AWS Elastic Beanstalk”, after selecting profile click on Next.
  • In the Application Options section add the key value pair. And click Next
  • Now click Deploy

 

Step4: Check database connections

  • Open PgAdmin4
  • Get the Host Name from the AWS Console  RDS  Instances  Copy the End Point (Host Name)
  • Now create New Server  Enter the Credentials of RDS.
  • Create your tables required for the application.

 

Step5: Install Angular Packages in EC2 instance using Remote Desktop

  • Go to EC2 Service
  • Click on “Instances”
  • Find your instance and right click on it, then choose “Get Windows Password”

  • Now it will ask you to upload “Key Pair Path” Get the <Key Pair Name>.pem file that we have created when deploying the Web App.
  • Once you upload it will generate the Password, make sure to store it a secured directory.
  • Now you can connect to the Remote desktop using that password.
  • Once you have connected go to C:\\inetpub\\wwwroot.
  • Open command prompt for wwwroot directory.
  • Download Node from the https://nodejs.org/en/ .
  • Now in the command prompt type “npm install”, this will install the packages required for angular.

  • Now run the application

 

Round Entry in Xamarin Froms

Introduction:

In Xamarin Forms Entry control allows a single line of text to be edited. This article demonstrates how to create a custom renderer for the Entry control, enabling developers to override the default native rendering with their own platform-specific customization.

Custom Renderer:

  1. This sample demonstrates a custom renderer for the Entry control, “Enabling developers to override the default native rendering” with their own platform-specific customization.
  2. Custom renderers provide a powerful approach for customizing the appearance and behavior of Xamarin Forms controls. They can be used for small styling changes or sophisticated platform-specific layout and behavior customization.

 

 

Step1: Create the Mobile App (Xamarin Forms) Project

Open VisualStudio 2017    File    New    Project    Choose Cross-Platform Template     Choose MobileApp (Xamarin.Forms )    Name it as RoundEntry    Click on OK    Chose .NetStanderd    Click OK

Step2: Creating CustomEntry.cs

Go to Project CustomEntry    Right Click    Add Class CustomEntry.cs

 

FileName:CustomEntry.cs

A custom Entry can be created by sub classing the Entry control, as shown in the following code

The CustomEntry control is created in the .NET Standard library project and is simply  ENTRY control. Customization of the control will be carried out in the custom renderer, so no additional implementation is required in the CustomEntry control.

 

Step2:  Create a class in the Android directory and name it as CustomRenderer.cs

Go to RoundEntry.Android  Right Click   Add Class CustomRenderer.cs

 

 

Brief Explanation of the above Code:

Here Added the ASSEMBLY attribute it means like declarations

  • Custom Entry is the name of the placeholder class in your common (PCL or Shared) Forms library.
  • Export Renderer is the name of the actual platform specific implementation class in your iOS/Android/WP project.

Essentially, telling Forms, “when you need to render Custom Entry on Platform X, use the class CustomRenderer.”

  1. Create a subclass of the EntryRenderer class that renders the native control.
  2. Override the OnElementChangedmethod that renders the native control and write logic to customize the control. This method is called when the corresponding Xamarin Forms control is created.
  3. Added an ExportRendererattribute to the custom renderer class to specify that it will be used to render the Xamarin Forms control. This attribute is used to register the custom renderer with Xamarin Forms.

 

Step 3: Create UI for Round Entry 

File Name: MainPage.xaml

Here for Example I have taken Login Form for better Understand

Here we have to declare the Local Refernce nameSpace in MainPage.xaml

Output: Here we go.. Press Ctrl+F5

Border less Entry in Xamarin Forms

Introduction:

In Xamarin Forms Entry control allows a single line of text to be edited. This article demonstrates how to create a custom renderer for the Entry control, enabling developers to override the default native rendering with their own platform-specific customization.

Custom Renderer:

  1. This sample demonstrates a custom renderer for the Entry control, “Enabling developers to override the default native rendering” with their own platform-specific customization.
  2. Custom renderers provide a powerful approach for customizing the appearance and behavior of Xamarin Forms controls. They can be used for small styling changes or sophisticated platform-specific layout and behavior customization.

 

Step1: Create the Mobile App (Xamarin Forms) Project

Open VisualStudio 2017    File   New   Project   Choose Cross-Platform Template   Choose MobileApp (Xamarin.Forms )   Name it as BorderLessEntry   Click on OK   Choose .NetStanderd   Click OK

 

Step2: Creating CustomEntry.cs

Go to project BorderLessEntry   Right Click   Add Class CustomEntry.cs

File Name: CustomEntry.cs

A custom Entry can be created by subclassing the Entry control, as shown in the following code

The CustomEntry control is created in the .NET Standard library project and is simply an Entry control. Customization of the control will be carried out in the custom renderer, so no additional implementation is required in the CustomEntry control.

 

Step 3: Create a class in the Android directory and name it as CustomRenderer.cs

Go to BorderlessEntry.Android   Right Click   Add Class CustomRenderer.cs

 

File Name: CustomRenderer.cs

Brief Explanation of the above Code:

Here Added the ASSEMBLY attribute it means like Declarations

  • CustomEntry is the name of the placeholder class in your common (PCL or Shared) Forms library.
  • ExportRenderer is the name of the actual platform specific implementation class in your iOS/Android/WP

 

Essentially, telling Forms, “When you need to render CustomEntry on Platform X, use the class CustomRenderer

  1. Create a subclass of the EntryRenderer class that renders the native control.
  2. Override the OnElementChangedmethod that renders the native control and write logic to customize the control. This method is called when the corresponding Xamarin.Forms control is created.
  3. Added an ExportRendererattribute to the custom renderer class to specify that it will be used to render the Xamarin Forms control. This attribute is used to register the custom renderer with Xamarin Forms.

 

Step 4: Create UI for Border less Entry 

File Name: MainPage.xaml

I have taken example as Registration Form for better Understand

Here we have to declare the Local Reference namespace in MainPage.xaml

 

Output: Tadaa, here is the expected output

Pinch and Pan Image in Xamarin Forms

ZoomImage (PINCH and PAN) In Xamarin Forms

Step1: Create the Mobile App (Xamarin Forms) Project

Open VisualStudio 2017    File    New    Project    Choose Cross-Platform Template    Choose MobileApp (Xamarin.Forms )    Name it as ZoomImageApp    Click on OK    Chose .NetStanderd    Click OK

Step2: Creating DoubleExtension.cs

Go to PCF file In ZoomImageApp    Right Click    Add Class DoubleExtention.cs

File Name: DoubleExtensions.cs

Step 3: Creating Pinch & Pan Container

Create a class in the root directory and name it as PinchAndPanContainer.cs

File Name: PinchAndPanContainer.cs

Step 5: Copy any source image to Zoom it.

Go to ZoomimageApp.Android    Resources    Drawable    In my case I’ve taken slip.png

Step 6:  Creating UI for Pinch & Pan Container

File: MainPage.xaml

Output: Tadaaa, Run the program Ctrl+F5

Xamarin.Forms CarouselView with image indicators

Download source code

Most of us when we are very familiar with Bootstrap carousel, we expect the same output in mobile CarouselView either. But the problem with Xamarin.Form CarouselView doesn’t provide us such CarouselView with Image Indicators. 

So this article will help the crazy professionals

Step1: Create a Mobile App (Xamarin.forms) project

Open Visual Studio 2017    File    New    Project    Choose Cross-Platform template    choose Mobile App (Xamarin.Forms)    Name it as CarouselViewApp    Click on OK    choose .Net Standard    Click OK

 

Step2: Install CarouselView NuGet Package

Right click on CarouselViewApp    Manage NuGet Packages    type CarouselView.FormsPlugin and Install the package

 

Step3: Create a Model for Images as ImageModel.cs

Before that add the images in CarouselViewApp.Android    Resource    drawable

File: ImageModel.cs

 

Step4: Create ViewModel for MainPage.xaml

Right click on CarouselViewApp    Add    NewItem    Visual C#    Add new class MainPageViewModel.cs

File: MainPageViewModel.cs

 

Step5:  Adding namespace in the MainPage.xaml

 

Step6: Assign BindingContext for MainPage.xaml.cs

File: MainPage.xaml.cs

 

Step7: Creating UI for MainPage.xaml

File: MainPage.xaml

  1. By using Image.GestureRecognizers, we are firing click events using MVVM Architecture
  2. Rotation property for ListView helps us to set or get the current rotation of the element. Here we are rotating ListView to 270 deg
  3. Here the indicators row in Grid is build using RelativeLayout.
  4. RelativeLayout is used here to turn the ListView in Horizontal Direction
    1. At first we move ListView into RelativeLayout, and maintaining the RelativeLayout HeightRequest.
    2. Now we need to fit the ListView in RelativeLayout bounds, this we can do it by using RelativeLayout Constraints.
    3. RelativeLayout.XConstraint, RelativeLayout.YContraint  are used to fix the x,y positions. And then RelativeLayout.WidthConstraint is to set the width for image, RelativeLayout.HeightContraint is to set the height for image.
    4. And the final step is to rotate the ContentView. This will first rotate the cell and the fit image into it.

 

output: Now run the application

  

Authentication and Authorization in ASP.NET Web API using Custom Filters

  • Web API is a platform for building RESTful applications on DotNet Framework. 
  • These API’s can be consumed from Console, Windows, Web, Mobile Applications.
  • As Web API is a part of core ASP.NET, it can be created on either MVC applications, or any other web applications.
  • Web API’s uses all the HTTP features like Request and Response headers, caching and so on…
  • Web API’s can return the data in various formats like
    • string format
    • Json format
    • XML format
    • BSON format

Step 1: Create a  ASP.NET Web API application

Open Visual Studio –> File –> New –> Project –> choose template Web –> click on ASP.NET Web Application  and provide name of the application–> choose Web API from the below check boxes –> Click OK

Step 2: Create a Model and inherit GenericIdentity from Security.Principal assembly

File: UserModel.cs

 

Step 3: Now add a new class for Creating custom filter as MyAuthorization and inherit AuthorizationFilterAttribute and add the following assemblies MyAuthorization class.

File: MyAuthorization.cs

 

Step 4: Here is your CustomAuthorization Filter MyAutorization

 

Step 5: Now create an API Controller and add your custom filter. Here I’m adding for only one method for testing you can add it for the entire class or add it globally.

File: Global.asax 

Add the below line in Application_Start( ), this registers our custom Filter for the entire application.

 File: EmployeeAPIController.cs

 

Step 6: Now create your GUI and on a button click write a server side method. Form this method you can communicate with API. In my case I took a console application.

  1. If you run the web project you will get your local host URL, in my case it was http://localhost:58100/
  2. Here in the authorization Header I have added my username and password in the given format username:password and encoding it to Base64 so that it provides security.
  3. If you don’t pass valid credentials from here, in the method OnAuthorization it should add Unauthorized Response.

 

Step 7: Create console / windows/ web application to consume the API

Here I’ve created Console application.

File: Program.cs

  • Here HTTPClient is used to consume RESTful API’s.
  • And then creating the Authorization header to pass the username and password in format (username: password).
  • client.GetAsync consumes the API and returns the Result.
  • From the result we can check the Status Code.

 

Connected and Disconnected Architectures in DotNet

  • NET (Active x Data Object) is mediator between front end and back end that interacts with client side application and server side application which supports two types of Data Accessing models, one is Connection oriented and Disconnected oriented.
  • NET leverages the power of XML for accessing data using disconnected architecture. It was completely designed with XML classes in .NET Framework.

 

Note: Before going into this article you should have a basic understanding on SQL queries on select, insert, update and delete commands.

Connection String

Connection string plays very crucial role in connecting your front end application and back end application. It’s a normal string which contains the information to establish the connection between backend Database and application and secured information such as user Id and password.

  • Usually Data Providers uses this connection string which contains parameters that are needed for establishing the connection.
  • Let’s have a look at Data Providers that are supported by .Net Framework.

List of Data providers which is supported by .Net Framework.

SQL server Provider connection string:

OLEDB Provider connection string:

ODBC Provider connection string:

 

Connection Oriented Architecture

 

The architecture which needs an open connection to access the data from database is known as Connection Oriented Architecture.

Following are the list of classes on which Connection Oriented Arch is built on:

  • ConnectionUsed to establish the connection between front end and back end.
  • CommandEnables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information
  • Data Reader Used to read the data from Source. Provides high performance stream of data from data source.
  • Data Adapter
  1. Mediator between front end and back end which doesn’t have feature of containing data with in this , so it uses Dataset which is a result set.
  2. Also provides bridge between DataSet and data source.
  3. Use Command Objects to execute commands.

As Connected architecture needs connection for every transaction and creates much traffic to database since it do several trips. It shows very high impact on performance when the transaction has many commands i.e. for larger transactions. If it’s doing smaller transactions it is normally much faster.

Note:  In this Connected oriented arch the application stays connected even when it’s not doing any operations on database. To overcome this ADO.NET introduced a new component called DataSet which is a central component in Disconnected Architecture.

DataSet ds = new  DataSet( );

 

Disconnection Oriented Architecture

 

The architecture in which data can be retrieved from database even when the connection gets disconnected or closed is known as Disconnected Oriented Architecture.

Following are the list of classes on which disconnected arch is built on:

  • Connection
  • Command Builder Can generate insert, update and delete commands on single data base table for a data adapter.
  • Data Adapter
  • Data Set Contains the set of Data Tables (Data Table is set of Data Rows and Data Columns)

  • Data View It’s a view of table available in Can be used to perform insert, update and delete commands as in case of Data Set. Can be used to find, sort and filter the records.

  • Disconnected architecture is a method of retrieving the result set from database and giving the user ability to perform all CRUD operations like insert, update and delete. No traffic issues will get occurred because even though connection was gone data will be get already stored into dataset object.
  • By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance.
  • Any changes to data in DataSet doesn’t show effect on database directly, to save the changes need to use Update() method of Data Adapter.
  • Can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application.

 

Da.Update(ds,”Table Name”);

 

Differences between Connection and Disconnection Oriented Architecture

 

 


 
 

How To Upload Files In MVC Using Ajax

I Assume you have a file input control and you need to upload the files asynchronously  to your server. To do this we have FormData() i.e FormData() can be appended with the data as key-value pair.

From the following code

  1.  key: “selectedImage”, value: file
  2.  key: “userId”, value: 10

 

Step 1: Frame FormData  for passing file with  parameters (if required)

 

 

Step 2: Write Controller Action method code