#1
|
|||
|
|||
Subtitle Editor Uygulamasi
Yeni baslayanlar icin C# ' in bir cok ozelliginin kullanildigi faydali bir uygulama. Yaptigi is ise, turkce karakter iceren text dosyalarinin, turkce karakterleri, ingilizce karsiliklarina map etmesi. Form1.cs Kod:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using System.Text; namespace Subtitle_Editor { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.OpenFileDialog fileDlg; private System.Windows.Forms.Button button2; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private string str; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.StatusBar status; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.CheckBox checkBox12; private System.Windows.Forms.CheckBox checkBox11; private System.Windows.Forms.CheckBox checkBox10; private System.Windows.Forms.CheckBox checkBox9; private System.Windows.Forms.CheckBox checkBox8; private System.Windows.Forms.CheckBox checkBox7; private System.Windows.Forms.CheckBox checkBox6; private System.Windows.Forms.CheckBox checkBox5; private System.Windows.Forms.CheckBox checkBox4; private System.Windows.Forms.CheckBox checkBox3; private System.Windows.Forms.CheckBox checkBox2; private System.Windows.Forms.CheckBox checkBox1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.button2 = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.checkBox12 = new System.Windows.Forms.CheckBox(); this.checkBox11 = new System.Windows.Forms.CheckBox(); this.checkBox10 = new System.Windows.Forms.CheckBox(); this.checkBox9 = new System.Windows.Forms.CheckBox(); this.checkBox8 = new System.Windows.Forms.CheckBox(); this.checkBox7 = new System.Windows.Forms.CheckBox(); this.checkBox6 = new System.Windows.Forms.CheckBox(); this.checkBox5 = new System.Windows.Forms.CheckBox(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.fileDlg = new System.Windows.Forms.OpenFileDialog(); this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.status = new System.Windows.Forms.StatusBar(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // tabControl1 // this.tabControl1.Controls.AddRange(new System.Windows.Forms.Control[] { this.tabPage1, this.tabPage2}); this.tabControl1.Location = new System.Drawing.Point(32, 16); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(352, 312); this.tabControl1.TabIndex = 0; // // tabPage1 // this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] { this.button2, this.groupBox1}); this.tabPage1.Location = new System.Drawing.Point(4, 25); this.tabPage1.Name = "tabPage1"; this.tabPage1.Size = new System.Drawing.Size(344, 283); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Editor"; // // button2 // this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button2.Location = new System.Drawing.Point(96, 192); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(160, 32); this.button2.TabIndex = 1; this.button2.Text = "Start"; this.button2.Click += new System.EventHandler(this.button2_Click); // // groupBox1 // this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1, this.textBox1}); this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.groupBox1.Location = new System.Drawing.Point(24, 64); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(304, 104); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Choose the subtitle file to edit"; // // button1 // this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button1.Location = new System.Drawing.Point(112, 64); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 24); this.button1.TabIndex = 1; this.button1.Text = "Browse"; this.button1.Click += new System.EventHandler(this.button1_Click); // // textBox1 // this.textBox1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162))); this.textBox1.Location = new System.Drawing.Point(16, 32); this.textBox1.Name = "textBox1"; this.textBox1.ReadOnly = true; this.textBox1.Size = new System.Drawing.Size(272, 21); this.textBox1.TabIndex = 0; this.textBox1.Text = ""; // // tabPage2 // this.tabPage2.Controls.AddRange(new System.Windows.Forms.Control[] { this.groupBox2, this.button4, this.button3}); this.tabPage2.Location = new System.Drawing.Point(4, 25); this.tabPage2.Name = "tabPage2"; this.tabPage2.Size = new System.Drawing.Size(344, 283); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Settings"; // // groupBox2 // this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] { this.checkBox12, this.checkBox11, this.checkBox10, this.checkBox9, this.checkBox8, this.checkBox7, this.checkBox6, this.checkBox5, this.checkBox4, this.checkBox3, this.checkBox2, this.checkBox1}); this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.groupBox2.Location = new System.Drawing.Point(16, 8); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(304, 232); this.groupBox2.TabIndex = 14; this.groupBox2.TabStop = false; this.groupBox2.Text = "Choose which letter conversations you want"; // // checkBox12 // this.checkBox12.Checked = true; this.checkBox12.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox12.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox12.Location = new System.Drawing.Point(184, 192); this.checkBox12.Name = "checkBox12"; this.checkBox12.TabIndex = 23; this.checkBox12.Text = "ö -> o"; // // checkBox11 // this.checkBox11.Checked = true; this.checkBox11.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox11.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox11.Location = new System.Drawing.Point(184, 160); this.checkBox11.Name = "checkBox11"; this.checkBox11.TabIndex = 22; this.checkBox11.Text = "Ö -> O"; // // checkBox10 // this.checkBox10.Checked = true; this.checkBox10.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox10.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox10.Location = new System.Drawing.Point(184, 128); this.checkBox10.Name = "checkBox10"; this.checkBox10.TabIndex = 21; this.checkBox10.Text = "ü -> u"; // // checkBox9 // this.checkBox9.Checked = true; this.checkBox9.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox9.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox9.Location = new System.Drawing.Point(184, 96); this.checkBox9.Name = "checkBox9"; this.checkBox9.TabIndex = 20; this.checkBox9.Text = "Ü -> U"; // // checkBox8 // this.checkBox8.Checked = true; this.checkBox8.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox8.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox8.Location = new System.Drawing.Point(184, 64); this.checkBox8.Name = "checkBox8"; this.checkBox8.TabIndex = 19; this.checkBox8.Text = "ç -> c"; // // checkBox7 // this.checkBox7.Checked = true; this.checkBox7.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox7.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox7.Location = new System.Drawing.Point(184, 32); this.checkBox7.Name = "checkBox7"; this.checkBox7.TabIndex = 18; this.checkBox7.Text = "Ç -> C"; // // checkBox6 // this.checkBox6.Checked = true; this.checkBox6.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox6.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox6.Location = new System.Drawing.Point(24, 192); this.checkBox6.Name = "checkBox6"; this.checkBox6.TabIndex = 17; this.checkBox6.Text = "ğ -> g"; // // checkBox5 // this.checkBox5.Checked = true; this.checkBox5.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox5.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox5.Location = new System.Drawing.Point(24, 160); this.checkBox5.Name = "checkBox5"; this.checkBox5.TabIndex = 16; this.checkBox5.Text = "Ğ -> G"; // // checkBox4 // this.checkBox4.Checked = true; this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox4.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox4.Location = new System.Drawing.Point(24, 128); this.checkBox4.Name = "checkBox4"; this.checkBox4.TabIndex = 15; this.checkBox4.Text = "ı -> i"; // // checkBox3 // this.checkBox3.Checked = true; this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox3.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox3.Location = new System.Drawing.Point(24, 96); this.checkBox3.Name = "checkBox3"; this.checkBox3.TabIndex = 14; this.checkBox3.Text = "İ -> I"; // // checkBox2 // this.checkBox2.Checked = true; this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox2.Location = new System.Drawing.Point(24, 64); this.checkBox2.Name = "checkBox2"; this.checkBox2.TabIndex = 13; this.checkBox2.Text = "ş -> s"; // // checkBox1 // this.checkBox1.Checked = true; this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox1.Location = new System.Drawing.Point(24, 32); this.checkBox1.Name = "checkBox1"; this.checkBox1.TabIndex = 12; this.checkBox1.Text = "Ş -> S"; // // button4 // this.button4.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button4.Location = new System.Drawing.Point(176, 248); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(88, 24); this.button4.TabIndex = 13; this.button4.Text = "Clear All"; this.button4.Click += new System.EventHandler(this.button4_Click); // // button3 // this.button3.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button3.Location = new System.Drawing.Point(72, 248); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(88, 24); this.button3.TabIndex = 12; this.button3.Text = "Select All"; this.button3.Click += new System.EventHandler(this.button3_Click); // // mainMenu1 // this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem3}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem2}); this.menuItem1.Text = "&File"; // // menuItem2 // this.menuItem2.Index = 0; this.menuItem2.Text = "&Close"; this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); // // menuItem3 // this.menuItem3.Index = 1; this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem4}); this.menuItem3.Text = "&Help"; // // menuItem4 // this.menuItem4.Index = 0; this.menuItem4.Text = "&About"; this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); // // status // this.status.Location = new System.Drawing.Point(0, 342); this.status.Name = "status"; this.status.Size = new System.Drawing.Size(424, 24); this.status.TabIndex = 1; this.status.Text = "Choose a file."; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 16); this.ClientSize = new System.Drawing.Size(424, 366); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.status, this.tabControl1}); this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Subtitle Editor"; this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { fileDlg.Title = "Choose the subtitle file to edit"; fileDlg.Filter = "Text Files (*.txt)|*.txt|Srt Files (*.srt)|*.srt|Sub Files (*.sub)|*.sub|All files (*.*)|*.*"; if( fileDlg.ShowDialog() == DialogResult.OK ) { textBox1.Text = fileDlg.FileName; status.Text = "File chosen, now you can start editing."; } } private void button2_Click(object sender, System.EventArgs e) { if( textBox1.Text == "" ) { MessageBox.Show( "You must choose a file first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop ); return; } else { StreamReader reader = new StreamReader(textBox1.Text, Encoding.Default); string editedFile = textBox1.Text + "_edited.txt"; StreamWriter writer = new StreamWriter(editedFile); status.Text = "Editing started, please wait..."; str = reader.ReadLine(); while ( str != null ) { MapCharacters(); //textBox2.Text += str + "\r\n"; writer.WriteLine(str); str = reader.ReadLine(); } MessageBox.Show("Editing subtitle has finished", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); status.Text = "Finished successfully."; reader.Close(); writer.Close(); } } private void menuItem2_Click(object sender, System.EventArgs e) { Application.Exit(); } private void menuItem4_Click(object sender, System.EventArgs e) { About afrm = new About(); afrm.Show(); } private void MapCharacters() { if( checkBox1.Checked == true ) str = str.Replace('Ş','S'); if( checkBox2.Checked == true ) str = str.Replace('ş','s'); if( checkBox3.Checked == true ) str = str.Replace('İ','I'); if( checkBox4.Checked == true ) str = str.Replace('ı','i'); if( checkBox5.Checked == true ) str = str.Replace('Ğ','G'); if( checkBox6.Checked == true ) str = str.Replace('ğ','g'); if( checkBox7.Checked == true ) str = str.Replace('Ç','C'); if( checkBox8.Checked == true ) str = str.Replace('ç','c'); if( checkBox9.Checked == true ) str = str.Replace('Ü','U'); if( checkBox10.Checked == true ) str = str.Replace('ü','u'); if( checkBox11.Checked == true ) str = str.Replace('Ö','O'); if( checkBox12.Checked == true ) str = str.Replace('ö','o'); } private void button3_Click(object sender, System.EventArgs e) { checkBox1.Checked = true; checkBox2.Checked = true; checkBox3.Checked = true; checkBox4.Checked = true; checkBox5.Checked = true; checkBox6.Checked = true; checkBox7.Checked = true; checkBox8.Checked = true; checkBox9.Checked = true; checkBox10.Checked = true; checkBox11.Checked = true; checkBox12.Checked = true; } private void button4_Click(object sender, System.EventArgs e) { checkBox1.Checked = false; checkBox2.Checked = false; checkBox3.Checked = false; checkBox4.Checked = false; checkBox5.Checked = false; checkBox6.Checked = false; checkBox7.Checked = false; checkBox8.Checked = false; checkBox9.Checked = false; checkBox10.Checked = false; checkBox11.Checked = false; checkBox12.Checked = false; } } } |
#2
|
|||
|
|||
Cevap: Subtitle Editor Uygulamasi
About.cs
Kod:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace Subtitle_Editor { /// <summary> /// Summary description for About. /// </summary> public class About : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.PictureBox pictureBox1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public About() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(About)); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.SuspendLayout(); // // label1 // this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.label1.Location = new System.Drawing.Point(16, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(352, 24); this.label1.TabIndex = 0; this.label1.Text = "This program replaces the turkish characters to their english equivalents"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label2 // this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.label2.Location = new System.Drawing.Point(16, 88); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(200, 23); this.label2.TabIndex = 1; this.label2.Text = "Coder : Selcuk OZDOGAN"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label3 // this.label3.FlatStyle = System.Windows.Forms.FlatStyle.System; this.label3.Location = new System.Drawing.Point(16, 112); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(200, 23); this.label3.TabIndex = 2; this.label3.Text = "ITU Computer Eng."; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label4 // this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System; this.label4.Location = new System.Drawing.Point(16, 136); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(200, 24); this.label4.TabIndex = 3; this.label4.Text = "E-mail : [email protected]"; this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // pictureBox1 // this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image"))); this.pictureBox1.Location = new System.Drawing.Point(240, 56); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(88, 104); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.TabIndex = 4; this.pictureBox1.TabStop = false; // // About // this.AutoScaleBaseSize = new System.Drawing.Size(5, 14); this.ClientSize = new System.Drawing.Size(392, 182); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.pictureBox1, this.label4, this.label3, this.label2, this.label1}); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(162))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "About"; this.Text = "About"; this.ResumeLayout(false); } #endregion } } |