|
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
|
|
|
|
|
thats what i was dreading. thanks for having a look for me though dave much appreciated
|
|
|
|
|
Hi:
I am somewhat new to C# and I am trying to create a class that my forms use. The SCICommunication class contains a method called SCIgetCal. See below for code. My goal is to get the calibration data (X0g, X1g, Y0g, Y1g, Z0g, Z1g) from this function and work with it in my form class RawData.cs. I call it in my RawData.cs by the following: SCI_Communication.SciGetCal(X0g, X1g, Y0g, Y1g, Z0g, Z1g); How can I do this? What am I doing wrong? Do I need to add any headers or anything to RawData.cs to use this function? Please help!
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.IO.Ports;<br />
using System.IO;<br />
using System.Threading;<br />
<br />
namespace Triax_ReVamp<br />
{<br />
public partial class SCI_Communication<br />
{<br />
<br />
<br />
public static int SciGetCal(int X0g, int X1g, int Y0g, int Y1g, int Z0g, int Z1g)<br />
{<br />
int readCal;<br />
int[] readXYZCalBytes = new int [9];<br />
<br />
COM_Port.SCIPort.Write("K");<br />
int readCalBytes = COM_Port.SCIPort.BytesToRead;<br />
if (readCalBytes == 9)<br />
{<br />
for (int j = 0; j < readCalBytes; j++)<br />
{<br />
readCal = COM_Port.SCIPort.ReadByte();<br />
readXYZCalBytes[j] = readCal;<br />
return 1; <br />
}<br />
if (readXYZCalBytes[0] == 88 && readXYZCalBytes[3] == 89 && readXYZCalBytes[6] == 90)<br />
{<br />
X0g = readXYZCalBytes[1];<br />
X1g = readXYZCalBytes[2];<br />
Y0g = readXYZCalBytes[4];<br />
Y1g = readXYZCalBytes[5];<br />
Z0g = readXYZCalBytes[7];<br />
Z1g = readXYZCalBytes[8];<br />
return 1;<br />
}<br />
else<br />
{<br />
X0g = Y0g = Z0g = 128;<br />
X1g = Y1g = Z1g = 189;<br />
return 0;<br />
}<br />
<br />
}<br />
}<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
}<br />
Laura
|
|
|
|
|
You need to provide some additional information. Like what error are you getting? It would be helpful if you gave a slightly more comprehensive idea of what you are doing.
I have two comments:
1) In your first "for" loop you have a "return 1" statement. So you won't get to the rest of your code.
2) You may need to add references to the SCICommunications class. Visual Studio will complain if these references are needed.
Is SCICommunications class something you wrote, or is it from a third party?? I Googled it but I didn't find anything.
Best regards-
Squeaker
|
|
|
|
|
My goal in this project is to read in accelerometer data from a semiconductor board. The board responds to a protocol. If I write to the board a "K" it responds with 9 bytes of calibration data. The calibration data is as follows x, X0g, X1g, y, Y0g, Y1g, z, Z0g, Z1g. I am trying to create a class that has a built in function that writes a K to get the 9 calibration bytes. So that is why I wrote the class SciCommunications. I want to then call the function from a different class in order to get the calibration values in the RawData Class and other form classes. I am not getting an error but I am also not sure how to get the 9 calibration bytes in my RawData.cs. In my Raw Data I call it by doing
? = SCI_Communication.SciGetCal(X0g, X1g, Y0g, Y1g, Z0g, Z1g); Is this how I can get the 9 calibration bytes? What should I set the question mark to be, int or array? Hope this makes more sense!;P
Laura
|
|
|
|
|
Looking at your code for SciGetCal() it looks like it should work. Since this method returns an integer, you need to define a variable like ( int result; ) and then call your function like ( result = SciGetCal(...); }
1. Are you getting any errors?
2. Have you tried a normal serial communications program to see that the accelerometer board is working properly? HyperTerminal is the worst choice. If you need to get a simple one, I recommend Br@y Terminal. Free. And it doesn't install anything on your computer.
3. Do you have the serial port set up with proper baud rate, parity, stop bits, etc. ??
4. In Visual Studio you should put a break point when you start into your SciGetCal() method and step through the code line by line. This is pretty straight-forward since you only have a few lines of code. Are you using Visual Studio? What version?
5. Are you using Net 2.0??
Don't despair! Serial communications is tricky.
Regards-
Squeak
|
|
|
|
|
1. The following is the error that I am getting:
Error 4 'Triax_ReVamp.SCI_Communication.SciGetCal(int, int, int, int, int, int)': not all code paths return a value
I want it to be a boolean function.
2. I know that the serial communication is working, I have it working with a C++ program that we wrote previously which is very similair to this one and it works perfect!
3. I do have it set up properly: baud rate, stop parity, etc. I actually have this same code in my RawData.cs and it works. The reason I am trying to write a SCICommunication class is because I have multiple forms that will be calling the calibration function so I thought it would be better to have an outside serial class that has the function that I can call from all my forms.
4. I am using Visual Studio 2005 C#
I have attatched my code. I am trying to make it a boolean function, so that if it is successful in getting the calibration data it returns true, if it is not then it returns false.
Thanks so much for your help! I appreciate it!
<br />
public static bool SciGetCal(int X0g, int X1g, int Y0g, int Y1g, int Z0g, int Z1g)<br />
{<br />
int readCal;<br />
int[] readXYZCalBytes = new int [9];<br />
<br />
COM_Port.SCIPort.Write("K");<br />
int readCalBytes = COM_Port.SCIPort.BytesToRead;<br />
if (readCalBytes == 9)<br />
{<br />
for (int j = 0; j < readCalBytes; j++)<br />
{<br />
readCal = COM_Port.SCIPort.ReadByte();<br />
readXYZCalBytes[j] = readCal;<br />
<br />
}<br />
if (readXYZCalBytes[0] == 88 && readXYZCalBytes[3] == 89 && readXYZCalBytes[6] == 90)<br />
{<br />
X0g = readXYZCalBytes[1];<br />
X1g = readXYZCalBytes[2];<br />
Y0g = readXYZCalBytes[4];<br />
Y1g = readXYZCalBytes[5];<br />
Z0g = readXYZCalBytes[7];<br />
Z1g = readXYZCalBytes[8];<br />
return true;<br />
}<br />
else<br />
{<br />
X0g = Y0g = Z0g = 128;<br />
X1g = Y1g = Z1g = 189;<br />
return false;<br />
}<br />
<br />
}<br />
Laura
|
|
|
|
|