|
BillWoodruff wrote: I've made sure this example actually works by testing it. I got the same compiler-error as Richard
Bonus points for your exception-handling; I use MSDN to see which exceptions I can expect, and they're often listed nicely. Makes life much easier if you can inherit a class and throw exact the same exceptions, knowing that there'll be known exception-handling routines you did not break. Must have missed passing the exception as a second argument to pass it as an inner-exception.
This amount of advice on code that actually looks impressive is why people dislike code-reviews
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy, thanks for commenting ! I'm kind of a "hermit" in a tropical country (by choice) and technical feedback from my peers and betters is just "catnip" to me
As I commented to Richard, the 'get only "automatic property" is legal syntax in .NET; it just means it is de facto 'readonly. Whether that's good style, or code smell ? I haven't really thought about. What do you think ?Eddy Vluggen wrote: Must have missed passing the exception as a second argument to pass it as an inner-exception. Oh yeah, that is a bad thing to leave out.
cheers, Bill
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
BillWoodruff wrote: I'm kind of a "hermit" in a tropical country Any tips on how to become one?
BillWoodruff wrote: is legal syntax in .NET The compiler said "Property or indexer 'YourNameSpace.MyModel.FilePath' cannot be assigned to -- it is read only". Didn't check to see if it was a warning that is treated as an error, or an actual error.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy, in my reply to Richard above I explain that (surprise) using VS 2015 CTP 6 compiling with FrameWork 4.5 allows a 'get only auto-property: no error, no compiler warning. So there's a compiler difference, evidently (?). My bad.
Becoming a hermit ... ahhh ... well you just have to cut the anchor-chains, unfurl your sails, and cast--off
cheers, Bill
«To kill an error's as good a service, sometimes better than, establishing new truth or fact.» Charles Darwin in "Prospero's Precepts"
|
|
|
|
|
BillWoodruff wrote: So there's a compiler difference, evidently (?). My bad. No bad, just an observed difference. Sounds like good news actually, means I won't have to add a backing-field manually anymore
BillWoodruff wrote: Becoming a hermit ... ahhh ... well you just have to cut the anchor-chains, unfurl your sails, and cast--off If I did that, I'd end up on the streets
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
code clicks picture but doesnt save it. getting blanks image as output.
i want to click picture and save it on start up of OS! Newbie is here.. HELP Frown | :(
SAME CODE WORKS ON BTN CLICK BUT DOESNT ON WINFORM LOAD!
picBOx1.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpg);
|
|
|
|
|
Member 11388199 wrote: i want to click picture and save it on start up of OS! How can you do that, since you have no control until after the OS has finished loading and you have logged on. You need to show the code that does not work and explain exactly what happens. Are you sure the image is available when you try to save it? Do you check the return values to see if the method call succeeded? Do you trap exceptions and report them? etc.
|
|
|
|
|
Quote: it works on btn click just wanted make it on form load..
or any other way to click picture "after" OS started.
I'm working on project that tracks lost laptop.
Exceptions->
An error occurred while capturing the video image. The video capture will now be terminated.
Object reference not set to an instance of an object.
HERE IS THE WHOLE CODE..
public partial class mainWinForm : Form
{
public mainWinForm()
{
InitializeComponent();
}
WebCam webcam;
private void mainWinForm_Load(object sender, EventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref imgVideo);
webcam.Start();
imgCapture.Image = imgVideo.Image;
Helper.SaveImageCapture(imgCapture.Image);
}
private void bntStart_Click(object sender, EventArgs e)
{
webcam.Start();
}
private void bntStop_Click(object sender, EventArgs e)
{
webcam.Stop();
}
private void bntContinue_Click(object sender, EventArgs e)
{
webcam.Continue();
}
private void bntCapture_Click(object sender, EventArgs e)
{
webcam.Start();
imgCapture.Image = imgVideo.Image;
}
private void bntSave_Click(object sender, EventArgs e)
{
webcam.Start();
imgCapture.Image = imgVideo.Image;
Helper.SaveImageCapture(imgCapture.Image);
}
private void bntVideoFormat_Click(object sender, EventArgs e)
{
webcam.ResolutionSetting();
}
private void bntVideoSource_Click(object sender, EventArgs e)
{
webcam.AdvanceSetting();
}
}
|
|
|
|
|
Make what work on FormLoad? And what does any of this have to do with video capture?
There is clearly a bug in your code, but without seeing it no one can guess what you are doing wrong. Please try and explain your problem in proper detail.
|
|
|
|
|
want to click user picture and save it without knowing to user. that can be used for tracking lost laptop.
as I'm new i thought it would work if i copy paste code from btn click to form load.
|
|
|
|
|
Member 11388199 wrote: i thought it would work if i copy paste code from btn click to form load. Programming is, I am afraid, a bit more than that.
|
|
|
|
|
thanks for help !
AND FOR YOUR KIND INFO I MADE IT WORK! THE ISSUE IS ITS JST NOT SAVING THE CAPTURED IMAGE.! it does all in background! see "ctrl c" "ctrl v" works !
|
|
|
|
|
Please do not shout. We are all capoable of reading normal sentences.
|
|
|
|
|
|
On Form Load, the image probably hasn't been loaded into the picture box yet - try in the Form Shown event instead, which occurs once when the form is first displayed.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
What does any of this have to do with "tracking a lost laptop"?
If the laptop is lost or stolen, what does taking a screen shot or video of the screen contents have to do with finding it?
|
|
|
|
|
Well, the thief might be at home and using Google maps...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
And conveniently holding Google Maps up beside there face with a handy marker labeled "Home" on it.
|
|
|
|
|
Ah, but Herself watches all these US crime documentaries: NCIS, CSI, you know the ones. So all you have to do is take the picture, zoom in on the guys eyeball, isolate the reflection of the computer and you can read the IP address because it's encoded in the screen pixels.
As you well know...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
If you are chasing a lost laptop, would it not be better to send the location details, IP address, or internet connection in the background. Just how useful do you expect an image to be!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
|
I figured out to add a new record to the table, but I can't figure out how to update an existing record.
I'm not sure how to proceed here.
I tried Add again, but it bombed in the entity part.
This is my first time doing this using the DAL without binding, actually I have no clue how to bind it either.
private int data_Save(Guid pValue)
{
int dwRCode = 2;
string m_businessName = BusinessNameTextBox.Text.Trim();
string m_firstName = firstNameTextBox.Text.Trim();
string m_lastName = lastNameTextBox.Text.Trim();
StoreContext context = new StoreContext();
if (Guid.Empty == pValue)
{
Customer c = new Customer
{
BusinessName = m_businessName,
FirstName = m_firstName,
LastName = m_lastName
};
context.Customers.Add(c);
dwRCode = context.SaveChanges();
}
else
{
dwRCode = context.SaveChanges();
}
return dwRCode;
}
|
|
|
|
|
I wrote the delete record, and figured update was similar in code.
I'm sure about the return value from save, it the int is the record added or if 1 = added successfully, and 0 = updated successfully
private int data_Save(Guid pValue)
{
int dwRCode = 2;
string m_businessName = BusinessNameTextBox.Text.Trim();
string m_firstName = firstNameTextBox.Text.Trim();
string m_lastName = lastNameTextBox.Text.Trim();
StoreContext context = new StoreContext();
if (Guid.Empty == pValue)
{
Customer c = new Customer
{
BusinessName = m_businessName,
FirstName = m_firstName,
LastName = m_lastName
};
context.Customers.Add(c);
dwRCode = context.SaveChanges();
}
else
{
var customer = context.Customers.Where(i => i.ID == pValue).FirstOrDefault();
if (customer != null)
{
context.Customers.Attach(customer);
customer.BusinessName = m_businessName;
customer.FirstName = m_firstName;
customer.LastName = m_lastName;
dwRCode = context.SaveChanges();
}
}
return dwRCode;
}
|
|
|
|
|
Never printed graphics before, I am stuck in the beginning.
I've got some graphics elements, like rectangles and circles. They show OK on the screen. Now I need to print them keeping proper scaling: all sizes are in millimetres. And first question is: how do I print a rectangle 100 x 100 mm? What size on paper does this rectangle have:
gr.DrawRectangle(Pens.Black, 100, 100, 100, 100)?
I know it must be linked somehow to default printer's resolution, but I am lost: could not find anything useful in help.
(using C# in Visual Studio 2012)
Thank you
|
|
|
|