PresentationConverter.CancelConversion() Method

The CancelConversion method stops the conversion process and optionally deletes the generated files.

Syntax

void CancelConversion(bool deleteGeneratedFiles = true)
  

Parameters

deleteGeneratedFiles - a boolean value which indicates whether the generated files must be deleted. The default value of this parameter is true.

Description

This method stops the presentation conversion process which was started using GenerateFlash, GenerateSolidPresentation, GenerateCompoundPresentation, and GenerateStandaloneSlides methods of the PresentationConverter Class. It is usually called in the conversion event handler.

Return value

none.

Example

C# Sample

The following sample creates a simple window with Convert and Cancel buttons.

Form1

When the user clicks the Convert button, the "c:\test.ppt" file is converted to the "c:\test.swf" Flash file. During conversion process, currently processed slide index is displayed on the form. When user clicks the Cancel button, the conversion process is aborted using the CancelConversion method.

using System;
using System.Windows.Forms;

using iSpring;

namespace GUITest
{
    public partial class Form1 : Form
    {
        private PresentationConverter m_converter;

        public Form1()
        {
            InitializeComponent();

            m_converter = new PresentationConverter();

            // initialize event handlers
            m_converter.OnIdle += new _ISpringEvents_OnIdleEventHandler(converter_OnIdle);
            m_converter.OnSlideProgressChanged += new _ISpringEvents_OnSlideProgressChangedEventHandler(converter_OnSlideProgressChanged);

        }

        void converter_OnSlideProgressChanged(int slideIndex, int totalSlides)
        {
            // display currently processed slide
            currentSlideLabel.Text = "Current slide: " + (slideIndex + 1) + " / " + totalSlides;
            Application.DoEvents();
        }

        void converter_OnIdle()
        {
            // handle window events during conversion
            Application.DoEvents();
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            btnConvert.Enabled = false;
            btnCancel.Enabled = false;
            try
            {
                m_converter.OpenPresentation("c:\\test.ppt");
                m_converter.GenerateSolidPresentation("c:\\test.swf", "", null);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            btnCancel.Enabled = false;
            btnConvert.Enabled = true;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            btnCancel.Enabled = false;
            m_converter.CancelConversion(true);
            btnConvert.Enabled = true;
        }
    }
}