|
Download the Windows Media SDK from http://msdn.microsoft.com/library/en-us/dnanchor/html/audiovideo.asp[^], read it well, then create an interop assembly (using tlbimp.exe or VS.NET itself by adding a reference to your project from the COM tab) and follow the Visual Basic 6 documentation, which uses the very same automation interfaces and supporting types that gets thrown into the interop assembly (RCW; Runtime Callable Wrapper).
There should be some articles that may help you here on this site, so use the search box at the top of every page right below the logo to search for them.
This uses the automation interfaces to make use of the WMV/WMA codecs (encoders and decoders), as well as other codecs on the system (you'll need the codecs for the AVI file, since AVI is only a file format - not a file encoding - and can use any codec the author wants to use).
Beyonds this, any questions you have about converting formats should be addressed in a different forum. If you have questions specific to C# (calling methods, constructing objects, P/Invoking native APIs not exposed in the automation interfaces, etc.), this forum is the place to ask.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I have been developing a test application in Windows Forms (C#) to integerate with a Web Service to return a formatted XML document and then apply an XSLT template to convert the XML into a useful format.
Within the Windows Form enviorment I have had no problems, however when ported over to a class file i keep getting a protection error with the XslTransform object. (code snippet of the method that applies the transform below):
<br />
<font color="Green"><br />
private void WriteFFWImportFile(string strFileToLoad, string strFileToSave)<br />
{<br />
<font color="Green">
XslTransform myXsl = new XslTransform();<br />
myXsl.Load(ConfigurationSettings.AppSettings["XsltImportTransform"]);<br />
<br />
<font color="Green">
XsltArgumentList myArgs = new XsltArgumentList();<br />
myArgs.AddParam("ParsolImport","",strFileToLoad);<br />
<br />
<font color="Green">
Stream fs = new FileStream(strFileToSave,FileMode.Create);<br />
XmlWriter writer = new XmlTextWriter(fs,System.Text.Encoding.Unicode);<br />
<br />
<font color="Green">
XmlDocument myXml = new XmlDocument();<br />
myXml.Load(strFileToLoad);<br />
myXsl.Transform(myXml,myArgs,writer,null);<br />
<br />
<font color="Green">
writer.Close();<br />
fs.Close();<br />
}
Basically the code that I ported into a Class is exactly the same apart from where I am calling ConfigurationSettings.AppSettings["XsltImportTransform"] in WinForms - I have exposed via a property of the Class.
When I attempt to build the solution I get:
"Integration.cs(122): 'System.Xml.Xsl.XslTransform.XslTransform(object)' is inaccessible due to its protection level" . I don't understand why this is happening ... is it a bug
Paul Griffiths
.Net Developer
|
|
|
|
|
There several things wrong with this line:
myXsl.Load(ConfigurationSettings.AppSettings["XsltImportTransform"]); What if the .config file isn't present or that setting isn't found? Either do validation checking or catch the inevitable exception that will occur from the null return value. Validation is far less expensive than throwing exceptions, though you should do that anyway (the XML document that contains the XSLT might be invalid, so Load will throw an exception).
What is that property called? You said you encapsulated the preceeding line in a property? Depending on the namespaces you're importing for that source file and the name of the property, you may have a naming conflict. Showing us line 122 and surrounding lines of Integration.cs would be most helpful.
For example, if you're importing System.Xml.Xsl and your property type and name are both XslTransform then you'll have a name clash and the compiler will complain (how it complains depends on the circumstances). If this is the case, you should either fully-qualify your property type or use an alias like so:
using XSLT = System.Xml.Xsl.XslTransform;
public XSLT XslTransform
{
get { return ConfigurationSettings.AppSettings["XsltImportTransform"]; }
} Don't forget to dermine if that property returns null .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for the reply.
With regards to the ConfigurationSettings line of code, this was purely for a test application that I had direct control over so I hadn't put any validation in the code at the time.
Within my Class file I defined two string properties that will give a path to an import and export XSLT file. When these properties are set I will check for a valid path etc ... I've just illustrated the null case below.
<br />
public string XslImportTransform<br />
{<br />
get { return m_XslImportTransform; }<br />
set { m_XslImportTransform = value;<br />
RuleBroken("** Error: Invalid XSLT file.",m_XslExportTransform == null); }<br />
}<br />
When I tried to create an XslTransform object in a private method of the class, using the string property to Load() the XslTransform, I was encountering the protection level error (NB: It was not the Load() method that was causing the problem but the instantiation call XmlTransform myXsl = new Transform(); ). I couldn't understand why this was happening because I was creating the XslTransform as a local variable to the method (the name did not clash with any reserved words, public or private members).
<br />
public void WriteFFWImportFile(string strFileToLoad, string strFileToSave)<br />
{<br />
try<br />
{<br />
XslTransform myXsl = new XslTransform(this.m_XslImportTransform);<br />
myXsl.Load(this.m_XslImportTransform);<br />
<br />
XsltArgumentList myArgs = new XsltArgumentList();<br />
myArgs.AddParam("ParsolImport","",strFileToLoad);<br />
<br />
Stream fs = new FileStream(strFileToSave,FileMode.Create);<br />
XmlWriter writer = new XmlTextWriter(fs,System.Text.Encoding.Unicode);<br />
<br />
XmlDocument myXml = new XmlDocument();<br />
myXml.Load(strFileToLoad);<br />
myXsl.Transform(myXml,myArgs,writer,null);<br />
<br />
writer.Close();<br />
fs.Close();<br />
}<br />
catch(Exception ex)<br />
{<br />
ExceptionManager.Publish(ex);<br />
}<br />
}<br />
Is it simply a case that all XslTransform objects have to be exposed as public when used in a Class? If so why is that the case?
I have changed the class so I can set a transform object as a public property and everything works fine, although I only wanted to load the transform when a specific method is called.
Once again thanks for all your help.
Paul Griffiths
.NET Developer
|
|
|
|
|
Whoopsie bit of a school boy error.
Realised that I accidently put the string property into the constructor of the XslTransform object!
Tiredness is my worst enemy!
Again thanks for the input and apologies for wasting your time.
Paul Griffiths
.NET Developer
|
|
|
|
|
Hi
I have an Image class object.
How I can get a new Image - rectangular piece of first Image.
Is there a function like
Image piece = SourceImage.GetSubImage(int x1, int y1, int x2, int y2);
?
Thanks.
|
|
|
|
|
DrawImage has overloaded methods that allow you to draw part of an image ( via a graphics object ) onto another image ( via a Graphics object ).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I was going to answer this question but you got to it first.
Alex Korchemniy
|
|
|
|
|
//VC++ :
wSizeReturned = MAKEWORD(*pDataBuffer, *(pDataBuffer+1));
what does the identical C# code look like?
|
|
|
|
|
MAKEWORD is a macro, which probably expands to something like this: *pDataBuffer + (*pDataBuffer+1)>>4) and the code is the same in C#.
The >> operator shifts the bits of the number, so that in binary, 1 >> 4 becomes 10000
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Uh, you need to shift a byte by 8, and left-shifts multiply - right-shifts divide. The C++ definition is pretty complex, ensuring that the values to be shifted are actually bytes (by masking).
Rough equivalent:
public static ushort MakeWord(byte a, byte b)
{
return (ushort)a | ((ushort)b << 8);
} It doesn't make much difference whether you use + or |, but the original macro uses |, so I have too.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi!Graus,
Thanks!I have got it.
By the way,
"I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's.",what
does this mean?;)
Best wishes!
momer
|
|
|
|
|
I dunno - someone else said it, I just thought it was funny.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
In .NET it is very easy to create a custom event and eventhadlers.You can add any number of parameter on your custom event. What you need to do is, Declare your delegate in such a way.
Eg:
<br />
Delegate declaration.<br />
<br />
public delegate void CustomDel(string a);<br />
<br />
event declaration of the type CustomDel<br />
<br />
private event CustomDel CustomDelEvt;<br />
<br />
Adding event handler.<br />
<br />
CustomdelEvt+=new CustomDel(Button_Devevt);<br />
<br />
Handler definision<br />
<br />
private void Button_Devevt(string a)<br />
{<br />
Messagebox.Show(a);<br />
}<br />
now you can call this event anywhere in your class file. This is how Custom event.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
iemand wrote:
btnMtnStandards = new LinkButton();
If this means you're using the System.Web.UI.WebControls.LinkButton class simply use the Command event in combination with the CommandName and/or CommandArgument property.
Take a look at the MSDN topic[^] for more information.
www.troschuetz.de
|
|
|
|
|
You can still use your OpenMtnStandards event handler for multiple buttons, you can simply cast the sender object back to a LinkButton to find out which button it came from.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thank Nick, but can You Show me some code how to cast the sender object back to a LinkButton??
Thnx
joost
|
|
|
|
|
A LinkButton question really belongs in the ASP.NET forum, however the concept really just applies to .NET. Here is an example for a Windows application, but the underlying code should work the same assuming you change the class from a Button to a LinkButton . HTH
public class test : System.Windows.Forms.Form
{
Button b, b2;
public test()
{
InitializeComponents();
}
public void InitializeComponents()
{
b = new Button();
b2 = new Button();
b.Text = "Some text";
b2.Text = "Some other text";
b2.Location = new Point(20, 20);
b.Click += new EventHandler(bClick);
b2.Click += new EventHandler(bClick);
this.Controls.AddRange(new Control[] {b, b2});
} fs
private void bClick(object sender, EventArgs e)
{
Button b = sender as Button;
if(b != null)
{
MessageBox.Show(b.Text);
}
}
[STAThread]
public static void Main()
{
Application.Run(new test());
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks a lot nick, it worked
|
|
|
|
|
You can't add a parameter. Event handlers (callbacks) must match the signature exactly for the events (multi-cast delegates).
For most events in the .NET BCL, however, you already have a way to do this. What do you think the sender (first parameter) is? It's the object that fired the event. So cast this to a LinkButton and then you can determine which LinkButton fired the event easily using a name or ID, or use referential equality to determine which LinkButton was clicked, or don't even care and just print what a LinkButton would define. Examples of all three are below:
linkButton1.Click += new EventHandler(OpenMtnStndards);
linkButton2.Click += new EventHandler(OpenMtnStndards);
linkButton3.Click += new EventHandler(OpenMtnStndards);
private void OpenMtnStandards(object sender, EventArgs e)
{
LinkButton lb = sender as LinkButton;
if (lb != null)
{
Trace.Warn(lb.Text);
switch (lb.ID)
{
case "lb1":
Trace.Warn("You clicked LinkButton 1");
break;
case "lb2":
Trace.Warn("You clicked LinkButton 2");
break;
case "lb3":
Trace.Warn("You clicked LinkButton 3");
break;
}
}
if (sender == linkButton1)
Trace.Warn("You clicked LinkButton number 1");
else if (sender == linkButton2)
Trace.Warn("You clicked LinkButton number 2");
else if (sender == linkButton3)
Trace.Warn("You clicked LinkButton number 3");
} If you read the documentation for the EventHandler class - the type of the Click event, it does tell you want the sender parameter is (you can declare it as any name you want, however).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Can anyone tell me how to add a parameter to an event handler??
this is the code(sharepoint):
btnMtnStandards = new LinkButton();
btnMtnStandards.Text = "Maintain Standards";
btnMtnStandards.Click += new EventHandler(this.OpenMtnStandards);
this.Controls.Add(btnMtnStandards);
I want to add a parameter to the event OpenMtnStandards so that I can use this event for more buttons and not only for one button.
Thanks
joost
|
|
|
|
|
Hi all, I've got a bit of a problem here, and maybe the solution is obvious but I cant seem to find it.
We are developing a client app that reads a whole lot of numerical data through keyboard input. The main input control is NET's base library DataGrid. This application will have to be localized in different countries which means that the decimal separator might be a comma or a period depending where the application is running.
The problem is that .NET's DataGrid will always recognize the numeric keypad decimal key as a period (unlike for example MS Excel, where it will always recongize it as the decimal separator no matter what the current culture info is).
This isn't too much of a problem in countries where the decimal separator is a period, but in countries where its a comma, the decimal key in the numericpad is useless, thus lowering the user's keyboard input performance.
Is there any way that I can intercept the keyboard event and change the input to a generic CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator string/char? Obviously DataGrid's key events dont work because they dont capture the events when editing a cell and I cant seem to hook up any event to a datagridcell.
I've been looking at windows messages and I'm not sure if the same thing is happening...messages in the messageloop of the currentcell are not going through the datagrid control ???
PD Changing OS Culture Info is not a valid solution.
any help would be appreciated, and sorry for any spelling mistakes, I'm not english spoken
thanks.
|
|
|
|
|
|
I am trying to develop an application using UPnP technologies.Well doing it in C# is not quite a piece of cake.Anyone working on the same field would be interested in cooperating so we can start using this technology with c#?
Thanks
Kill The Tester
|
|
|
|
|
Can anyone tell me if its possible and how to programatically (in c#) open a dialog on a secondary display monitor ? ie: The main app interface displays on the primary monitor and on certain events a dialog is opened/displayed on the secondary monitor ?
Any help will be greatly appreciated.
Cheers
Craig
|
|
|
|