|
AFAIK there is no such event. What happens if you wait 50 msec before taking the snapshot?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks!
Simple solution that works nice.
It is true..i was not able to find such event
AFG
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Have you tried using the DropDownClosed event for the parent of the menu item in question? I'd probably set a flag in the item's Click event, then check it in the parent's DropDownClosed event and do your screen capture after the drop down menu has closed.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Yes and it doesn't work. I solved doing the screenshot 50 ms after the click.
|
|
|
|
|
I'm a little confused.
You say
manustone wrote: The point is that in doing this way ... the image includes also the open menu;
Then you say
manustone wrote: I need to call the function right after the menu item gets close
If you take the screenshot right after the menu is closed, how will the screenshot have the menu opened? Which do you want? Do you want the screenshot with the menu open or without the menu?
If you want to include the menu in the screenshot, I would create the image during the MouseDown and then save it during the Item_Click like so:
private Bitmap bmpScreenShot;
private Graphics gfxScreenShot;
private void takeScreenshotToolStripMenuItem_Click(object sender, EventArgs e)
{
bmpScreenShot.Save(@"D:\temp\screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
}
private void takeScreenshotToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
{
bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
gfxScreenShot = Graphics.FromImage(bmpScreenShot);
gfxScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0,
Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
}
If, however, you're trying to do something after the menu is closed, you could handle its parents DropDownClosed event.
|
|
|
|
|
So, the screenshot captures the drop down and you want to find a way to get the screenshot without the dropdown? But you want it to be taken right after an item in the drop down is captured?
Perhaps you could try doing a Refresh() on the form to force it to redraw itself and then perform the screen capture. You might also initiate an asyncronous event via this.BeginInvoke and have that event take the screen capture.
|
|
|
|
|
how can i bind checklistbox control with object in memory in asp.net
|
|
|
|
|
Well, in one sense all objects used for DataBinding are in memory. So for anyone to be able to give a meaningful answer I think you are going to have to give a better description of what you are trying to do.
If possible, include a small snippet of the code you have and a description of any errors etc.
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
what is the object you are referring to. Is it a dataset?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Hi,
I have the following complex type,
public class record()
{
string name1;
string name2;
}
I create a list of records in another function
public list<record> records();//list of records
Now I have to sort this class first by name1 and then by name2. Is there any simple way to do this?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
Write a comparer that does what you want and use Sort?
|
|
|
|
|
using System.Linq;
public class record
{
public string name1;
public string name2;
}
List<record> records = new List<record>();
records.Add(new record() { name1 = "a", name2 = "b" });
records.Add(new record() { name1 = "c", name2 = "d" });
records.Add(new record() { name1 = "e", name2 = "f" });
records.Add(new record() { name1 = "g", name2 = "h" });
records.Add(new record() { name1 = "i", name2 = "j" });
var r = records.OrderByDescending(sort => sort.name1).OrderBy(sort2 => sort2.name2);;
|
|
|
|
|
rvdenden wrote: var r = records.OrderByDescending(sort => sort.name1).OrderBy(sort2 => sort2.name2);;
This isn't correct.Because IOrderedEnumerable<telement> inherits from IEnumerable<t>, you can call OrderBy or OrderByDescending on the results of a call to OrderBy, OrderByDescending, ThenBy or ThenByDescending. Doing this introduces a new primary ordering that ignores the previously established ordering.
You need to use ThenBy[^] for the second stage of the sort.
var r = records.OrderByDescending(sort => sort.name1).ThenBy(sort2 => sort2.name2);
Simon
|
|
|
|
|
There are lots of ways of sorting the list: see here[^].
I would suggest you implement the IComparable<T>[^] interface and provide an appropriate body for CompareTo method. You can find such an example here[^].
Ramkithepower wrote: Now I have to sort this class first by name1 and then by name2.
In this case a possible implementation of the CompareTo method could be:
public int CompareTo(Record other)
{
int res = name1.CompareTo(other.name1);
if(res == 0)
res = name2.CompareTo(other.name2);
return res;
}
|
|
|
|
|
You can use OrderBy[^]
var sortedData = records.OrderBy(r => r.name1 + r.name2); You just concatenate the names in the key selector to achieve the ordering you want.
Opps. PIEBALDconsult[^] is of course totally right. That was a very stupid suggestion of mine, I don't know what I was thinking. Please ignore the above suggestion.
This is how you should really do it (using ThenBy[^]):
var sortedData = records.OrderBy(sort => sort.name1).ThenBy(sort2 => sort2.name2);
Simon
|
|
|
|
|
I don't think that's reliable.
|
|
|
|
|
|
Unless you right-pad name1. Or are you counting on case-sensitivity?
|
|
|
|
|
Ohh...
You are very right.
Thanks. Will edit.
Simon
|
|
|
|
|
because it is wrong. consider the following set of string pairs:
a,bd
ab,c
and try sorting them the right way and the concatenated way.
It would be right if you were to use string1 + charMax + string2 where charMax is a character that sorts last in the character collection.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Suppose name1 is the empty string..?
edit: ok you changed it
modified on Thursday, May 27, 2010 9:47 AM
|
|
|
|
|
Thank you all for the reply.
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
This article[^] covers the regular ways of sorting; it should be easy to understand and offer good performance at the same time; it does not offer the latest LINQ fancy things.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
How can I get event action (especially mouse events) on windows form use another program?
For example; User darw rectangle on form use with "Program1". Another program (may be windows service) detect user action in "Program1".
Main problem is "Program1" and other program (windows service) in different application domain.
How can I get event from another program?
Thanks...
|
|
|
|