|
WinForm application for How to capture Image from any web cam and store it in a SQL Server using c#
|
|
|
|
|
|
nice solution
Sankarsan Parida
|
|
|
|
|
Do you want to capture image from a web cam ?
|
|
|
|
|
What have you tried? Where are you stuck?
/ravi
|
|
|
|
|
How to connect two systems using C# without using any third server ?
I want to create an gaming application(something like Tic-Tac-Toe game), which two players can play it via their own respective systems.
I don't know how to connect two different systems. It can be a Server Client connection or Peer-to-Peer connection.
|
|
|
|
|
The simplest way would be to use TCP. Alternatively, you could investigate using WCF and turn one of the clients into the host system.
|
|
|
|
|
Can you explain it further ? Please..
|
|
|
|
|
If you just want examples then Google for "chat" programs written in C#.
The basics that they use for communicating are the same you would need for a game.
If you want to start with the basics then look at the other response about socket communications.
|
|
|
|
|
In the same local area network (LAN) - or via the internet? The latter case is far too complicated for someone who has no experience with communication between two machines.
|
|
|
|
|
I want to connect via Internet.. No problem if it is too complicated.
Also tell me about the LAN method..
|
|
|
|
|
|
Hello,
I have this C# code but I get the error in the title. on the "FromFile" part. I want to simply publish images in my PC on a WPF application.
How can I get rid of this error?
Thanks.
Code :
using System.Drawing;
namespace Photo
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
string filename1 = @"C:\images\mainicon.jpg";
Image image1 = Image.FromFile(filename1);
}
}
}
Error :
'System.Windows.Controls.Image' does not contain a definition for 'FromFile'
|
|
|
|
|
At a guess, do you have a control on your window with the name set to "Image"?
Try creating an alias for the Image type name, or using the fully qualified type name:
using DrawingImage = System.Drawing.Image;
...
DrawingImage image1 = DrawingImage.FromFile(filename1);
var image1 = System.Drawing.Image.FromFile(filename1);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Your codes contains
using System.Drawing
but you are getting error from System.Windows.Controls namespace. Most likely there is either some namespace confusion for compiler. Try specify the namespace explicitly in the last line:
Image image1 = System.Drawing.Image.FromFile(filename1);
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
Thank you for your reply, I did what you said and I get this :
The type or namespace name 'Image' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)
Thanks.
|
|
|
|
|
Do you reference System.Drawing.dll in your project?
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
I'm sorry if I am wrong, but I would rather do this as follows. I guess this is a better way of loading the file dynamically
Uri filename1 = new Uri(@"C:\images\mainicon.jpg");
image1.Source = new BitmapImage(filename1);
Is this something helpful?
|
|
|
|
|
i have two forms, in one form i have three textboxes
and in another form i have one datagrid view control,
i want that the data i entered in textboxes will shown in datagridview control after i click on add button all the records will store in it may it is n number of record all n number of record will be shown in datagridview control but without creating database..
Is there any mechanism how to do this..????
|
|
|
|
|
This is so simple to do.
Create a class which contains 3 properties for all three text boxes.
Say for example here is the sample code
public class Form1Class
{
public string TextBox1Value { get; set; }
public string TextBox2Value { get; set; }
public string TextBox3Value { get; set; }
}
Now say for example you have a button named Button1 and on the click even, you need to open Form2 and bind the textbox values to datagridview.
For this, first you have to create an object of Form1Class which will take these three textbox values into my object (here it is Form1Class). Once you created an object, you need to pass the object to Form2
Here, you have to think about data passing mechanism from one form to another form (Form1 to Form2).
There are many methods that we can pass data from one form to another.
1. You can use sessions, querystring etc...
For detailed view of how to pass data from one form to another form in asp.net , have a look at below links
MSDN article
or this article also gives you an idea
Null Skull link
Once you pass the data from From1 to Form2 and the receiver side (i.e Form2) you need to receive the data and bind it to the datagridview.
As you are passing a single object from Form1 to Form2 and you need to see how to bind an object to datagridivew.
here is the stackoverflow answer on how to bind an object or a list of object(s) to a datagridview.
Stack Overflow answer
Once you are bind the data to a datagrid view, you can able to see the data that you enter in textbox(es) in Form1.
Try this and let us know, if it is working or else facing any issues.
Happy coding
Regards,
Ganesh
|
|
|
|
|
In this case what you can do is create a custom data table in the form, having three columns as the three text box,
Once you have this structure in place you can create a data row and append it to the table and set the datatable as the data source of the gridview.
let me know if you have any question.
|
|
|
|
|
I have a random class (determined at runtime)... this class constructor may or may not have parameters (determined via a lookup table). I need to new up said class as fast as humanly possible. So I went with expression trees. Since I don't know how many parameters the constructor will have (until I'm building the expression tree), my concept is to get the parameters into an object[] and then type cast o[0], o[1], o[2], etc. to the proper types. The expression comes out as:
.Lambda #Lambda1<System.Func`2[System.Object[],System.Object]>(System.Object[] $var1) {
.New ConsoleApplication1.Test(
(System.String)$var1[0],
(System.Int32)$var1[1],
(System.Drawing.Color)$var1[2])
}
So I'm getting a Func<object[], object>... seems kind of slow (relatively) to be honest... is compiling it to a lambda causing overhead? or is there some other overhead I'm not seeing? Since the params can be any type, I don't know how I could store them in anything else other then an object[]. Seems like I might be generating a method vs. doing it inline?
Any ideas? This code is called *a lot*, so every ms counts .
|
|
|
|
|
Are you creating the expression tree every time you need a new instance of one of the classes, or are you caching the compiled Func<object[], object> for each class type?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm caching the Func<object[], object>'s in a dictionary. Just seems slower then doing a normal new up for the same # of iterations and I was under the impression its supposed to be just about the same performance. I realize my code has other overhead, of course, but still...
|
|
|
|
|
Seems like it might have something to do with the parameters. Right now the constructor for the test class is:
public Test(string str, int i, Color color)
{
}
and new'ing up 1M takes 475ms with my current code. By doing NOTHING but changing the constructor to just:
public Test(/*string str, int i, Color color*/)
{
}
it drops to 200ms. So I tried adding 1 param back and it jumps to 312ms. 2 params = 390ms.
So... every additional param is adding quite a bit of time .
Now, adding back the first param was +112ms, but the 2nd one was only an additional +78ms. I would expect adding back the first param would be expensive since it would now travel down the param code path where without params it skips all that. However, I expected adding the 2nd param would be much cheaper since its just adding another iteration to the param loop.
A standard new up with all 3 params for 1M iterations takes only 31ms.
I'm estimating that there is about 140ms of overhead built into my dynamic new up code, I'm just not getting why adding params is so expensive. So I tried one more test...
for (int i = 0; i < 1000000; i++)
{
int j = 5;
string s = "hello";
Color cr = Color.Red;
// 0ms
//int k = j;
// 15ms
//object k1 = j;
// 0ms
//object k2 = s;
// 46ms!!
object k3 = cr;
}
Seems like the boxing & type casting of the int and color is killing the performance. Boxing a string seems to be pretty cheap. The int and color are structs though...
|
|
|
|