|
There is nothing in the .NET Framework Base Class Library (BCL) that can do this. You should download Microsoft DirectX 9.0 with the managed classes that will allow you to use C#. Read the docs so that you understand the concepts, which is basically to string readers, decoders, encoders, and writers together. In your case, it's slightly different. You should also search this site because I'm sure I've seen an example or two on this topic.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
Thank u Heath Stewart, let me download Microsoft DirectX 9.0 with the managed classes. Let me also search more this into this site and then i will decide what can i do.
Khurram.
|
|
|
|
|
OK, I have spent hours trying to figure this out on my own. I think I just don't know what the correct terminology is.
I am trying to call a form enter some data and pass that data back to the calling form. I am using a custom form and not a built in dialog.
Can someone point me in the right direction. I can't seem to even find an example on CP, MSDN, or a mayrid of other websites as well as two C# books.
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
Jeff,
You should check into delegates, events, and eventargs. You can derive a class from EventArgs from which you can specify whatever values you want to pass. Events allow you to register delegates which are held in some-what of a linked-list fashion which are then invoked when the event fires. There are several good articles available, some which are on CP (check out Chris Sell's article: .NET Delegates: A C# Bedtime Story[^]). Hope this is of some help. Here is just one example of how delegates and events work together:
using System;
using System.Windows.Forms;
namespace Test
{
class Class1 : System.Windows.Forms.Form
{
public Class1(){}
public delegate void MyEventHandler(int i);
public event MyEventHandler MyEvent;
static void Main(string[] args)
{
Class1 cls = new Class1();
cls.MyEvent += new MyEventHandler(SomeMethod);
cls.MyEvent += new MyEventHandler(AnotherMethod);
if(cls.MyEvent != null)
cls.MyEvent(6);
cls.ShowDialog();
}
public static void SomeMethod(int i)
{
MessageBox.Show("Hello from SomeMethod. " +
i + " was passed in.");
}
public static void AnotherMethod(int i)
{
MessageBox.Show("Hello from AnotherMethod. " +
i + " was passed in.");
}
}
}
-Nick Parker
DeveloperNotes.com
|
|
|
|
|
Thanks Nick, I will have to study this a little more indepthly. I read the "Bed Time Story" before I posted this message and it looked like it was more complicated that what I was trying to do. I guess not.
Thanks
Jeff Patterson
Programmers speak in Code.
http://www.anti-dmca.org[^]
|
|
|
|
|
Hi guys,
I am currently implementing an application which needs to support paths like:
%windir%\Microsoft.NET\Framework\
The pointers (eg %windir%) are supported by .NET, so i can access file listings easily.
However, Directory.Exists returns some wierd results:
Directory.Exists("%windir%") => false
Directory.Exists("%windir%\Microsoft.NET\") => true
Does anyone know of a way to validate these directories properly. I can just request a directory listing, and wait for an exception but this isn't good coding and will slow down the process too much as potentially hundreds will need to be evaluated.
Thanks,
Tatham Oddie
Developer, SSW (www.ssw.com.au
|
|
|
|
|
These are actually called environment variables, not pointers. Windows 98 and ME don't always support the same environment variables as Windows NT. It is better to use Environment.GetFolderPath , since this is supported by all operating systems that currently support the CLR. The functions that this method use are actually used by Windows Explorer, Windows Installer, various Microsoft and non-Microsoft applications, and the .NET Framework, of course. It is far more reliable and more robust to use this like so:
string system = Environment.GetFolderPath(Environment.SpecialFolder.System);
string windir = Directory.GetParent(system).FullName;
string framework = Path.Combine(windir, "Microsoft.NET\\Framework"); A little long-winded, but - as I said - is supported on any OS supporting the CLR and uses the paths that administrators might set up in a roaming profile or for home directories and what not (overriding the defaults).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there any way to have a function that accepts a function name as a parameter and is then able to call it?
EXAMPLE:
public void MyFunc(Function func)
{
func();
}
Help is greatly appreciated.
|
|
|
|
|
May be you can use Delegate and pass out delegate function.
|
|
|
|
|
The following is a quick example of a delegate in C#.
using System;
namespace Test
{
class Class1
{
delegate void Func(int i);
static void Main(string[] args)
{
Func f = new Func(SomeMethod);
f(4);
}
public static void SomeMethod(int i)
{
Console.WriteLine("Hello from SomeMethod. " +
i + " was passed in.");
Console.Read();
}
}
}
-Nick Parker
DeveloperNotes.com
|
|
|
|
|
Call the funcitzon "by name":
public void MyFunc(Function func)
{
//get the type of the object containing the method
Type type = this.GetType();
//get the method
System.Reflection.MethodInfo methodInfo = type.GetMethod(func, BindingFlags.Default);
String result;
if(methodInfo == null){
result = TextConstants.MSG_MethodNotFound.Replace("Method not found");
}else{
//call the method
result = methodInfo.Invoke(this, null).ToString();
}
}
|
|
|
|
|
I'm working on an app where I have some objects that are displayed onscreen and the user needs to be able to link them together by dragging and dropping a field from one to the other (just like a graphical sql query designer does only this is with business objects).
I need to do the bit where the lines are drawn that link the objects together visually. I can easily draw a straight line between them and keep track of the anchor points, but this doesn't look very nice compared to programs that route the lines efficiently.
Before I re-invent the wheel, anyone know of any source of info on this?
I support two teams: the Canucks and whoever is playing the Leafs!
|
|
|
|
|
does anyone have good examples of where attributes are put to good use in C#? MSDN have decent examples on "HOW TO" use them, but pretty thin on the "WHY" to use them section.
Phil.C
|
|
|
|
|
Why use attributes? Because it makes somethings easier. Attributes are metadata that is exposed so that other bits of software can discover what your code does and can interface appropriately to it.
NUnit (A unit/regression testing tool) use attributes to define test methods. Why? So that when you create a testing method you can put the attribute to tell NUnit that this is a test method with the code that does the test, rather than in, say, some secondary file which won't get updated properly, or contain errors because it was updated badly, etc.
You can use attributes when you are creating serializable classes to assist with the process. (They help define how it gets serialized). Why? Because it keeps the information next to the place that exposes the value, if something should happen to the value, the attribute can be updated easily.
If you create custom controls, the attributes you place on properties let the IDE know what should and should not go in the designer, what icon to use in the toolbox etc. Why? To keep together the information about the property with the property. If the property changes, so might the information and it would be much easier if all the changes are in the one place.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
I am desperately looking for Managed DirectSound (in DirectX 9.0) resources. There are *none* out there. I have looked at the pathetic Managed DirectSound section at MSDN (no articles, no examples, only a brief "play a sound", and a more advanced "play a sound, now with volume controller" example... ok a few more, but nothing much ), and in addition the headings on all MSDN Managed DirectX articles says "Note: This documentation is preliminary and is subject to change".
I have also examined the C# examples in the DirectX 9.0 SDK, but these are also very beginner.
I have found only *one* other "resource" at Craig Andreas weblog[^] which is a great but very beginners tutorial.
Can anyone help me with this?
... and yes, I have tried google
Øyvind
|
|
|
|
|
Øyvind Bratland wrote:
I have also examined the C# examples in the DirectX 9.0 SDK, but these are also very beginner.
Okay, I'm probably going to get flamed for this, but if you're looking for tutorials on how to use managed DirectSound...then you are a beginner (at least for managed DirectSound/DirectX)! Learn to walk before you run.
If you're no n00b to DirectSound/DirectX, the principals are still the same - you just don't have to worry about the oodles of code required for even the most trivial functionality.
As far as the warning in the documentation, I'm not sure why it's still there. It's been there for the last 3 or 4 updates to the release code (it's understandable why it's there for alpha/beta code). I seriously doubt they forgot it. Maybe it's just because the managed DirectX library is so infant that they don't want to gaurantee that anything will stay the same.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
Okay, I'm probably going to get flamed for this, but if you're looking for tutorials on how to use managed DirectSound...then you are a beginner (at least for managed DirectSound/DirectX)!
Well, Heath, if you remember some days ago, I asked for DirectSound help in this same message board, and you answered this:
...you can mix and match readers, decoders, mixers, encoders, and writers in practically any way...
Ok, I didn't know what this was (readers, mixers, etc) so I search google. I didn't find any help. Then I tried MSDN/DirectSound. Found some help, but only the basic stuff, nothing on readers, writers, mixers, etc. Then I looked at the samples in SDK, that was not very much help either.
I never said I was anything other than a DirectSound n00b (that cool writing, Heath!). So, do I understand you right with this: If you are familiar with the code in the SDK samples, then you are an advanced DirectSound user?
If the SDK samples are not "walking", then please advice me where to learn to walk. And, when I'm a good walker, where do I learn to run? Definitly not from MSDN or the SDK samples.
I appreciate any help on DirectSound.
Øyvind.
|
|
|
|
|
Øyvind Bratland wrote:
If you are familiar with the code in the SDK samples, then you are an advanced DirectSound user?
Hardly, but it's a good place to start.
Øyvind Bratland wrote:
...then please advice me where to learn to walk.
I learned many different languages and many different APIs/frameworks by reading the documentation and exploring even the most basic samples to see how everything comes together. The documentation might not be great, but it's important to read it and see what all is available. If you actually take the time to read it - and the articles within (which I remember very many good ones on at least other DirectX technologies) - everything should come together.
If not, I remember giving either you or someone else recently this link: http://www.microsoft.com/windows/directx[^]. When dealing with anything that has to do with development, you should always check MSDN as well: http://msdn.microsoft.com/directx[^].
There's many articles in there plus links, an NNTP (newsgroups) web interface, and more.
I also said that CodeProject[^] has many articles on DirectX technologies like DirectShow that you also asked about (which is necessary for decoding / encoding, while DirectSound is typically used to actually play the audio file). Googling for both DirectShow and DirectSound found many, many results - including those here on CP.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
I learned many different languages and many different APIs/frameworks by reading the documentation and exploring even the most basic samples to see how everything comes together
Of course, me too, I just didn't know which documentation to read.
Heath Stewart wrote:
CodeProject[^] has many articles on DirectX technologies like DirectShow that you also asked about (which is necessary for decoding / encoding, while DirectSound is typically used to actually play the audio file).
Ah! Thanks for clarifying this. I thought all this was DirectSound, but DirectShow... that makes a difference! Actually, I was looking for this in managed DirectX 9, but it looks like I have to do it the way NETmaster does it in his article here at CP.
Thanks for your help,
Øyvind
|
|
|
|
|
I looking to have a sortedlist that I can bind to form controls. I can write a class that extends SortedList and implements the IList interface. My first question is the syntax for extending a class and implementing an interface are the same. How does the compiler know to differeniate between the two. My other question is since the SortedList class already implments many of the methods required for the IList interface (e.g. Add, Clear, Contains, etc...) do I have to overwrite these methods?
|
|
|
|
|
The compiler knows because the names match up to a single definition. If there are multiple methods with the same signature (based on name and param types) in various interfaces (for which a class can implement many) or in the base class (for which a class can extend only one), then you must use explicit interface methods (which answers another question):
public class MyClass : BaseClass, IMyInterface
{
public override void Foo()
{
DoSomething();
}
void IMyInterface.Foo()
{
DoSomethingElse();
}
} This is really only necessary when the returns types differ or when you want a method based on one class or interface to do something different when from another interface. Many times, just let both BaseClass.Foo and IMyInterface.Foo refer to the same code (which the compiler handles just fine). Properties are probably benefited from this the most.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
So if I'm understanding you correctly. If I write a class and extend SortedList I get all the functionality of a SortedList and implement IList for databinding by doing the following:
public abstract class IndexSortedList: SortedList, IList //Does order matter here?
{
//This is the only IList method not implemented by SortedList
public void Insert()
{
DoSomething();
}
//Do I have to include this method as well and just simply
//tell it to call the Add method from the SortedList?
//This method is already implented in SortedList, but required by IList.
public override void Add()
{
//call SortedList's Add method
base.Add();
}
}
Can you confirm the questions in my comments? Thanks!
|
|
|
|
|
If the SortedList alredy implements an Add method with the right signature, you don't need to do anything! It's already done for you. An interface is just a contract that ensures that an implementing class has members defined in the interface. Your class already inherits an Add method (as well as many others) so you don't need to do anything. Just implement Insert and call it good.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks! Much appreciated. I'm gonna give it a try later this afternoon.
|
|
|
|
|
I've looked through the documentation on MSDN, and have found the SHGetFileInfo method, and the structure SHFileInfo, which have helped my understanding a great deal.
The one problem I have is locating the SHGFI Flag list. While heath appears to have posted the whole lot, they are not included in the enumeration and variables section of the MSDN library (or anywhere else for that matter), and there are 2 results from google which aren't waht I am looking for.
How did you find out which variables to use and in which order the flags are declared?
Thanks
Cata
|
|
|
|
|