|
private void zemin_MouseMove(object sender, MouseEventArgs e)
{
if (!this.ClientRectangle.Contains(e.X, e.Y)) return;
AtkiCozguNo(e.X, e.Y);
if (!tusaBasildi) return;
if (atki == sonAtki & cozgu == sonCozgu) return;
sonAtki = atki;
sonCozgu = cozgu;
renkKontrol(e.X, e.Y);
}
private void renkKontrol(int x, int y)
{
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==this.BackColor.ToArgb())
{
kutuDoldur(Color.Red);
}
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==Color.Red.ToArgb())
{
kutuDoldur(this.BackColor);
}
}
private void kutuDoldur(Color renk)
{
using (Graphics myKutu = Graphics.FromImage(kutuResmi))
{
myKutu.FillRectangle(new SolidBrush(renk),new Rectangle(xKoordinat,yKoordinat,kutuEbadı,kutuEbadı));
}
Invalidate();
}
private void zemin_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(kutuResmi, 0, 0);
}
|
|
|
|
|
First, it is hard to read your code, because it isn't formated (with <pre></pre> tags) and because there are a lot of non english variable names.
I woud love a few screenshot, how it shoud be and how it does happen. Have you thought of adding MouseUp and MouseDown events?
|
|
|
|
|
Hi Saksida,
I have already used MouseUp and MouseDown events to ensure left-mousebutton pressed.
I have screenshot but dont know how to send via forum.
The idea is on mousemove event check the grid cells whether filled or not with color red while left-mousebutton pressed.Cells were checking by GetPixel static method,checking is being done only entering new cell.
private void zemin_MouseMove(object sender, MouseEventArgs e)
{
if (!this.ClientRectangle.Contains(e.X, e.Y)) return;
AtkiCozguNo(e.X, e.Y);
if (!tusaBasildi) return;
if (atki == sonAtki & cozgu == sonCozgu) return;
sonAtki = atki;
sonCozgu = cozgu;
renkKontrol(e.X, e.Y);
}
private void renkKontrol(int x, int y)
{
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==this.BackColor.ToArgb())
{
kutuDoldur(Color.Red);
}
if(bitmapPixel.GetPixel(this, x, y).ToArgb()==Color.Red.ToArgb())
{
kutuDoldur(this.BackColor);
}
}
private void kutuDoldur(Color renk)
{
using (Graphics myKutu = Graphics.FromImage(kutuResmi))
{
myKutu.FillRectangle(new SolidBrush(renk),new Rectangle(xKoordinat,yKoordinat,kutuEbadı,kutuEbadı));
}
Invalidate();
}
private void zemin_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(kutuResmi, 0, 0);
}
|
|
|
|
|
I do not see any problem with it. Nor do I know what kind of confusion it is, xKoordinat and yKoordinat properly calculated?. Also for screen shot, you could upload to www.photobucket.com and put here a link.
PS: Sorry for not answering your email. I was in a hurry
|
|
|
|
|
|
Now that picture says a lot.
shoudn't line be:
if (atki == sonAtki && cozgu == sonCozgu) return;
|
|
|
|
|
I have tried double "&&" but result was the same.
|
|
|
|
|
does this problem occur with fast moving or slow moving mouse?
|
|
|
|
|
No, it does not change result.
I also tried "protected override" methods instead of "private void",but result did not change.
maybe I should write codes again in new project.
|
|
|
|
|
First, try setting breakpoint at renkKontrol(e.X, e.Y);//check color and look if you get called every time your mouse is at different rectangle. Make sure you have enabled your form to be top most and your IDE at side. When you reach breakpoint, don't move mouse, just continue and try next one.
|
|
|
|
|
That is unreadable withour proper formatting. Please edit and insert PRE tags.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi all,
I have an app that is currently being built for a windows mobile 6 device and a CE5 device.
The screens on these devices are different - one is landscape the other is portrait.
I need to display the app correctly on both devices. but was wondering what is the best way to approach this ?
1) Should i find screen orientation from Windows.Forms.screens.... then simply create a form for each of the orientations?
2) make a form that has anchored controls (in some way) so it doesn’t matter the orientation.
3) Has Microsoft got some other way of doing this ?????
The app has an output type of windows Application.
Any ideas would be gratefully appreciated !
Thanks
John
|
|
|
|
|
I had a similar problem; I needed my app to look good at any resolution.
My solution: I designed the GUI for the lowest resolution, then on startup I got the actual resolution and added the extra space in the X and Y directions to selected controls on each window.
Certain controls (like listboxes) could use extra space to show longer lines (X direction) or show more lines (Y direction). So each control had a percentage of extra space it would use in each direction.
In my case, I designed for 800x600, and my approach gave good results for 1024x768 and 1280x1024. After the app was released, some people used it at resolutions I had never heard of and it still looked good!
|
|
|
|
|
Hi,
That sounds like exactly what i want to do !!
Could i be really cheaky and ask if you have any sample code to get me started
Thanks
John
|
|
|
|
|
The code I have is in C++/MFC, so I don't know if you could use it. I don't have it here right now, but here's the general approach I used:
1. I invented a language called WASP (Window Arrangement Specification Protocol) which consisted entirely of ints, so I could easily store it in a static array in the class. This avoided all parsing and syntax issues. #defines were used for the ints to make the WASP program human-readable.
2. Each WASP op code was followed by the MFC int ID(s) of one or more dialog controls, and parameters. Each percentage (for the extra space for that control) was an int representing the numerator, assuming a 32768 denominator. This avoided having to encode floating-point percentages in the WASP program.
3. Sample WASP ops: Add a given percentage of the extra space in the X direction to the following control(s), terminated by a -1. Space the given controls evenly in the allotted extra space.
4. I also created a Wasp class that (as I recall) took a pointer (reference in C#) to the dialog, and the int array containing that dialog's WASP program. Each dialog called a method in the Wasp class to execute the WASP program to arrange the controls before it was first shown.
5. On startup, the screen dimensions are obtained and stored in static members in the WASP class to get the extra space we have to work with in both dimensions.
|
|
|
|
|
Hi Friends
An error "Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' is denied." occured in below code. How can i solve this problem
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "hello", "c:\\hello.exe");
thanks in advance-kk.tvm-
|
|
|
|
|
A non-administrative user does not have write access to HKEY_LOCAL_MACHINE.
What is the purpose of your project? Would it be ok to put a link into the user's startup folder? Or are you trying to create a Windows service? Then its installation routine would be run in administrative context and can write that key.
|
|
|
|
|
Hi bhiller
I am trying to build a program which appears as system tray, that starts everytime when system starts.
If i put program in user's starup folder, it will easily disable.
thanks in advance-kk.tvm-
|
|
|
|
|
Hi, I'm having a 1.4M record table stored in MS Access file and I thought the fastest way to retrieve some row data was to load it in a DataTable once in the first loading screen and then just filter it using the .Select() but surprisingly, it is very slow!!
Any similar experience??
Thanks!
|
|
|
|
|
did you try assigning it to a view and change row filter?
|
|
|
|
|
Som Shekhar wrote: assigning it to a view and change row filter?
Can you kindly shed some more light on that??
Thanks!
|
|
|
|
|
Look as Dave suggested, the first preference should be to let it be handled by the database since they are more optimized to do this.
However, if you insist on loading all data into a datatable, you can try using a dataview. However i am not so sure about the performance. Test it atleast.
DataView view = table.DefaultView;
view.RowFilter = "Value>2";
|
|
|
|
|
Thanks mate, unfortunately, I can't do that as I need to load the whole table to the datatable to cut down trips to the database.. And using the dataGridView control is not an option too as I'm using the listView control!.. Thanks anyways mate!
|
|
|
|
|
I used the following code and Dataview method is faster than the select method. I do not know why but it is.
Try it. May be it helps you.
DataTable table = new DataTable();
table.Columns.Add(columnName);
for (int i = 0; i < 1000000; i++)
{
table.Rows.Add(i);
}
MessageBox.Show("Loaded", "");
string condition = columnName + ">500 AND " + columnName + "<10000";
DateTime timeStart = DateTime.Now;
DataView view = table.DefaultView;
view.RowFilter = condition;
DataTable newTable = view.ToTable();
DateTime timeStop = DateTime.Now;
TimeSpan span = timeStop - timeStart;
MessageBox.Show(span.TotalMilliseconds.ToString(), "");
timeStart = DateTime.Now;
DataRow[] rows = table.Select(condition);
timeStop = DateTime.Now;
span = timeStop - timeStart;
MessageBox.Show(span.TotalMilliseconds.ToString(), "");
|
|
|
|
|
Did you also try just letting the database do the work by having it just return the rows you need instead of 1,400,000 of them and throwing a bunch out?
|
|
|
|