public XPropertySet InsertProgressBar(int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nProgressMax, int _nProgress, String sName = "")
        {
            XPropertySet xPBModelPSet = null;

            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = createUniqueName(MXDlgModelNameContainer, "PROGRESS_BAR");
                }
                else
                {
                    sName = createUniqueName(MXDlgModelNameContainer, sName);
                }

                // create a controlmodel at the multiservicefactory of the dialog model...
                Object oPBModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_PROGRESS_BAR_MODEL, MXContext);

                XMultiPropertySet xPBModelMPSet = (XMultiPropertySet)oPBModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xPBModelMPSet.setPropertyValues(
                    new String[] { "Height", "Name", "PositionX", "PositionY", "Width" },
                    Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, _nWidth }));

                // The controlmodel is not really available until inserted to the Dialog container
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oPBModel));
                xPBModelPSet = (XPropertySet)oPBModel;

                // The following properties may also be set with XMultiPropertySet but we
                // use the XPropertySet interface merely for reasons of demonstration
                xPBModelPSet.setPropertyValue("ProgressValueMin", Any.Get(0));
                xPBModelPSet.setPropertyValue("ProgressValueMax", Any.Get(_nProgressMax));
                xPBModelPSet.setPropertyValue("ProgressValue", Any.Get(_nProgress));
            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return(xPBModelPSet);
        }
        public Object InsertHorizontalFixedLine(String _sLabel, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int orientation, String sName = "")
        {
            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = createUniqueName(MXDlgModelNameContainer, "FIXED_LINE");
                }
                else
                {
                    sName = createUniqueName(MXDlgModelNameContainer, sName);
                }

                // create a controlmodel at the multiservicefactory of the dialog model...
                Object            oFLModel      = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_FIXED_LINE_MODEL, MXContext);
                XMultiPropertySet xFLModelMPSet = (XMultiPropertySet)oFLModel;

                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xFLModelMPSet.setPropertyValues(
                    new String[] { "Height", "Name", "Orientation", "PositionX", "PositionY", "Width" },
                    Any.Get(new Object[] { _nHeight, sName, orientation, _nPosX, _nPosY, _nWidth }));

                // The controlmodel is not really available until inserted to the Dialog container
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oFLModel));

                // The following property may also be set with XMultiPropertySet but we
                // use the XPropertySet interface merely for reasons of demonstration
                XPropertySet xFLPSet = (XPropertySet)oFLModel;
                xFLPSet.setPropertyValue("Label", Any.Get(_sLabel));

                return(oFLModel);
            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return(null);
        }
        public XTextComponent InsertEditField(String defaultText, int _nPosX, int _nPosY, int _nWidth, int _nHeight, String echoChar, XTextListener _xTextListener, XFocusListener _xFocusListener, XKeyListener _xKeyListener, String sName = "")
        {
            XTextComponent xTextComponent = null;

            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = createUniqueName(MXDlgModelNameContainer, "EDIT");
                }
                else
                {
                    sName = createUniqueName(MXDlgModelNameContainer, sName);
                }


                // create a controlmodel at the multiservicefactory of the dialog model...
                Object            oTFModel      = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_EDIT_MODEL, MXContext);
                XMultiPropertySet xTFModelMPSet = (XMultiPropertySet)oTFModel;

                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xTFModelMPSet.setPropertyValues(
                    new String[] { "Height", "Name", "PositionX", "PositionY", "Text", "Width" },
                    Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, defaultText, _nWidth }));

                // The controlmodel is not really available until inserted to the Dialog container
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oTFModel));

                if (!echoChar.Equals(String.Empty))
                {
                    XPropertySet xTFModelPSet = (XPropertySet)oTFModel;

                    // The following property may also be set with XMultiPropertySet but we
                    // use the XPropertySet interface merely for reasons of demonstration
                    xTFModelPSet.setPropertyValue("EchoChar", Any.Get((short)echoChar.ToCharArray(0, 1)[0]));
                }

                if (_xFocusListener != null || _xTextListener != null || _xKeyListener != null)
                {
                    XControl xTFControl = GetControlByName(sName);

                    // add a textlistener that is notified on each change of the controlvalue...
                    xTextComponent = (XTextComponent)xTFControl;
                    XWindow xTFWindow = (XWindow)xTFControl;
                    if (_xFocusListener != null)
                    {
                        xTFWindow.addFocusListener(_xFocusListener);
                    }
                    if (_xTextListener != null)
                    {
                        xTextComponent.addTextListener(_xTextListener);
                    }
                    if (_xKeyListener != null)
                    {
                        xTFWindow.addKeyListener(_xKeyListener);
                    }
                }
            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return(xTextComponent);
        }
        public XTextComponent InsertCurrencyField(int _nPositionX, int _nPositionY, int _nWidth, int _nHeight, string curencySymbol, double defaultValue, XTextListener _xTextListener, String sName = "")
        {
            XTextComponent xTextComponent = null;

            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = createUniqueName(MXDlgModelNameContainer, "CURRENCY_FIELD");
                }
                else
                {
                    sName = createUniqueName(MXDlgModelNameContainer, sName);
                }


                // create a controlmodel at the multiservicefactory of the dialog model...
                Object            oCFModel      = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_CURRENCY_FIELD_MODEL, MXContext);
                XMultiPropertySet xCFModelMPSet = (XMultiPropertySet)oCFModel;

                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xCFModelMPSet.setPropertyValues(
                    new String[] { "Height", "Name", "PositionX", "PositionY", "Width" },
                    Any.Get(new Object[] { _nHeight, sName, _nPositionX, _nPositionY, _nWidth }));

                // The controlmodel is not really available until inserted to the Dialog container
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oCFModel));
                XPropertySet xCFModelPSet = (XPropertySet)oCFModel;

                // The following properties may also be set with XMultiPropertySet but we
                // use the XPropertySet interface merely for reasons of demonstration
                if (!curencySymbol.Equals(String.Empty))
                {
                    xCFModelPSet.setPropertyValue("PrependCurrencySymbol", Any.Get(true));
                    xCFModelPSet.setPropertyValue("CurrencySymbol", Any.Get(curencySymbol));
                }
                else
                {
                    xCFModelPSet.setPropertyValue("PrependCurrencySymbol", Any.Get(false));
                }
                xCFModelPSet.setPropertyValue("Value", Any.Get(defaultValue));

                if (_xTextListener != null)
                {
                    // add a textlistener that is notified on each change of the controlvalue...
                    Object oCFControl = GetControlByName(sName);
                    xTextComponent = (XTextComponent)oCFControl;
                    xTextComponent.addTextListener(_xTextListener);
                }
            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return(xTextComponent);
        }
        /// <summary>
        /// Inserts a fixed text label.
        /// Properties: Height, Name, PositionX, PositionY, Step, TabIndex, Tag, Width, Align, BackgroundColor, Border, BorderColor, Enabled, FontDescriptor, FontEmphasisMark, FontRelief, HelpText, HelpURL, Label, MultiLine, Printable, TextColor, TextLineColor, VerticalAlign
        /// </summary>
        /// <param name="name">The base name of the element - will be set to a unique one by this function.</param>
        /// <param name="text">The text that should be insert.</param>
        /// <param name="_nPosX">The x position of the element.</param>
        /// <param name="_nPosY">The y posistion of the elemnt.</param>
        /// <param name="_nWidth">The width of the element.</param>
        /// <param name="_nHeight">The Height of the element.</param>
        /// <param name="_nStep">The step index.</param>
        /// <param name="_xMouseListener">A mouse listener.</param>
        /// <returns>XFixedText object</returns>
        public virtual XFixedText InsertFixedLabel(String text, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nStep, XMouseListener _xMouseListener, String sName = "")
        {
            XFixedText xFixedText = null;

            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = createUniqueName(MXDlgModelNameContainer, "TEXT_FIXED");
                }
                else
                {
                    sName = createUniqueName(MXDlgModelNameContainer, sName);
                }

                // create a controlmodel at the multiservicefactory of the dialog model...
                Object            oFTModel      = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_TEXT_FIXED_MODEL, MXContext);
                XMultiPropertySet xFTModelMPSet = (XMultiPropertySet)oFTModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!

                String[] valueNames = new String[] { "Height", "Name", "PositionX", "PositionY", "Step", "Width", "Label" };
                var      valueVals  = Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, _nStep, _nWidth, text });

                xFTModelMPSet.setPropertyValues(
                    valueNames, valueVals
                    );
                // add the model to the NameContainer of the dialog model
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oFTModel));

                var element = MXDlgModelNameContainer.getByName(sName).Value;
                if (element != null)
                {
                    OoUtils.SetProperty(element, "PositionX", _nPosX);
                    OoUtils.SetProperty(element, "PositionY", _nPosY);
                    OoUtils.SetProperty(element, "Width", _nWidth);
                    //if (element is XControl)
                    //{
                    //    ((XControl)element).getModel();
                    //}
                    //if (element is XMultiPropertySet)
                    //{
                    //    ((XMultiPropertySet)element).setPropertyValues(valueNames, valueVals);
                    //}
                }


                // reference the control by the Name
                XControl xFTControl = GetControlByName(sName);
                xFixedText = (XFixedText)xFTControl;
                if (_xMouseListener != null)
                {
                    XWindow xWindow = (XWindow)xFTControl;
                    xWindow.addMouseListener(_xMouseListener);
                }
            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return(xFixedText);
        }