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?
Related
I know there is already a post with the same name as this but it provides a partial solution for the problem. The post is: VSTO Word post save event
I'm using this class and it helped me a lot. However, when I make changes in the Word file and try to Close the application clicking in the option "Not Save" the event of save is raised.
How can I know if the user has clicked in the "Save" or "Not Save" buttom when trying to close the window? I've tried everything but I can't know this information.
A quick test in VBA makes me believe this approach would be promising. DocumentBeforeClose is triggered before DocumentBeforeSave.
Declare a class-level field (saveStatus in the below code snippet).
In DocumentBeforeClose set it to "False" on the assumption the user won't save. If the user does save, set the value to True in DocumentBeforeSave. If you need to do something with the document when it's saved, put that code in this event, as well.
Private saveStatus as Boolean
Private Sub app_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
saveStatus = False
Debug.Print saveStatus
End Sub
Private Sub app_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
saveStatus = True
Debug.Print saveStatus
End Sub
For those facing the same problem I found a solution. Before I open the file in Word I read all bytes and store in a class variable, for example, wordContent using
wordContent = System.IO.File.ReadAllBytes(path);
Then, every time that I save without closing the application (i.e clicking in the save buttom in Word) I update this variable wordContent.
So, when I close the application and the event AfterSave is fired with my variable isClosed == true, in this point I don't know if the user closed the application clicking in Save or Not Save. So, I read the bytes of the word File and compare with my wordContent. When the user has clicked in the "Save" option the contents will be different, and when the user has clicked in the "Not Save" options the contents will be equal.
So, whatever it needs to be done it'll be in the comparison of this two byte arrays.
Remembering that I'm using the WordSaveHandler provided by the post that I pointed in the question above, this class can handle if the users save by clicking in the Save Buttom or by closing the application.
I am working on C#.
I am creating application which takes input from multiple barcode reader via USB.So,i want to know that from which reader i am getting value
Bar code scanners work by letting the system think their input comes from the keyboard.
So, one way of doing this:
bar code scanners can be programmed to send pre- and or suffixes with every scan.
You could prefix every scan with the e.g. 'F12' key for one scanner and with the 'F11' key for the other scanner. In the main form of your application, in the keypreview event, you scan for 'F12' and 'F11' keys, and if one comes in, you pop up a modal dialog with a textbox that has the focus. The rest of the scanned characters will end up in the textbox of that dialog. If on top op that, you also program an 'Enter' keysequence as a suffix to the scanned code, it would automatically close that dialog (if the dialog is well built). One of the advantages of this pattern is that, if a code is not readable, you can press F11 or F12, and the dialog will pop up and you can manually type the number.
I know the question isn't very clear, I will try to explain, can't provide code because most of the variables are written in my language so you wouldn't be able to understand them.
I'm writing a simple software that maintains a list of cars, their owners and repairs made on the cars(I've developed 3 separate classes for cars, owners, and repairs). Important info is that each car has an attribute which is a list of repairs done to it, and my idea was as follows: I made a form which allows you to enter relevant data about the owner and the car and containing a checkbox saying Has repairs, and a button to add a new object to the list. When I click this button, it checks the status of the checkbox, if it is checked, a new form opens whose constructor receives references to a list and a car containing 2 buttons, 1 to exit the form, the other one to add repairs to the said list. But what happens is, I click the button, and it adds the car while the other form is still in the air, not doing what I need it to do, since the car is already in the list.
To be clear, I need a way to make the code execution stop when I enter this new form, and resume when I leave it. Any help would be welcome!
form1.Show() shows a form and continues execution once the form is opened.
Try form1.ShowDialog() - this makes the form modal, meaning it will hold code execution until you close the form.
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.
Scenario:
Existing winforms application with embedded word using dsoframer
Problem:
When user hits preview and exits preview, the fields are showing the codes like '{FORMTEXT}' instead of the actual values. When I click on print options on print preview, the 'Show field codes instead of their values' option is disabled. Don't know why.
I am looking to achieve previewclosed event so I can iterate through the fields and set the field.ShowCodes to false.
The print options are not relevant to what the user sees when print preview exits. Word has no event that triggers for print preview. But you don't need to iterate through the fields to ensure that field codes are not displaying. Use:
Document.ActiveWindow.View.ShowFieldCodes = False
Is there a way to override the functionality of the preview exit? Then you can send a callback before you exit the preview.