|
|
|
foysal mamun wrote: how to Windows Service
|
|
|
|
|
Hi!
How could I capture video from webcam (Microsoft LifeCam VX-3000) using .NET 2.0 or WinFX (.NET 3.0) and save it to WMV or AVI? Actually, using WinFX (WPF, WCF, etc.) is preferable.
Thank you in advance!
--
Yours sincerely,
Dmitry Alekseenko
|
|
|
|
|
Why you were voted a five I have no idea, maybe someone appreciates a clear-cut question following the posting guidelines...
Anyway I don't think that you can do this directly with .NET 3 (but not being able to install it on Win2K I wouldn't know). The easiest solution would be to grab DShowNET (just do a CP search for it), it's a wrapper around the DirectShow API and provides four or five very good examples on capturing from a webcam. There is even one example which does exactly what you want.
|
|
|
|
|
A question like this can be quite open-ended and actually requires quite a lot of knowledge of the camera as well as the internal processes available.
I would suggest you take a peak at Coding4Fun which is out on the MS website. (I think it is www.coding4fun.microsoft.com) There is a project out there on building a baby monitor system.
The article not only shows what the developer did to get it to work, but also illustrates the steps you would do in answering this question.
|
|
|
|
|
I have an unfinished C# puzzle game I wrote, and I want to change it to use a text file to load the levels by parsing the text. I don't know how exactly to do it. I would also like to be able to read a directory and list each text file in an array, so I don't have to alter the code to add new levels.
Can someone please help?
|
|
|
|
|
you can search some data in msdn about File's read and write.Believe me , it is very easy.you can do that by yourself
|
|
|
|
|
There are a few processes you could look into for accomplishing this...but it depends on the design you want to do.
First you need to know the exact data you need to save and determine if you want to expose this data in a simple text file. (cheaters can hack a text file to death)
Then you need to determine if you can get all of the puzzle data into a single object. This helps drive your design.
Finally I find the best way to parse such data is to let the system do as much work as possible. This can easily be accomplished simply by using a binary serializer / deserializer to accomplish the task.
So the steps you would then follow -- if this looks good to you -- is as follows:
Define your object and all collections within that object.
Make certain that every class that makes up that puzzle object has the [Serializable] attribute added to the definition. Also make sure that your puzzle object consists of (hopefully) nothing but private data with getter/setter logic to encapsulate the data and expose the data to the serializer.
Next research what you need to do to get a BinarySerializer cooking (which isn't much) and you will also need System.IO to do your file stuff.
Then create your stream, create your serializer for your object type, then do a serializer.Serialize( stream, myPuzzleObject );
You will find your object is dumped into the filename the user defines if you use the FileDialog and you will find that when you do a serializer.Deserialize() that you have a fully populated puzzle object loaded. This is how I persist my Sudoku puzzles for my library displays, library adds, and current puzzle state saves.
|
|
|
|
|
Ok, well, it's a puzzle game much like PopCap's Mummy Maze. The parts that I would put in a text file is simply the starting point of the player and enemy (or enemies), the exit, and the walls. All of which I currently have hard coded into an array. Since I only have one level, it seems nice enough, but on a 25x25 grid, and a two dimensional array, it takes a lot of lines of manual code to fill it up for just one level. That's why I don't want to have to hard code several levels. It would be so much easier if I could just compile the program once, and just add files as I go along, thus adding more levels.
Sure, cheaters could just place themselves next to the exit, but what is the fun in that?
As for all this serializing stuff...I don't think I have learned that yet. Also, I work much better with examples. Preferably commented examples. So, could you please point me toward one? I would very much appreciate it.
I know how to open files and use the stremreader, but I only know how to use the StreamReader for one line at a time, though I suppose I could use a For loop to go through the characters and then use a Switch...Case statement to parse the text into the correct object for the array. But I was hoping for something easier.
Assuming it is possible to make it easier.
|
|
|
|
|
Tip: If you want to learn by example, go to MSDN and search for the key items you want to do ... such as Serialize. You can find quite a bit of documentation and usage info out there. But here is something to get you started quickly. I used shorthand for the public accessors...you SHOULD know how to implement those!
private PuzzleArray level = new PuzleArray();
...
private void SaveLevel ( PuzzleArray currentLevel, string path )
{
using (FileStream stream = File.Create(path) )
{
BinarySerializer ser = new BinarySerializer(typeof(PuzzleArray));
ser.Serializer(stream, level);
}
}
private void LoadLevel ( ref PuzzleArray currentLevel, string path )
{
using (FileStream stream = File.Open(path))
{
BinarySerializer ser = new BinarySerializer(typeof(PuzzleArray));
currentLevel = (PuzzleArray) ser.Deserialize( stream );
}
}
....
[Serializable]
public class PuzzleArray : List<Puzzle>{}
[Serializable]
public class Puzzle
{
Point playerPosition;
public Point PlayerPostition{get; set;}
Point enemyPosition;
public Point EnemyPosition{get; set; }
Point[] walls
public Point[] Walls{get; set;}
private Point lastMove = new Point();
}
|
|
|
|
|
i cannt show a form in center of its parent form. i use to show "form1.ShowDialog();"
plx help me;
|
|
|
|
|
you can set form position property .
|
|
|
|
|
setting property like this:
this.StartPosition = FormStartPosition.CenterScreen;
|
|
|
|
|
but it dose not work. it show at topleft conner. i can solve the problem by setting the properties. plz help..
|
|
|
|
|
Hello
This should Do it:
private void MyShowMethod()
{
Form1 form = new Form1();
form1.StartPosition = FormStartPosition.Manual;
int X = Left + Width / 2 - form1.Width / 2;
int Y = Top + Height / 2 - form1.Height / 2;
form1.Location = new Point(X, Y);
form1.ShowDialog();
}
Regards
|
|
|
|
|
Open the form in Visual Studio.
Look at the properties for that window.
Change StartPosition from WindowsDefaultLocation to CenterParent.
|
|
|
|
|
Hi,
i had a problem doing drag-dropping of images, i could only drag to a picturebox control and it will be the main image and displayed in the center of the picturebox. however, i wanted to be able to drag an image and drop it in any position of a picturebox which already contains an image(eg. the main pic is a photo, and i want to add a star image on the bottom left corner of the photo) and also to render both together. Do anyone have any idea on how can i go about it?
Thanks
|
|
|
|
|
Hi!
That's something you cannot do with a regular PictureBox . The PictureBox holds (and displays) a single image only.
To achive the effect you desire, you'll have to create your own control. This will have to have a collection of Image s and perform painting and handling of these images on its own.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hi,
thanks for your reply! currently i'm using an ink picturebox control from the tablet sdk, which i can only do painting functions on. Do you have any links to any references which i can refer to, on creating my own controls?
|
|
|
|
|
There are plenty of articles here, why not just search[^] for them?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
hi
i have some dll that i use it in my c# project.but i don't want that end user access to my dll.
i can add dll to my project and change emabedded resource property but how to use it ?
thanks ..
|
|
|
|
|
Yes you can although anyone with Reflector will be able to get it out.
The only way I can think of at the moment is to load the assembly using Reflection from a ResourceStream. See this[^] msdn page. However this will have added complications writing the application because it'll only be accessible during runtime and not at compile time.
A better solution if you can would be to simply (if you wrote the DLL) to included it in the source code of the program, it can even be linked in rather than copied so that you can build your dll if you want and also compile it inside the application.
|
|
|
|
|
Hello,
I'm trying to load an MHT file to a WebBrowser control from a stream. If I use the Navigate method, there's no problem. However, if I use the DocumentStream property it doesn't load correctly.
Is there any way to load it directly from a stream, without saving a temp file on disk?
I tried:
WebBrowser1.DocumentText = global::TestProject.MyResourceFile.MHTFileName;
But it's print the content of the file as if I opened it in Notepad
Thanks in advance for any help given.
|
|
|
|
|
I believe the WebBrowser initializes to content-type of text/html. Mht is a mime file so you would have to change the content-type. I don't know if this is possible through the interface. content-type is normally set either as a HTTP header or by the controls recognition of the file extension.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|