|
thanks. One last question before I call it quits for the night.
On the toolstrip one can have add delete save whatever.
Well if I remove the delete button how in the heck can i get it back or do I have to delete the toolstrip
and start over? Or is there an easy way to add an event that does the same thing as the delete?
Like databindingsource.delete(current) or whatever? Sorry for all the questions I'm just trying to understand this stuff.
|
|
|
|
|
If you use a source control solution you'll be able to "commit" your working code. If you then decide to remove the "delete" button and change your mind on that, you can simply put back the old code using you source control program and the button will be there again.
I have no idea what it is that you want to delete, but if you need to duplicate the function of your delete button you can just copy the code in the event handler for it's click event to the place you need it to be. If this concept is unclear you might want to pick up a book on c# as this is very very basic stuff.
Standards are great! Everybody should have one!
|
|
|
|
|
Source control is what you need. There are a number of free ones and even more that cost you. Just google for source control and you will find loads. This is how the vast majority of commercial development is controlled.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I want save some information(gps data and coordinates and ...) in text file and then export this text file to .m file (for useing in matlab7.1).
|
|
|
|
|
Good, go ahead and do it. Or was there a question somewhere that I missed?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Howdy,
I'm working with an widget that is getting key strokes as (System.Windows.Forms) KeyEventArgs. In particular I'm currently working on controlling input from the numeric keypad on that widget.
When this widget gets input from the numeric keypad, I want to ignore whether or not caps lock is on and always enter a number: pressing numeric keypad 4 should enter a number 4 whether or not num lock is on.
I don't think I can just ignore the num lock status (although I'm open to suggestions), so I'm trying to come up with a way to work with the KeyEventArgs. I'd like to determine how I can map the KeyEventArg that the widget gets and send a number instead.
The problem is:
I can't find anyway to differentiate the numeric key pad 4 with num lock off (that sends a '<-') from the actual '<-' key input.
I also can't tell the difference between the numeric key pad 7 with num lock off (that sends 'home') from the 'home' key input.
Its obvious how I could go the other way and tell the difference between the numeric keypad 4 with num lock on (sending a 4 or more specifically a Keys.Num4) and the '4' key (that would send Keys.D4).
Is it possible to differentiate between control characters sent from the numeric key pad and the normal control keys? Is there another way I might get the effect I'm looking for?
(Hope that's readable, that whole key pad 4 with num lock off is a bit wordy, so ask me to clarify it if you can't follow).
Thanks,
Chris
modified on Monday, January 18, 2010 6:30 PM
|
|
|
|
|
AFAIK managed code will not help out; for the numeric keypad, all KeyEventArgs properties depend on NumLock, and when not locked the keys duplicate other keys.
So I expect you will need a lower-level solution and some P/Invoke. I don't have the details though.
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. [The QA section does it automatically now, when do we get it on regular forums?]
|
|
|
|
|
Hi all, pardon me, I need helping at the following code. When I run this code to get the IP address (at statement Console.WriteLine(ipAddress)) I get the IP address, subnet mask and network family at this maner:
169.254.25.129
255.255.0.0
255.255.255.255
but I need to get each of them uniqly (each one alone of others), and I need to get these using this code of the programe (this code from SharpPcap.2-1-1)….
Regards…………………………..
public Sockaddr(IntPtr sockaddrPtr)
{
// A sockaddr struct. We use this to determine the address family
PcapUnmanagedStructures.sockaddr saddr;
// Marshal memory pointer into a struct
saddr = (PcapUnmanagedStructures.sockaddr)Marshal.PtrToStructure(sockaddrPtr,
typeof(PcapUnmanagedStructures.sockaddr));
// record the sa_family for informational purposes
_sa_family = saddr.sa_family;
byte[] addressBytes;
if(saddr.sa_family == Pcap.AF_INET)
{
type = Type.AF_INET_AF_INET6;
PcapUnmanagedStructures.sockaddr_in saddr_in =
(PcapUnmanagedStructures.sockaddr_in)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr_in));
ipAddress = new System.Net.IPAddress(saddr_in.sin_addr.s_addr);
Console.WriteLine(ipAddress);
}
}// end of Sockaddr function
/////////////////////////////////////////////////////////////////////////////////
// A PcapUnmanagedStructures class is here:
public class PcapUnmanagedStructures
{
#region Unmanaged Structs Implementation
[StructLayout(LayoutKind.Sequential)]
public struct sockaddr
{
public UInt16 sa_family; /* address family */
[MarshalAs(UnmanagedType.ByValArray, SizeConst=14)]
public byte[] sa_data; /* 14 bytes of protocol address */
};
/// <summary>
/// Structure that holds an ipv4 address
/// </summary>
public struct in_addr
{
public UInt32 s_addr/*= 1111*/;
}
/// <summary>
/// Structure that holds an ipv4 address
/// 'struct sockaddr'
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct sockaddr_in
{
public UInt16 sa_family; /* address family */
public UInt16 sa_port; /* port */
public in_addr sin_addr; /* address */
// TODO: would be great to be able to have the compiler take care of this for us
// but I'm not sure how to
// pad the size of sockaddr_in out to 16 bytes
[MarshalAs(UnmanagedType.ByValArray, SizeConst=8)]
private byte[] pad;
};
}// end of the PcapUnmanagedStructures class
|
|
|
|
|
|
Hey everyone!
This is my first question that I've asked on this forum. I'm a fairly experienced C# coder who has browsed this site but never posted anything.
My question is simple, fairly straight forward. I would like to be able to select an object I have drawn with the System.Drawing.Graphics class. I would like to know how I could process the drawn-on control's MouseDown event so that the program can detect which objects have been drawn
this.CreateGraphics().DrawLine(new Pen(Color.Blue) { Width = 2.5f }, new Point(0, 0), new Point(50, 150));
This kind of drawing. I don't want to create a new control for every object being drawn on the screen, unless of course there is some way of doing it that doesn't hamper performance.
I have 2 ideas, but they aren't efficient enough, especially with a managed language such as C#. It is as follows: the program stores the information of which points inside the control are painted on. For example, the software could know that there is a blue pixel at point (20; 40). If the MouseDown event has to process every point, than I would imagine this method is extremely inefficient. Also, working out the area of a completely irregularly shaped object would be possible, but not in this case considering there are going to be user-defined/created objects drawn on screen.
Any advice on how I should do this? Any advice would be very helpful. Code samples would be a huge help.
Thanks A Lot,
Genius Mchlahla, (Amateur South African Programmer)
|
|
|
|
|
Which out of the following are you doing? I can give you an answer for any of them...
- Hit-testing individual shapes - i.e. determining whether the mouse is over a shape, and if so, which one of the shapes on your control it is over.
- Hit-testing the entire control - i.e. determining whether the mouse is over any drawn object on the control
- Determining redraw or clipping areas
I'll assume the first one for now, so here's a fairly efficient way to hit-test to determine which individual shape, if any, the mouse (or any other single point) is over.
First, you need to set up code to create a GraphicsPath for the shape that matches what's being drawn. For example, a GraphicsPath for a set of circles could be created like this:
var gp = new GraphicsPath();
gp.AddEllipse(myCircleRect1);
gp.AddEllipse(myCircleRect2);
Now, you can call gp.IsVisible(pt) to determine if a given point is over any filled part (as opposed to the outline) of the shape if it is a filled shape, or gp.IsOutlineVisible(pt, pen) to determine if a point is within the outline of the shape if it is not filled. If you want to check both the outline and the inside of a shape at the same time, use gp.Widen(pen) when you create the graphics path, after adding the shapes. In either case, be sure that your pen has all the characteristics of the one being used to actually draw the shape - width, mitre mode, end caps, dash type, etc. The GraphicsPath hit testing methods take these into account, which saves you a huge amount of coding to determine the actual line's hit test area.
To make use of this efficiently, this is probably the best way:
1. Re-build the shape's graphics path when the shape and/or drawing pen changes. Use gp.GetBounds() to get the outer bounding rectangle of the graphics path. Make sure to either pass the pen to GetBounds(), or use gp.Widen() when creating it as I mentioned above. Store the bounds of the shape with the object itself. If you have a whole lot of shapes, don't keep the graphics path around - call Dispose() on it and get rid of it. If you have a smaller number of shapes, you might want to store the GraphicsPath along with the cached bounds.
2. When a mouse down event happens, search through your list of objects (sorted by z-order so that you check the topmost shapes first), and find the first bounding rectangle that contains the mouse cursor point. When you find one, either retrieve your stored graphics path or create a new one (as above), and use IsVisible() or IsOutlineVisible() as above to find out if the mouse is actually over the shape. If not, continue to check bounding rectangles until you find another one that the mouse is within, and test the graphics path on that one, etc.
If you store the graphics paths, sure to cache the bounding rectangle when an individual shape changes, instead of calling GetBounds() on each object each time the mouse is clicked. Otherwise you won't be saving some CPU expense that you could otherwise save. Also no matter what you do with the GraphicsPath objects (caching them or discarding them immediately), always call Dispose() when you're completely done with them, just like you do with Graphics, Pen, and Brush objects.
Also note that the bounding rectangle is good to do hit testing with, but if you're determining the drawn area for redraw purposes or for clipping, you'll need to widen the bounds by a pixel in each direction to account for the possibility of antialiasing effects that could be outside of the hit testing bounds.
|
|
|
|
|
Thank you! I've been trying to figure this out myself but to no avail... This code is helpful
|
|
|
|
|
Glad to help
|
|
|
|
|
Can anyone explain how to edit one of the text fields in a report based off the an entry submitted by a user on a form textbox.
|
|
|
|
|
|
Collin Jasnoch wrote: Anyone done any speed comparisons in getting the info to file or the Event Logs?
Never done so; logging an exception is something that happens exceptionally, not every second. The EventLog is not the right place if you're logging a lot of traffic, but it is the right place to report problems to the SysAdmin of that network.
I think that you shouldn't be checking whether it's "speedy" enough, but rather if you can easily get all the information from it that you need. The fact that one can read an EventLog remotely doesn't matter much to me, as one can do the same with a simple text file.
I are Troll
|
|
|
|
|
|
Collin Jasnoch wrote: So what would be the right place?
For a lot of traffic, I'd go for a textfile and import that into a database. Easy to zip & mail, and appending text to a file doesn't cost much cpu-time. This is ideal for logging lots of data, as you can simply dump it without much ado. It would also be the best place to hide your exceptions from the customer if you wanted to - you can encrypt the string before writing it.
The EventLog would be the ideal place for exceptions, and general diagnostic events. Things like starting a service, or registering a new license.
|
|
|
|
|
Never had reason to test it, but I'm quite confident that speed is not an issue.
I'd use a framework such as the Microsoft Enterprise Library Exception Handling Block and Logging Application Block to give you the flexibily to change where and how you store such information if an issue does arise with one method.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Lookup TracerX. Very good at logging Messages/Exceptions. You can also set the level of the logs.
|
|
|
|
|
Log4Net provides a good way of performing the logging you need. The speed has allways been more than adequate for my purposes.
The Log file can be configured in the app.config file and can be sent to single or multiple destinations (event log, database, text file etc), and what is logged is customisable.
Log4Net is also fail-safe (ie almost never throws and error that stops your code), which is good for trace and error logging. Logging is not guaranteed (due to the fail-safe nature, a failure results in no message) and is therefore no good for audit requirements, but once you have it is configured and tested, I've not seen a message missed so it is pretty reliable.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Hi
i need help ...
i want to make program which can dial a phone using modem connected with a telephone line..and similarly record a
conversation and also set up a voice mail..i'm a bit familiar with c sharp language so would like to do in a c sharp language..if anyone had got any idea about it then..plz help me..
Thank You
|
|
|
|
|
In our company we use TopTAPI (the dll-version) to do this maybe you should test it. TopTAPI (its not freeware)!
Alternativly take a look at the TAPI (I would use TAPI3).
At least 1 hint: Its not fun to do this for analog connectors/telephones because you need a special modem (full-duplex and some other stuff I forgot) to do this and also in most cases the connection is only a one way (both are connected but only one of them could speak).
So just use it with ISDN and above (for example VoIP, but I never tested with TAPI).
Greetings
Covean
|
|
|
|
|
Hi!Covean
Thank x for your suggestion...isn't it possible with the inbuilt modem in a computer(the one which is used to connect dial up line)..what i want is if the phone line is connected to the computer via modem then..is it possible that all the phone works i.e. dialling or receiving call...could be done with the application..this is wht all i want..
Regards
DRS2010
|
|
|
|
|
As said before, it depends on the caps of the modem. But in theory it should work.
But here some impressions of mine, I made during our "virtual portier"-project.
Some day a customer of us wanted this solution but on a analog telephone system (we only installed it on ISDN before). This project really drove me cracy. We tested about 5 modem-types. Sometimes we had a full connection, sometimes only one of us could speak and so on... Till the end of the project we never found a stable solution for this (at least we solved it with an analog<->ISDN converter)!
So it should be possible but I would not recommend it!
Edit: To your question: I don't think that you will be able or happy to do this with the build-in-modem. But checking the line status, dialing and recieving calls will be able with TAPI.
Greetings
Covean
modified on Tuesday, January 19, 2010 3:48 AM
|
|
|
|
|