Capture and save multiple images with `CameraCaptureDialog` - c#

I have a Windows Mobile (Compact framework 2) application that defines a user control MPhotoControl. MPhotoControl shows a default image and when the user clicks on this image a CameraCaptureDialog is opened to allow a photo to be captured. Once captured, the photo is then displayed in the user control. This works fine for capturing a single photo and then going back to the application.
The problem is that when there are lots of these controls on a particular form then the user interface becomes very unfriendly because the user has to show the camera dialog, take a photo, save and close the dialog for every photo control on the form. What the users are asking for is a mechanism to open the CameraCaptureDialog, take several photos without the dialog closing until all the photo controls have images.
I am trying to implement this, but I don't see a way to get the CameraCaptureDialog to capture and save several photos at once. As far as I can tell it is not possible, because when the dialog shows on my HTC Touch Diamond, I only have the options to "Accept the photo" (arrow icon), "Capture again" (camera icon) or "cancel and close dialog" (dustbin icon). And when I click the arrow to accept it always closes the dialog box.
So does anyone know of a way of capturing and saving more than one image at a time using CameraCaptureDialog?
I then thought of trying to open the CameraCaptureDialog multiple times as a work around. So as soon as the first image is saved the dialog is immediately opened again to capture the second image. Here is my code showing my attempt at a workaround:
public partial class MPhotoControl : UserControl
{
public static IEnumerable<MPhotoControl> PhotoControls;
...
private void CaptureMultiplePhotos()
{
foreach (MPhotoControl photo in PhotoControls)
{
using (CameraCaptureDialog cameraDialog = new CameraCaptureDialog())
{
if (cameraDialog.ShowDialog() != DialogResult.OK)
{
break;
}
photo.CapturePhoto(cameraDialog.FileName);
}
}
}
}
The problem with this is that the CameraCaptureDialog still only opens once and the subsequent call to the ShowDialog method simply returns DialogResult.Cancel. So, does anyone know why this workaround does not work and if it is possible to get the dialog to immediately re-open once the previous captured image has been saved?

Please look here: http://www.hjgode.de/wp/2012/10/17/windows-mobile-cameracapturedialog-alternative/
I am unable to attach any code or binaries here, so I did a new blog post.
The code start the camera app, waits for its close-down and presents you with a list of new photos.
Code is not yet perfect but a starting point.

Related

PDF995 set Product code to create 2 documents

I have a c# method that needs to create two documents separately using PDF995. The simplified version:
public void PrintDocuments(PrintDocument report1, PrintDocument report2) {
PrintUtility.SetPDF995Key(); // Method to set the product code in the registry.
report1.Print(); // PDF995 "Save as" dialog box appears here.
PrintUtility.SetPDF995Key();
report2.Print();
}
In order to create a document and avoid having all the PDF995 advertising banners appear, I first have to set the Product Code as a Registry item. However as soon as you click on Save in the PDF995 Save File Dialog, the product key is blanked out, which means I would have to set the Product Code again to create the second document.
The problem is, the Save File dialog box is displayed as an asynchronous / modeless dialog box, which means that the code which creates the second document is reached before the user has had a chance to click on Save for the first one.
So now, even though the Product Code is set a second time, clicking on Save for the first document will blank it out, and because the program has already passed the call to the PrintUtility.SetPDF995Key() method before printing the second one, it will still be blank when the second Save File Dialog appears and so I get the annoying "Trial version" banners.
So is there any way around this? e.g. is there a way to make the Save As dialog Modal, or an event when "Save" is clicked that can be fired so I can call PrintUtility.SetPDF995Key() immediately, or some way of permanently setting the Product Code or something else?

Disabling Dialog Flashing C#

I have a populated ListView dialog. If a user clicks on an option in the ListView, a new dialog is shown above the ListView.
My problems is that when I click off of the new top-most dialog (onto the ListView behind it), the new dialog's borders flash/blink several times. The icon on the taskbar also flashes. I wish to disable the flashing, but cannot find a property to change.
To show my dialog, I use the following code:
if (detail == null)
detail = new Details(opt, val, user, desc, m_l);
else
detail = null;
detail.ShowDialog();
This is intended behavior, it's because the new dialog is modal. It's drawing attention to the fact that something needs to be done.
If you need to make a non-modal form, instead of using ShowDialog(), simply use Show().
Sounds like to me you are creating modal windows each time. And you cannot resume the previous dialogs until you dismiss your new top-most window.
Take a look at this wikipedia article for information about modal dialogs.
I would advise you look at how you are creating/showing your windows.
In WPF you show windows via Show() or ShowDialog(), however, I do not know which type of ListView you are using
EDIT:
Per your comment, you want modal dialogs. The only ways I can think of even trying to remove the flashing is going into WINAPI. This doesn't seem like a job for .NET.
I want to suggest a few things:
Take a look at options for showing each window. See this MSDN page
Take a look at the options for styling each window. See this MSDN page
Reconsider your design. I know this may take a lot of work, but having so many layers of windows is kind of unappealing to most users. Ultimately, I believe this option will make your application the best.
Thank you all for your answers and guidance. I have found the best way to handle my problem.
I was using an event ItemActivated. This event was called when an a highlighted item on the ListView was clicked. This became a problem when the user would double click on an already selected item. This would cause the new dialog to show, but also flash several times.
By using the DoubleClick event instead, a single click on a selected object does nothing. A double click on either a selected or non-selected item opens the dialog without the flashes. The flashes still appear if you try to click off of the dialog box, but are not as much of an issue.

C# Windows App remove page

I made a simple Windows 8 quiz game.
I have 3 pages: MainPage, GamePage and ScorePage
The GamePage has a timer so I have to answer as many questions in 30 seconds as I can. It also has a Back button in case I want to give up and a Retry button to start over.
The problem is that whenever I click the Back or Retry button, the new page is displayed correctly but the old GamePage still works in the background and when the time is up it will display the ScorePage
For example I open the app, start the game and click Back. After the time is up, even if I closed the game (or so i thought), the ScorePage will still be displayed...
So how can I completely dispose of that instance of the page?
It is the first time I tried to make a W8 App, I only used WinForms before, where I used this.Close(); to completely get rid of the pages/forms.
To open pages I used this.Frame.Navigate(typeof(GamePage), null); and this.Frame.Navigate(typeof(ScorePage), new int[] { Correct, Wrong });
The below code remove back entries from the stack
if (NavigationService.CanGoBack)
{
while (NavigationService.RemoveBackEntry() != null)
{
NavigationService.RemoveBackEntry();
}
}
You can close the app this way
Application.Current.Terminate();

Custom dialog box in wpf issue

I'm calling my custom dialog window with this code:
GUI.SLDialog sd = new GUI.SLDialog();
if (sd.ShowDialog() == false)
{
return;
}
But sd.ShowDialog() always returns nothing (i think), because the function breaks, but the waypoint at return; isn't reached.
Dialog is automaticly closing when I add to button:
this.DialogResult = false;//or true
Anybody know what am I doing wrong?
Thanks in advance for your help.C.H.
#edit
This is my SLDialog:
xaml: http://wklej.org/hash/9fb67fb0c7c/
cs: http://wklej.org/hash/16e3ccc6c0d/
I don't think I can tell you much here unless you post the code for the dialog but I do have a suggestion in the mean time.
Since you're already unhappy with the standard dialog boxes and customization is clearly an option why not move towards what people are coming to expect? Instead of your standard dialog why not just create a user control that lays over the rest of your UI and blurs everything out from the background? Much like a jquery dialog box you might see on a web page.
Modality is easier to control since it's just a matter of covering your entire app window with a translucent rectangle and then make the dialog window appear however you want.
Just a suggestion.

C# WinForms Wait on form to proceed

I'm tired and hungry, so I might of missed it, but from what I can see no existing post covers this...
I'm writing a plugin for an application. My plugin loads a form to get some data specifically, it uses the webcam to scan for a barcode. Once it's found a barcode, the form hides itself (incase it's needed again later). This is how I currently call the form that does the barcode work:
string readData = null;
if (eye == null)
{
System.Windows.Forms.Application.EnableVisualStyles();
eye = new CamView();
}
eye.Show();
if (eye.found)
{
readData = eye.readData;
}
return readData;
So, my problem is that eye.show() doesn't block. It makes the form appear and carries right on before there's a chance for the barcode to appear. I imagine I need to use some form of threading or locking, but my crude attempts to do so have just frozen the interface completely.
The "eye" form is basically just a viewfinder for the webcam, and relies on the camera_OnImageCapture event to make it do it's image checks for the barcode.
Is there an elegant way to make the application calling the plugin wait for the form to finish? Or do I just need to add an accept button to the "eye form?"
Cheers. And humble apologies if this is in anyway a repost.
.ShowDialog();
http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx
"You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed."
You are on the right track. You change the code to show CamView as a modal dialog but do no add an Accept button. Instead change camera_OnImageCapture to close the dialog.

Categories