Monday 12 June 2017

Implement open Weather Api using C# using the windows application

 you can implement this weather API
against City or the against the Lattitude and Longitude

while designing  I used  eight labels to show the Values of Respected JSON
first u need to install NuGet package using package manager console
 Install-Package Newtonsoft.Json
 private void Frm_WeatherReport_Load(object sender, EventArgs e)
        {
string latitide = "19.9975";
            string longitude = "73.7898";

            const string apikey = "You nee
d to put your key here ...";
     
                using (WebClient wcumum = new WebClient())
                {
                    try
                    {

                        // Ag city
                       // string request = string.Format("http://api.openweathermap.org/data/2.5/weather?q={0}&appid={1}&units=metric", textBox1.Text, apikey);
                   
                        String request = "http://api.openweathermap.org/data/2.5/weather?lat=" + latitide + "&lon=" + longitude + "&appid=f63af5e4778e517ec5e7599d6172eae5";
                        var jsonres = wcumum.DownloadString(request);
                        var objectres = JsonConvert.DeserializeObject<OpenWeatherMap.Root>(jsonres);
               
                        OpenWeatherMap.Root resultobj = objectres;
                 

                        string ctry = string.Format("{0}", resultobj.sys.country);
                        string cty = string.Format( resultobj.name);
                        string lttd = string.Format("{0}", resultobj.coord.lat);
                        string lngtd = string.Format("{0}", resultobj.coord.lon);
                        string tmprtr = string.Format("{0} C", resultobj.main.temp);
                        string wthr = string.Format("{0}:{1}", resultobj.weather[0].main, resultobj.weather[0].description);
                        string hmdty = string.Format("{0}", resultobj.main.humidity);
                        string prssr = string.Format("{0}", resultobj.main.pressure);
                        string wind = string.Format("{0}", resultobj.wind.speed);

                         wind = string.Format("{0}", resultobj.wind.speed);

                         lcity.Text = cty + ", " + ctry;
                        ltemp.Text = (float.Parse(tmprtr.ToString().Remove(tmprtr.Length - 2)) - 273.15).ToString().Substring(0, 5) + " °C";
                        lwind.Text = wind+" mph";
                        lhumidity.Text = hmdty+ " %";
                        lpressure.Text = prssr+" hpa";
                 
                        lweather.Text = wthr;
                    }
                    catch (Exception exc)
                    {
                        XtraMessageBox.Show("Please enter correct lattitude and langitude.", "Weather Master", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                }









 public class OpenWeatherMap
    {
        public class Coord
        {
            public double lon { get; set; }
            public double lat { get; set; }
        }

        public class Sys
        {
            public int type { get; set; }
            public int id { get; set; }
            public double message { get; set; }
            public string country { get; set; }
            public int sunrise { get; set; }
            public int sunset { get; set; }

        }

        public class Weather
        {
            public int id { get; set; }
            public string main { get; set; }
            public string description { get; set; }
            public string icon { get; set; }
        }

        public class Main
        {
            public double temp { get; set; }
            public int humidity { get; set; }
            public double pressure { get; set; }
            public double temp_min { get; set; }
            public double temp_max { get; set; }
        }

        public class Wind
        {
            public double speed { get; set; }
            public double gust { get; set; }
            public double deg { get; set; }
        }

        public class Clouds
        {
            public int all { get; set; }
        }

        public class Root
        {
            public Coord coord { get; set; }
            public Sys sys { get; set; }
            public List<Weather> weather { get; set; }
            public string @base { get; set; }
            public Main main { get; set; }
            public Wind wind { get; set; }
            public Dictionary<string, double> rain { get; set; }
            public Clouds clouds { get; set; }
            public int dt { get; set; }
            public int id { get; set; }
            public string name { get; set; }
            public int cod { get; set; }
        }

Thursday 13 April 2017


Wednesday 1 February 2017

Learn Python - Introduction



    


Hello guys, Welcome to mydotnetwebapp.blogspot.in

Introducing Python: The Python programming language was created by Dutchman Guido van Rossum in thelate1980s.

"  Python is a widely used, general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C. The language provides constructs intended to enable clear programs on both a small and large scale. "

How the python programming language is different:
  1. Programs are not cluttered up with braces ({…}) and semicolons (;).
  2. Python implements structure using indentation (whitespace)rather than punctuation.
  3. The Python keywords are powerful, limited in number, and do what you expect them to do.
  4. If you can’t work out a way to do something in your code, there is always a library somewhere that does it for you.
  5. You can get an awful lot done with a limited knowledge of the language.

Downloading Python:
All Python downloads can be found at "https://www.python.org/downloads/ "You need to choose a Python version before you download.there are two versions - V2 ,V3 .

Download Python for Windows:
Download and Installing steps of python: - 
Download the python:
Fig1: Download and Install python 
  I downloaded python version 3.6.0 on my PC
After download:
Install the python 
Fig2: Download and Install Python
1) checkbox "Install launcher for all users" must be checked.
2)"Add Python 3.6 to PATH ": --- check this check box.
3) After that click on "Install Now".
Fig3:Download and Install Python

Fig4: Download and Install Python
After that close the window.
Python is Successfully installed.
If you are facing any problem then check the path 
go to : control panel-"edit the system environment variables ". 
Fig5: Download and Install Python

click on the Environment Variables, and verify your path.
Fig6: Download and Install Python

open the Python IDLE,
Fig7: Python IDLE

 Editing Your Python Code:I recommend using either a language-sensitive editor or the editor that comes with your python installation.

use the IDLE Integrated Development Environment ( IDE ) or perhaps Notepad++, notepad.

Saturday 10 December 2016

C# Timer

Hello guys ,
Welcome to http://mydotnetwebapp.blogspot.in . This Article is totally regarding about " Timer control " which is the most important part in c# Programming.

C# Timer Control


1) use :  A) C# Timer control is use for designing Time Oriented windows applications .
B) A Timer control raises an event at a given time interval . If you need to execute some code after certain interval of time so , you can use a Timer control .

2) namespace : System.Timers ; 

3) Properties (Behavior) : C# Timer control has two important properties  1) Enabled  2) Interval
Enabled property of timer indicate that Timer is currently Running . We can set this property to true for start and false for stop.
Interval property indicates time on in milliseconds.
1 second  = 1000 milliseconds . 
2 second = 2000 milliseconds  and so on ...

Timer t1 = new Timer();
t1.Interval = 2000;
timer1.Enabled = true;

4) Example : C# Timer control

C# Timer

C# Timer Properties




Example :

 //For Blinking Label
        private void timer1_Tick(object sender, EventArgs e)
        {
            Random rm = new Random(); 
            int a = rm.Next(0,255);    
/* generate random number from 0 to 255 */
            int b = rm.Next(0, 255);
            int c = rm.Next(0, 255);

            label1.ForeColor = Color.FromArgb(a,b,c);
/* label1 starts blinking with random colors .*/
        }

 Set Timer Properties : 
1) enabled = true ;
2) Interval = 100 ; 

5) Event : 

1)  Disposed :  When the component is Disposed by a call to the Dispose Method . 

2)  Elapsed :  When the Interval Elapses .

Friday 2 December 2016

Love Meter

Love Meter | Love Percentage Checker - Windows Application

Hello guys ,
Welcome to mydotnetwebapp.blogspot.in . In this session , I am gonna tell you about creating a simple love calculator using c# programming language .
Actually creating any type of window based application is quite easy , all we have to do is to create your own efficient logic .


love calculator | love meter test | love compatibility Checker


I created this application using c# programming language , but you can use the same logic in any other programming languages.

lets start Our Love meter Test ,

1) Open Microsoft Visual Studio
2) Select Windows Forms Application
3) Start Coding 


love meter


Click here to [Download] Love Meter



step 1 :  Two blinking labels.

For blinking the label you have to drag and drop the timer in the project . and on the timer_click event ... import the following code.

Set the Timer Properties.

Double click on the [timer1]


 private void timer1_Tick_1(object sender, EventArgs e)
        {
            Random rm = new Random();
            int a = rm.Next(0, 255);
            int b = rm.Next(0, 255);
            int c = rm.Next(0, 255);
            label3.ForeColor = Color.FromArgb(a, b, c);
            label4.ForeColor = Color.FromArgb(a, b, c);
         }

step 2: Button click Event
      

 private void Form1_Load(object sender, EventArgs e)
        {
            label4.Visible = false;

        }

private void button1_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("Person Name - Invalid");
            }
            else
            {
                int sum, sum1;
                sum = 0;
                sum1 = 0;
                int xsum = 0;
                int xxsum = 0;
                label4.Visible = true;
                string str = textBox1.Text;
                string str1 = textBox2.Text;

                foreach (int temp in str)
                {
                    sum = sum + temp;
                }
                foreach (int temp1 in str1)
                {
                    sum1 = sum1 + temp1;
                }
                int rem, rem1;
                while (sum != 0)
                {
                    rem = sum % 10;
                    xsum = xsum + rem;
                    sum = sum / 10;
                }
                while (sum1 != 0)
                {
                    rem1 = sum1 % 10;
                    xxsum = xxsum + rem1;
                    sum1 = sum1 / 10;
                }
                int total;

                total = 3 * (xsum + xxsum);
                if (total >= 100)
                {
                    //Thread.Sleep(2000);
                    label4.Text = "98" + "%";

                }
                else
                {
                    //Thread.Sleep(2000);
                    label4.Text = total.ToString() + "%";
                }
            }
        }
        


Click here to [Download] Love Meter


Everything About Love Meter in One Pdf [Download]


Download Problem : Ask me
[ukademangesh@gmail.com]
I will send You Love Meter Test solution file Directly.


Keyword (by relevance) : 
love test | love percentage | love compatibility
love test game | love meter test | love meter game
love meter calculator | love calculator |love calculator game | love meter | love tester online

Tic-tac-toe

Tic-tac-toe

Hello guys ,
Welcome to mydotnetwebapp.blogspot.in. In this session , I am gonna tell you about creating a simple Tic-Tac-Toe game using c# programming language 

Tic-Tac-Toe






Click here to download [tic-tac-toe]



1) Basic Requirements : 

1)Two panels
2)Three Labels :1 label for blinking purpose(Include).
3)Two Text boxes
4)10 Buttons : (9 simple , 1 play).



Requirements

2) Logic And Coding :

1) take a counter(Initial value of counter = 1) that can increase after every button click.
2) We are developing the game for two players so , A) First player  B) Second Player
3) For 'A' (First Player)
       i) 'A' Starts the game So , When 'A'(first player) clicks on the button then the background color of that button is automatically changes to 'BLUE'.
   ii) This is possible because : (if counter = 1 , 3 , 5 , 7 , 9 , then assign button's background to 'BLUE'.)
   iii) At every turn blocks(Buttons) are turned into 'BLUE' .  
   iV) counter values will be 1 , 3 , 5 , 7 ,9 .  
4) 3) For 'B' (Second Player)
       i) 'B' Starts the game after "A's " turn So , When 'B'(Second player) clicks on the button then the background color of that button is automatically changes to 'RED'.
   ii) This is possible because : (if counter = 2 , 4 , 6 , 8 then assign button's background to 'RED'.)  
   iii)  At every turn blocks(Buttons) are turned into 'RED' .
   iv) counter values will be 2 , 4 , 6 , 8 .
5) counter table

counter value        turn
   1            A (first player) ---- BLUE
   2            B (Second player) --- RED
   3            A (first player) ---- BLUE
   4            B (Second player) --- RED
   .
   .
   .

So on...

6) Checking the Condition ...
if the buttons which are in sequence ( 1 , 2 , 3) || ( 1 , 4 , 7) || ( 1 , 5 , 9) || ( 2 , 5 , 8) || ( 3 , 6 , 9) || ( 3 , 5 , 7) || ( 4 , 5 , 6) || ( 7 , 8 , 9)  

are all 'BLUE' Or all 'RED' then Particular player will declare as a winner.

step 1 : Just Drag and Drop the Labels And Text-Boxes.


step 2 : Put 9 buttons in one panel (called Panel2) and arrange them in following way .

Buttons Arrangement 
step 3 : At the time of Form_load 

 private void Form1_Load_1(object sender, EventArgs e)
    {
            panel2.Visible = false; 
/*panel2 is not visible until you specify the term, like panel2.visible = true */
      }

step 4 : Write Code for each Event generated by button_click.

public string s1, s2, s3, s4, s5, s6, s7, s8, s9; 
/*all these string variables store the name of button's Background color.*/
public int count = 1  

private void button1_Click(object sender, EventArgs e)
        {            
/* if counter == 1 , means first click (1st player) , counter = 2 , means second click (second Player) ...*/
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)   
            {
/* if counter = 1,3,5,7,9 means all the clicks done by first player */ 
                button1.BackColor = Color.Blue;
/*Assign the  " BLUE " color for First player */
                s1 = button1.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;
                    }
                }
                catch (Exception ee){}
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
/ *if counter = 2,4,6,8 means all the clicks done by Second Player */


/*Assign " Red " for second player */
                button1.BackColor = Color.Red;
                s1 = button1.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
/*label4 is present at the bottom of application layout (UI) */
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;
                    }
                }
                catch (Exception ee){}
              }
            count++; 
         


Do the same coding for Every Button_click. 

private void button2_Click(object sender, EventArgs e)
        {
            
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button2.BackColor = Color.Blue;
                s2 = button2.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }

                }
                catch (Exception ee)
                {
                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button2.BackColor = Color.Red;
                s2 = button2.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;
                    }
                    
                }
                catch (Exception ee)
                {
                }
            }
            count++;
        }


private void button3_Click(object sender, EventArgs e)
        {
            
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button3.BackColor = Color.Blue;
                s3 = button3.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }

                }
                catch (Exception ee)
                {
                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button3.BackColor = Color.Red;
                s3 = button3.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;

                    }

                   
                }
                catch (Exception ee)
                {

                }

            }
            count++;
        }


 private void button4_Click(object sender, EventArgs e)
        {
            
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button4.BackColor = Color.Blue;
                s4 = button4.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                       
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }
                    
                }
                catch (Exception ee)
                {
                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button4.BackColor = Color.Red;
                s4 = button4.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;

                    }
                    
                }
                catch (Exception ee)
                {

                }
            }
            count++;
            
        }

 private void button5_Click(object sender, EventArgs e)
        {
           
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button5.BackColor = Color.Blue;
                s5 = button5.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        //if(s1 == "Blue")
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }
                    //else
                      //  label3.Text = "No Result";
                }
                catch (Exception ee)
                {

                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button5.BackColor = Color.Red;
                s5 = button5.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        //if(s1 == "Blue")
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;

                    }
                    //else
                      //  label3.Text = "No Result";
                }
                catch (Exception ee)
                {
                }
            }
            count++;
        }

 private void button6_Click(object sender, EventArgs e)
        {
            
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button6.BackColor = Color.Blue;
                s6 = button6.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }

                    
                }
                catch (Exception ee)
                {

                }

            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button6.BackColor = Color.Red;
                s6 = button6.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;
                    }
                }
                catch (Exception ee)
                {
                }
            }
            count++;
        }


 private void button7_Click(object sender, EventArgs e)
        {
            
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button7.BackColor = Color.Blue;
                s7 = button7.BackColor.Name.ToString();

                try
                {
                    if ((String.Equals(s1,"Blue") && String.Equals(s2,"Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1,"Blue") && String.Equals(s5,"Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                       
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }
                   
                }
                catch (Exception ee)
                {

                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button7.BackColor = Color.Red;
                s7 = button7.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;
                    }
                }
                catch (Exception ee)
                {
                }

            }
            count++;
        }

 private void button8_Click(object sender, EventArgs e)
        {
           
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button8.BackColor = Color.Blue;
                s8 = button8.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;

                    }
                }
                catch (Exception ee)
                {

                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button8.BackColor = Color.Red;
                s8 = button8.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;

                    }
                }
                catch (Exception ee)
                {
                }

            }
            count++;
        }

 private void button9_Click(object sender, EventArgs e)
        {
            
            if (count == 1 || count == 3 || count == 5 || count == 7 || count == 9)
            {
                button9.BackColor = Color.Blue;
                s9 = button9.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Blue") && String.Equals(s2, "Blue") && String.Equals(s3, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s5, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s1, "Blue") && String.Equals(s4, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s2, "Blue") && String.Equals(s5, "Blue") && String.Equals(s8, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s6, "Blue") && String.Equals(s9, "Blue")) || (String.Equals(s3, "Blue") && String.Equals(s5, "Blue") && String.Equals(s7, "Blue")) || (String.Equals(s4, "Blue") && String.Equals(s5, "Blue") && String.Equals(s6, "Blue")) || (String.Equals(s7, "Blue") && String.Equals(s8, "Blue") && String.Equals(s9, "Blue")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox1.Text + " Won";
                        panel2.Enabled = false;
                    }
                }
                catch (Exception ee)
                {

                }
            }
            if (count == 2 || count == 4 || count == 6 || count == 8)
            {
                button9.BackColor = Color.Red;
                s9 = button9.BackColor.Name.ToString();
                try
                {
                    if ((String.Equals(s1, "Red") && String.Equals(s2, "Red") && String.Equals(s3, "Red")) || (String.Equals(s1, "Red") && String.Equals(s5, "Red") && String.Equals(s9, "Red")) || (String.Equals(s1, "Red") && String.Equals(s4, "Red") && String.Equals(s7, "Red")) || (String.Equals(s2, "Red") && String.Equals(s5, "Red") && String.Equals(s8, "Red")) || (String.Equals(s3, "Red") && String.Equals(s6, "Red") && String.Equals(s9, "Red")) || (String.Equals(s3, "Red") && String.Equals(s5, "Red") && String.Equals(s7, "Red")) || (String.Equals(s4, "Red") && String.Equals(s5, "Red") && String.Equals(s6, "Red")) || (String.Equals(s7, "Red") && String.Equals(s8, "Red") && String.Equals(s9, "Red")))
                    {
                        label4.Visible = true;
                        label4.Text = textBox2.Text + " Won";
                        panel2.Enabled = false;

                    }
                }
                catch (Exception ee)
                {
                }

            }
            count++;
           
                   }


step 5 :   
Tic-Tac-Toe : Step 1
Tic-Tac-Toe : Step 2


Tic-Tac-Toe : Step 3
Coding for the event generated by Button 10 Click

 public int major = 0;
        private void button10_Click(object sender, EventArgs e)
        {
            ++major;    
/*For first time button click : - it checks the condition whether the text boxes are empty or not. */   
            if (major == 1)
            {
                if (textBox1.Text == "" || textBox2.Text == "")
                {

                    MessageBox.Show("Enter Player Name");
                }
                else
                {
                    panel2.Visible = true;

                }
            }
            else
            {
/* but for second time its assume the request is as to start the game again. */
/* so ,  for second time - all the buttons will turn into white. */
                panel2.Enabled = true;
                count = 0;
                label4.Visible = false;
             
                button1.BackColor = Color.White;
                button2.BackColor = Color.White;
                button3.BackColor = Color.White;
                button4.BackColor = Color.White;
                button5.BackColor = Color.White;
                button6.BackColor = Color.White;
                button7.BackColor = Color.White;
                button8.BackColor = Color.White;
                button9.BackColor = Color.White;
                s1 = "";
                s2 = "";
                s3 = "";
                s4 = "";
                s5 = "";
                s6 = "";
                s7 = "";
                s8 = "";
                s9 = "";
            }
        }

[ if you want the coding for Blinking label ....
then please visit the love-meter windows application  Article. ]


Enjoy the Game !

Click here to download [tic-tac-toe]



If you want all coding part : Ask Me Directly.
[ukademangesh@gmail.com]
I will send You - Tic-tac-toe project.


Keyword (by relevance) : 
tic-tac-toe | tic tac toe C# | C# game programming | C# tic tac toe | tic tac toe c# code | tic tac toe in C# | tic tac toe C# tutorial | Game programming in C#