|
Well I tried your suggestion and the TreeView still does not scroll to the selected node and show it as selected. Must be a bug in the TreeView control.
Thanks for the assistance.
Mark
|
|
|
|
|
Hi,
Would anyone explain the meaning of the yellow highlighted code?
I am specifically not sure on what it means as a declaration.
// Constructor that defaults to case-insensitive switches and
// defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols) : this(switchSymbols, false, new string[] { "/", "-" })
{
}
// Constructor that defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches)
: this(switchSymbols, caseSensitiveSwitches, new string[] { "/", "-" })
And how would you rewrite it in a simplified way (Easy to read and understand)
Thank you.
Rad
public abstract class ArgumentParser
{
private String[] switchChars; // For example: "/", "-"
private String[] switchSymbols; // Switch character(s)
private Boolean caseSensitiveSwitches; // Are switches case-sensitive?
// Domain of results when processing a command-line argument switch
protected enum SwitchStatus { NoError, Error, ShowUsage };
// Constructor that defaults to case-insensitive switches and
// defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols) : this(switchSymbols, false, new string[] { "/", "-" })
{
}
// Constructor that defaults to "/" and "-" as the only valid switch characters
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches)
: this(switchSymbols, caseSensitiveSwitches, new string[] { "/", "-" })
{
}
// Constructor with no defaults
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches, String[] switchChars)
{
this.switchSymbols = switchSymbols;
this.caseSensitiveSwitches = caseSensitiveSwitches;
this.switchChars = switchChars;
}
Thanks,
Rad
|
|
|
|
|
radshaykho wrote: Would anyone explain the meaning of the yellow highlighted code?
What yellow highlighted code?
|
|
|
|
|
Colin Angus Mackay wrote: What yellow highlighted code?
Got me on that...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I don't understand your post.
You mentioned some yellow, the only yellow is the NEW sign on the subject line.
It's my guess the class intends to parse command lines, things that take
filenames (or some other objects) plus optional "switches" which start with
a special symbol such as - or / (as is often the case on UNIX/LINUX and Windows).
And then what follows that symbol may or may not be case-insensitive.
Now what is the problem ?
BTW: there are PRE tags to show code with background color and indentation.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
First, you should wrap your code sections in <pre> tags to make them easier to read. Second there was no section highlighted in yellow so everything that follows is based on guessing what you were asking.
public abstract class ArgumentParser
{
private String[] switchChars;
private String[] switchSymbols;
private Boolean caseSensitiveSwitches;
protected enum SwitchStatus { NoError, Error, ShowUsage };
protected ArgumentParser(String[] switchSymbols) : this(switchSymbols, false, new string[] { "/", "-" })
{
}
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches)
: this(switchSymbols, caseSensitiveSwitches, new string[] { "/", "-" })
{
}
protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches, String[] switchChars)
{
this.switchSymbols = switchSymbols;
this.caseSensitiveSwitches = caseSensitiveSwitches;
this.switchChars = switchChars;
}
} Based on the code presented here, the third constructor (protected ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches, String[] switchChars) ) is the one that actually does the work. The other two constructors are overloading the object constructor and providing two additional "short-hand" ways of declaring an instance of the ArgumentParser class that require fewer parameters. The this calls after the function declaration tell the runtime to call that version of the constructor before running any code in the requested constructor. (In this case, there isn't any additional code being run.)
The sequence that happens would be this:
- You call the
ArgumentParser(String[] switchSymbols) constructor, which
- calls the
ArgumentParser(String[] switchSymbols, Boolean caseSensitiveSwitches) constructor, passing in switchSymbols (from your call), false , and the string array { "/", "-" } as the parameters.
- This constructor runs and returns control back to the constructor you called, which
- runs any code contained in it's body (in this case, there isn't any.)
There really isn't a way to make this any simpler other than to remove the overloads and force everyone to call the full constructor; but that isn't really simplifying it.
|
|
|
|
|
I have a pdf file as byte[] coming from ReportingService, it is ok If I want to save it in client PC "Response.BinaryWrite(myReport)";
, but how can I send it as an atachment in email message?
.
.
.
byte[] myReport;
myReport= rs.Render(path,fileFormat, null, @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>", parameter, null, null,
out encoding, out mimeType, out parametersUsed,
out warnings, out streamIds);
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
//this one works ok:
Response.BinaryWrite(myReport);
//but I want to add attachment:
MailMessage em = new MailMessage();
em.Attachments.Add(myReport);//this doesn't work, I need to somehow change the "myReport" byte[] to pdf file
em.From = "myemail@email.com";
em.To = "myemail@email.com";
SmtpMail.SmtpServer = "emailserver";
SmtpMail.Send(em);
vafa
|
|
|
|
|
Create a MemoryStream from the byte data, then create an Attachment object by reading from the MemoryStream .
---
single minded; short sighted; long gone;
|
|
|
|
|
No, you need to covert it back to MemoryStream.
MemoryStream ms = new MemoryStream(myReport);
em.Attachments.Add(new Attachment(ms, [your mime type]));
modified 17-Jul-19 21:02pm.
|
|
|
|
|
ok, thanks for the postings, I could not get it done since I am not using .NET 2
in older version it just accepts the file path, but new one gets the MemoryStream too.
|
|
|
|
|
I would like to create a handler for form.GotFocus(). In VB I would use a procedure created by the IDE:
vb:
Private Sub Form1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
DOIT()
End Sub
How is this reflected in c#?
private void Form1_GotFocus(object sender, EventArgs e)
{
}
Jon
|
|
|
|
|
that seems correct. just add "DOIT();" to the methods body.
What is the problem?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
the problem was finding the command that tells .NET which function handles which event; I had second thoughts and used the EventHandler.
Jon
|
|
|
|
|
OK, I see; as Christian already replied, you add a delegate to the Focus event:
this.Focus+=new EventHandler(Form1_GotFocus);
the nice thing about Visual Studio C# is as soon as you enter the +=
it suggests the remainder of the line; tab twice to accept and automatically
get the handler's skeleton.
Alternatively you can do the same thru Visual Designer (if so, the this.Focus+=
line will appear file in Form1.Designer.cs)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
You can do it in the designer, or you can put some code somewhere that says this.Focus += new EventHandler(this.Form1_GotFocus); Something like that.
Yes, I like how VB does it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
I want to create an application that reads the videostream from a webcam, alter the videostream by applying filters, and send the altered stream to an application (like MSN, Skype and other apps that can use cams). To get this to work I guess I have to create an app that reads data from my default webcam, alter the videostream and sends this to a webcam driver that I have created.
In order to let MSN view the altered videostream by default, I need windows to think it has an extra webcam. In MSN it is possible to choose from several cams, and if I can et my "fake" driver to appear in that list, I can send my altered videostream to that driver.
Is this the way to do it? And how can I make this driver? Do I need anything else than WDK?
I'll appreciate all help.
-Martin
|
|
|
|
|
Maybe this holds the key[^]
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanx for the reply, but I didn't find what I'm looking for.
Instead, anyone who can tell me what I need in order to create a driver? Is WDK the only thing I need?
|
|
|
|
|
I am trying to create new "Communications cable connection between two computers"s in C# to be used with an existing or new Direct Connection (PPP link) in the RAS phone book. I have not been able to find any documentation on this and have been completely unsuccessful in figuring it out.
Any help would be GREATLY appreciated.
----------------------------------------------
Keith
|
|
|
|
|
KeithWT wrote: have been completely unsuccessful in figuring it out.
That's unfortunate.
KeithWT wrote: Any help would be GREATLY appreciated.
Read the first thread in this forum titled "How to get an answer to your question".
|
|
|
|
|
My initial posting was cryptic and so I will clarify it.
Windows RAS uses a "Communications cable between two computers" hardware object in the modem section of Device Manager, which is basically a virtual driver that lays on top of an existing serial or LPT port (like an external modem driver).
What I am trying to do is programmatically create or modify a "Communications cable between two computers" hardware object in the modem section of Device Manager. Exactly what I want to modify is the [Serial Port Number] and the [Baud Rate].
The Windows platform is WinXP Home/Professional, but I think that Win2K is exactly the same.
|
|
|
|
|
If you're using .Net 2.0 or above, look into using the "SerialPort" class. However, with .Net 1.x, you will have to look at using one of the serial port implementations that exist on this website.
Phil
|
|
|
|
|
When I rename the file that the code below is trying to open, I would expect an exception to be thrown(according to MSDN documentation). However, no exception is thrown and sr == null. Can anybody show me what I may be missing here?
StreamReader sr = null;
try
{
sr = File.OpenText(strFileName);
}
catch(System.IO.FileNotFoundException)
{
listBoxErrors.Items.Add("Unable to locate upload file.");
}
catch(Exception ex)
{
listBoxErrors.Items.Add("general error.");
}
Thanks,
Craig
Craig
|
|
|
|
|
You're not getting an exception because you are not trying to catch the correct exception. Using FileNotFoundException will throw an exception when a file you attempt to access doesn't exist. Replace your catch with the one below and it should work.
<br />
catch(FileNotFoundException ex)<br />
{<br />
listBoxErrors.Items.Add("general error.");<br />
}</
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
I am trying to catch the FileNotFoundException so I don't what your talking about. Look closer at my code sample. Have you ever tried this yourself. It seems to me that I should get a FileNotFoundException but that's not my experience.
Craig
|
|
|
|
|