|
I did not say "it has never been implemented in C#", I said "What if you find that it hasn't".
But that doesn't matter. Your reply shows a commendable attitude, and I hope that you succeed. Even if you are doing it backwards.
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.”
|
|
|
|
|
Does anybody know of any simple tutorials on Plugin Architecture that I can wrap my little brain around? I have read quite a few in the past 48 hours and seem to be having difficulty getting my head around it.
While the tutorials/articles were very informative, I found that the projects they created for the articles were very overwhelming and a little too complex for a noob.
Also, I have found a few links relating to the System.AddIns namespace on the MSDN site, but that just made me even more confused because it's completely different from all the other articles I've read. Can anyone offer any advice/ help on this?
Thanks heaps,
jase
|
|
|
|
|
|
Yay thank you very much Curtis, that was very helpful and much appreciated.
Thanks
jase
|
|
|
|
|
No problem! I'm glad I could be of help.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi,
How to Extract/Search Document,Excel-Sheet,etc using Indexing Services
Can anybody give me example.
|
|
|
|
|
I wrote
Random RollOne = new Random();
Random RollTwo = new Random();
dieOne = RollOne.Next(1, 7);
dieTwo = RollTwo.Next(1 , 7);
sum = dieOne + dieTwo;
but dieOne and dieTwo are always equal, how do you make two independent random values?
Edit:
Thanks Mikanu, it works now.
modified on Monday, July 13, 2009 10:43 PM
|
|
|
|
|
The correct way to do that is to create an instance of the Random class and then call one of the following methods:
- Next(Int32 max) // will return a random number smaller than max
- NextByte() // will return a random byte (between 0 and 255)
-
NextDouble()
Here's a code sample which will generate two random numbers, a and b, between 0 and 10
Random rnd = new Random();
int a = rnd.Next(10);
int b = rng.Next(10);
----
<a href="www.mdinescu.com">www.mdinescu.com</a>
|
|
|
|
|
To add to the other post ( which was correct ), there is no such thing as a random number to a computer. It only looks that way. A random sequence is started by what's called a seed value. You can specify a seed value to regenerate the same pseudo random sequence if you need to. If you don't specify one, the current date and time are used. As you can see, you created two random objects with the same seed, so they will both start on the same number.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
You should create one instance of Random as a static field of the class and use it whenever you need it.
It should never be a local variable of a method.
|
|
|
|
|
Hello everyone,
I'm looking for a way of monitoring the incoming ping requests on a machine, I'm looking specifically for the Requesting host (IP or name, either works) and the size of the request. Does anyone know if this is possible with C#?
Thanks
modified on Monday, July 13, 2009 9:50 PM
|
|
|
|
|
I don't know how to do it in your code...
But here is a tool:
http://www.wireshark.org/[^]
(+ I Think you can't on Vista, some times ago I tested a C# sniffer code, but it broke on Vista, some socket required functionality being disabled on Vista, for security reason!)
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I have inherited a load of code and I am seeing things that I find troubling but Im not sure how serious they are. Im coming from years of experience with C++ and java, but Im relatively new to C#.
Some troubling things....
- One class is 5500 lines alone, another 4000. These are STATIC classes! I have never seen so many statics in one codebase before. Classes, methods, variables, etc. Lots of classes like this. My philosophy has been to prefer instantiable singletons over statics unless it is a small lightweight utility class. Is there a good reason to have so many statics?
- I have classes with over 20000 lines of code in ONE class. Not static thank god but still. There are probably about 15 classes over 10000 lines each. How can I refactor or manage this code? Lots of cut and paste obviously.
- There are 180,000 lines of code, and only 2 namespaces encompasing all of it. Shouldn't namespaces be used similar to packages in java? Each package helps to break down the code base into functional groups, right? Or is a namespace in C# different?
These seem like reasons to be concerned, if not run out the door right away... thoughts?
|
|
|
|
|
saxisa wrote: Is there a good reason to have so many statics?
It's just an idiom. I prefer to write static classes, but a class with a static Instance property works just as well. What is the difference ? If a class does not have state, then static makes sense to me.
The big classes are another thing.
saxisa wrote: How can I refactor or manage this code?
If you want to seperate in to smaller files, then you need to use partial classes. If you want to create smaller classes, it's up to you to decide how to break one class in to many.
saxisa wrote: There are 180,000 lines of code, and only 2 namespaces encompasing all of it. Shouldn't namespaces be used similar to packages in java?
Namespaces work in a similar way to C++, but dumbed down a little, like most of C#. I like to break things up in to folders when I create a project, and inherit namespaces from there, but I don't see anything inherently wrong with having less namespaces, so long as nothing clashes.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: It's just an idiom. I prefer to write static classes, but a class with a static Instance property works just as well. What is the difference ? If a class does not have state, then static makes sense to me.
Yes, It's just an idiom. But do you think creating a class (static) is reasonable just for grouping a set of methods? This is where C++'s free (non member) functions takes advantage. It will not force to create classes just for putting some methods. I really wish to see free functions in C#.
|
|
|
|
|
Hi,
I agree with what Christian said. I'll add some in my own words:
1. I don't mind static classes or singleton classes. When there is no state at all I think I'd prefer a static class over a singleton, since there is no real use in an instance then.
2. I don't mind large classes if they make sense. If they can be logically split into smaller ones, I'd go for that. Although it puts more burden on the user (remembering which method is in which class).
3. I would mind large methods very much. When refactoring, I'd go for smaller methods, and probably some internal helper classes. And use many files. I tend to keep files smaller than 400 lines.
4. yes namespaces are like packages (without the relation to folders though); having only a few does not hurt, until you get name clashes.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
In C#, I prefer static classes to classical singletons. I believe static classes were created to provide a more fool-proof way of writing singletons.
Big classes and big methods may be a code smell, but if you can't find ways to reduce them then they're fine. Some times classes and methods just need to be big.
I use only a few namespaces; I may have X.Y.Data , X.Y.Library , X.Y.Forms , etc.
I don't know Java, but I would assume that a .net assembly would be similar to a package.
An assembly may contain many namespaces, and a namespace may span many assemblies.
|
|
|
|
|
is there a best practice for mapping the work flow for the application menu, toolbar and the actual handler for the tasks behind the menu/toolbar items?
----------------------------------------------------------
Lorem ipsum dolor sit amet.
|
|
|
|
|
Hi,
when actions can be commanded in several ways (e.g. menu item, toolbar icon, ...) I tend to create a Command class, which sits in between the GUI and the business model. So the business layer can say enable/disable the Command without knowing any GUI details, allowing easy GUI redesigns (moving menu items around, adding/changing buttons, etc).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Forgot to mention, there are several patterns that generalize and formalize this.
Google for MVC (model-view-controller) and MVP (model-view-presenter).
I haven't fully understood them yet. IMO my Command classes are a pragmatic subset of MVC.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
i try to build a user interface like Paint, or a primitive kind of it.
It should be possible to click onto a picturebox and write something to that location.
I don't know where and when to initialise the textbox-object. Before runtime and just "activate" it when text is written, or dynamical if needed?
What is the best appoach to realise that the user can just click onto the picturebox (if the PrintText button was pressed) and get a curser where the text can be written.
Hopefully somebody can help.
Bye,
Michael
|
|
|
|
|
Hi,
just throwing Controls on top of each other won't cut it. If you want to create a paint program, using several controls is not the way to go. You really need:
- a single control that shows it all; I would use a simple Panel;
- a data structure that holds all the different objects that constitute your artwork; you might want to define a DrawableItem class, and derive specific objects from that; then collect them in a List<DrawableItem>
- a Paint handler that paints everything in the list;
- some Mouse handlers to click and selects DrawableItems so you can move, resize, delete them.
- etc.
Have a look at some of the paint articles here on CP, or Google for Paint.NET
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for your post.
To be more specific: it's a program to transformate and tesselate a picturebox. The design of this picturebox is just the first step.
I already use a class to manage all the different objects. In this class i have a list of GraphicsPath Objects, each connected to a pen which was used for this object.
Painting freehand-curves, regular shapes and other stuff works fine, but i don't get how to deal with the dynamic textbox.
I take a look at the paint articles, but i've already searched google with all keywords -suitable to this issue- i could think of.
|
|
|
|
|
Of course, you might choose to use a TextBox for inputting the text. But once the string becomes part of the artwork, the text is just a drawable item like the rest of them. Whether you use Graphics. DrawLine() or Graphics.DrawString() doesn't make any difference.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thats fine. I want to save it as a GraphicsPath-textobject anyway and handle it like all the other graphic objects.
But how to put the dynamic text into the pb? You see where my prob is?
|
|
|
|