|
I would recommend using Socket Class which provides you to resume, stop your downloading or Uploading.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
i would like to know how to add a mousehovr effec to lines in the richtext control
Bad = knowing 2 much
|
|
|
|
|
You can use the GetCharIndexFromPosition() method of the rich text box to get the index of the character nearest to the specified position and then use this index to create a tooltip for each line.
See here for an example on how to use GetCharIndexFromPosition() .
|
|
|
|
|
I used the following code in a programming lesson to help me with a project but the lecturer says it is hard to maintain although I made it like that for better manageability:
static List<Person> _person = new List<Person>();
static void Main()
{
Dictionary<string, Action> methodList = new Dictionary<string, Action>();
methodList.Add("1", (() =>
_person.ForEach(s => Console.WriteLine("{0} {1}", s.Name, s.Title))));
_person.Add(new Person( "James","Prog" ));
_person.Add(new Person( "Claire","Illu"));
Console.WriteLine("Press 1 to show all data or 2 to quit");
string input = Console.ReadLine();
if (methodList.ContainsKey(input)) methodList[input]();
Console.Read();
}
|
|
|
|
|
Was he talking about the lamda stuff? If so, he's right. Rookie programmers would have a learning curve to go through. The lamda stuff doesn't give you anything in terms of speed, so it's rather pointless. If it doesn't improve the speed, obfuscated code like that is nothing more than a hindrance.
Of course, you'll find others here that disagree with me.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I can see your point however I disagree about lambda being a hindrance, the lambda expression in there is not complicated and saves me the hassle of having to make a method just to display the members which may only happen once. Although I can see that if I needed to display the details in other classes it would not be very productive.
Thanks for the reply !
|
|
|
|
|
We're talking about maintenance, not productivity. If you want better maintainability, you shouldn't use the lamda. Adding code complexity with no tangible performance gain is bad practice, IMHO.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
A simpler anonymous method may suffice.
|
|
|
|
|
It gives you speed when compared to overrides.. a switch is much faster though (and in this case probably also clearer)
That doesn't mean I disagree, of course.
|
|
|
|
|
But we're not talking about overrides. We're talking about populating a dictionary from a list...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I know, but soon the "anti switch" guerrillas will find the thread and suggest "a beautiful OO solution"
|
|
|
|
|
Don't you just hate zealots?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
"I know that there are people who do not love their fellow man, and I hate people like that!" -- Tom Lehrer
|
|
|
|
|
PIEBALDconsult wrote: Tom Lehrer
One of my heroes!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
You rang?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Did your XML generics get swallowed?
What exactly is he concerned about?
|
|
|
|
|
Thanks for the replies so far!
I think my lecturer is assuming that the program that was shown could be "grown" so I did not use switch as I assumed if the system were to grow adding more switch statements would decrease its quality?
Is there a better way around this instead of encapsulating the routines into the dictionary?
|
|
|
|
|
More switches? Why not just add more cases to a big switch?
|
|
|
|
|
That is true I initially used switches but as the project has an "unknown" amount of lookups I thought the latter approach would suit it?
|
|
|
|
|
Perhaps you should have told us what the requirements were.
What would he say to a system of plug-ins?
|
|
|
|
|
Where does that "unknown" come from? Unknown at compile time? (that would eliminate switch as option..)
|
|
|
|
|
It relates to an "unknown" GUI requirement as we have not been told what options we will provide the user with so options 1 and 2 are there for show.
|
|
|
|
|
Well if it's just that you could just go back and add some cases.. right?
|
|
|
|
|
Ok thanks for all the comments, it appears that a switch is all that is needed
|
|
|
|
|
If you need that logic in multiple places, there might be some value in putting it in a dictionary structure (e.g., if you need a combination of the values and the logic for selecting which keys depends on where the dictionary is used). That way, you can pass the dictionary around. Then again, you could just wrap a switch statement in a delegate and pass that around (may not work well if there is custom logic to access several keys). In this specific case, I see no reason a switch statement should not be used. It is certainly simpler and I recommend choosing the simpler approach unless there is a real chance you will need the more complex approach later.
|
|
|
|