Page 1 of 3

Customizing Preview/Viewer

Posted: Sun May 06, 2007 7:05 pm
by fphealthcare
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

Customizing Preview/Viewer

Posted: Mon May 07, 2007 10:58 am
by Edward
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
Please use the following code:

Code: Select all

StiOptions.Preview.Window.ShowBookmarksPanel = false;
report.PreviewSettings = (report.PreviewSettings & (int)(~StiPreviewSettings.Bookmarks));
fphealthcare wrote: Multiple Pages - We would like to keep all the pages buttons but remove the 'Multiple Pages' button
We will add this ability in one-three days.
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.
Please use the following code:

Code: Select all

            foreach (StiService service in StiConfig.Services.GetServices(typeof(StiExportService)))
            {
                if (!(service is StiPdfExportService))
                {
                    service.ServiceEnabled = false;
                }
            }
These settings may be save/load via the following:

StiConfig.Save();

StiConfig.Load();

Thank you.

Customizing Preview/Viewer

Posted: Tue May 08, 2007 6:34 pm
by fphealthcare
Edward wrote: Please use the following code:

Code: Select all

StiOptions.Preview.Window.ShowBookmarksPanel = false;
report.PreviewSettings = (report.PreviewSettings & (int)(~StiPreviewSettings.Bookmarks));
Please use the following code:

Code: Select all

            foreach (StiService service in StiConfig.Services.GetServices(typeof(StiExportService)))
            {
                if (!(service is StiPdfExportService))
                {
                    service.ServiceEnabled = false;
                }
            }
Works very well thanks. We have some questions regarding exporting to PDF.
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?
Edward wrote: These settings may be save/load via the following:

StiConfig.Save();

StiConfig.Load();
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?

Thanks

Customizing Preview/Viewer

Posted: Wed May 09, 2007 5:56 am
by Edward
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?
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.

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);
        }
For more information about control saving(exporting) of the rendered report please see the following topic:
http://forum.stimulsoft.com/Default.aspx?g=posts&t=529
fphealthcare wrote:When you say the settings can be save/load ... Do you mean the settings get saved to the report file?
No, the configuration of the Preview Control will be saved via command

Code: Select all

StiConfig.Save();
into the following file:
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() 
method in the start of your application.
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?
No, only saving the configuration of the preview control into config file.

Thank you.

Customizing Preview/Viewer

Posted: Wed May 09, 2007 8:59 pm
by fphealthcare
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.

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);
        }
For more information about control saving(exporting) of the rendered report please see the following topic:
http://forum.stimulsoft.com/Default.aspx?g=posts&t=529
Thanks. This is great, we have been able to do what we wanted. We do have 2 more questions.

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
to disable a button. We've noticed you can also use

Code: Select all

StiOptions.Preview.Window.ShowOpenButton = false
to disable a button. What is the difference and which one should we be using?

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

Posted: Thu May 10, 2007 2:51 am
by Edward
fphealthcare wrote: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
to disable a button. We've noticed you can also use

Code: Select all

StiOptions.Preview.Window.ShowOpenButton = false
to disable a button. What is the difference and which one should we be using?
It is doesn't matter. The second way is more simple - please use this one.
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?
Please use the following code:

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);
            }
        }
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.

Thank you.

Customizing Preview/Viewer

Posted: Thu May 10, 2007 8:56 pm
by fphealthcare
Edward wrote: Please use the following code:

Code: Select all

        stiPreviewControl1.ClickSendEMailButton += new EventHandler(stiPreviewControl1_ClickSendEMailButton);

        private void stiPreviewControl1_ClickSendEMailButton(object sender, EventArgs e)
        {
           ....
           ....
        }
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.

Thank you.
Thanks again for the quick reply.
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);
We get an error.

The code you gave us earlier with the saving document works fine in this manner

Code: Select all

StiPreviewControl.SavingDocument += new EventHandler(StiPreviewControl_SavingDocument);
How can we get around this problem?

Thanks

Customizing Preview/Viewer

Posted: Fri May 11, 2007 8:08 am
by Edward
fphealthcare 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 code

Code: Select all

StiPreviewControl.ClickSendEMailButton += new EventHandler(stiPreviewControl1_ClickSendEMailButton);
We get an error.
It is the correct behavior, because the static event handler
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);
            }
2. Use the latest build from the May, 11. There accessible new static event StiPreviewControl.LoadPreviewControl. This event will occur for each Preview control in your application.

Thank you.

Customizing Preview/Viewer

Posted: Wed May 16, 2007 6:16 am
by Vital
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.

Customizing Preview/Viewer

Posted: Mon Jun 25, 2007 7:53 am
by Dave Canto
Edward wrote:
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
Please use the following code:

Code: Select all

StiOptions.Preview.Window.ShowBookmarksPanel = false;
report.PreviewSettings = (report.PreviewSettings & (int)(~StiPreviewSettings.Bookmarks));
Thank you.
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?