|
It's suprising how often that comes in useful.
Join the cool kids - Come fold with us[ ^]
"Program as if the technical support department is full of serial killers and they know your home address" - Ray Cassick Jr., RIP
|
|
|
|
|
Yes, in all seriousness I actually use it quite a lot. I've learnt on environments where the debugger is either non-existent or so flaky one shouldn't use it, so I have a habit of dumping all relevant information to the console and looking to see which bits are wrong.
|
|
|
|
|
With such a general question you should always try a little research and study for yourself first: debugging[^].
The best things in life are not things.
|
|
|
|
|
Google and Bing are better at answering such broad questions than CodeProject forums.
|
|
|
|
|
Damn. I thought CodeProject forums were how you debugged...
|
|
|
|
|
GenJerDan wrote: Damn. I thought CodeProject forums were how you debugged...
Well, they are, sort of. See, the runtime throws a scary exception and then you run it through codeproject to get the human readable version. Sort of like a superman version of Exception::ToString().
|
|
|
|
|
There is this good article here[^] that could be useful to you.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Not sure what you consider "professional" level debugging, but here is an introductory video: Debugging C# in Visual Studio 2008. Some of the things covered in that video: compile errors, warnings, mouse-over errors, runtime errors, unresponsive programs, breakpoints, inspecting variable values. There are a bunch of other videos out there if that one does not suit you.
|
|
|
|
|
Hi,
1. I'm banging my head against the wall trying to write regualar expressions for local folder, shared folder and ftp paths, but didn't quite succeed as I relied on SrcString.LastIndexOf to check against illegal characters in the string as supposed to using pure regular expressions.
2. Code below - any problem? I couldn't find list of invalid char for FTP paths...
Thanks!
<br />
public static bool IsLocalPath(string strToCheck)<br />
{<br />
if (string.IsNullOrEmpty(strToCheck))<br />
{<br />
return false;<br />
}<br />
string strPattern = @"([a-zA-Z]:\\)[.]*";<br />
if (strToCheck.LastIndexOf(@"\\") >= 0)
{<br />
return false;<br />
}<br />
if (strToCheck.Contains(@"/")<br />
|| strToCheck.Contains(@"*")<br />
|| strToCheck.Contains(@"?")<br />
|| strToCheck.Contains("\"")<br />
|| strToCheck.Contains(@"<")<br />
|| strToCheck.Contains(@">")<br />
|| strToCheck.Contains(@"|")<br />
)<br />
{<br />
return false;<br />
}<br />
Regex objIsLocalPathPattern = new Regex(strPattern);<br />
return objIsLocalPathPattern.IsMatch(strToCheck);<br />
}<br />
<br />
public static bool IsShare(string strToCheck)<br />
{<br />
if (string.IsNullOrEmpty(strToCheck))<br />
{<br />
return false;<br />
}<br />
string strPattern = @"\\\\[.]*";<br />
if (strToCheck.LastIndexOf(@"\\") > 0)
{<br />
return false;<br />
}<br />
if (strToCheck.Contains(@"/")<br />
|| strToCheck.Contains(@"*")<br />
|| strToCheck.Contains(@"?")<br />
|| strToCheck.Contains("\"")<br />
|| strToCheck.Contains(@"<")<br />
|| strToCheck.Contains(@">")<br />
|| strToCheck.Contains(@"|")<br />
)<br />
{<br />
return false;<br />
}<br />
Regex objIsSharePattern = new Regex(strPattern);<br />
return objIsSharePattern.IsMatch(strToCheck);<br />
}<br />
<br />
public static bool IsFtpPath(string strToCheck)<br />
{<br />
if (string.IsNullOrEmpty(strToCheck))<br />
{<br />
return false;<br />
}<br />
string strPattern = @"[.]*";<br />
if (strToCheck.LastIndexOf(@"\\") >= 0)
{<br />
return false;<br />
}<br />
Regex objIsFtpPathPattern = new Regex(strPattern);<br />
return objIsFtpPathPattern.IsMatch(strToCheck);<br />
}<br />
dev
|
|
|
|
|
You might do better in the regex forum (this isn't really a C# question).
Broadly speaking you want a pattern like
prefix([a-zA-Z0-9#&\.]+[\\|$])+
... with prefix being "[A-Za-z]:\\", "\\\\" or empty for the three cases. $ is for the end of string; I can't remember if that's the right special character. You want a complete list of valid characters in the path section. Also, for FTP, chances are / is valid and \ may not be.
edit: the path section doesn't need to be a parenthesised group
modified on Monday, June 6, 2011 6:49 AM
|
|
|
|
|
You could always use a variant of this regex:
^((([a-zA-Z]:)(\\{2}[a-zA-Z]+)(\\{2}\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?=(\\(\w[\w ]*)))(\\\w[\w ]*)*)$ This might have been better placed in the regular expression forum.
|
|
|
|
|
Hello Friends,
I am trying to built an application that could store username and passwords for different site (facebook,twitter,yahoomail,gmail etc)and as soon as the user opens the site the username and the corresponding password should immediately get in the fields.Can any 1 help me out with this.Is there any algorithm for it????
well password must be encrypted when stored in the application well that could be done by using RSA algo but the main problem is how will the system detect which fields should be filled in the webpage????? i wish to code this in C#
Please do help me out and thanks in advance
|
|
|
|
|
I have never done that before but I have a few ideas that may help
Each website has different "fields" in their forms but generally they have an "id" and some variable that stores the link to the address where the contents in that field may be processed.
You need to always make sure each supported website is maintained so that the app always knows what each sites "schema" is...
You will then need to figure out what platforms your app will check, firefox, Ie ... as you will need to write a plug-in to interact with form elements, probably different for each environment (c# may not be 100% any more).
Overall its simply getting your browser to recognise the web page, grabbing the stored details from the user, decrypting the credentials and sending it via a browser plugin to the form elements based on the unique schema.
...Just some ideas...
|
|
|
|
|
Thanks for ur suggestion what i was thinking was to search for fields like id/username and the password fields is pretty common so if i could search these in the webpage and then fill the corresponding fields but how to fill the fields ????????
|
|
|
|
|
Doing a search like that wouldn't be reliable, and looking at the GMail login code it wont work...
I am afraid you will have to maintain each sites schema, luckily for you they don't change often.
Filling in the form with the user text requires (I would assume) an interface between your repository of user data (c# app stuff) and the web page.
As mentioned briefly before you will most likely need to write this "intermediate" app in a language that your desired browser needs. There may even be library's in C# from the browser dev team for public use, definitely in fire-fox anyway...
If the intermediate app can read local data, you could decrypt the user data required locally and get the app to read it before finally deleting it as a method of passing variables from the c# app to the plug-in?
You will have to delve deeper to make this, C# alone will probably not be the only tool to achieve this!
Hope it helps.
|
|
|
|
|
venomation wrote: I am afraid you will have to maintain each sites schema, luckily for you they
don't change often.
Actually, they change as soon as you've come to rely on the automated login filler and have forgotten the password.
|
|
|
|
|
There are a couple of ways of doing this, the easiest/most reliable I've found is to recreate the submission form with the same target and fill the fields there, and then autosubmit the form. This can be totally invisible to the user I've never done this using .NET but it can be done with static HTML and some basic javascript so doing it with .NET should be a doddle.
I have come across a couple of secure sites that wouldn't play ball with this but they're rare.
|
|
|
|
|
can u help me out with the java scripts for it????
|
|
|
|
|
This is a very simple example...
Notice there is only one inline javascript function that submits the form, the rest is plain html.
<html>
<head>
</head>
<body>
<!--
<form name="elementNameForm" action="targetPage.html" method="post">
<input type="hidden" name="elementNameUserName" value="userName" />
<input type="hidden" name="elementNamePassword" value="password" />
<!--
<input type="hidden" name="elementNameSubmitButton" value="submitText" />
</form>
<script language="javascript" type="text/javascript">
<!--
document.forms[0].submit();
</script>
</body>
</html>
|
|
|
|
|
I have a panel (win forms) that has scroll bars, the problem is that when the scroll button on the mouse is scrolled it is meant to just execute x, instead it is executing x and scrolling vertically!
How do I disable mouse scrolling only for the scroll panel and still capture the mouse scroll?
If I have confused you:
I would like the following:
1:Execute x command when mouse is scrolled
What it is doing (the problem):
1:Execute x command when mouse is scrolled
2:Scrolling vertically (DO NOT WANT)
Thanks
|
|
|
|
|
This works to disable mousewheel scroll for a listbox, so I'm guessing it may work for a panel as well.
listBox1.MouseWheel += new MouseEventHandler(listBox1_MouseWheel);
...
void listBox1_MouseWheel(object sender, MouseEventArgs e)
{
(e as HandledMouseEventArgs).Handled = true;
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks, I tried it but it did help
Still scrolls + executes instead of just execute.
MapRender.MouseWheel += MapRender_MouseWheel;
...
void MapRender_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta > 0)
_presenter.IncreaseTileSize();
else _presenter.DecreaseTileSize();
(e as HandledMouseEventArgs).Handled = true;
}
|
|
|
|
|
To avoid confusing the user, you should not do that... The best thing to do would be to uses a modifier key (like Shift + Mouse wheel) for your action.
Anyway, you would need to mark the event as handled to avoid default execution. For that, you probably have to handle to WM_MOUSEWHEEL message... or uses something else than a scrollable panel.
One possibility would be have have a regular panel and scrollbar controls and handle yourself the scrollbar.
Another possibility might be to have a control that handle the mouse wheel inside the panel and require the user to be over that control for you special function. It could then works similary to nested panel inside Internet Explorer... The inner most one would handle the event.
Philippe Mori
|
|
|
|
|
Thanks for the reply, I have already tried handling WM_MOUSEWHEEL messages but does not work...
Philippe Mori wrote: The best thing to do would be to uses a modifier key (like Shift + Mouse wheel) for your action.
This scenario seems like it would also fit the same problem im currently facing?
I would still have to sent the MouseWheel event and then check...
Such as:
MapRender.MouseWheel += MapRender_MouseWheel;
MapRender.KeyDown += MapRender_KeyDown;
MapRender.KeyUp += MapRender_KeyUp;
...
void MapRender_KeyUp(object sender, KeyEventArgs e)
{
if(_current == e.KeyCode)
{
_current = Keys.None;
}
}
private Keys _current = Keys.None;
void MapRender_KeyDown(object sender, KeyEventArgs e)
{
_current = e.KeyCode;
}
void MapRender_MouseWheel(object sender, MouseEventArgs e)
{
if(_current != Keys.ControlKey) return;
if (e.Delta > 0)
_presenter.IncreaseTileSize();
else _presenter.DecreaseTileSize();
}
Still have to pass through the same event handler which calls the scroll bar to change...?
|
|
|
|
|
You don't really have to hook keyboard events as it it possible to check the current keyboard state at the time MouseWheel is called.
But effectively, you still have to prevent the event...
Maybe one possibility would be to derive a control from the panel and override OnMouseWheel method.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmousewheel.aspx
Otherwise, the trick to uses a non scrollable panel and manual scrollbar controls would works...
Also, you have to be carefull about which control has the focus... Typically the inner control (the one inside the scrollable panel) should be focusable and handle the mouse wheel.
Philippe Mori
|
|
|
|