-->

Saturday, October 3, 2015

How to get information about drive and their properties using windows form

Using The DriveInfo Class

The DriveInfo class provides access to information related to a drive, such as space availabe on a drive, total storage space of the drive and drive name. The DriveInfo class can also be used to query the format of a drive, such as NTFS or FAT and type of the drive, such as fixed, CD-ROM, or removable. This class throws an exception if a drive is currently not ready. For example, if we want to get information of a CD-ROM that does not contain a CD in it, The DriveInfo class will throw an exception. We can avoid such exceptions by using the IsReady property of the DriveInfo class. If the DriveInfo property returns true, we can access a drive without an exception.
In previous example we have been accessed Logical drives of the system. See previous image

How to access drive of the system

Now in this example we will access Logic drive information such as drive type , drive size and free space of the drive. So first we take four label control to the design window after that handle comboBox1_SelectedIndexChanged event in the program.

Complete code


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] str = Directory.GetLogicalDrives();
            foreach (string item in str)
            {
                comboBox1.Items.Add(item);

            }

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string drive = comboBox1.SelectedItem.ToString();
                label1.Text = "you have Selected Drive " + drive;
                DriveInfo info = new DriveInfo(drive);
                label2.Text = "Drive Type " + info.DriveType.ToString();
                label3.Text = "Free space on drive " + info.AvailableFreeSpace.ToString();
                label4.Text = "Total Size " + info.TotalSize.ToString();



            }
            catch (Exception exp)
            {

                label1.Text = exp.Message;

            }
        }
    }
}


Output
How to Access drive information in c#

Thursday, October 1, 2015

Use pen paint tool online using html5 canvas with JQuery

Introduction
In this article i will show you how to draw using pencil, i mean to say your mouse cursor behaves like pencil on specific area of web browser. You can draw something on web browser using mouse cursor. Also you can use this for digital signature. Through this article i will explain how to design paint online for drawing something.



Description
In this article i will use Html5 canvas with JQuery. i will use canvas for drawing area and sketch.js file is used for drawing on it. I explained Button working as file upload control using JQuery, Open and close new window using Jquery , event inside event example in JQuery etc.

Source code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://intridea.github.io/sketch.js/lib/sketch.min.js"></script>
    <script>
        $(function () {
            $('#sketch').sketch();

            $(".digital a").eq(0).attr("style", "color:#ddd");
            $(".digital a").click(function () {
                $(".tools a").removeAttr("style");
                $(this).attr("style", "color:#000");
            });


            $("#savebtn").bind("click", function () {
                var base64 = $('#sketch')[0].toDataURL();
                $("#imgc").attr("src", base64);
                $("#imgc").show();
    });
        });
     </script>


</head>
<body>
    <div class="digital">
        <a href="#sketch" data-tool="marker">marker</a>
        <a href="#sketch" data-tool="remover">remover</a>
            </div>

    <br/>
    <canvas id="sketch" width="600" height="300"></canvas>
    <br/>
    <input type="button" id="savebtn" value="image save"/>
    <img id="imgc" alt="" style="display:none"/>



</body>
</html>

Code Generate the following output

WPF: Show Each row details in DataGrid when we click on rows

Introduction
In this article i will explain how to bind the DataGrid with list, which is already bind with public class. Also explain, when we click on any row of DataGrid then it display detailed information of selected row. This things is possible through RowDetailsTemplate of DataGrid Template. In this DataGrid we have two TextColumn and one TextBlock.

Source Code

<Grid Name="grid1" Margin="0,10,0,0">
        <DataGrid Name="dg" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding Id}"/>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}"/>


            </DataGrid.Columns>
            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Details}"/>
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>          
        </DataGrid>    

    </Grid>

Code Behind 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for addcolumn.xaml
    /// </summary>
    public partial class addcolumn : Window
    {
        public addcolumn()
        {
            InitializeComponent();
            List<student> students = new List<student>();
            students.Add(new student() { Id = 1, Name = "Jacob" });
            students.Add(new student() { Id = 2, Name = "Bill" });
            students.Add(new student() { Id = 3, Name = "Ammey" });
            students.Add(new student() { Id = 4, Name = "John" });
            students.Add(new student() { Id = 5, Name = "kitty" });
            dg.ItemsSource = students;
       
        }
     public class student
     {
         public int Id { get; set; }
         public string Name { get; set; }
         public string Details
         {
             get
             {
                 return String.Format("{0}=>this is row id and {1}=> this is row name", Id, Name);
             }
         }
     }
           
    }
}

Code generate the following output

WPF: Show Each row details in DataGrid when we click on rows

Wednesday, September 30, 2015

fire event inside another event using JQuery

Introduction
In this article i will show you how to fire event inside event using JQuery. I will give an example of it. In this article, first we create a table using JQuery then append the table with the dynamically created table. First, we get the column of the table for inside event then generate function on table row. Lets check the example.

Source code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="browserdetails.aspx.cs" Inherits="browserdetails" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <title></title>
    <script>
 

        $(function () {
            $("#btncreate").click(function () {
                var newtable = '<table id="mytable"><tr><td>Column1</td><td>Column2</td></tr><tr><td>Row11</td><td>Row12</td></tr></table>';
                $("#tbcontainer").append(newtable);

                var tblid = $("#tbcontainer table").attr("id");
           
                $("#" + tblid).on("click", "tr:last", function () {
                    var val1 = $(this).find("td").eq(0).text();
                    var val2 = $(this).find("td").eq(1).text();
                    alert(val1 + "  " + val2);
                })
            })
        })
</script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    <label id="tbcontainer" />
   
        <input id="btncreate" type="button" value="button" />
    </div>
    </form>
</body>
</html>

Code Generate the following output
fire event inside another event using JQuery

Open and close new window using JQuery

Introduction
In this article i will show you how to open new window when we click on button using JQuery. I will give an example of it. Also do some thing like when we click on other button then opened new window will closed also mentioned in the example.

Description
I have explained Get browser details using JQuery, Button work as fileupload control in JQuery.
Source code
<!DOCTYPE html>
<html>
<head>
    <title> OPen and close window using JQuery </title>
</head>
<body>

    <form name="form1">
        <input type="button" value="Open New Window" id="btnOpen" />
        <p> <input type="button" value="Close New Window" id="btnClose" />

    </form>
    <script src="https://code.jquery.com/jquery-2.1.4.js"></script>
    <script type="text/javascript">
     
        var Window1;
        $(function () {
            $(form1.btnOpen).click(function () {
                Window1 =  window.open('', 'YourWindow', 'height=500,width=500');
            });
            $(form1.btnClose).click(function () {
                Window1.close();
            });
        });

   
 
    </script>
</body>
</html>
Code Generate the following output
Open and close new window using JQuery

Tuesday, September 29, 2015

Get browser details using JQuery

Introduction 
In this article i will show you how to determine which web browser is selected for your application or you can say that how many user open your website in which web browser. Through this article i will show you Browser type, Browser version etc. Lets check the example of getting browser details using JQuery.



Description
In previous article i explained Button work as fileupload control in JQuery  , Select box validation using JQuery , JQuery TextBox validation when it emptyRetrieve selected Radio button and checkbox value using JQueryHow to show popup on page load using JQuery .

Code Example:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="browserdetails.aspx.cs" Inherits="browserdetails" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <label id="blbl" />
        <script>
            $(function () {

                $.each($.browser, function (i, val) {

                    $("#blbl").append(i + '=>' + val + '<br/>');

                });
             
            })

        </script>
    </div>
    </form>
</body>
</html>
Code Generate the following output

Get browser details using JQuery

Sunday, September 27, 2015

How to deploy windows phone 8.1 application to device

If you want to run your windows phone 8.1 application to your physical device or you can say phone that you can follow these instruction which is mentioned below:
1. Search windows phone developer registration 8.1 from your window start screen.


windows phone 8.1 registration

2. Register your windows phone now.

windows phone 8.1 registration

3. After successfully registration, set platform of windows phone by build menu in visual studio like:

Configuration manager of build menu
4. Select Platform as "ARM" from Dropdown option.

windows phone device
 5. Now, connect your phone with your computer from USB cable.
6. Run your application.
© Copyright 2013 Computer Programming | All Right Reserved