C#

Hello World

Budeme potřebovat 1x textbox a j1x button
2x klikneme na button a napíšeme textbox1.text = "Hello World";

nepomohlo? zkus video:
http://www.youtube.com/watch?v=8O-z9Qh2nzo

Kalkulačka, která umí pouze sčítat 

Budeme potřebovat 3x textbox a 1x button
2x klikneme na button a napíšeme    int cislo1;
           int cislo2;
           float vysledek;

            cislo1 = int.Parse(textBox1.Text);
            cislo2 = int.Parse(textBox2.Text);
           

            vysledek = cislo1 + cislo2;
            textBox3.Text = vysledek.ToString();

nepomohlo? zkus video
http://www.youtube.com/watch?v=JvUpzppZeXM

ScreenShoter

Budeme potřebovat 3x button 1x picturebox 1x timer  a 1x saveFileDialog
Celý kód :
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 ScreenShoter1._0
{
    public partial class Form1 : Form
    {
        Graphics g;

        Size screenBounds = Screen.PrimaryScreen.Bounds.Size;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            {
             
                this.Hide();
                timer1.Start();
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            
            

   Bitmap capture = new Bitmap(screenBounds.Width, screenBounds.Height);

   g = Graphics.FromImage(capture);
   g.CopyFromScreen(Point.Empty, Point.Empty, screenBounds);
  
   pictureBox1.Image = capture;
   this.Show();
   button2.Enabled = true;
   timer1.Stop();
}

        private void button2_Click(object sender, EventArgs e)
        {
            {
              
                DialogResult res = saveFileDialog1.ShowDialog();

                if (res == DialogResult.OK)
                {
                  
                    string ext = System.IO.Path.GetExtension(saveFileDialog1.FileName);

                    if (ext == ".jpg")
                        pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                    else if (ext == ".gif")
                        pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif);
                    else if (ext == ".png")
                        pictureBox1.Image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = null;
        }
        }
    }

Žádné komentáře:

Okomentovat