csharp windows gadget



Using C# you can have your  own Windows 7. Desktop Google Gadget. Now you can  Search any web , image , Android application or even a  You tube Video directly from Your Desktop. In this tutorial we will teach you to build your own Windows 7 Desktop Google Gadget.

 First of all you may notice that above form is border less and if you make your form border less  you  won't  be able to move it after debugging your application. so for this you have to study one of our  Tutorial on  how to move Borderless form.

using System.Diagnostics;
//Design  your form  and then  you have to  following code in  Go button .
private void gobtn_Click_1(object sender, EventArgs e)     
  {
         if (webrbtn.Checked == true)
Process.Start("https://www.google.com.pk/?gws_rd=cr&ei=qHlKUobnMqSN4ATH_4CIBQ#q=" + txt.Replace(" ", "+"));

else if
                (img_rbtn.Checked == true)

Process.Start("https://www.google.com.pk/search?q="+txt+"l&um=1&ie=UTF-8&hl=en&tbm=isch&source=ogsa=Ntab=wi&ei=FnxKUrbqDKbR4QT5z4DQBw#hl=en&q=" + rep + "&tbm=isch&um=1");

else if
               
           (playrbtn.Checked == true)
Process.Start("https://play.google.com/storehl=en&q="+rep+ "&bav=on.2,or.r_cp.r_qf.&bvm=bv.53371865,d.bGE,pv.xjs.s.en_US.i8jRULGL-Ys.O&biw=1280&bih=913&dpr=1&ie=UTF-8&sa=N&tab=i8");


      else if
(youtuberbtn.Checked ==true)

Process.Start("https://www.youtube.com/results?search_query="+rep+"&oq="+rep+"&"gs_l=youtube.3..0l10.711.3520.0.3682.16.10.0.0.0.0.694.3126.3j0j1j5-4.8.0...0.0...1ac.1.11.youtube.kzRdIqQpQ-Y");

}

private void searchtb_KeyDown(object sender, KeyEventArgs e)
    {
       if (e.KeyCode == Keys.Enter)
       {
       gobtn_Click_1((object)sender, (EventArgs)e);
        }
    }

SQlite Login Form Csharp

using Finisar.SQLite;

private void SetConnection()

{

sql_con = new SQLiteConnection("Data Source=test.db;Version=3;New=False;Compress=false;"); 

}
              private void ExecuteQuery(string txtQuery)

        {
            SetConnection();
            sql_con.Open();
            sql_cmd = sql_con.CreateCommand();

            sql_cmd.CommandText = txtQuery;
            sql_cmd.ExecuteNonQuery();

            sql_con.Close();

        }


                 private void LogInBtn(object sender, EventArgs e)
      
       {

           string query = "select from  (UserInfo) where Password='" + textBox1.Text + "'";
            ExecuteQuery(query);
            SQLiteDataReader dr = sql_cmd.ExecuteReader();
            int count = 0;
            string password = "";

while (dr.Read())
            {

                 count++;

            }

            if (count == 1)

            {

               MessageBox.Show("Logged In ");
           }

            else

                          MessageBox.Show("Wrong Password");

      }
    }
}

Introduction to Break Points

The very first thing about debugging that you need to know, is the break point. It actually does exactly what the name implies - it marks a point in your code where the execution will take a break (and no, it won't actually break your code, don't worry). Placing a breakpoints in Visual Studio or one of the Express versions, is as simple as left-clicking in the gutter, which is the grey are to the left of your code. Once you click it, you will get a shiny, red circle as a reward - this circle marks where the debugger will halt when you execute your application. You better have a look for your self, and to see the effect, we will use the following piece of code: 

namespace DebugTest
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 5, b = 8, c = 233;
            int d = a + c - b;
            Console.WriteLine(d);
        }
    }
}

Now, can you predict the result just from looking at the code? Probably, and if not, you could just get out the old calculator and do the math, but that's not really the point. Just imagine the amount of code being much bigger, and let's debug the thing! Place a breakpoint by clicking in the left gutter - your IDE should now look something like this: 

Breakpoint 

Okay, you're ready to start your first debugging session. As soon as you have placed the breakpoint, you can just run your application like you normally would - from the menu, the toolbar or by pressing F5. What happens now is that the application is executed just like normal, but as soon as a line with a breakpoint is reached, the execution is stopped right before that line would be executed. In this case, it means that the variables a, b and c will have a value, but d will only have it's default value (which is 0 for an integer), since it won't be set before the line with the breakpoint has been evaluated. Now, here comes the cool part - try hovering your mouse over the different variables - the IDE will tell you what they contain. As mentioned, the d variable will have it's default value, but let's change that, by moving forward in the execution. In the next chapter, I will show you how to navigate around your code, while it's being executed.

C sharp Tweeter api call




Features

  1. Drag and drop image from any where.
  2. Auto attach  URL of your blog to your tweet image.

API Download : 

Before Creating your C# app you must know to create new app in Twitter Dev. the following link Contains only API Download and its documentation  Click Here 

Source 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;
using System.Windows.Forms;
using Tweetinvi;
using Tweetinvi.Core.Interfaces;
using Tweetinvi.Core.Interfaces.Controllers;
using Tweetinvi.Core.Interfaces.DTO;
using Tweetinvi.Core.Interfaces.Factories;
using Tweetinvi.Core.Interfaces.Models;
namespace TwitterApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        protected bool validData;
        string path;
        protected Image image;
        protected Thread getImageThread;
      
        
        string AccessToken="Your_Access_token";
        string TokenSecret = "Your_Token_Secret";
        string ConsumerKey = "Your_Consumer_key";
        string ConsumerSecret ="Your_Consumer_Secret";
        
           
        private void Form1_Load(object sender, EventArgs e)
            
        {
            
           Tweetinvi.TwitterCredentials.SetCredentials(AccessToken,TokenSecret,ConsumerKey,ConsumerSecret);
        }


        private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            if (validData)
            {
                while (getImageThread.IsAlive)
                {
                    Application.DoEvents();
                    Thread.Sleep(0);
                }
                pictureBox1.Image = image;
            
            }
        }
        protected void LoadImage()
        {
            image = new Bitmap(path);

        }



        private void Form1_DragEnter(object sender, DragEventArgs e)
        {
            string filename;
            validData = GetFilename(out filename, e);
            if (validData)
            {
                path = filename;
                getImageThread = new Thread(new ThreadStart(LoadImage));
                getImageThread.Start();
                e.Effect = DragDropEffects.Copy;
            }
            else
                e.Effect = DragDropEffects.None;
        }

        private bool GetFilename(out string filename, DragEventArgs e)
        {
            bool ret = false;
            filename = String.Empty;
            if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                Array data = ((IDataObject)e.Data).GetData("FileDrop") as Array;
                if (data != null)
                {
                    if ((data.Length == 1) && (data.GetValue(0) is String))
                    {
                        filename = ((string[])data)[0];
                        string ext = Path.GetExtension(filename).ToLower();
                        if ((ext == ".jpg") || (ext == ".png") || (ext == ".bmp"))
                        {
                            ret = true;
                        }
                    }
                }
            }
            return ret;
        }

       
        private void TweetBtn_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true && checkBox2.Checked==true)
            {

                string BlogUrl = "Click www.ziabse.blogspot.com For More...";

                byte[] file = File.ReadAllBytes(path);
                var tweet = Tweet.PublishTweetWithMedia(BlogUrl,file);
                var imageURL = tweet.Entities.Medias.First().MediaType;
                label1.Text = "Tweet Posted With Image :)";


            }

            else

                if (textBox1.Text != "")

                { 
                    Tweet.PublishTweet(textBox1.Text);
                    label1.Text = "    Tweet Posted :)";
                }

                else 
                    
                    label1.Text = "Tweet Can't Be Blank :D";
        }
    }
}

C sharp two combo boxes


Source Code 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;



namespace ComboBox

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)

        {

            comboBox1.Items.Add("BATA");

            comboBox1.Items.Add("SERVICE");
         }



        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

               comboBox2.Items.Clear();

               if (comboBox1.SelectedItem == "BATA")

            {

                comboBox2.Items.Add("BATA MALE SHOES");

                comboBox2.Items.Add("BATA LADIES SHOES");

                comboBox2.Items.Add("BATA KIDS SHOES");

            }

            else if (comboBox1.SelectedItem == "SERVICE")

            {

                comboBox2.Items.Add("SERVICE LADIES SHOES");

                comboBox2.Items.Add("SERVICE MALE SHOES");

                comboBox2.Items.Add("SERVICE KIDS SHOES");

            }

        }

    }

}


Sending SMS Via Windows Form Application Using any Android Smart Phone  Source Code  using System ; using System . C...