/// <summary>
        /// Called by the owner to initialize
        /// </summary>
        public void SetData(RasterCodecs rasterCodecsInstance)
        {
            // Set the state of the controls

            // Event hooks
            _pageWidthTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _pageWidthTextBox.LostFocus      += new EventHandler(_textBox_LostFocus);

            _pageHeightTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _pageHeightTextBox.LostFocus      += new EventHandler(_textBox_LostFocus);

            _leftMarginTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _leftMarginTextBox.LostFocus      += new EventHandler(_textBox_LostFocus);

            _topMarginTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _topMarginTextBox.LostFocus      += new EventHandler(_textBox_LostFocus);

            _rightMarginTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _rightMarginTextBox.LostFocus      += new EventHandler(_textBox_LostFocus);

            _bottomMarginTextBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _bottomMarginTextBox.LostFocus      += new EventHandler(_textBox_LostFocus);

            _resolutionComboBox.PreviewKeyDown += new PreviewKeyDownEventHandler(_textBox_PreviewKeyDown);
            _resolutionComboBox.LostFocus      += new EventHandler(_resolutionComboBox_LostFocus);

            // Initialize the units
            _unitComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentUnit>(CodecsRasterizeDocumentUnit.Pixel, "Pixel"));
            _unitComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentUnit>(CodecsRasterizeDocumentUnit.Inch, "Inch"));
            _unitComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentUnit>(CodecsRasterizeDocumentUnit.Millimeter, "Millimeter"));

            _sizeModeComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentSizeMode>(CodecsRasterizeDocumentSizeMode.None, "None"));
            _sizeModeComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentSizeMode>(CodecsRasterizeDocumentSizeMode.Fit, "Fit"));
            _sizeModeComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentSizeMode>(CodecsRasterizeDocumentSizeMode.FitAlways, "Fit always"));
            _sizeModeComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentSizeMode>(CodecsRasterizeDocumentSizeMode.FitWidth, "Fit width"));
            _sizeModeComboBox.Items.Add(new Tools.ValueNameItem <CodecsRasterizeDocumentSizeMode>(CodecsRasterizeDocumentSizeMode.Stretch, "Stretch"));

            CodecsRasterizeDocumentLoadOptions rasterizeDocumentLoadOptions = rasterCodecsInstance.Options.RasterizeDocument.Load;

            // Get the temporary values
            _pageWidth    = rasterizeDocumentLoadOptions.PageWidth;
            _pageHeight   = rasterizeDocumentLoadOptions.PageHeight;
            _leftMargin   = rasterizeDocumentLoadOptions.LeftMargin;
            _topMargin    = rasterizeDocumentLoadOptions.TopMargin;
            _rightMargin  = rasterizeDocumentLoadOptions.RightMargin;
            _bottomMargin = rasterizeDocumentLoadOptions.BottomMargin;
            _unit         = rasterizeDocumentLoadOptions.Unit;
            _resolution   = rasterizeDocumentLoadOptions.XResolution;
            _sizeMode     = rasterizeDocumentLoadOptions.SizeMode;

            // Now set the current values

            UpdateControlsFromValues();

            UpdateUIState();
        }
        /// <summary>
        /// Called by the owner to get the data
        /// </summary>
        public bool GetData(RasterCodecs rasterCodecsInstance)
        {
            bool ret = true;

            CodecsRasterizeDocumentLoadOptions rasterizeDocumentLoadOptions = rasterCodecsInstance.Options.RasterizeDocument.Load;

            // Get the rasterize document load settings

            if (ret)
            {
                ret = GetResolution();
            }

            if (ret)
            {
                TextBox[] valuesTextBox =
                {
                    _pageWidthTextBox,
                    _pageHeightTextBox,
                    _leftMarginTextBox,
                    _topMarginTextBox,
                    _rightMarginTextBox,
                    _bottomMarginTextBox
                };

                for (int i = 0; i < valuesTextBox.Length && ret; i++)
                {
                    ret = GetTextBoxValue(valuesTextBox[i]);
                }
            }

            if (ret)
            {
                // Everything is ok, update the options
                rasterizeDocumentLoadOptions.PageWidth    = _pageWidth;
                rasterizeDocumentLoadOptions.PageHeight   = _pageHeight;
                rasterizeDocumentLoadOptions.LeftMargin   = _leftMargin;
                rasterizeDocumentLoadOptions.TopMargin    = _topMargin;
                rasterizeDocumentLoadOptions.RightMargin  = _rightMargin;
                rasterizeDocumentLoadOptions.BottomMargin = _bottomMargin;
                rasterizeDocumentLoadOptions.Unit         = _unit;
                rasterizeDocumentLoadOptions.XResolution  = _resolution;
                rasterizeDocumentLoadOptions.YResolution  = _resolution;
                rasterizeDocumentLoadOptions.SizeMode     = _sizeMode;
            }

            return(ret);
        }