Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, 21 June 2018

How to capture image in Xamarin Forms? – Solved

Hi developers, I am writing this blog for helping one of my internet friend who asked for my help.

Query – How to capture an image in Xamarin Forms? And image size should not be greater than 5MB in size?

In this article, I have explained not only how to capture an image by phone camera but also an easy way to validate the size of an image (highlighted in yellow color) whose size should not be greater than 5MB in size with a real-time example where one can use this and learn more.

In this example, I am capturing an image using Mobile Camera using Xamarin Forms.

(Note: You need to install Xamarin.Mobile(or xamstore-xamarin.mobile) from Nuget package manager)

Practical Implementation:

TakeAPicturePage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="DemoXamarin.TakeAPicturePage">
    <ContentPage.Content>
        <StackLayout>
            <Button Clicked="TakeAPicture_Clicked" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

TakeAPicturePage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Media;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace DemoXamarin
{
       [XamlCompilation(XamlCompilationOptions.Compile)]
       public partial class TakeAPicturePage : ContentPage
       {

              public static MediaPicker MediaPicker;
              public TakeAPicturePage ()
              {
                     InitializeComponent ();
              }

        private async void PickAPicture_Clicked(object sender, EventArgs e)
        {
            if (IsBusy)
                return;

            try
            {
                IsBusy = true;

                var picker = MediaPicker;
                if (!picker.IsCameraAvailable)
                    Console.WriteLine("No camera!");
                else
                {
                    try
                    {
                        MediaFile file = await picker.PickPhotoAsync();

                        byte[] bytes = new byte[0];

                        var memoryStream = new MemoryStream();
                        {
                            file.GetStream().CopyTo(memoryStream);
                            file.Dispose();

                            bytes = memoryStream.ToArray();
                        }

                        //Validating image
                        int fileSize = bytes.Length;
                        if (fileSize > 5242880)
                        {
                            Console.WriteLine("File Attachment should be less than 5 MB");
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        Console.WriteLine("Canceled");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
    }
}

Demo 



Hope you find the article helpful and interesting. For any query, comment us below.

 

Click imagination hunt to read latest blogs.



Keep learning and sharing...
Read More »

International Yoga Day: Importance You Need To Know

In India 21st June is celebrated as International Day of Yoga. Yoga is fundamentally a spiritual discipline based on an extremely precise science which focuses on bringing harmony between mind and body. It is an art and science for a healthy living. The word “Yoga” is derived from the Sanskrit root ‘yuj’ meaning “to join”, ”to yoke” or “to unite”. 



Yoga is not a set of exercise that keeps the body fit. It enhances health assurance and wellness. According to Yogic scriptures, the practice of Yoga leads to the fusion of an individual consciousness with the universal consciousness.  According to modern scientists, everything in the world is just a manifestation of the similar quantum firmament. One who experiences or fell this oneness of existence is said to be “Yoga” and is termed as a yogi who has attained a state of freedom, referred to as mukti, nirvana , kaivalya or moksa.




Yoga works to the extent of one’s body and soul. “Yoga” also refers to an intellectual science comprising of discipline through which human beings can achieve union between the body and mind to attain self-realization. The aim of Yoga practice is to overwhelm all kinds of sufferings that lead to a sense of freedom in every walk of life with holistic health, happiness, and harmony.


Share your Yoga experience with others and make them happy. 
#yoga #yogaeverydamnday #internationalDayofYoga2018
Read More »

Monday, 18 June 2018

How to find relationship between Purchase order table and Cost Center in Dynamics AX? – Solved

Hi developers, I am writing this blog for helping one of my internet friend who asked for my help.

Query - How to get Financial Dimension Cost Center value for the Report in Dynamics AX? He needs financial dimension cost center value for Purchase order report. 



Solution Query:

select distinct CC.NAME,D1.DIMENSIONATTRIBUTEVALUESET
from dbo.PURCHTABLE P
join dbo.PURCHLINE PL on P.PURCHID = PL.PURCHID
left join DIMENSIONATTRIBUTEVALUESETITEM D1 on D1.DIMENSIONATTRIBUTEVALUESET = PL.DEFAULTDIMENSION
left join DIMENSIONATTRIBUTEVALUE D2 on D2.RECID = D1.DIMENSIONATTRIBUTEVALUE
left join DIMENSIONATTRIBUTE D3 on D3.RECID = D2.DIMENSIONATTRIBUTE        
left join DimAttributeOMCostCenter CC on CC.VALUE = D1.DISPLAYVALUE
where D3.NAME = 'CostCenter'


Hope you find the article helpful and interesting. For any query, comment us below.

 

Click imagination hunt to read latest blogs.


Keep learning and sharing...
Read More »

Wednesday, 13 June 2018

What is Blockchain?

This is the common assumption that the most of the people think of blockchain as the technology that power bitcoin. While this was its original purpose, blockchain capable to do much more. despite the sound of the word, there's not just one blockchain. The blockchain is process for a whole suite of the distributed ledger technologies that can be programmed to record and track anything of value from land or property deal, financial transition, and even medical records.


You might be thinking: we already have processes in place to track data. What's so special about blockchain? Let's break down the reason  why blockchain technology stands to revolutionize the way we interact with each other:

Reason 1: The way it tracks and stores data. Blockchain stores information in batches, known as blocks, that are linked together in a proper order to form a continuous line, a chain of blocks. If you make a change to the information stored in the specified block. You don't rewrite it instead, the change is stored in a new block showing that x changes are made at particular time and date.

It's is a non-destructive way to track data changes over the period of time. Here's one example. 
Let's say there was a dispute between Tony Stark and Capt. America over who found a piece of Tesseract cube that been in the shield for years because blockchain technology uses the ledger method, there is an entry in the ledger showing that Capt. first found the cube in 1942. Later on, cube passed to another person but particular date and time are stored.

Now, here's where things get really interesting. Unlike the age-old ledger method specifically a book. The blockchain is designed to be decentralized and distributed across a large network of computers. This decentralizing of information reduces the ability for data tampering.



Reason 2: It creates trust in the data. Before a block can be added to the chain, a few things happen. First, a cryptographic puzzle must be solved thus creating a block. Second, the computer that solves the puzzle shares this solution to all the other computer in the network, this is known as the Proof of work. Third, the network will then verify this proof of work and, if correct the block will be added to the chain. 

Reason 3: Blockchain technology is such a game changer that No more Intermediaries.

Read More »

Tuesday, 12 June 2018

Communication System Multiple Choice Questions

 Electronics and Communication Multiple Choice Questions


1. In PCM if the transmission path is very long?
a. repeater stations are used
b. pulse width may be increased
c. pulse amplitude is increased
d. pulse spacing is reduced


2. Frequency shift keying is used mostly in?
a. radio transmission
b. telegraphy
c. telephony
d. none of these


3. Leak type bias is used in a plate modulated class C amplifier to?
a. increase the bandwidth
b. prevent excessive grid current
c. prevent tuned circuit damping
d. prevent overmodulation


4. The frequency of normal sound wave determines its?
a. quantity
b. echo
c. loudness
d. pitch


5. Which of the following is most likely to be found in an SSB transistor?
a. Class A, RF output amplifier
b. Class B, RF amplifier
c. tuned modulator
d. Class C, audio amplifier


6. A longwave AM Broadcast transmitter needs?
a. very small carrier power
b. very large carrier power
c. small carrier power
d. large carrier power


7. The term noise temperature is used for?
a. white noise source only
b. thermal noise source only
c. non-thermal noise source only
d. all of the above


8. The thermal noise is due to random?
a. motion of atoms and molecules
b. motion of free electrons
c. vibrations of atom about their mean position, inside the conducting medium
d. none of these


9. At high frequencies, which of the following types of noise become most important?
a. flicker noise
b. short noise
c. thermal noise
d. transit time noise


10. Which of the following is not uniformly distributed over all frequencies?
a. white noise
b. flicker noise
c. short noise
d.  thermal noise


Answers:


1. a
2. b
3. b
4. d
5. b
6. b
7. d
8. b
9. d
10. b


Share your comments. #gate #psu #eto
Read More »

Monday, 11 June 2018

Control System Multiple Choice Questions

 Electronics and communication Multiple Choice Questions


1. Poles are the complex frequencies of a transfer function where the response becomes?
a. infinite
b. zero
c. oscillatory
d. decaying


2. Zeros are the complex frequencies of a transfer function where the response becomes?
a. infinite
b. zero
c. oscillatory
d. decaying


3. Which of the following is an open loop system?
a. ward Leonard control
b. Amplidyne
c. Armature controlled d.c. motor
d. Field controlled d.c. motor


4. A driver maintains the speed of a car at 50 Km per hour. Here the feedback element is?
a. steering wheel
b. needle of the speedometer
c. eyes
d. all of these


5. Transient response of a system is basically because of?
a. coupling
b. forces
c. friction
d. stored energy


6. In a critically damped system, the damping factor of the system is?
a. zero
b. unity
c. less than unity
d. greater than unity


7. With feedback, the transient response of the system as compared to that without feedback?
a. decays slowly
b. decays more quickly
c. rises at a faster rate
d. remain unaltered


8. By increasing the gain k of the system, the steady state error of the system?
a. decreases
b. increases
c. remain unchanged
d. may increase or decreases


9. Integral error compensation is also called?
a. proportional minus integral compensation
b. proportional plus integral compensation
 c. proportional plus derivative compensation
d. proportional minus derivative compensation


10. For 2% tolerance band, the settling time the second order linear system is? Where t is the time constant.
a. t/2
b. t
c. 2t
d.  4t


Answers:

1. a
2. b
3. d
4. b
5. d
6. b
7. b
8. a
9. b
10. d

Share you comments. #gate #psu #eto


Read More »

Sunday, 10 June 2018

How To Get the Geocode of An Address in Xamarin forms maps? [Solved]

This article is a step by step guide to get the Geo-coordinates of an Address in Xamarin Forms. This is also known as Reverse Geocode.

For this article, we need to install Xamarin.Forms.Maps package from NuGet package. This package provides GeoCoder class which converts string Address to latitude and longitude.

We will proceed step by step to understand better.

Step-1: Create a New Xamarin Forms Project. For this Open Visual Studio -> File -> New Project -> in the left pane, under the Installed tab, select Visual C# -> Select Mobile App (Xamarin.Forms) -> Enter File Name and Location. -> Click the Ok button -> Select a template (Blank App), check all Platform and Sharing Strategy as “Shared Project” -> Click Ok button.





Step-2: Install Xamarin.Forms.Maps Package. In the Menu bar, select Tools TAB -> Select NuGet Package Manager -> Select Manage NuGet Packages for Solutions -> Under “Browse” TAB search Xamarin.forms.maps and install for all Mobile O.S. -> For pop-up click “OK” and “I Accept” button. -> Wait till the output Window shows “Finished”.



Step-3: Add Xamarin.Forms.Maps package.

For Android:

Expand Android project -> Open MainActivity.cs File.
Add Namespace: using Xamarin.Forms.Maps;

Add following line of code below Forms.Init()

global::Xamarin.Forms.Forms.Init(this, bundle);
global::Xamarin.FormsMaps.Init(this, bundle);

For iOS:

Expand iOS project -> AppDelegate.cs Open File.

Add Namespace: using Xamarin.Forms.Maps;

Add following line of code below Forms.Init();

global::Xamarin.Forms.Forms.Init();
global::Xamarin.FormsMaps.Init();

Step-4: By default MainPage.xaml is created if not Add a New Item -> Under Installed Tab -> Expand Visual C# -> Xamarin.Forms -> Select Content Page with extension (FileName.xaml) -> Click Add button.

Step-5: Some configuration that you need to follow strictly.

For Android:

To use Google maps on Android device you need to generate an API key and place it on your Android project. Follow the instruction for generating API key Obtaining Google Map Key.

Note: If the key is not valid/added you will not be able to see the map or some grey screen appears.

Once the key is generated you need to place the key in the Android project Properties/AndroidManifest.xml file. For than Open Android project -> Open Properties -> Open AndroidManifest.xml file.

Example:

<application android:label="MapsDemo.Android">
    <!-- Put your Google Maps V2 API Key here. -->
    <meta-data android:name="com.google.android.geo.API_KEY" android:value="##############################################" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>

Also, you need to enable some permissions. R.Click on the Android project and select Properties -> On the Left pane select Android Manifest -> Scroll down to see the Required Permission and check the below permissions:

1. AccessCoarseLocation
2. AccessFineLocation
3. AccessLocationExtraCommands
4. AccessMockLocation
5. AccessNetworkState
6. AccessWifiState
7. Internet

And save the file. To see the added permissions. Open Android project/ Properties/AndroidManifest.xml file.

Example:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

Step-6: Add below code on MainPage.xmal and MainPage.xaml.cs file.

Use below code on MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:MapsDemo"
             x:Class="MapsDemo.MainPage"
             Title="Map View">
    <ContentPage.Content>       
    </ContentPage.Content>
</ContentPage>


Use below code on MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Maps;

namespace MapsDemo
{
    public partial class MainPage : ContentPage
    {
        Geocoder geocoder;

        public MainPage()
        {
            InitializeComponent();
            geocoder = new Geocoder();
            AddMapComponent();
        }

        public async void AddMapComponent()
        {
            try
            {
                IList<Position> positions = new List<Position>();

                var addressPosition = new Position();
               
                //Test : Getting Positions For Address
                var address = "The City of Taj Mahal, Agra, Uttar Pradesh, India";
                var approximateLocations = await geocoder.GetPositionsForAddressAsync(address);
                foreach (var position in approximateLocations)
                {
                    addressPosition = new Position(position.Latitude, position.Longitude); ;
                }
                positions.Add(addressPosition);

                var map = new Map(MapSpan.FromCenterAndRadius(new Position(0, 0), Distance.FromMiles(0.3)))
                {
                    IsShowingUser = true,
                    MapType = MapType.Street,
                    HeightRequest = 100,
                    WidthRequest = 960,
                    VerticalOptions = LayoutOptions.FillAndExpand
                };

                var stack = new StackLayout { Spacing = 0 };
                stack.Children.Add(map);
                Content = stack;

                foreach (var position in positions)
                {
                    var pin = new Pin
                    {
                        Type = PinType.Place,
                        Position = position,
                        Label = "Imagination Hunt"
                    };

                    map.Pins.Add(pin);
                }

                if (positions.Count() > 0)
                {
                    MapSpan span = new MapSpan(positions.First(), 360, 360);
                    map.MoveToRegion(span);
                }
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee);
            }
        }
    }
}

Step-7: Run the project.




Hope you find the article helpful and interesting. For any query, comment us below.

 

Click imagination hunt to read latest blogs.



Keep learning and sharing...
Read More »

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...