what is XAMARIN



XAMARIN enable developers to create native ios, android and other mobile apps using C#.NET.
It gives native user interface, native performance, shared code across platforms to every moblie platform using C#.NET.

You can also use VB.NET bussiness and data logic code.

https://xamarin.com/    - Official website to download free trial of templates to use in Visual studio to create apps.

Approaches to create native apps without XAMARIN
XCode with Objective C for IOS App, Eclipse with Java for Android App, Visual Studio with C#.NET for Windows app.
Write once, run anywhere approach with browser fragmentation is like executing app on browser which is not equal to native app.

XAMARIN's Unique approach
It gives native user interface, native performance, shared code across platforms to every moblie platform using C#.NET.

C#.NET is Awesome we have excellent features like LINQ support, Work with XML easily XDocument, Event handling and delegates.

Link for XAMARIN documents
http://docs.xamarin.com/guides/cross-platform/getting_started/beginning_a_xamarin_trial/

Link for C#.NET tutorial
http://www.dbakings.com/CSharp/Default.aspx


XAMARIN APIs are always up to date with the latest APIs.



Sunday, 23 February 2014
Posted by Sudhir Chekuri

New Features in MS Visual Studio 2013

You can change the theme of visual studio  and you can also create you own custom theme for your visual studio.

Roaming settings can be saved and applied to your visual studio by signing in using live account.

shortcut to organize code
alt + up arrow will take your code one line above
alt + down arrow will take your code one line down

you can use the search textbox at the top of visual studio to search for the options in tools to change ide options.

flag button is used to show the notifications about the updates.

you can use an option - don't copy blank text so that ctrl+c will not work if you select no text.

you can the change the selected text color in code editing window.

on the right side you can see the yellow bar which displays all the unsaved code in your code window to check easily by displaying code on mouse hover

ctrl + k + d to arrange the code in order.

Now you can do something while your build is running.

f12 will take you to the definition ie., go to definition and alt+f12 will display the definition right in the location where you have method name.

 ctrl+i is for incremental search which is used to search when you are typing the chars in search box.

In console application output screen right click on the icon to go to properties where you can change the colors, fonts and lot more.

If your cursor is inside the parenthesis you can press tab key to come out of one brace at a time.

ctrl + k + c to comment
ctrl + k + u to uncomment



Friday, 3 January 2014
Posted by Sudhir Chekuri

Tips to create youtube videos for good traffic, visits, and visitors

Tips to follow to create good youtube videos that can attract visitors

1. Length of the video should be short and not more than 1 hour.
2. Ask users to subscribe, share, like and comment after watching the video.
3. Upload videos at regular intervals of time atleast one video every week.
4. Maintain continuity and explain the continuity in the videos.
5. Create playlists and all videos into different playlist so that users can find all related videos under a playlist.
6. Choose a custom thumbnail that is related to the playlist in which you are going to add that video.
7. Make sure that you added appropriate meta data for the video such as title, tags and description.


Wednesday, 25 December 2013
Posted by Sudhir Chekuri

WPF Browse Image with OpenFileDialog and saving it in SQL Server database using C# ADO.NET Code

SQL Query to create table in SQL Server database to save image selected from WPF application


CREATE TABLE [dbo].[saveimage](
[sno] [int] IDENTITY(1,1) NOT NULL,
[img] [varchar](max) NULL
)

XAML Code in WPF application containing browse button, image and Upload button


<Window x:Class="SaveImageInDb.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel VerticalAlignment="Center" >
            <Button Name="BtnUBrowse" Height="50" Width="150" Click="BtnBrowse_Click" >Browse Image</Button>
            <Border BorderBrush="Black" BorderThickness="1" Height="200" Width="150">
            <Image Name="Img1" Height="200" Width="150" ></Image>
            </Border><Button Name="BtnUploadImage" Height="50" Width="150" Click="BtnUploadImage_Click" >Upload Image</Button>
        </StackPanel>

    </Grid>
</Window>


C#.NET and ADO.NET Code to browse image using OpenFileDialog and uploading it after showing it in image control


using Microsoft.Win32;
using System;
using System.Data.SqlClient;
using System.IO;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SaveImageInDb
{
  
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void BtnBrowse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();
            op.Title = "Select a picture";
            op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
                "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
                "Portable Network Graphic (*.png)|*.png";
            if (op.ShowDialog() == true)
            {
                Img1.Source = new BitmapImage(new Uri(op.FileName));
            }
        }
        private void BtnUploadImage_Click(object sender, RoutedEventArgs e)
        {
            var imageBuffer = BitmapSourceToByteArray((BitmapSource)Img1.Source);
            SqlConnection con = new SqlConnection("Data Source=SUDHIR;Initial Catalog=db_wpfimage;Integrated Security=True");
            SqlCommand cmd = new SqlCommand("insert into saveimage values('" + imageBuffer + "')", con);
            con.Open();
            int i = cmd.ExecuteNonQuery();
            con.Close();
            if (i > 0)
            { MessageBox.Show("Image Uploaded to database"); }
        
        }
        private byte[] BitmapSourceToByteArray(BitmapSource image)
        {
            using (var stream = new MemoryStream())
            {
                var encoder = new PngBitmapEncoder(); // or some other encoder
                encoder.Frames.Add(BitmapFrame.Create(image));
                encoder.Save(stream);
                return stream.ToArray();
            }
        }
    }
}

Monday, 23 December 2013
Posted by Sudhir Chekuri
Tag :

Windows store app code to consume web service data to display in gridview

C# code in Web service

  [WebMethod]
    public donardetails  Required(string m)
    {

        SqlCommand cmd = new SqlCommand("select* from tbl_DonateBlood where BloodGroup='" + m + "'", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        List<string> l = new List<string>();
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            string s = ds.Tables[0].Rows[i][0].ToString() + "," + ds.Tables[0].Rows[i][1].ToString() + "," + ds.Tables[0].Rows[i][2].ToString() + "," + ds.Tables[0].Rows[i][3].ToString() + "," + ds.Tables[0].Rows[i][4].ToString();
            l.Add(s);
        }
        donardetails d = new donardetails();
        d.details  = l;
        return  d;

    }

   public class donardetails
    {
       public List<string> details;
    
    }



XAML Code

 <GridView x:Name="Grid_Details"  Height="640"   >
                <GridView.ItemTemplate>
                    <DataTemplate>
                            <Border BorderBrush="Red" BorderThickness="1" Padding="11">
                                <Grid>
                           <Grid.RowDefinitions>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="40"/>
                                    <RowDefinition Height="40"/>
                                </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                             
                                <TextBlock  Grid.Row="0" Grid.Column="0"  Text="SNo:"  Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SNo}"  Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="1" Grid.Column="0" Text="Name:" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Name}" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="2" Grid.Column="0" Text="Mobile Number:" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding MobileNo}" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="3" Grid.Column="0" Text="Blood Group:" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding BloodGroup}" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="4" Grid.Column="0" Text="Location:" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                <TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding Location}" Width="150" Height="25" Foreground="Red" FontSize="15" HorizontalAlignment="Left"/>
                                </Grid>
                            </Border>
                        </DataTemplate>
                </GridView.ItemTemplate>
                </GridView>

C# Code

  public async void GetData()
         {
            
                 Give_Blood.GiveBloodServiceReference.BloodDonarWebServiceSoapClient o = new BloodDonarWebServiceSoapClient();
                 RequiredResponse a = await o.RequiredAsync(t.Text);
                 int count = a.Body.RequiredResult.details.Count;
                 if (t.Text != "bloodgroup")
                 {
                     if (count == 0)
                     {
                         MessageDialog msg = new MessageDialog("Blood Donars Not Available For '" + t.Text + "' Blood Group");
                         await msg.ShowAsync();
                     }
                 }

                 string[] rowarr = new string[count];
                 int k = 1;
                 for (int i = 0; i < count; i++)
                 {
                     string s = a.Body.RequiredResult.details[i];
                     //string s = a.Body.RequiredResult[i].ToString();
                     rowarr = s.Split(',');
                     //rowarr contains a row data 

                     for (int j = 0; j < (rowarr.Length - 1); )
                     {
                         tbl_GiveBlood h = new tbl_GiveBlood();

                         h.SNo = k.ToString();
                         j++;
                         h.Name = rowarr[j];
                         j++;
                         h.MobileNo = rowarr[j];
                         j++;
                         h.BloodGroup = rowarr[j];
                         j++;
                         h.Location = rowarr[j];
                         j++;
                         k++;
                         Grid_Details.Items.Add(h);

                     }
                 }
        }

Saturday, 14 December 2013
Posted by Sudhir Chekuri

Windows phone c# code to Call and Message from windows phone

 C# code for sending message:


            SmsComposeTask smsComposeTask = new SmsComposeTask();
            smsComposeTask.To = "6786543672"; //  phone number to whom the sms is to be sent
            smsComposeTask.Show(); // this will invoke the native sms edtior

C# code to make a call:


              phoneCallTask.PhoneNumber = "6786543672";
              phoneCallTask.DisplayName = "Name";
              phoneCallTask.Show();


Posted by Sudhir Chekuri

Windows phone C# code to get selected data by selecting checkbox in listbox

Here is the example to get selected data by selecting checkbox in listbox:

xaml code


<ListBox Height="600" Name="listBox1"  Margin="0,0,0,0" >
                     <ListBox.ItemTemplate>
                          <DataTemplate>
                        
                            <Grid x:Name="grid">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                  <ColumnDefinition Width="150"/>
                                   <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                            <CheckBox x:Name="cb" Tag="{Binding PhoneNo}" IsChecked="{Binding IsSelected}" IsEnabled="True" Checked="cb_Checked_1" Unchecked="cb_Unchecked_1" Grid.Column="0" />
                            <TextBlock x:Name="Txt_Name" Grid.Column="1" Text="{Binding Name}" VerticalAlignment="Center"/>
                            <TextBlock x:Name="Txt_PhNo" Grid.Column="2"  Text="{Binding PhoneNo}" VerticalAlignment="Center" />
                            <TextBlock Grid.Column="3"  Text="{Binding Location}" VerticalAlignment="Center"/>
                             </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
               </ListBox>


C# code:


 string option_selected = "";
        int check_count = 0;
       
        private void cb_Checked_1(object sender, RoutedEventArgs e)
        {
              check_count = 0;
              option_selected = "";
            SearchElement(listBox1);
           string s = " Total Selected Checkboxes : " + check_count.ToString()
                 + Environment.NewLine + " Value Associated : " + option_selected;
        }
        
        private void cb_Unchecked_1(object sender, RoutedEventArgs e)
        {
            check_count = 0;
            option_selected = "";
            SearchElement(listBox1);
           string s = " Total Selected Checkboxes : " + check_count.ToString()
                + Environment.NewLine + " Value Associated : " + option_selected;
        }

        private void SearchElement(DependencyObject targeted_control)
        {
            var count = VisualTreeHelper.GetChildrenCount(targeted_control);   // targeted_control is the listbox
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    var child = VisualTreeHelper.GetChild(targeted_control, i);
                    if (child is CheckBox) // specific/child control 
                    {
                        CheckBox targeted_element = (CheckBox)child;
                        if (targeted_element.IsChecked == true)
                        {
                            if (option_selected != "")
                            {
                                option_selected = option_selected + " , " + targeted_element.Tag;
                            }
                            else
                            {
                                // get the value associated with the "checked" checkbox  
                                option_selected = targeted_element.Tag.ToString();
                            }
                            // count the number of "Checked" checkboxes
                            check_count = check_count + 1;
                            return;
                        }
                    }
                    else
                    {
                        SearchElement(child);
                    }
                }
            }
            else
            {
                return;
            }

        }



Posted by Sudhir Chekuri

Followers

Total Pageviews

Powered by Blogger.

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -