C# ile vakit geçirmek için yapmış olduğum programı sizlerle paylaşıyorum umarım işinize yarar. İçerisinde .php , .asp , .html kayıt seçenekleri mevcut.
C# ile vakit geçirmek için yapmış olduğum programı sizlerle paylaşıyorum umarım işinize yarar. İçerisinde .php , .asp , .html kayıt seçenekleri mevcut.
Kaynak Kodlarını Da Paylaşıyorum İşinize Yaraması Umuduyla...
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;
namespace text_to_binary
{
public partial class XtraForm1 : XtraForm
{
public XtraForm1()
{
InitializeComponent();
}
Byte[] GetBytesFromBinaryString(String binary)
{
var list = new List();
for (int i = 0; i < binary.Length; i += 8)
{
String t = binary.Substring(i, 8);
list.Add(Convert.ToByte(t, 2));
}
return list.ToArray();
}
private void XtraForm1_Load(object sender, EventArgs e)
{
timer1.Enabled =true;
openFileDialog1.FileName = "Dosya Seç";
openFileDialog1.Title = " Lütfen Bir Dosya Seçiniz.";
openFileDialog1.InitialDirectory = "SetDesktopLocation";
saveFileDialog1.FileName = "Dosya Kayıt İsmi Girin";
saveFileDialog1.Title = "Dosya Kayıt İsmi Girin";
saveFileDialog1.InitialDirectory = "SetDesktopLocation";
if (button2.Enabled == true)
{
richTextBox1.TextChanged += delegate
{
try
{
string strText = richTextBox1.Text;
byte[] btText = System.Text.Encoding.UTF8.GetBytes(strText);
Array.Reverse(btText);
BitArray bit = new BitArray(btText);
StringBuilder sb = new StringBuilder();
for (int i = bit.Length - 1; i >= 0; i--)
{
if (bit[i] == true)
{
sb.Append(1);
}
else
{
sb.Append(0);
}
}
richTextBox2.Text = sb.ToString();
button1.Enabled = false;
button2.Enabled = true;
}
catch
{
MessageBox.Show("Dönüşüm Yapılırken Bir Hata Oluştu");
}
};
}
else if (button2.Enabled == false)
{
richTextBox1.TextChanged += delegate
{
button2.PerformClick();
};
}
}
private void button1_Click_1(object sender, EventArgs e)
{
richTextBox1.Text = "";
button1.Enabled = false;
button2.Enabled = true;
}
private void button2_Click_1(object sender, EventArgs e)
{
try
{
string data = richTextBox1.Text.Trim();
var yaz = GetBytesFromBinaryString(data.ToString());
var text = Encoding.UTF8.GetString(yaz);
richTextBox2.Text = text.ToString();
button1.Enabled = true;
button2.Enabled = false;
}
catch
{
MessageBox.Show("Çevrim Yapılırken Hata Oluştu, Lütfen Girdiğiniz Metnin Çevrilebilir Olmasını Sağlayın");
}
}
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
SaveFileDialog save = new SaveFileDialog() { Filter = "Php dosyaları (*.php)|*.php|Asp dosyaları (*.asp)|*.asp|Metin dosyaları (*.txt)|*.txt|Html dosyaları (*.html)|*.html|Tüm dosyalar (*.*)|*.*", OverwritePrompt = true, CreatePrompt = false, FileName = "_end" };
if (save.ShowDialog() == DialogResult.OK)
{
StreamWriter Kayit = new StreamWriter(save.FileName);
Kayit.WriteLine(richTextBox2.Text);
Kayit.Close();
}
}
catch
{
MessageBox.Show("Dosya Kaydedilirken Hata Oluştu");
}
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
richTextBox1.Text = new StreamReader(openFileDialog1.OpenFile()).ReadToEnd();
}
catch
{
MessageBox.Show("Dosya Açılırken Bir Hata Oluştu");
}
}
private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
barButtonItem1.PerformClick();
}
private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
barButtonItem2.PerformClick();
}
private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
this.Close();
}
private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
label1.Visible = true;
label2.Visible = true;
}
private void label2_Click(object sender, EventArgs e)
{
label1.Visible = false;
label2.Visible = false;
}
private void label2_MouseHover(object sender, EventArgs e)
{
label2.ForeColor = System.Drawing.Color.White;
}
private void label2_MouseLeave(object sender, EventArgs e)
{
label2.ForeColor = System.Drawing.Color.Red;
}
int a = -50;
private void timer1_Tick(object sender, EventArgs e)
{
a++;
if (a == 5)
{
richTextBox1.Text += "H";
a++;
}
if (a == 10)
{
richTextBox1.Text += "o";
a++;
}
if (a == 15)
{
richTextBox1.Text += "ş";
a++;
}
if (a == 20)
{
richTextBox1.Text += " ";
a++;
}
if (a == 25)
{
richTextBox1.Text += "G";
a++;
}
if (a == 30)
{
richTextBox1.Text += "e";
a++;
}
if (a == 35)
{
richTextBox1.Text += "l";
a++;
}
if (a == 40)
{
richTextBox1.Text += "d";
a++;
}
if (a == 45)
{
richTextBox1.Text += "i";
a++;
}
if (a == 50)
{
richTextBox1.Text += "n";
a++;
}
if (a == 55)
{
richTextBox1.Text += "i";
a++;
}
if (a == 60)
{
richTextBox1.Text += "z";
a++;
}
}
}
}