|
I made a T9 dictionary please take look I'am waiting your opinions.
Here is the code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace T9Sozluk
{
public partial class frmT9 : Form
{
public frmT9()
{
InitializeComponent();
}
SqlConnection Baglanti = new SqlConnection(Properties.Settings.Default.DBYolu.ToString());
SqlCommand Komut;
SqlDataReader dr;
string text = "", sonuc = "";
string[] dizi = new string[1];
int sayi = 0, deger=0, Lstart = 0, Lend = 0;
Point pnt;
bool swich = true;
bool show = true;
private void Form1_Load(object sender, EventArgs e)
{
Baglan(true);
listBox1.Hide();
}
public void Baglan(bool value)
{
if (value)
{
if (Baglanti.State == ConnectionState.Closed)
Baglanti.Open();
}
else if (!value)
{
if (Baglanti.State == ConnectionState.Open)
Baglanti.Close();
}
}
private void MakeSelection()
{
richTextBox1.SelectionStart = richTextBox1.TextLength;
richTextBox1.SelectedText = Convert.ToString(listBox1.SelectedItem);
sonuc = richTextBox1.Text;
sonuc = sonuc.Remove((Lend - sayi), sayi);
richTextBox1.Text = sonuc;
Lstart = richTextBox1.TextLength;
swich = true;
listBox1.Hide();
}
private void ShowSelection()
{
if (!show)
{
listBox1.Items.Clear();
Lend = richTextBox1.TextLength;
sayi = Lend - Lstart;
text = richTextBox1.Text;
if (Lstart > 3)
text = text.Remove(0,Lend-sayi);
text = text.TrimStart(Convert.ToChar(" "));
sayi = text.Length;
text = text + "%";
Komut = new SqlCommand("select count(kelimeadi) from kelimeler where " +
"kelimeadi like @KelimeAdi", Baglanti);
Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text.ToString();
try
{
dr = Komut.ExecuteReader(CommandBehavior.SingleResult);
if (dr.Read())
deger = dr.GetInt32(0);
}
catch (Exception hata)
{
MessageBox.Show(hata.ToString());
}
dr.Close();
dr.Dispose();
if (deger>0)
{
Komut = new SqlCommand("Select Kelimeadi From Kelimeler Where" +
" KelimeAdi like @KelimeAdi", Baglanti);
Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text;
dr = Komut.ExecuteReader();
if (dr.Read())
{
for (int i = 0; i < deger; i++)
{
dizi[0] = dr.GetString(0);
listBox1.Items.Add(dizi[0]);
dr.Read();
}
}
dr.Close();
dr.Dispose();
}
if (deger>0)
{
pnt = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength);
pnt.X = pnt.X + 15;
pnt.Y = pnt.Y + 20;
listBox1.Location = pnt;
listBox1.Show();
}
}
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar == 17))
{
show = false;
swich = false;
}
else
show = true;
if (!swich)
{
if (e.KeyChar == 13)
MakeSelection();
else
ShowSelection();
}
}
private void tsItemEkle_Click(object sender, EventArgs e)
{
Komut = new SqlCommand("Insert into Kelimeler(KelimeAdi) values(@KelimeAdi)", Baglanti);
Komut.Parameters.Add("@KelimeAdi", SqlDbType.NVarChar).Value = text.Remove(sayi);
try
{
Komut.ExecuteNonQuery();
MessageBox.Show("Kelime Listeye Eklendi...");
}
catch (Exception hata)
{
MessageBox.Show(Convert.ToString(hata));
}
return;
}
}
}
modified on Wednesday, May 6, 2009 4:46 PM
|
|
|
|
|
Use <pre></pre> tags around your code. (Use the code block widget below the reply area rather than type them if you prefer.)
Then format the code, you know indenting and so on, to make it readable, and you might get some answers. Probably not though.
If you like the code you have written then make an article around it and submit it in the normal way.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you for advice it looks better now.
|
|
|
|
|
emrah1982 wrote: I'am waiting your opinions.
A man's got to believe in something. I believe I'll have another beer!
|
|
|
|
|
Hi,
Is there any way to get the following to work?
bool s = _myProperty == true ? Method1() : Method2();
Or is this just silly talk?
|
|
|
|
|
Yes so long as the return types of Method1/2 are bool also.
|
|
|
|
|
I believe they (method1/2) would also have to be static (?)
---------------------------------------------
Help... I'm embedded and I can't get out!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
Only unless the method that is using this code is also static... otherwise they dont need to be. From the looks he is testing an internal variable so chances are it wont be static.
Edit: But it could be static even if it wasnt static... could go either way.
|
|
|
|
|
Jammer wrote: bool s = _myProperty == true ? Method1() : Method2();
Why doesn't it work? It should, as long as Method1() and Method2() return bool, or return types convertible to each other and to bool.
|
|
|
|
|
S. Senthil Kumar wrote: or return types convertible to each other and to bool
Good lord, I still remember that post on your blog. I asked a few people, and nobody knew it! I wonder why they made that restriction.
Cheers,
Vikram. Current activities:
Films: Sense and Sensibility
TV series: Friends, season 2
Books: Longitude, by Dava Sobel. Carpe Diem.
|
|
|
|
|
Hi,
I see ... the problem was the methods are void return types. Can this be used with void?
Cheers,
|
|
|
|
|
No, the expression containing the ternary operator must be of some type. If both the methods take no parameters, this will work
Action result = p ? new Action(M1) : new Action(M2);
result();
|
|
|
|
|
Jammer wrote: Is there any way to get the following to work?
bool s = _myProperty == true ? Method1() : Method2();
It should work, if both Method1 and Method2 are static and retrun a Bool value.
|
|
|
|
|
I don't get it, why should the methods be static?
|
|
|
|
|
They dont need to be as I said earlier... i.e.
class Conditional
{
private bool _myProperty;
public bool MyProperty
{
get { return _myProperty; }
set { _myProperty = value; }
}
public bool DoSomething()
{
bool s = _myProperty == true ? Method1() : Method2();
return s;
}
public bool Method1()
{
return true;
}
public bool Method2()
{
return false;
}
}
|
|
|
|
|
sorry on that - I had another issue on my mind when I read the question and posted that. I just thought of how I would stick that in a console app - where method1 & 2 were helpers to Main (ie. methods in the Program class) - in which case static would be required. But on considering.. should have just posted my own question quietly.
---------------------------------------------
Help... I'm embedded and I can't get out!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
|
Hello there,
Can anyone name me a site where I can download a huge or a limited quantity of icon files (*.ico images)!
Your help will truly be appreciated,
Rajdeep.NET
|
|
|
|
|
Have a Google for free icons, loads of hits. You'll have to select what suits you, for yourself though.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Well I can give you advice If you are using visual basic . net Framework There you can make icon for you .exe files
Here I give you a link they have licence about you can free download there Icons for windows applicacion or what ever you want .
The link :
miloszwl.deviantart.com
|
|
|
|
|
|
Is it possible to somehow pass an image to a report? I have the byte[] but the ReportParameter only takes strings. So how do I pass the byte (which contains an image) and pass it to the report and display the image in the report?
Currently I'm passing this:
ReportParameter[] parameters = new ReportParameter[6];
parameters[0] = new ReportParameter("Tag", this.Tag);
parameters[1] = new ReportParameter("Completed", dateTimeCompleted.Value.ToLongDateString());
parameters[2] = new ReportParameter("HDModel", txtModel.Text);
parameters[3] = new ReportParameter("HDSerial", txtSerial.Text);
parameters[4] = new ReportParameter("HDSize", txtSize.Text);
parameters[5] = new ReportParameter("Signature", GetSig().ToString());
GetSig() gets the bytes:
byte[] GetSig()
{
MemoryStream ms = new MemoryStream();
Bitmap SaveBMP = new Bitmap(panelSig.Size.Width, panelSig.Size.Height);
panelSig.DrawToBitmap(SaveBMP, new Rectangle(0, 0, panelSig.Size.Width, panelSig.Size.Height));
SaveBMP.Save(ms, ImageFormat.Png);
byte[] sigPic = ms.ToArray();
ms.Close();
ms.Dispose();
SaveBMP.Dispose();
return sigPic;
}
But how do I display that in the reportviewer on the report?
|
|
|
|
|
hi
does return form a value such as function ???
|
|
|
|
|
Return[^] simply returns from the method (function). If the method signature specifies a return type then the return needs to return an instance of that type.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
thanks a lot
yes
but where must i write? in witch part??
|
|
|
|