|
there are 37 numbers on a roulette wheel (without number zero the casino could be in trouble pretty soon); and you probably also want some intermediate positions, especially when the wheel slows down, so 37*5 images seems more like it.
|
|
|
|
|
|
PIEBALDconsult wrote: 38 in the U.S. -- 00 .
0 for the casino.
00 for the government?
|
|
|
|
|
Heck no, the guv'mint takes more than that.
|
|
|
|
|
Rob Philpott wrote: Yes, WPF makes things like that considerably easier.
I am excited to get started with WPF, however, I think I should get through my "Head First C#" Book first, and learn C# properly.
I will look into what you have sugested, and see if I can get something going.
Thank you for the sugestion,
Regards,
Stephen
|
|
|
|
|
Not entirely on-topic, but... I can't stand games that waste time doing crap like that. Just randomize the number already!
I'll always remember that the Amstrad that my father bought (mid-80s) had a Wheel Of Fortune game installed, but the clock was much slower than the developers had intended -- waiting for the wheel to stop spinning was horrible.
What I recommend is randomizing a number and displaying just that number. Do it a few (10?) times so the user sees the numbers flashing. That's what I do for a dice game I wrote; it's much quicker and easier.
|
|
|
|
|
PIEBALDconsult wrote: I can't stand games that waste time doing crap like that.
Maybee. I do see where your comming from, but the idea is to design a realistic and working mini roulette game, so the spinning wheel is a real big part of it.
Also, this is just a fun app, and a doubt many other people will use it.
The main idea for this is a learning curve for a beginner, and not so much the spinning wheel, but the fact that I can learn how to spin the wheel realisticaly, which may be usefull for other stuff.
but thank you for your point of view!
Steve
|
|
|
|
|
You should just bite the bullet and learn WPF.
Doing this in, well, GDI/GDI+ is the correct term here since Winforms has nothing to do with your question, will require you to worry about such silly things as multi-threading, timers, double buffering, geometry, etc and you'll have to write a lot of code.
In WPF, you just attach an animation that animates the rotation angle from 0 to 360 degrees and you're done. 5 minute job max. ZERO code as it can all be done with one line of XAML.
|
|
|
|
|
SledgeHammer01 wrote: You should just bite the bullet and learn WPF.
What? While learning C#?
SledgeHammer01 wrote: one line of XAML.
Could you show one line that does this?
Either way, I am starting to lean toward the idea of WPF.
Thank you,
Steve
|
|
|
|
|
|
Thank you,
That has gave me something to look over the weekend.
Regards,
Stephen
|
|
|
|
|
For a more realistic spinning roulette wheel (even on a slow system) use blurred intermediate images. These will give an appearance more like what a person would actually perceive seeing a real wheel spinning. Transition to actual images as the wheel slows down.
|
|
|
|
|
Alan Balkany wrote: For a more realistic spinning roulette wheel (even on a slow system) use blurred intermediate images. These will give an appearance more like what a person would actually perceive seeing a real wheel spinning. Transition to actual images as the wheel slows down.
This sounds like a very interesting idea, however, I would not have a clue where to start by doing this. Would you possibly be able to provide a little more information please?
Thank you,
Regards,
Stephen
|
|
|
|
|
This http://www.blackpawn.com/texts/blur/default.html[^] gives basic blurring algorithms, but they're rectangle-oriented, and you need to adapt them for rotation.
So, instead of averaging in a rectangular region for each pixel, you'd use an arc representing a fraction of the roulette wheel's rotation, at the pixel's distance from the center +/- a delta constant.
|
|
|
|
|
Thank you,
I will look into this.
Regards,
Stephen
|
|
|
|
|
I want to compare 2 lists
i should get result if any of their property matches
I have this code
var list1 = new List<Emp>();
var list2 = new List<Emp>();
list1.Add(new Emp { Empname = "nitin", ID = 1 });
list2.Add(new Emp { Empname = "nitin", ID = 1 });
list2.Add(new Emp { Empname = "nitin", ID = 1 });
list2.Add(new Emp { Empname = "Sean", ID = 3 });
foreach(var p in list1.Count()>list2.Count() ? list2:list1 )
{
var u=list2.Where(x => x.ID == p.ID || x.Empname == p.Empname );
}
This works fine but results are displayed twice it should be only one. currently i get {nitin,1} twice in u.
where is the issue.
|
|
|
|
|
Don't use Linq, and break after the first match.
Or maybe use distinct? Is there one?
|
|
|
|
|
That's what the selection on list2 will give. (Think about it for a moment.)
What you want is something along the lines of
var matches = list1.Where(x => list2.Contains(x));
Since you apparently want a value comparison you should override Equals (and maybe == too) on Emp. That would test that all the properties matched (and I think it would make Contains work in the above expression).
If you really want to check that any of the properties match, you need to write a Contains equivalent (it's a one line LINQ expression). But that seems unlikely.
Ideally you'd be using the same actual object for what appears to be a reference to the same database row, but if it's actually coming out of a database provider that may not be possible. Classes that represent database entities often want value semantics for equality (unless you're using some clever entity management framework that gives you the same instance for the same row).
|
|
|
|
|
Just use a First query on the end of your Where query like this
foreach(var p in list1.Count()>list2.Count() ? list2:list1 )
{
var u=list2.Where(x => x.ID == p.ID || x.Empname == p.Empname ).FirstOrDefault();
}
and that will return the first such emp. I use FirstOrDefault() in case there are no matches it will return a null Emp instead of throwing an Exception if there are no matches.
You need to look out if List2 is longer than List1 as you will then be matching List2 to List2 here list2.Where .
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Since you are adding Emp{Empname="nitin", ID=1} twice I guess finding it twice in your foreach shouldn't be that much of a surprise.
I would use intersect. That means implementing IEquatable for your class (and perhaps GetHashCode).
Like this:
class Emp : IEquatable<Emp>
{
public string Empname { get; set; }
public int ID { get; set; }
#region IEquatable<Emp> Members
public bool Equals(Emp other)
{
if (Object.ReferenceEquals(other, null)) return false;
if (Object.ReferenceEquals(other, this)) return true;
return ID == other.ID &&
Empname.Equals(other.Empname);
}
#endregion
public override int GetHashCode()
{
return Empname == null ? 0 : Empname.GetHashCode()^
ID.GetHashCode();
}
}
And then use it as:
var u = list2.Intersect(list1);
|
|
|
|
|
Hi,
In my windows application i am using file dialog box for uploading the file. If the file is in use i am not able to upload its giving exception.
How can i solve it,i mean to say if still the file is in use i want to upload it.
Can any one suggest me how can i do it ?
Thanks in advance.
|
|
|
|
|
If another application has the file open, and locked for reading, you cannot read from it. That's an OS level restriction. You can give yourself a chance by requesting a read-sharable lock to the file yourself:
FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
This will succeed where an attempt to open the file read/write won't if another application has done the same thing. However, most applications lock files completely while in use (and some, notably MS Office, keep the file locked while it is open ... bad practice, that), and there is simply no way to read such a file while the other application has it open.
Check that your own application isn't opening a file and forgetting to close it, though. That's a good way of creating this exception that can be fixed. You can generally put a FileStream or StreamReader in a using block which makes sure it is always closed.
|
|
|
|
|
thanks it helped me a lot.
|
|
|
|
|
BobJanova wrote: This will succeed where an attempt to open the file read/write won't if another application has done the same thing. However, most applications lock files completely while in use (and some, notably MS Office, keep the file locked while it is open ... bad practice, that), and there is simply no way to read such a file while the other application has it open.
I don't agree on you that it is bad practice. If MS Word is doing intermittent writes to it and share it for reading, then another application reading the file could get strange results, where the first half of the file is 'old' and the second half is 'new'. Locking files (appropriately) while in use is a good thing.
Consider a user deleting a file, and it keeps coming back. "Why is this happening?!". Because the application that is writing to the file doesn't have it locked, so at every write it comes back*. With locks, the user gets the immediate error that the file is in use.
The lock is there because the file is in use, and access to it can't reasonably work properly, so it is protecting other applications.
* slightly fictional situation, but it is a good example of why files have locks
|
|
|
|
|
The file should be locked against reading when it is actually being written. In a document editing app, that should be the time between pressing 'Save' and the save completing. There's no reason for a program like Word (or Adobe Reader, lest ye think I'm just being anti-Microsoft) to hold the file open the entire time you are looking at it.
The basic point I'm trying to make is that yes, locks are for when the file is in use. Once a document is loaded, it is in memory and the file shouldn't be in use; you should be able to open, delete, edit it etc in another editor (as you can with text editors, image editors etc) while it is being viewed in one editor.
This is kind of a tangent but I don't mind because I think the OP already got a good answer.
|
|
|
|