|
If you are using a custom control (i.e., a UserControl), and you've placed an instance of it on the design-surface at design-time, it will not exhibit the behavior of other native C# container controls: where drag-dropping another control ... from the ToolBox ... into the container automatically makes the dropped control a child of the container.
Look for an article here on CP by Henry Minute explaining how to enable this "swallow dropped controls and make them children of the container" for custom controls used at design-time, and look for comments by me here on CP, suggesting the possibility of a simpler solution.
best, Bill
"Humans are amphibians ... half spirit and half animal ... as spirits they belong to the eternal world, but as animals they inhabit time. This means that while their spirit can be directed to an eternal object, their bodies, passions, and imaginations are in continual change, for to be in time, means to change. Their nearest approach to constancy, therefore, is undulation: the repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
|
|
|
|
|
I have a win form that you can click a browse button - navigate to your image file - and view the image in the win form. I've been trying to associate my progress bar to the load time of the image selected with no success. Can anyone take a look at my code and see what I'm missing?
private void startButton_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.FileName = "";
open.Filter = "Image Files(*.tif; *.jpg; *.jpeg; *.gif; *.bmp)|*.tif; *.jpg; *.jpeg; *.gif; *.bmp";
open.InitialDirectory = @"g:\All Scanned Jobs\";
if (open.ShowDialog() != DialogResult.Cancel)
{
pictureBox1.Image = new Bitmap(open.FileName);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.WaitOnLoad = false;
pictureBox1.LoadAsync(open.FileName);
}
}
void pictureBox1_LoadProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
|
|
|
|
|
make sure the pictureBox1_LoadProgressChanged method is associated with the pictureBox event, i tested your code here and it works without modifications, have you tried to put a breakpoint into the pictureBox1_LoadProgressChanged method?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
I have this in my Form1.Designer.cs code.
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.BackColor = System.Drawing.SystemColors.ButtonFace;
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.ImageLocation = "";
this.pictureBox1.Location = new System.Drawing.Point(13, 71);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(1303, 701);
this.pictureBox1.TabIndex = 3;
this.pictureBox1.TabStop = false;
this.pictureBox1.LoadProgressChanged +=new System.ComponentModel.ProgressChangedEventHandler(pictureBox1_LoadProgressChanged);
Is that where it needs to be?
|
|
|
|
|
your code are exactly the same as mine, still, works fine, the image loads pretty fast, so the progressbar moves fast, but stops at 100% you said that a breakpoint don't helped, what was the behavior? the method isn't being called? the image isn't loading?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
The break gives me this:
ImageViewer.exe!ImageViewer.Form1.pictureBox1_LoadProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e) Line 71 + 0x5 bytes C#
ImageViewer.exe!ImageViewer.Program.Main() Line 18 + 0x1d bytes C#
I'm using 2010 Express of visual studio would that have anything to do with it?
|
|
|
|
|
And everything works just fine except I do not see the progress bar fill up at all and once the image is done loading completely I still dont see any green.
|
|
|
|
|
And a breakpoint didn't come up with much help.
|
|
|
|
|
Did you set the Maximum on the progress bar to be something sensible?
|
|
|
|
|
I have the Min set to 0 and the Max set to 100.
|
|
|
|
|
Member 8956301 wrote: pictureBox1.Image = new Bitmap(open.FileName);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.WaitOnLoad = false;
pictureBox1.LoadAsync(open.FileName);
OK, let's break this code down line by line
1) Open the file, create a bitmap and set as the picturebox image
2) Set size mode
3) tell picturebox that future image loading will be async
4) Do async load from the file, this is now reloading
So you are loading the image twice.
I think all you need is
pictureBox1.WaitOnLoad = false;
pictureBox1.LoadAsync(open.FileName);
Alan.
|
|
|
|
|
Thanks for catching that for me. I've made that corrections but the progress bar still does nothing.
|
|
|
|
|
So how long is it taking to load the image?? The ProgressChange event if only fired every once in a while, not on every byte that's loaded. It may not even be fired at 100% either.
There's a second event that you can handle to get notified that the image is completely loaded. That's the LoadCompleted event. When this one is raised, you can set your progress bar to 100% and consider the operation done.
|
|
|
|
|
It's taking a good 10 to 12 seconds to open.
|
|
|
|
|
I need help with an SDK to develop an application that will work with the built in camera or any external camera. The camera should be able to take snapshots.. This application will of course be used on windows and will be programmed with C#..
|
|
|
|
|
What part of the app do you need help with? Please indicate what you've tried and ask a more specific question if possible. This will allow us to help you better.
/ravi
|
|
|
|
|
i know i shouldn't do this (post here), but actually i'm interested in this kind of thing to, you have any material about how to connect to built-in web cams from c#? or a starting point? i've only found unmanaged solutions, so if you have any managed solution, please share...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: or a starting point?
Did you try to search this site? We got a lot of articles on webcam's, and most of them are in managed code.
Bastard Programmer from Hell
|
|
|
|
|
tried, only found solutions that use a unmanaged dll, i'll try once more...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Try this[^] one.
Bastard Programmer from Hell
|
|
|
|
|
thanks, i've seen this article, the problem is that i can't use external dlls (stupid requirement that i'm trying to remove...)
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
How about this[^] fully managed solution?
/ravi
|
|
|
|
|
5 doesn't seems enough to thank you for that, this solution is perfecty
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Glad to be of help!
/ravi
|
|
|
|
|
I need to be able to use my c# written code to access my webcam(in-built). The one i got from this site isn't what I wanted. This application should be with winforms not wpf
|
|
|
|