|
I posted a question earlier re. genarics for .net 2.0 and seems that what I'm trying to do is unfeasible.
So here's my last (I think it's last) question on generics:
Is it possible to reference "current class" instead of hard-coding the class name in the code?
E.g.
abstract class BaseClass
{
static void GenericStaticMethod < T > (args)
{
...
}
void Foo()
{
GenericStaticMethod <CurrentClass>.(args);
}
}
class C1 : BaseClass
{
...
}
class C2 : BaseClass
{
...
}
when calling C1.Foo() , it should in turn call GenericStaticMethod < C1 > (...) or calling C2.Foo(), it should in turn call GenericStaticMethod < C2 > (...) ?
- Malhar
|
|
|
|
|
I don't think so. The best way to accomplish what you're trying to do is to make Foo() virtual, then override Foo in the base classes to do call GenericStaticMethod<t> using the current class type.
|
|
|
|
|
that's what i was afraid of! i wanted to use generics to the fullest. i wonder why microsoft couldn't have anticipated need for such.
- Malhar
|
|
|
|
|
GenericStaticMethod <this.GetType()>.(args);
Does not work?
/M
|
|
|
|
|
|
I want to display some values like Windows Task Manager - Performance:
Commit Charge (K) -- Peak
Physical Memory (K) -- Total, System Cache
How can I get this values using PerformanceCounter ?
Thanks.
|
|
|
|
|
That would be quite a trick. You would have to descend from PerformanceCounter to build a composite class that got that information for you from the class(es) you should be getting that information from directly. That would sort of be the long way around the problem kinda sorta wouldn't it?
Search your documentation and find the class(es) that do what you need to do. Call their methods or read their properties, and you won't have to design a class that uses that class to find out you can use that class directly.
BTW, here is what your documentation says about PerformanceCounter (I checked, just not to embarrass myself to horribly):
http://msdn2.microsoft.com/en-us/system.diagnostics.performancecounter(VS.71).aspx
If you don't find an appropriate member, your class search has just begun.
|
|
|
|
|
Thanks.
|
|
|
|
|
Hi all,
i have a problem, i need playing mp3 from stream (stream nor mp3 file from my hdd) but i dont now how
I hope anybody can help me with this problem. Sorry for my english .
bb
|
|
|
|
|
Hello ,
Can you please explain more about what you really want to do ??
Regards ,
nishu
|
|
|
|
|
ok i try this
i need play mp3 from memorystream without saving on disk.
Example: load mp3 file to memorystream and play him... All function need string with filepath and this is my problem.
|
|
|
|
|
hi,
I am trying to capture events happening on IE (especially anchor click).
I used typical IHTMLDocumentEvent2_Event method, but unfortunately this method was blocking up mouse activiteis(wheeling, selection and such)
So I tried to use custmoized handler that I found at http://west-wind.com/WebLog/posts/393.aspx[^]
But to do that, I need to access IE.docment.parentWindow to get IHTMLEvetObj.
I am using SHDocVw.InternetExplorer not WebBrowser nor AxWebBrowser, so it did not allow to access the actual IE window to retrieve events.
such as
IHTMLDocument2 document = IE.document as IHTMLDocuemnt2;
then, when I tried to do "document.parentWindow.@event"
I reports InvalidCastException.
Is there any one who has suggestions.
Thanks
|
|
|
|
|
You can try basic a debugging technique:
enter this line
double d = document.parentWindow;
Now, of course, this will not compile cleanly, and that is just what we want! Look at the error message and it will tell you that it can't convert from type zzz to double. (zzz will be a real type name, of course.)
Now you know that this should work, so enter it:
zzz z = document.parentWindow as zzz;
Then try to proceed from there. One step at a time.
|
|
|
|
|
I have a TabControl in my application. I have several TabPage's in it and as I add more my main form class is getting more and more cluttered. When you add an event (such as a button click) to a tab page, Visual Studio adds the code to the main form.
It seems to me that it would make sense to create a class for each tab page and have the buttons owned by it instead of the main form.
Is there a standard way to do this? I've searched the net and haven't found any examples.
Thanks much!
---
"No one would surrender to the Dread Pirate Westley."
|
|
|
|
|
If you have more than a 100 or so controls on a page you probably have too many as a general design principle.
As for tabs, one common method is for each tab page to contain a control. The control would have the UI portion on it. Then through public properties and events listeners could be used.
File Not Found
|
|
|
|
|
imho, your suggestion is very logical, but implementing it (in my experience) and other associated functionality is far beyond the practical limits of project development. It's a library development issue, and certainly not a lightweight one. I'm working on both C# and C++ library implementations which will accommodate you, but not for a few months down the road.
Nonetheless, in the current IDE implementation, indeed the pages are separate classes. The reason they are owned by the form is so that they may be supported by the form's designer. This is essential to the current serialization scheme.
Your "standard way" of doing this requires revising this whole system for some ostensible class design advantage. But your real complaint (if I understand you correctly) is the cluttered implementation of your conventional page control. Indeed, it has critical limitations, not just because it wastes space, or even because it may not internally manage resources as efficiently as a scheme might... but because your project may require so many pages that the navigation system (the tabs) would require all the available interface real estate.
OK. Some people will immediately scoff, "That would be a crazy application design."
But no, with a good design and underlying architecture provided by the underlying control, you can do this very efficiently and build applications which (through further shared resources) get much more accomplished than MDI implementations for instance can on the same footprint.
One thing I can suggest for you to save some interface real estate is to nest page controls. Build an outer page control which branches to several categories of interfaces, and navigate through branches to destinations.
This of course imposes extra clicks on navigation of your application. Solve the extra click issue by building shortcuts from within your pages to destination pages -- focusing the necessary outer page controls to do so. Wherever possible, also focus intended data. In other words, if you have a Property record which references an owner field, don't just provide a shortcut that focuses the owner page, leaving the lookup to the operator. Make your shortcut focus the necessary Owner record as well.
This will make your users happy for the while. Better solutions yet are just down the road.
|
|
|
|
|
Thank you both for your quick replies.
It does seem like Visual Studio doesn't have an easy way to create a class to hold all the controls in a tab page.
I'm not sure if this was the meaning of having each "tab page containing a control" but I took that idea and added a UserControl which created a container for my buttons and such. When I added it to the tab page it displays the design at least (although I couldn't edit it directly) and it does route the events to the UserControl UI correctly.
Is this how you suggest I do it? Or is there something simpler?
Thanks again.
---
"No one would surrender to the Dread Pirate Westley."
|
|
|
|
|
The reason you cannot (yet) edit it directly (evidently) is you probably haven't authored properties which interface the composite control you have built.
It's commendable you have gotten that far, actually. That's pretty good.
What I had in mind as sharing controls for all your pages -- in other words, use one set of controls built into your page control, and focus those on material of the focused/active page. That's just an alternate suggestion, and it is only pertinent if it would suit your purposes. But it is the most efficient way to go, because instead of deploying many controls, each of which do a given thing with given objects of one page, each of those controls is focused on the objects of the whatever number of pages... one page at a time of course, with the one page being the focused page.
|
|
|
|
|
Hello everyone,
I have created Two Windows Applications using C#. How can I call Windows Application "One" inside the Window Application "Two"?
Thank you so much for your help.
Khoramdin
|
|
|
|
|
What do you mean by "call"??
You can launch another application using the Process[^] class. "Calling" another application leaves lots of room for interpretation.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If you really want to windows applications to "talk" this is usually done through windows messaging. I have a sample article that uses windows messaging to tell a running application to show it self if it is currently minimized or on the tray. Here is the link:
http://www.codeproject.com/dotnet/windowsappsingleinstance.asp[^]
Hope that helps.
Ben
|
|
|
|
|
I assume you understand it is best to combine the applications, if practical. (You are the author.)
|
|
|
|
|
We have a bunch of adobe xdf files that are linked to pdf files and we want to programmatically convert them (output them) to tiff images. Anyone have a good tool recommendation? The few I have tested that work with PDF's fall flat when presented with xdf's!
File Not Found
|
|
|
|
|
hi all
does the transactionscope feature in .net 2.0 actually work with the filesystem or sending emails etc etc.?
i keep reading mixed blog posts.
i cant get it to work.
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
fileSystemManagement.CreateDirectory(folder);
userAccountManagement.AddUser(session.OriginatorUsername, session.OriginatorPassword);
userAccountManagement.AddUser(session.RequestorUsername, session.RequestorPassword);
emailGateway.SendOriginatorConfirmationEmail(session);
scope.complete()
}
|
|
|
|
|
Not in the way youre trying to use it, no. It won't back any of this stuff out if one of the lines in the transaction fails. It's primary use is in database transactions, not file system or email.
There is no way for the transaction to know how to rollback these operations if any one of them fails. You'd have to write you own wrappers, around each operation, that implements the ITransaction interface (I think!), and supply the code to commit and rollback those operations should the need arise. Although, there's no way to rollback an email operation...
You can find out how the entire Transaction namespace works and relates here[^]
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|