29 Kasım 2015 Pazar

C# Hava Durumu Öğrenme



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;



namespace Hava_Durumu_Deneme
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            HavaDurumu("İstanbul");
        }
        private static string BilgiCek(string url)
        {
            StringBuilder sb = new StringBuilder();
            byte[] buf = new byte[8192];
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream resStream = response.GetResponseStream();
            string tempString = null;
            int count = 0;
            do
            {
                count = resStream.Read(buf, 0, buf.Length);
                if (count != 0)
                {
                    tempString = Encoding.UTF8.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);
            return sb.ToString();
        }

        private static string ToClearText(string tarih)
        {
            return Regex.Replace(tarih, @"<(.|\n)*?>", string.Empty);
        }
        string deger,durum="";
        private void HavaDurumu(string gelen_Sehir)
        {
            string url = "http://www.mgm.gov.tr/tahmin/il-ve-ilceler.aspx?m=" + gelen_Sehir;
            string html = BilgiCek(url);
            deger = "";
            string havadurumu = @"<em class";
            int pos1 = html.IndexOf(havadurumu);
            int pos2 = html.IndexOf("</em>", pos1);
            string derece = html.Substring(pos1, pos2 - pos1);
            string sondurum = @"/FILES/img";
            int pos5 = html.IndexOf(sondurum);
            int pos6 = html.IndexOf(".png", pos5);
            string sdurum = html.Substring(pos5, pos6 - pos5);
            sdurum = ToClearText(sdurum);
            string resim = sdurum + ".png";
            derece = ToClearText(derece);
            pictureBox1.Image = Resim(@"http://www.mgm.gov.tr/" + resim);
            string durum = @"<tbody>";
            int pos3 = html.IndexOf(durum);
            int pos4 = html.IndexOf("</tbody>", pos3);
            string ddeg = html.Substring(pos3, pos4 - pos3);
            ddeg = ToClearText(ddeg);
            string[] pars2 = ddeg.Split("".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string[] pars = derece.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            label1.Text = gelen_Sehir;
            string dene = pars[0];
            int i = 0;
            while (dene[i] != '#')
            {
                deger += dene[i];
                i++;
            }
            if (resim == "/FILES/imgIcon/99/e_72x72t_png/-23.png")
                durum = "Çok Bulutlu";
            if (resim == "/FILES/imgIcon/99/e_72x72t_png/-29.png")
                durum = ("Güneşli");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/63.png")
                durum = ("Yağmurlu");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/-25.png")
                durum = ("Parçalı Bulutlu");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/68.png")
                durum = ("Karla Karışık Yağmurlu");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/73.png")
                durum = ("Kar Yağışlı");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/73.png")
                durum = ("Kar Yağışlı");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/82.png")
                durum = ("Kuvvetli Sağanak Yağışlı");
            if (resim == "/FILES/imgIcon/99/e_36x36t_png/75.png")
                durum = ("Yoğun Kar Yağışlı");
            if (resim == "/FILES/imgIcon/99/e_72x72t_png/45.png")
                durum = ("Sisli");
            if (resim == "/FILES/imgIcon/99/e_72x72t_png/-28.png")
                durum = ("Az Bulutlu");
            label1.Text = gelen_Sehir + " " + deger + "° C " + durum;
        }
        Bitmap Resim(string Url)
        {
            WebRequest rs = WebRequest.Create(Url);
            return (Bitmap)Bitmap.FromStream(rs.GetResponse().GetResponseStream());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            HavaDurumu(textBox1.Text);
        }


    }
}

Paylaş:

C# Kur Fiyatlarını İnternet' ten Çekmek



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;



namespace Kur_Fiyatları_v2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string today = "http://www.tcmb.gov.tr/kurlar/today.xml";
            var xmlDoc = new XmlDocument();
            xmlDoc.Load(today);

            // Xml içinden tarihi alma - gerekli olabilir
            DateTime exchangeDate = Convert.ToDateTime(xmlDoc.SelectSingleNode("//Tarih_Date").Attributes["Tarih"].Value);

            string USD = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='USD']/BanknoteSelling").InnerXml;
            string EURO = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='EUR']/BanknoteSelling").InnerXml;
            string POUND = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='GBP']/BanknoteSelling").InnerXml;
            string JPY = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='JPY']/BanknoteSelling").InnerXml;

            listBox1.Items.Add(string.Format("Tarih  {0}   USD/TRY       : {1}", exchangeDate.ToShortDateString(), USD));
            listBox1.Items.Add(string.Format("Tarih  {0}   EURO/TRY      : {1}", exchangeDate.ToShortDateString(), EURO));
            listBox1.Items.Add(string.Format("Tarih  {0}   POUND/TRY     : {1}", exchangeDate.ToShortDateString(), POUND));
            listBox1.Items.Add(string.Format("Tarih  {0}   JPY/TRY       : {1}", exchangeDate.ToShortDateString(), JPY));

        }
    }
}

Paylaş:

17 Kasım 2015 Salı

C# İnternet Üzerinden Yazıyı Sese Çevirme(Text To Speech) Programı Yapımı

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

namespace text_to_speech
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                webBrowser1.Navigate("https://translate.google.com.tr/");
                webBrowser1.ScriptErrorsSuppressed = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            webBrowser1.Document.GetElementById("gt-src-listen").InvokeMember("click");
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            webBrowser1.Document.GetElementById("source").InnerText = textBox1.Text;
        }
    }
}

Paylaş:

C# Google Haritaları Kullanmak

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace harita
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void Donustur()
        {
            textBox1.Text = textBox1.Text.Replace("ı", "i");
            textBox1.Text = textBox1.Text.Replace("ü", "u");
            textBox1.Text = textBox1.Text.Replace("ğ", "g");
            textBox1.Text = textBox1.Text.Replace("İ", "I");
            textBox1.Text = textBox1.Text.Replace("Ğ", "G");
            textBox1.Text = textBox1.Text.Replace("Ü", "U");
            textBox1.Text = textBox1.Text.Replace("Ç", "C");
            textBox1.Text = textBox1.Text.Replace("ç", "c");
            textBox1.Text = textBox1.Text.Replace("ö", "o");
            textBox1.Text = textBox1.Text.Replace("Ö", "O");
            textBox1.Text = textBox1.Text.Replace("Ş", "S");
            textBox1.Text = textBox1.Text.Replace("ş", "s");

            textBox2.Text = textBox2.Text.Replace("ı", "i");
            textBox2.Text = textBox2.Text.Replace("ü", "u");
            textBox2.Text = textBox2.Text.Replace("ğ", "g");
            textBox2.Text = textBox2.Text.Replace("İ", "I");
            textBox2.Text = textBox2.Text.Replace("Ğ", "G");
            textBox2.Text = textBox2.Text.Replace("Ü", "U");
            textBox2.Text = textBox2.Text.Replace("Ç", "C");
            textBox2.Text = textBox2.Text.Replace("ç", "c");
            textBox2.Text = textBox2.Text.Replace("ö", "o");
            textBox2.Text = textBox2.Text.Replace("Ö", "O");
            textBox2.Text = textBox2.Text.Replace("Ş", "S");
            textBox2.Text = textBox2.Text.Replace("ş", "s");

            textBox3.Text = textBox3.Text.Replace("ı", "i");
            textBox3.Text = textBox3.Text.Replace("ü", "u");
            textBox3.Text = textBox3.Text.Replace("ğ", "g");
            textBox3.Text = textBox3.Text.Replace("İ", "I");
            textBox3.Text = textBox3.Text.Replace("Ğ", "G");
            textBox3.Text = textBox3.Text.Replace("Ü", "U");
            textBox3.Text = textBox3.Text.Replace("Ç", "C");
            textBox3.Text = textBox3.Text.Replace("ç", "c");
            textBox3.Text = textBox3.Text.Replace("ö", "o");
            textBox3.Text = textBox3.Text.Replace("Ö", "O");
            textBox3.Text = textBox3.Text.Replace("Ş", "S");
            textBox3.Text = textBox3.Text.Replace("ş", "s");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Donustur();
            string sokak = textBox1.Text;
            string sehir = textBox2.Text;
            string ulke = textBox3.Text;
            string posta = textBox4.Text;
            try
            {
                StringBuilder adres = new StringBuilder();
                adres.Append("https://www.google.com/maps/place/");

                if (sokak != String.Empty)
                {
                    adres.Append(sokak + "," + "+");
                }
                if (sehir != String.Empty)
                {
                    adres.Append(sehir + "," + "+");
                }
                if (ulke != String.Empty)
                {
                    adres.Append(ulke + "," + "+");
                }
                if (posta != String.Empty)
                {
                    adres.Append(posta + "," + "+");
                }
                webBrowser1.Navigate(adres.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"Hata");
            }
        }
    }
}

Paylaş:

C# Gelişmiş Hesap Makinesi Yapımı



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

namespace Hesap_Makinesi
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        double s1, s2;
        string isaret;
        private void İslemler(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            if (btn.Text == "+")
            {
                if (s1 != 0)
                {
                    double sayi;
                    double.TryParse(textBox1.Text, out sayi);
                    textBox1.Text = (s1 + sayi).ToString();
                }
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text =s1 + " " + isaret;
                textBox1.Text = "0";
            }
            else if (btn.Text == "-")
            {
                if (s1 != 0)
                {
                    double sayi;
                    double.TryParse(textBox1.Text, out sayi);
                    textBox1.Text = (s1 - sayi).ToString();
                }
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text = s1 + " " + isaret;
                textBox1.Text = "0";
            }
            else if (btn.Text == "/")
            {
                if (s1 != 0)
                {
                    double sayi;
                    double.TryParse(textBox1.Text, out sayi);
                    if (sayi == 0) label1.Text = "Hata"; else textBox1.Text = (s1 / sayi).ToString();
                }
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text = s1 + " " + isaret;
                textBox1.Text = "0";
            }
            else if (btn.Text == "*")
            {
                if (s1 != 0)
                {
                    double sayi;
                    double.TryParse(textBox1.Text, out sayi);
                    textBox1.Text = (s1 * sayi).ToString();
                }
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text = s1 + " " + isaret;
                textBox1.Text = "0";
            }
            else if (btn.Text == "%")
            {
                if (s1 != 0)
                {
                    double sayi;
                    double.TryParse(textBox1.Text, out sayi);
                    if (sayi == 0) label1.Text = "Hata"; else textBox1.Text = (s1 % sayi).ToString();
                }
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text = s1 + " " + isaret;
                textBox1.Text = "0";
            }
            else if (btn.Text == "n!")
            {
                double sayi;
                double fakt=1;
                double.TryParse(textBox1.Text, out sayi);
                try
                {
                    for (int i = 1; i <= sayi; i++)
                    {
                        fakt = fakt * i;
                    }
                    if (fakt.ToString() == "Infinity")
                    {
                        label1.Text = "Hata"; textBox1.Text = "0";
                    }
                    else
                    {
                        textBox1.Text = fakt.ToString();
                        label1.Text = sayi + "!";
                    }
                }
                catch (Exception ex)
                {
                    label1.Text = ex.Message;
                    textBox1.Text = "0";
                }
            }
            else if (btn.Text == "√")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Sqrt(s1).ToString();
                label1.Text = "√" + s1;
            }
            else if (btn.Text == "³√")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Pow(s1, (double)1 / 3).ToString();//Math.Pow(s1, 0.333333333333333).ToString();//0.333333333333333 sayısı 1/3 ün sonucudur...
                label1.Text = "³√" + s1;
            }
            else if (btn.Text == "PI")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.PI.ToString();
                label1.Text = "PI";
            }
            else if (btn.Text == "Sin")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Sin(Math.PI * s1 / 180).ToString();
                label1.Text = "Sin " + s1;
            }
            else if (btn.Text == "Cos")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Cos(Math.PI * s1 / 180).ToString();
                label1.Text = "Cos " + s1;
            }
            else if (btn.Text == "Tan")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Tan(Math.PI * s1 / 180).ToString();
                label1.Text = "Tan " + s1;
            }
            else if (btn.Text == "x²")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = (s1 * s1).ToString();
                label1.Text = s1 + "²";
            }
            else if (btn.Text == "x³")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = (s1 * s1 * s1).ToString();
                label1.Text = s1 + "³";
            }
            else if (btn.Text == "Üs")
            {
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text = s1 + "^";
                textBox1.Text = "0";
            }
            else if (btn.Text == "ln")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Log(s1).ToString();
                label1.Text = "ln " + s1;
            }
            else if (btn.Text == "Log10")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.Log10(s1).ToString();
                label1.Text = "Log10 " + s1;
            }
            else if (btn.Text == "Log(sy,tbn)")
            {
                double.TryParse(textBox1.Text, out s1);
                isaret = btn.Text;
                label1.Text = "Log(" + s1 + ",taban)";
                textBox1.Text = "0";
            }
            else if (btn.Text == "1/x")
            {
                double.TryParse(textBox1.Text, out s1);
                label1.Text = "1/" + s1;
                if (s1 != 0) textBox1.Text = (1 / s1).ToString(); else label1.Text = "Hata";
            }
            else if (btn.Text == "e")
            {
                double.TryParse(textBox1.Text, out s1);
                textBox1.Text = Math.E.ToString();
            }
            else if (btn.Text == "C")
            {
                s1 = 0;
                s2 = 0;
                isaret = "";
                textBox1.Text = "0";
                label1.Text = "";
            }
            else if (btn.Text == "<-")
            {
                try
                {
                    if (textBox1.Text.Length != 0)
                    {
                        textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
                        if (textBox1.Text.Length == 0)
                        {
                            textBox1.Text = "0";
                        }
                    }
                }
                catch
                { }
            }
            if (btn.Text == "=")
            {
                label1.Text = "";
                double.TryParse(textBox1.Text, out s2);
                if (isaret == "+") textBox1.Text = (s1 + s2).ToString();
                if (isaret == "-") textBox1.Text = (s1 - s2).ToString();
                if (isaret == "*") textBox1.Text = (s1 * s2).ToString();
                if (isaret == "/") if (s2 == 0) label1.Text = "Hata"; else textBox1.Text = (s1 / s2).ToString();
                if (isaret == "%") if (s2 == 0) label1.Text = "Hata"; else textBox1.Text = (s1 % s2).ToString();
                if (isaret == "Üs") textBox1.Text = Math.Pow(s1, s2).ToString();
                if (isaret == "Log(sy,tbn)") textBox1.Text = Math.Log(s1, s2).ToString();
            }
        }

        private void Rakamlar(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            if (textBox1.Text != "0")
            {
                textBox1.Text += btn.Text;
            }
            else
            {
                textBox1.Clear();
                textBox1.Text += btn.Text;
            }
        }

        private void button31_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Contains(",")) return;
            textBox1.Text += ",";
        }

        private void standartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Size = new System.Drawing.Size(286, 430);
        }

        private void gelişmişToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Size = new System.Drawing.Size(515, 430);
        }

        private void hakkımdaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Görsel Programlama Ödevi\nTasarlayan: Fikri KOCAOĞLAN","Hakkında",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }


    }
}

Paylaş:

15 Kasım 2015 Pazar

C# Türkçe - İngilizce Sözlük Yapımı




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace Sözlük
{
    public partial class Form1 : Form
    {


        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {

            try
            {
                webBrowser1.Navigate("https://translate.google.com.tr/#tr/en/");
                webBrowser1.ScriptErrorsSuppressed = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            webBrowser1.Document.GetElementById("source").InnerText = textBox1.Text;
            timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                webBrowser1.Document.GetElementById("gt-swap").InvokeMember("click");
                if (label1.Text == "Türkçe")
                {
                    label1.Text = "İngilizce";
                    label2.Text = "Türkçe";
                }
                else if (label1.Text == "İngilizce")
                {
                    label1.Text = "Türkçe";
                    label2.Text = "İngilizce";
                }
                webBrowser1.Document.GetElementById("source").InnerText = textBox1.Text;
            }
            catch
            { }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                textBox2.Text = webBrowser1.Document.GetElementById("result_box").InnerText;
            }
            catch
            { }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                webBrowser1.Document.GetElementById("gt-src-roman").InvokeMember("click");
            }
            catch
            { }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                webBrowser1.Document.GetElementById("gt-src-listen").InvokeMember("click");
            }
            catch
            { }
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            try
            {
                webBrowser1.Document.GetElementById("gt-res-listen").InvokeMember("click");
            }
            catch
            { }
        }
    }
}


Paylaş:

14 Kasım 2015 Cumartesi

Popüler

Son

Kategoriler