Customizing Preview/Viewer
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Customizing Preview/Viewer
We are using the latest version of StimulReport.NET for .NET 1.1.
We would like to control the buttons on the report viewer. We are able to do most of this by disabling the buttons after the report has been crated and loaded from file using the following code:
StiPreviewConfigService config = StiConfig.Services.GetService(typeof(StiPreviewConfigService)) as StiPreviewConfigService;
config.OpenEnabled = false;
config.SaveEnabled = false;
...
...
We have removed most of the buttons we need but are unable to remove the following:
Bookmarks - we would like to remove the bookmark button but keep the thumbnail button
Multiple Pages - We would like to keep all the pages buttons but remove the 'Multiple Pages' button
We have not found any way of removing these buttons. Can this be done?
We are keeping the Export and the Send Email funtionality, but want to restrict only to PDF. So when a user clicks on Export, it only exports to PDF, and same with email. Is this possible?
Thanks
We would like to control the buttons on the report viewer. We are able to do most of this by disabling the buttons after the report has been crated and loaded from file using the following code:
StiPreviewConfigService config = StiConfig.Services.GetService(typeof(StiPreviewConfigService)) as StiPreviewConfigService;
config.OpenEnabled = false;
config.SaveEnabled = false;
...
...
We have removed most of the buttons we need but are unable to remove the following:
Bookmarks - we would like to remove the bookmark button but keep the thumbnail button
Multiple Pages - We would like to keep all the pages buttons but remove the 'Multiple Pages' button
We have not found any way of removing these buttons. Can this be done?
We are keeping the Export and the Send Email funtionality, but want to restrict only to PDF. So when a user clicks on Export, it only exports to PDF, and same with email. Is this possible?
Thanks
Customizing Preview/Viewer
Please use the following code:fphealthcare wrote:We have removed most of the buttons we need but are unable to remove the following:
Bookmarks - we would like to remove the bookmark button but keep the thumbnail button
Code: Select all
StiOptions.Preview.Window.ShowBookmarksPanel = false;
report.PreviewSettings = (report.PreviewSettings & (int)(~StiPreviewSettings.Bookmarks));
We will add this ability in one-three days.fphealthcare wrote: Multiple Pages - We would like to keep all the pages buttons but remove the 'Multiple Pages' button
Please use the following code:fphealthcare wrote:We are keeping the Export and the Send Email funtionality, but want to restrict only to PDF. So when a user clicks on Export, it only exports to PDF, and same with email.
Code: Select all
foreach (StiService service in StiConfig.Services.GetServices(typeof(StiExportService)))
{
if (!(service is StiPdfExportService))
{
service.ServiceEnabled = false;
}
}
StiConfig.Save();
StiConfig.Load();
Thank you.
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Customizing Preview/Viewer
Works very well thanks. We have some questions regarding exporting to PDF.Edward wrote: Please use the following code:Please use the following code:Code: Select all
StiOptions.Preview.Window.ShowBookmarksPanel = false; report.PreviewSettings = (report.PreviewSettings & (int)(~StiPreviewSettings.Bookmarks));
Code: Select all
foreach (StiService service in StiConfig.Services.GetServices(typeof(StiExportService))) { if (!(service is StiPdfExportService)) { service.ServiceEnabled = false; } }
1. We have removed the 'Save' button and have kept the 'Export' button and have used the code above to only allow saving to PDF. Is it possible to change the icon of the 'Export' button to be the same as the icon of the 'Save' button (a disc).
2. We would like to suppress the PDF settings dialog so it never shows. It simply uses the default settings and prompts for a filename.
3. Is there a way to set so that everytime you chose to export as PDF it asks for a filename, but is always saved to a default folder?
When you say the settings can be save/load ... Do you mean the settings get saved to the report file? Does this mean that I need to set these settings once and simply load it each time I load the report rather than setting the settings again?Edward wrote: These settings may be save/load via the following:
StiConfig.Save();
StiConfig.Load();
Thanks
Customizing Preview/Viewer
These requirements may be achieved in the following way:fpheallthcare wrote:1. We have removed the 'Save' button and have kept the 'Export' button and have used the code above to only
allow saving to PDF. Is it possible to change the icon of the 'Export' button to be the same as the icon
of the 'Save' button (a disc).
2. We would like to suppress the PDF settings dialog so it never shows. It simply uses the default settings
and prompts for a filename.
3. Is there a way to set so that everytime you chose to export as PDF it asks for a filename, but is always
saved to a default folder?
You are disable Export button at all. Save button is visible but its behavior is changed via
StiPreviewControl.SavingDocument static event. Please note that you need to set this event only once (for example in the FormLoad event handler).
So you can get full control on the exporting(saving) process of the rendered report.
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
StiPreviewControl.SavingDocument += new EventHandler(StiPreviewControl_SavingDocument);
StiOptions.Preview.Window.ShowSaveButton = true;
}
private void StiPreviewControl_SavingDocument(object sender, EventArgs e)
{
StiReport report = sender as StiReport;
StiPdfExportSettings settings = new StiPdfExportSettings();
// here you can set additional export parameters for the export
settings.KeyLength = StiPdfEncryptionKeyLength.Bit128;
// Here you can ask user for the filename of the exported document
report.ExportDocument(StiExportFormat.Pdf, filename, settings);
}
http://forum.stimulsoft.com/Default.aspx?g=posts&t=529
No, the configuration of the Preview Control will be saved via commandfphealthcare wrote:When you say the settings can be save/load ... Do you mean the settings get saved to the report file?
Code: Select all
StiConfig.Save();
C:\Documents and Settings\Name of the Account\Local Settings\Application Data\Stimulsoft\Stimulsoft.Report.config
not into a mrt file.
Then these saved settings may be retrieved via
Code: Select all
StiConfig.Load()
No, only saving the configuration of the preview control into config file.fphealthcare wrote:Does this mean that I need to set these settings once and simply load it each time I load the report rather than setting the settings again?
Thank you.
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Customizing Preview/Viewer
Thanks. This is great, we have been able to do what we wanted. We do have 2 more questions.Edward wrote:These requirements may be achieved in the following way:
You are disable Export button at all. Save button is visible but its behavior is changed via
StiPreviewControl.SavingDocument static event. Please note that you need to set this event only once (for example in the FormLoad event handler).
So you can get full control on the exporting(saving) process of the rendered report.
For more information about control saving(exporting) of the rendered report please see the following topic:Code: Select all
private void Form1_Load(object sender, EventArgs e) { StiPreviewControl.SavingDocument += new EventHandler(StiPreviewControl_SavingDocument); StiOptions.Preview.Window.ShowSaveButton = true; } private void StiPreviewControl_SavingDocument(object sender, EventArgs e) { StiReport report = sender as StiReport; StiPdfExportSettings settings = new StiPdfExportSettings(); // here you can set additional export parameters for the export settings.KeyLength = StiPdfEncryptionKeyLength.Bit128; // Here you can ask user for the filename of the exported document report.ExportDocument(StiExportFormat.Pdf, filename, settings); }
http://forum.stimulsoft.com/Default.aspx?g=posts&t=529
1. From some code we've seen on this forum we have been using
Code: Select all
StiPreviewConfigService config = StiConfig.Services.GetService(typeof(StiPreviewConfigService)) as StiPreviewConfigService;
config.OpenEnabled = false
Code: Select all
StiOptions.Preview.Window.ShowOpenButton = false
2. Have now have an 'Email' button which now has only 1 option - PDF. However that brings up a settings box for the PDF before creating the PDF and emailing. We'd like to do the same with the 'Email' as with the 'Save' which is to use the default PDF settings, and to supress the settings box. Is this possible? Better yet, is it possible for the 'Email' button to default to PDF and go straigh to the email rather than having a dropdown box with the email options - like how the 'Save' button is implemented?
Thanks
Customizing Preview/Viewer
It is doesn't matter. The second way is more simple - please use this one.fphealthcare wrote:1. From some code we've seen on this forum we have been usingto disable a button. We've noticed you can also useCode: Select all
StiPreviewConfigService config = StiConfig.Services.GetService(typeof(StiPreviewConfigService)) as StiPreviewConfigService; config.OpenEnabled = false
to disable a button. What is the difference and which one should we be using?Code: Select all
StiOptions.Preview.Window.ShowOpenButton = false
Please use the following code:fphealthcare wrote:2. Have now have an 'Email' button which now has only 1 option - PDF. However that brings up a settings box for the PDF before creating the PDF and emailing. We'd like to do the same with the 'Email' as with the 'Save' which is to use the default PDF settings, and to supress the settings box. Is this possible? Better yet, is it possible for the 'Email' button to default to PDF and go straigh to the email rather than having a dropdown box with the email options - like how the 'Save' button is implemented?
Code: Select all
stiPreviewControl1.ClickSendEMailButton += new EventHandler(stiPreviewControl1_ClickSendEMailButton);
private void stiPreviewControl1_ClickSendEMailButton(object sender, EventArgs e)
{
StiPdfExportSettings settings = new StiPdfExportSettings();
stiPreviewControl1.Report.ExportDocument(StiExportFormat.Pdf, "D:\\MyFile.pdf", settings);
try
{
MAPI.SendEMail(report.ReportAlias != null && report.ReportAlias.Trim().Length > 0 ?
report.ReportAlias : report.ReportName, report.ReportDescription, "D:\\MyFile.pdf");
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
Thank you.
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
Customizing Preview/Viewer
Thanks again for the quick reply.Edward wrote: Please use the following code:
This code disables sub menu of the SendEmail button, in the settings variable you may specify all necessary parameters for the export. The standard export menu will be also suppressed.Code: Select all
stiPreviewControl1.ClickSendEMailButton += new EventHandler(stiPreviewControl1_ClickSendEMailButton); private void stiPreviewControl1_ClickSendEMailButton(object sender, EventArgs e) { .... .... }
Thank you.
We not using an StiPreviewControl, so we don't have an stiPreviewControl1 object. We are using the report object and using Report.Show(true) to bring up the veiwer. We have tried using this code
Code: Select all
StiPreviewControl.ClickSendEMailButton += new EventHandler(stiPreviewControl1_ClickSendEMailButton);
The code you gave us earlier with the saving document works fine in this manner
Code: Select all
StiPreviewControl.SavingDocument += new EventHandler(StiPreviewControl_SavingDocument);
Thanks
Customizing Preview/Viewer
It is the correct behavior, because the static event handlerfphealthcare wrote:We not using an StiPreviewControl, so we don't have an stiPreviewControl1 object. We are using the report object and using Report.Show(true) to bring up the veiwer. We have tried using this codeWe get an error.Code: Select all
StiPreviewControl.ClickSendEMailButton += new EventHandler(stiPreviewControl1_ClickSendEMailButton);
StiPreviewControl.ClickSendEMailButton is not exists.
My previous code was regarding the instance of the StiPreviewControl not for the static class StiPreviewControl.
So you have two ways to set the custom behavior of the reports preview:
1. Use an additional code to create a custom preview form before rendering the report and instead of calling report.Show(true) you should show this form as dialog.
Code: Select all
using (StiPreviewForm form = new StiPreviewForm(report))
{
form.PreviewControl.ClickSendEMailButton += new EventHandler(PreviewControl_ClickSendEMailButton);
report.Render();
form.ShowDialog();
form.PreviewControl.ClickSendEMailButton -= new EventHandler(PreviewControl_ClickSendEMailButton);
}
Thank you.
Customizing Preview/Viewer
We have added three new properties to StiPreviewConfigService:
PageViewModeSingleEnabled (equal to StiOptions.Preview.Window.ShowPageViewSingleMode)
PageViewModeContinuousEnabled (equal to StiOptions.Preview.Window.ShowPageViewContinuousMode)
PageViewModeMultipleEnabled (equal to StiOptions.Preview.Window.ShowPageViewMultipleMode)
Please check build from 16 May.
Thank you.
PageViewModeSingleEnabled (equal to StiOptions.Preview.Window.ShowPageViewSingleMode)
PageViewModeContinuousEnabled (equal to StiOptions.Preview.Window.ShowPageViewContinuousMode)
PageViewModeMultipleEnabled (equal to StiOptions.Preview.Window.ShowPageViewMultipleMode)
Please check build from 16 May.
Thank you.
-
- Posts: 18
- Joined: Mon Jan 22, 2007 11:51 am
- Location: Belgium
Customizing Preview/Viewer
I tried the code you recommended here, but the only result I get is a hidden "Show Bookmark Panel"-button. The thing I want to do is hiding the bookmarkpanel when the report is shown. The user can show it manually when he/she clicks the "Show Bookmark Panel"-button. How can this be done?Edward wrote:Please use the following code:fphealthcare wrote:We have removed most of the buttons we need but are unable to remove the following:
Bookmarks - we would like to remove the bookmark button but keep the thumbnail button
Thank you.Code: Select all
StiOptions.Preview.Window.ShowBookmarksPanel = false; report.PreviewSettings = (report.PreviewSettings & (int)(~StiPreviewSettings.Bookmarks));