12 Haziran 2014 Perşembe
PAINT-RESİM YAPMA PROGRAMI
Oto Ekspertiz Cihazları hakkında bilgi almak isterseniz
burayı
tıklayın
Paint Benzeri Bir Uygulama Örneği
:
KOD İNDİR
Public Class Form1 Dim xpos As Integer Dim ypos As Integer Dim ilkX As Integer Dim ilkY As Integer Dim secx As Integer Dim secy As Integer Dim resim1 As Boolean Dim KalemRengi As New Pen(Color.Black, 1) Dim FircaRengi As Brush Dim elipsCiz As Boolean Dim DikdortgenCiz As Boolean Dim TextYaz As Boolean Dim Sprey As Boolean Dim SpreyBaslamaYeri As Boolean Dim font1 As New Font("arial", 10) 'sakla Dim bm As New Bitmap(1300, 1300) Dim Grafik As Graphics = Graphics.FromImage(bm) Dim Ad_1 As String Dim Sakla As Boolean 'çokgen / üçgen çizmek Dim UcgenCiz As Boolean Dim Deger1 As Integer = 0 Dim ilkTiklama As Point Dim ikinciTiklama As Point Dim UcuncuTiklama As Point 'elips çizmek Dim elips2_Ciz As Boolean ' Diktörtgen Çiz Dim dikdortgrn_Ciz As Boolean 'Üçgen Çiz Dim Ucgen_Ciz As Boolean Dim Deger2 As Integer = 0 Dim ilkTiklama2 As Point Dim ikinciTiklama2 As Point Dim UcuncuTiklama2 As Point 'PictureBox 'u yeniden boyutlandır Dim PicBoyutla As Boolean Dim CizimiBoyutla As Boolean Dim picx As Integer Dim picy As Integer Dim Yenile As Boolean Dim PicEni As Integer Dim PicBoyu As Integer 'Yeni resim özellikleri Dim Yeniimaj As Bitmap Dim YeniimajCiz As Boolean Dim ZeminX As Integer Dim ZeminY As Integer 'görüntü boyutu Dim imajX As Integer Dim imajY As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ToolTip1.SetToolTip(RenkPal, " Renk Paleti ") ToolTip1.SetToolTip(DolguluDaire, " İçi Dolu Daire ") ToolTip1.SetToolTip(DolgusuzDaire, " İçi Dolgusuz daire ") ToolTip1.SetToolTip(CizimAlaniArkaFonPic, " Çizim Alanı Arka Fonu belirleme ") ToolTip1.SetToolTip(AlanKaydirPic, " Çizim Alanı Genişletme, belirleme ") ToolTip1.SetToolTip(AcBtn, " Dosya Aç ") ToolTip1.SetToolTip(SaklaPic, " Çizim Sakla ") ToolTip1.SetToolTip(SilBtn, " Sil ") ToolTip1.SetToolTip(FircaPic, " Fırça ") ToolTip1.SetToolTip(KalemPic, " Kalem ") ToolTip1.SetToolTip(DolguUcgen, " İçi Dolgu Üçgen ") ToolTip1.SetToolTip(DolgusuzUcgen, " Dolgusuz Üçgen ") ToolTip1.SetToolTip(DolguluKare, " Dolgulu Kare,Dikdörtgen") ToolTip1.SetToolTip(DolgusuzUcgen, " Dolgusuz Kare,Dikdörtgen ") ToolTip1.SetToolTip(KalemPic, " Kalem ") ToolTip1.SetToolTip(YaziYazPic, " Metin Yazdırma ") ToolTip1.SetToolTip(DolgusuzKare, " DolgusuzKare Oluşturma") ToolTip1.SetToolTip(FontSecPic, " Font seç") FircaRengi = Brushes.Black Me.WindowState = FormWindowState.Normal 'font TextBox2.Text = FontDialog1.Font.Name NumericUpDown2.Value = FontDialog1.Font.Size TextBox3.Text = FontDialog1.Font.Style.ToString 'Grafik oluştur CizimAlaniPic.CreateGraphics() 'picturebox6 durum bilgileri ToolStripStatusLabel3.Text = CizimAlaniPic.Width ToolStripStatusLabel4.Text = CizimAlaniPic.Height ToolStripStatusLabel6.Text = CizimAlaniPic.BackColor.Name.ToString ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString ToolStripStatusLabel13.Text = "hiçbiri" ToolStripStatusLabel15.Text = Windows.Forms.Cursor.Position.X ToolStripStatusLabel17.Text = Windows.Forms.Cursor.Position.Y End Sub Private Sub Panel2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KrmRenkPaneli.Click KalemRengi.Color = Color.Red FircaRengi = Brushes.Red 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged KalemRengi.Width = NumericUpDown1.Value End Sub Private Sub PortakalRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PortakalRenkPaleti.Click KalemRengi.Color = Color.Orange FircaRengi = Brushes.Orange 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub MaviRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MaviRenkPaleti.Click KalemRengi.Color = Color.Blue FircaRengi = Brushes.Blue 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub DesktopRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DesktopRenkPaleti.Click KalemRengi.Color = Color.Black FircaRengi = Brushes.Black 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub YeşiRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles YeşiRenkPaleti.Click KalemRengi.Color = Color.Green FircaRengi = Brushes.Green 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize Panel1.Width = Me.Width If Yenile = True Then CizimAlaniPic.Height = PicBoyu CizimAlaniPic.Width = PicEni 'Panel kaydırma Panel12.Height = PicBoyu Panel12.Width = PicEni Else CizimAlaniPic.Height = Me.Height CizimAlaniPic.Width = Me.Width Panel12.Height = Me.Height - 150 Panel12.Width = Me.Width - 20 End If End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KalemPic.Click resim1 = True Sprey = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub DolguluDaire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DolguluDaire.Click elipsCiz = True resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False Sprey = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub DolgusuzKare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DolgusuzKare.Click dikdortgrn_Ciz = True resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False Sprey = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub YaziYazPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YaziYazPic.Click 'geçerli araç ToolStripStatusLabel13.Text = "Text Yaz" If TextBox1.Text.Length > 0 Then TextYaz = True resim1 = False PicBoyutla = False Sprey = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False Else MsgBox("Girilecek metni yazınız." + vbNewLine + "Bu tuşa bastıktan sonra" + vbNewLine + "metnin görünmesini istediğiniz yeri tıklatın.", MsgBoxStyle.Information) End If 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub SilBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SilBtn.Click Try 'Renk Sil Using g As Graphics = Graphics.FromImage(CizimAlaniPic.Image) g.Clear(Color.White) Me.Refresh() End Using ' kalem genişliği NumericUpDown1.Value = 3 'Varsayılan Renk FircaRengi = Brushes.Black 'Araçlar TextYaz = False DikdortgenCiz = False resim1 = False elipsCiz = False 'Text sil TextBox1.Text = "" 'varsayılan text boyu NumericUpDown2.Value = 10 'Varsaılan kalem rengi KalemRengi.Color = Color.Black ' GÖRÜNTÜ AÇILIŞ SIRASINDA TÜM ARAÇ Seçimini Kaldır Ucgen_Ciz = False resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Sprey = False elips2_Ciz = False ' durum çubuğunu güncelleştir ToolStripStatusLabel6.Text = "Beyaz" ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString ToolStripStatusLabel13.Text = "hiçbiri" Catch ex As Exception 'MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) Beep() End Try End Sub Sub RenkSil() Dim bm As New Bitmap(1300, 1300) End Sub Private Sub FircaPic_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FircaPic.Click Sprey = True resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub SaklaPic_Click(sender As System.Object, e As System.EventArgs) Handles SaklaPic.Click Try If YeniimajCiz = True Then 'Kaynak bitmap alı Dim bm_source As New Bitmap(CizimAlaniPic.Image) 'Sonuç için bir bitmap yap Dim bm_dest As New Bitmap(CInt(CizimAlaniPic.Width), CInt(CizimAlaniPic.Width)) 'Sonuç Bitmap için bir Graf nesnesi yap Dim gr_dest As Graphics = Graphics.FromImage(bm_dest) 'Hedef bitmap halinde kaynak görüntüyü kopyala gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1) 'Sonucu görüntüle Dim DsySakla As New SaveFileDialog DsySakla.FileName = "image" DsySakla.Filter = "Bitmap dosyalar |*.bmp" DsySakla.ShowDialog() bm_dest.Save(DsySakla.FileName) End If If YeniimajCiz = False Then 'Görüntü ve arka plan rengini alın Dim eskiimaj As Image = CizimAlaniPic.Image Dim arkaRenk As Color = CizimAlaniPic.BackColor '--------------------------------------------------------- 'Kodu düzenle Dim picEni As Integer = CizimAlaniPic.Width Dim picBoyu As Integer = CizimAlaniPic.Height 'Uygun büyüklükte yeni bir resim yapmak ve üzerine çizmek için hazır olsun Dim Yeniimaj2 As Image = New Bitmap(picEni, picBoyu, Imaging.PixelFormat.Format32bppArgb) Using g As Graphics = Graphics.FromImage(Yeniimaj2) 'Arka planı çizin, sonra görüntüle Using arkaFirca As New SolidBrush(arkaRenk) g.FillRectangle(arkaFirca, 0, 0, Yeniimaj2.Width, Yeniimaj2.Height) g.DrawImage(eskiimaj, 0, 0) End Using End Using Clipboard.SetImage(Yeniimaj2) Dim DsySakla As New SaveFileDialog DsySakla.FileName = "image" DsySakla.Filter = "Bitmap dosyalar |*.bmp" DsySakla.ShowDialog() Yeniimaj2.Save(DsySakla.FileName) End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub SariRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SariRenkPaleti.Click KalemRengi.Color = Color.Yellow FircaRengi = Brushes.Yellow 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub GriRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GriRenkPaleti.Click KalemRengi.Color = Color.Gray FircaRengi = Brushes.Gray 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub MorRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MorRenkPaleti.Click KalemRengi.Color = Color.Purple FircaRengi = Brushes.Purple 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub PembeRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PembeRenkPaleti.Click KalemRengi.Color = Color.Pink FircaRengi = Brushes.Pink 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click TextBox1.Text = "" End Sub Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontSecPic.Click FontDialog1.ShowDialog() TextBox2.Text = FontDialog1.Font.Name NumericUpDown2.Value = FontDialog1.Font.Size TextBox3.Text = FontDialog1.Font.Style.ToString End Sub Private Sub PictureBox8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DolguUcgen.Click MsgBox("Formda üçgen noktalarını seç." + vbNewLine + "Ayrıca kalem rengini ve genişliğini de seçebilirsiniz.", MsgBoxStyle.Information) Ucgen_Ciz = True resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Sprey = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub DolgusuzDaire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DolgusuzDaire.Click elips2_Ciz = True resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False Sprey = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub DolguluKare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DolguluKare.Click DikdortgenCiz = True resim1 = False PicBoyutla = False TextYaz = False Sprey = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub DolgusuzUcgen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DolgusuzUcgen.Click 'Açıklama yap Göster MsgBox("Formda üçgen noktalarını seç." + vbNewLine + "Ayrıca kalem rengini ve genişliğini de seçebilirsiniz.", MsgBoxStyle.Information) UcgenCiz = True resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False Sprey = False Ucgen_Ciz = False elips2_Ciz = False 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub CizimAlaniArkaFonPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CizimAlaniArkaFonPic.Click CizimAlaniPic.BackColor = KalemRengi.Color ToolStripStatusLabel6.Text = CizimAlaniPic.BackColor.Name.ToString End Sub Private Sub BeyazRenkPaleti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BeyazRenkPaleti.Click KalemRengi.Color = Color.White FircaRengi = Brushes.White 'Şimdiki Renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End Sub Private Sub AlanKaydirPic_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles AlanKaydirPic.MouseUp 'PictureBox 'u yeniden boyutlandır PicBoyutla = True resim1 = False Sprey = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Ucgen_Ciz = False elips2_Ciz = False End Sub Private Sub PictureBox6_Resize(ByVal sender As Object, ByVal e As System.EventArgs) 'picturebox6 yükseklik ve genişliğini değiştir ToolStripStatusLabel3.Text = CizimAlaniPic.Width ToolStripStatusLabel4.Text = CizimAlaniPic.Height End Sub Private Sub AlanKaydirPic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlanKaydirPic.Click 'Şimdiki araç ToolStripStatusLabel13.Text = "Boyutlandı" 'Yeni görüntü üzerinde çizim düzeltme YeniimajDuzenle() End Sub Private Sub AcBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AcBtn.Click OpenFileDialog1.ShowDialog() OpenFileDialog1.Filter = "Bitmap Dosyalar (*)|*.bmp;*.gif;*.jpg;*.Png" 'Tüm Dosyalar|*.*| If IO.File.Exists(OpenFileDialog1.FileName) Then Dim file As String = OpenFileDialog1.FileName Dim validation As New IO.FileInfo(file) If CizimAlaniPic.Image IsNot Nothing Then Using g As Graphics = Graphics.FromImage(CizimAlaniPic.Image) g.Clear(Color.White) Me.Refresh() End Using End If Yeniimaj = New Bitmap(OpenFileDialog1.FileName) If Yeniimaj.Width > 1300 Or Yeniimaj.Height > 1300 Then CizimAlaniPic.Width = Yeniimaj.Width CizimAlaniPic.Height = Yeniimaj.Height Panel12.AutoScroll = True End If CizimAlaniPic.Image = Yeniimaj YeniimajCiz = True ' YENİ GÖRÜNTÜ AÇILIŞI SIRASINDA TÜM ARAÇLARIN Seçimini Kaldır Ucgen_Ciz = False resim1 = False PicBoyutla = False TextYaz = False DikdortgenCiz = False dikdortgrn_Ciz = False elipsCiz = False UcgenCiz = False Sprey = False elips2_Ciz = False 'görüntü boyutunu hatırla imajX = CizimAlaniPic.Width imajY = CizimAlaniPic.Height End If End Sub Private Sub PictureBox6_MouseDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CizimAlaniPic.MouseDown ilkX = e.X ilkY = e.Y 'test If Sprey = True Then SpreyBaslamaYeri = True End If ' üçgeni test et If UcgenCiz = True Then If Deger1 = 0 Then ilkTiklama = New Point(e.X, e.Y) End If If Deger1 = 1 Then ikinciTiklama = New Point(e.X, e.Y) End If If Deger1 = 2 Then UcuncuTiklama = New Point(e.X, e.Y) Dim pts() As Point = {ilkTiklama, ikinciTiklama, UcuncuTiklama} If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias graph1.DrawPolygon(KalemRengi, pts) CizimAlaniPic.Image = Yeniimaj Else Grafik.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias Grafik.DrawPolygon(KalemRengi, pts) CizimAlaniPic.Image = bm End If Deger1 = -1 End If Deger1 = Deger1 + 1 End If 'içidolu üçgen çiz If Ucgen_Ciz = True Then If Deger2 = 0 Then ilkTiklama2 = New Point(e.X, e.Y) End If If Deger2 = 1 Then ikinciTiklama2 = New Point(e.X, e.Y) End If If Deger2 = 2 Then UcuncuTiklama2 = New Point(e.X, e.Y) Dim pts1() As Point = {ilkTiklama2, ikinciTiklama2, UcuncuTiklama2} If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias graph1.DrawPolygon(KalemRengi, pts1) graph1.FillPolygon(FircaRengi, pts1) CizimAlaniPic.Image = Yeniimaj Else Grafik.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias Grafik.DrawPolygon(KalemRengi, pts1) Grafik.FillPolygon(FircaRengi, pts1) CizimAlaniPic.Image = bm End If Deger2 = -1 End If Deger2 = Deger2 + 1 End If If PicBoyutla = True Then CizimiBoyutla = True End If End Sub Private Sub CizimAlaniPic_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CizimAlaniPic.MouseMove xpos = e.X ypos = e.Y picx = e.X picy = e.Y ToolStripStatusLabel15.Text = xpos.ToString ToolStripStatusLabel17.Text = ypos.ToString 'Sprey If Sprey = True And SpreyBaslamaYeri = True Then Dim g As Graphics = CizimAlaniPic.CreateGraphics If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawEllipse(KalemRengi, e.X, e.Y, 10, 10) graph1.FillEllipse(FircaRengi, e.X, e.Y, 10, 10) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawEllipse(KalemRengi, e.X, e.Y, 10, 10) Grafik.FillEllipse(FircaRengi, e.X, e.Y, 10, 10) CizimAlaniPic.Image = bm End If End If If CizimiBoyutla = True Then CizimAlaniPic.Size = New Point(e.X, e.Y) Panel12.Height = Me.Height - 150 Panel12.Width = Me.Width - 20 'kullanılmayan rengi farklı yapmak için Me.BackColor = Color.Gray CizimAlaniPic.BackColor = Color.White ' .Bisque If YeniimajCiz = True Then CizimAlaniPic.Image = Yeniimaj Else CizimAlaniPic.Image = bm End If End If End Sub Private Sub PictureBox6_MouseUp1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles CizimAlaniPic.MouseUp secx = e.X secy = e.Y If resim1 = True Then If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawLine(KalemRengi, ilkX, ilkY, secx, secy) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawLine(KalemRengi, ilkX, ilkY, secx, secy) CizimAlaniPic.Image = bm End If End If '------------------------------------------- If elipsCiz = True Then Dim g As Graphics = CizimAlaniPic.CreateGraphics If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawEllipse(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) graph1.FillEllipse(FircaRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawEllipse(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) Grafik.FillEllipse(FircaRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = bm End If End If If DikdortgenCiz = True Then Dim g As Graphics = CizimAlaniPic.CreateGraphics If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawRectangle(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) graph1.FillRectangle(FircaRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawRectangle(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) Grafik.FillRectangle(FircaRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = bm End If End If If TextYaz = True Then Dim g As Graphics = CizimAlaniPic.CreateGraphics 'font Dim font2 As Font Dim textStyle As New FontStyle If TextBox3.Text = "Italic" Then textStyle = FontStyle.Italic ElseIf TextBox3.Text = "Regular" Then textStyle = FontStyle.Regular ElseIf TextBox3.Text = "Bold" Then textStyle = FontStyle.Bold ElseIf TextBox3.Text = "Strikeout" Then textStyle = FontStyle.Strikeout ElseIf TextBox3.Text = "Underline" Then textStyle = FontStyle.Underline Else 'Varsayılan textStyle = FontStyle.Regular End If font2 = New Font(TextBox2.Text, NumericUpDown2.Value, textStyle) If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawString(TextBox1.Text, font2, FircaRengi, ilkX, ilkY) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawString(TextBox1.Text, font2, FircaRengi, ilkX, ilkY) CizimAlaniPic.Image = bm End If End If If elips2_Ciz = True Then Dim g As Graphics = CizimAlaniPic.CreateGraphics If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawEllipse(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawEllipse(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = bm End If End If If dikdortgrn_Ciz = True Then Dim g As Graphics = CizimAlaniPic.CreateGraphics If YeniimajCiz = True Then Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) graph1.DrawRectangle(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = Yeniimaj Else Grafik.DrawRectangle(KalemRengi, ilkX, ilkY, secx - ilkX, secy - ilkY) CizimAlaniPic.Image = bm End If End If If PicBoyutla = True Then PicEni = e.X PicBoyu = e.Y If YeniimajCiz = True Then CizimAlaniPic.SizeMode = PictureBoxSizeMode.StretchImage Dim graph1 As Graphics = Graphics.FromImage(Yeniimaj) CizimAlaniPic.Image = Yeniimaj Else CizimAlaniPic.Image = bm End If CizimiBoyutla = False PicBoyutla = False Yenile = True End If SpreyBaslamaYeri = False End Sub Private Sub PictureBox6_Resize1(ByVal sender As Object, ByVal e As System.EventArgs) Handles CizimAlaniPic.Resize If YeniimajCiz = True Then ZeminX = CizimAlaniPic.Width ZeminY = CizimAlaniPic.Height End If ToolStripStatusLabel3.Text = CizimAlaniPic.Width ToolStripStatusLabel4.Text = CizimAlaniPic.Height End Sub Sub YeniimajDuzenle() If YeniimajCiz = True Then If CizimAlaniPic.SizeMode = PictureBoxSizeMode.StretchImage Then CizimAlaniPic.SizeMode = PictureBoxSizeMode.Normal CizimAlaniPic.Image = Yeniimaj End If If CizimAlaniPic.SizeMode = PictureBoxSizeMode.Normal Then Panel12.AutoScroll = True CizimAlaniPic.Width = imajX CizimAlaniPic.Height = imajY End If End If End Sub Private Sub RenkPal_Click(sender As System.Object, e As System.EventArgs) Handles RenkPal.Click 'daha Çok renk seç If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then KalemRengi.Color = ColorDialog1.Color FircaRengi = New SolidBrush(ColorDialog1.Color) 'Şimdiki renk ToolStripStatusLabel11.Text = KalemRengi.Color.Name.ToString End If End Sub End Class
3 Haziran 2014 Salı
BAŞLIKSIZ, TAŞINABİLİR VE BOYUTLANIR FORM
BAŞLIKSIZ, TAŞINABİLİR VE BOYUTLANIR FORM KODLARI
İNDİR
' başlıksız form Public Class Form1 Private mouse_offset As Point Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Const WS_CAPTION As Integer = &HC00000 Dim baseParams As CreateParams = MyBase.CreateParams 'Başlık olmasın baseParams.Style = baseParams.Style And Not WS_CAPTION Return baseParams End Get End Property Private Sub PictureBox1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown mouse_offset = New Point(-e.X, -e.Y) If e.Button = Windows.Forms.MouseButtons.Right Then Me.Close() End If End Sub Private Sub PictureBox1_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If e.Button = MouseButtons.Left Then Dim mousePos As Point = Control.MousePosition mousePos.Offset(mouse_offset.X, mouse_offset.Y) Location = mousePos End If End Sub End Class
DİZİ ÖRNEĞİ (Günler,Aylar)
DİZİ İŞLEME PROJE ÖRNEK KODLAR
İNDİR
Public Class Form1 Dim gunler() As String = {"pazartesi", "salı", "çarşamba", "perşembe", "cuma", "cumaretesi", "pazar"} Dim aylar() As String = {"Oacak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"} Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Clear() If RadioButton1.Checked = True Then For i = 0 To 4 ListBox1.Items.Add(gunler(i)) Next End If If RadioButton2.Checked = True Then For i = 5 To 6 ListBox1.Items.Add(gunler(i)) Next End If If RadioButton3.Checked = True Then For i = 0 To 6 ListBox1.Items.Add(gunler(i)) Next End If End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click ListBox1.Items.Clear() For i = 0 To 11 ListBox1.Items.Add(aylar(i)) Next End Sub End Class
Dosya İçinden Kelime Değiştirme
Hazır Bir Text dosyasının içinde geçen Sözcükleri Dosyayı açmadan değiştirme örnek kodları
KOD İNDİR
Imports System.IO Public Class Form1 Dim değişeceksöz, yenisöz As String Sub Main() Try Dim newLine As String Using sr As New StreamReader(Application.StartupPath & "\ARIYORUM.txt", System.Text.Encoding.Default) Dim line As String line = sr.ReadToEnd() newLine = line.Replace(TextBox1.Text, TextBox2.Text) End Using Using sw As New StreamWriter(Application.StartupPath & "\ARIYORUM.txt", 0, System.Text.Encoding.Default) sw.Write(newLine) End Using 'IO.File.WriteAllText(Application.StartupPath &"\ARIYORUM.txt", newLine, System.Text.Encoding.Default) Catch e As Exception Console.WriteLine("dosyayı bulamadım:") Console.WriteLine(e.Message) End Try End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "" Then Exit Sub Call Main() End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim processID As Integer Dim dsy As String = "ARIYORUM.txt" processID = Shell("C:\windows\Notepad.EXE ARIYORUM.txt", AppWinStyle.NormalFocus) AppActivate(processID) End Sub End Class
2 Haziran 2014 Pazartesi
WEB SAYFASININ KODUNU ALMA ÖRNEĞİ
WEB SAYFASININ KODUNU ALMA ÖRNEĞİ
İNDİR
Not
:
Explorerden CTRL+C ile kopyalanıp panoya alınan site linki kodları anında RichTextBox 'ta Gösterilir.
Imports System.IO Imports System.Runtime.InteropServices Public Class Form1 Private Const WM_DRAWCLIPBOARD As Integer = &H308 Private Const WM_CHANGECBCHAIN As Integer = &H30D Private mNextClipBoardViewerHWnd As IntPtr Private Event OnClipboardChanged()
_ Private Shared Function SetClipboardViewer(ByVal hWnd As IntPtr) As IntPtr End Function
_ Private Shared Function ChangeClipboardChain(ByVal hWnd As IntPtr, ByVal hWndNext As IntPtr) As _
Boolean End Function
_ Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, _ ByVal lParam As IntPtr) As IntPtr End Function Protected Overrides Sub WndProc(ByRef m As Message) Select Case m.Msg Case WM_DRAWCLIPBOARD RaiseEvent OnClipboardChanged() SendMessage(mNextClipBoardViewerHWnd, m.Msg, m.WParam, m.LParam) Case WM_CHANGECBCHAIN If m.WParam.Equals(mNextClipBoardViewerHWnd) Then mNextClipBoardViewerHWnd = m.LParam Else SendMessage(mNextClipBoardViewerHWnd, m.Msg, m.WParam, m.LParam) End If End Select MyBase.WndProc(m) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim kaynakkod As String Dim data As StreamReader Dim webRequest As Net.WebRequest Dim webresponse As Net.WebResponse webRequest = Net.WebRequest.Create(LinTxt.Text) webresponse = webRequest.GetResponse() data = New StreamReader(webresponse.GetResponseStream()) kaynakkod = data.ReadToEnd() RTB.Text = kaynakkod End Sub Private Sub ClipBoardChanged() If My.Computer.Clipboard.ContainsText Then If Uri.IsWellFormedUriString(My.Computer.Clipboard.GetText, UriKind.Absolute) Then LinTxt.Text = (My.Computer.Clipboard.GetText) End If End If End Sub Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load mNextClipBoardViewerHWnd = SetClipboardViewer(Me.Handle) AddHandler Me.OnClipboardChanged, AddressOf ClipBoardChanged End Sub Private Sub Form1_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing ChangeClipboardChain(Me.Handle, mNextClipBoardViewerHWnd) End Sub Private Sub LinTxt_TextChanged(sender As System.Object, e As System.EventArgs) Handles LinTxt.TextChanged Try Button1.PerformClick() Catch ex As Exception Debug.WriteLine(ex.Message) MessageBox.Show(ex.Message) Debug.WriteLine(ex.StackTrace) End Try End Sub End Class
Daha Yeni Kayıtlar
Önceki Kayıtlar
Ana Sayfa
Kaydol:
Kayıtlar (Atom)