10-20-2013, 09:59 AM
Mehrbod نوشته: خب کُد این برنامه کجاست؟ بگذار نگاه میکنیم.بخش اصلی این پروژه چیز دیگری بود و نوشتن برنامه بخشی فرعی بود.
فقط برگردان خط فارسی به تاجیکی در این برنامه انجام میشه.
یک بانک اطلاعاتی با اکسس براش ساخته بودم، که دو فیلد داشت. در پست بعد کلمات فارسی و معادل تاجیکی اونها رو میذارم.
+
هر سئوالی داشتی بپرس، اگه بودم جواب میدم. هرچند کدشو کامل یادم رفته.

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.Data.OleDb;
namespace Farsi___Tajiki
{
public partial class Form1 : Form
{
private const string _commandtext = "SELECT farsi,tajiki from farhang";
private const string _Connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\farhang.accdb";
OleDbConnection conn;
OleDbDataAdapter da;
DataSet ds;
DataView dw;
CurrencyManager cm;
double h;
private void filldatesetandview()
{
ds = new DataSet();
da.Fill(ds, "farhang");
dw = new DataView(ds.Tables["farhang"]);
cm = (CurrencyManager)(this.BindingContext[dw]);
}
private void bindfields()
{
txtTajiki2.DataBindings.Clear();
txtTajiki2.DataBindings.Add("Text", dw, "tajiki");
toolStripStatusLabel1.Text = "آماده";
}
public Form1()
{
conn = new OleDbConnection(_Connectionstring);
da = new OleDbDataAdapter(_commandtext, conn);
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
filldatesetandview();
bindfields();
}
private void Form1_Load_1(object sender, EventArgs e)
{
filldatesetandview();
bindfields();
}
private void txtLF_Click(object sender, EventArgs e)
{
darsad.Text="";
label5.Text = "";
progressBar1.Value = 0;
if (bestTranslate.Checked == true)
{
string m2 = txtFarsi.Text;
string newM2;
newM2 = m2.Replace("،", " ، ");
newM2 = newM2.Replace("?", " ? ");
newM2 = newM2.Replace(".", " . ");
newM2 = newM2.Replace("!", " ! ");
newM2 = newM2.Replace("؛", " ؛ ");
newM2 = newM2.Replace(":", " : ");
newM2 = newM2.Replace(";", " ; ");
newM2 = newM2.Replace("ُ", "");
newM2 = newM2.Replace("ِ", "");
newM2 = newM2.Replace("َ", "");
newM2 = newM2.Replace("ّ", "");
newM2 = newM2.Replace("'", " ' ");
newM2 = newM2.Replace("(", " ( ");
newM2 = newM2.Replace(")", " ) ");
newM2 = newM2.Replace("-", " - ");
newM2 = newM2.Replace("_", " _ ");
newM2 = newM2.Replace("{", " { ");
newM2 = newM2.Replace("}", " } ");
newM2 = newM2.Replace("ـ", " ـ ");
newM2 = newM2.Replace("؟", " ؟ ");
txtFarsi.Text = newM2;
}
listBox2.Items.Clear();
listBox1.Items.Clear();
txtTajiki.Text = "";
int intposition;
dw.Sort = "farsi";
string m = txtFarsi.Text + " ";
string ch = "";
string word = "";
int p = 0;
int lent = m.Length;
progressBar1.Value += 2;
for (int i = 0; i < lent; i++)
{
while (ch != " ")
{
ch = m.Substring(p, 1);
if (ch != " ")
{
word = word + ch;
}
p += 1;
ch = m.Substring(p, 1);
}
if (word != "")
{
listBox1.Items.Add(word);
intposition = dw.Find(word);
if (intposition == -1)
{
txtTajiki.Text += word + " ";
toolStripStatusLabel1.Text = "رکورد پیدا نشد";
}
else
{
toolStripStatusLabel1.Text = "رکورد پیدا شد";
cm.Position = intposition;
listBox2.Items.Add(txtTajiki2.Text);
txtTajiki.Text += txtTajiki2.Text + " ";
}
}
word = "";
h = (txtTajiki.Text.Length / txtFarsi.Text.Length) * 100;
if (progressBar1.Value + (int)h <= 100)
{
progressBar1.Value += (int)h;
}
if (p + 1 < m.Length)
{
ch = "";
}
}
label5.Text = "تعداد تقریبی کلمه ها =" + listBox1.Items.Count;
progressBar1.Value = 100;
darsad.Text = "تمام شد";
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < 100)
{
}
}
}
}
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.Data.OleDb;
namespace Farsi___Tajiki
{
public partial class Form1 : Form
{
private const string _commandtext = "SELECT farsi,tajiki from farhang";
private const string _Connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\farhang.accdb";
OleDbConnection conn;
OleDbDataAdapter da;
DataSet ds;
DataView dw;
CurrencyManager cm;
double h;
private void filldatesetandview()
{
ds = new DataSet();
da.Fill(ds, "farhang");
dw = new DataView(ds.Tables["farhang"]);
cm = (CurrencyManager)(this.BindingContext[dw]);
}
private void bindfields()
{
txtTajiki2.DataBindings.Clear();
txtTajiki2.DataBindings.Add("Text", dw, "tajiki");
toolStripStatusLabel1.Text = "آماده";
}
public Form1()
{
conn = new OleDbConnection(_Connectionstring);
da = new OleDbDataAdapter(_commandtext, conn);
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
filldatesetandview();
bindfields();
}
private void Form1_Load_1(object sender, EventArgs e)
{
filldatesetandview();
bindfields();
}
private void txtLF_Click(object sender, EventArgs e)
{
darsad.Text="";
label5.Text = "";
progressBar1.Value = 0;
if (bestTranslate.Checked == true)
{
string m2 = txtFarsi.Text;
string newM2;
newM2 = m2.Replace("،", " ، ");
newM2 = newM2.Replace("?", " ? ");
newM2 = newM2.Replace(".", " . ");
newM2 = newM2.Replace("!", " ! ");
newM2 = newM2.Replace("؛", " ؛ ");
newM2 = newM2.Replace(":", " : ");
newM2 = newM2.Replace(";", " ; ");
newM2 = newM2.Replace("ُ", "");
newM2 = newM2.Replace("ِ", "");
newM2 = newM2.Replace("َ", "");
newM2 = newM2.Replace("ّ", "");
newM2 = newM2.Replace("'", " ' ");
newM2 = newM2.Replace("(", " ( ");
newM2 = newM2.Replace(")", " ) ");
newM2 = newM2.Replace("-", " - ");
newM2 = newM2.Replace("_", " _ ");
newM2 = newM2.Replace("{", " { ");
newM2 = newM2.Replace("}", " } ");
newM2 = newM2.Replace("ـ", " ـ ");
newM2 = newM2.Replace("؟", " ؟ ");
txtFarsi.Text = newM2;
}
listBox2.Items.Clear();
listBox1.Items.Clear();
txtTajiki.Text = "";
int intposition;
dw.Sort = "farsi";
string m = txtFarsi.Text + " ";
string ch = "";
string word = "";
int p = 0;
int lent = m.Length;
progressBar1.Value += 2;
for (int i = 0; i < lent; i++)
{
while (ch != " ")
{
ch = m.Substring(p, 1);
if (ch != " ")
{
word = word + ch;
}
p += 1;
ch = m.Substring(p, 1);
}
if (word != "")
{
listBox1.Items.Add(word);
intposition = dw.Find(word);
if (intposition == -1)
{
txtTajiki.Text += word + " ";
toolStripStatusLabel1.Text = "رکورد پیدا نشد";
}
else
{
toolStripStatusLabel1.Text = "رکورد پیدا شد";
cm.Position = intposition;
listBox2.Items.Add(txtTajiki2.Text);
txtTajiki.Text += txtTajiki2.Text + " ";
}
}
word = "";
h = (txtTajiki.Text.Length / txtFarsi.Text.Length) * 100;
if (progressBar1.Value + (int)h <= 100)
{
progressBar1.Value += (int)h;
}
if (p + 1 < m.Length)
{
ch = "";
}
}
label5.Text = "تعداد تقریبی کلمه ها =" + listBox1.Items.Count;
progressBar1.Value = 100;
darsad.Text = "تمام شد";
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < 100)
{
}
}
}
}