public ResizingContainer(int width, int height, string sName)
        {
            #region inner Container

            // create a control model at the multi service factory of the dialog model...
            innerScrlContrModel = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER_Model) as XControlModel;
            innerScrlContr      = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER) as XControl;

            if (innerScrlContr != null && innerScrlContrModel != null)
            {
                innerScrlContr.setModel(innerScrlContrModel);
            }

            XMultiPropertySet xinnerScrlContMPSet = innerScrlContrModel as XMultiPropertySet;

            if (xinnerScrlContMPSet != null)
            {
                xinnerScrlContMPSet.setPropertyValues(
                    new String[] { "Name", "State" },
                    Any.Get(new Object[] { sName, ((short)0) }));
            }

            innerWidth  = width;
            innerHeight = height;

            // Set the size of the surrounding container
            if (innerScrlContr is XWindow)
            {
                ((XWindow)innerScrlContr).setPosSize(0, 0, innerWidth, innerHeight, PosSize.POSSIZE);
            }

            #endregion
        }
 /// <summary>
 /// Set the properties at the model - keep in mind to pass the property names in alphabetical order!
 /// </summary>
 /// <param name="xmps">The MultiPropertySet.</param>
 /// <param name="keys">The property names.</param>
 /// <param name="values">The property values.</param>
 public static void setPropertyValues(XMultiPropertySet xmps, String[] keys, Object[] values)
 {
     if (xmps != null && keys.Length > 0 && values.Length > 0 && keys.Length == values.Length)
     {
         // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
         xmps.setPropertyValues(keys, Any.Get(values));
     }
 }
        public virtual XFixedText CreateFixedLabel(String text, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nStep, XMouseListener _xMouseListener, String sName = "")
        {
            if (MXMcf == null)
            {
                return(null);
            }
            XFixedText xFixedText = null;

            try
            {
                // create a unique id 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);
                Object xFTControl = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_TEXT_FIXED, MXContext);

                XMultiPropertySet xFTModelMPSet = (XMultiPropertySet)oFTModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!

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

                if (oFTModel != null && xFTControl != null && xFTControl is XControl)
                {
                    ((XControl)xFTControl).setModel(oFTModel as XControlModel);
                }

                xFixedText = xFTControl as XFixedText;
                if (_xMouseListener != null && xFTControl is XWindow)
                {
                    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);
        }
        public XControl CreateHorizontalFixedLine(String _sLabel, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int orientation, String sName = "")
        {
            if (MXMcf == null)
            {
                return(null);
            }
            try
            {
                // create a unique id 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);
                Object oFLControl = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_FIXED_LINE, MXContext);

                if (oFLModel != null && oFLControl != null && oFLControl is XControl)
                {
                    ((XControl)oFLControl).setModel(oFLModel as XControlModel);
                }


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

                XPropertySet xFLPSet = (XPropertySet)oFLModel;
                xFLPSet.setPropertyValue("Label", Any.Get(_sLabel));

                return(oFLControl as XControl);
            }
            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 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);
        }
예제 #6
0
        /// <summary>
        /// registers various property listeners
        /// </summary>
        private void registerListeners()
        {
            try
            {
                if (refreshPagePropertiesTimer != null)
                {
                    refreshPagePropertiesTimer.Stop(); refreshPagePropertiesTimer.Dispose();
                }
                refreshPagePropertiesTimer = new System.Timers.Timer(5000);
                XPropertySet pageProperties = DrawPage as XPropertySet;
                if (pageProperties != null)
                {
                    //Debug.PrintAllProperties(pageProperties);

                    onRefreshPage(this, null);

                    pageProperties.addPropertyChangeListener("Orientation", eventForwarder);
                    pageProperties.addVetoableChangeListener("Orientation", eventForwarder);

                    pageProperties.addPropertyChangeListener("", eventForwarder);

                    refreshPagePropertiesTimer.Elapsed += new System.Timers.ElapsedEventHandler(onRefreshPage);

                    // start the refresh timer with some delay so not all pages will update their properties at the same time!
                    Task t = new Task(new Action(() =>
                    {
                        Thread.Sleep(rnd.Next(1000));
                        refreshPagePropertiesTimer.Start();
                    }));
                    t.Start();

                    //eventForwarder.Modified += eventForwarder_Modified;
                    //eventForwarder.NotifyEvent += eventForwarder_NotifyEvent;
                    //eventForwarder.PropertiesChange += eventForwarder_PropertiesChange;
                    //eventForwarder.PropertyChange += eventForwarder_PropertyChange;
                    //eventForwarder.VetoableChange += eventForwarder_VetoableChange;
                }
                XMultiPropertySet pageMultiProperties = (XMultiPropertySet)DrawPage;
                if (pageMultiProperties != null)
                {
                    pageMultiProperties.addPropertiesChangeListener(new string[] { }, eventForwarder);
                }
            }
            catch (DisposedException) { ((IDisposable)this).Dispose(); }
            catch (Exception) { }
        }
        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);
        }
        /// <summary>
        /// Initializes the Dialog with basic properties.
        /// </summary>
        /// <param name="name">The name of the object.</param>
        /// <param name="title">The title of the dialog window.</param>
        /// <param name="width">The width of the dialog window.</param>
        /// <param name="height">The height of the dialog window.</param>
        /// <param name="posX">The x posistion of the dialog window.</param>
        /// <param name="posY">The y posistion of the dialog window.</param>
        /// <param name="moveable">if set to <c>true</c> the dialog window can be moved.</param>
        /// <param name="tabIndex">Tab index of the dialog window.</param>
        /// <param name="step">The step index of the dialog window.</param>
        public virtual void InitalizeDialog(string name, string title, int width, int height, int posX, int posY, bool moveable, int tabIndex, int step)
        {
            String[] PropertyNames  = new String[] { "Height", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width" };
            Object[] PropertyValues = new Object[] { height, moveable, name, posX, posY, step, (short)tabIndex, title, width };

            try
            {
                XMultiPropertySet xMultiPropertySet = (XMultiPropertySet)MXDlgModelNameContainer;
                xMultiPropertySet.setPropertyValues(PropertyNames, Any.Get(PropertyValues));
            }
            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);
            }
        }
        protected virtual XFixedText CreateFixedLabel(String text, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nStep, XMouseListener _xMouseListener, String sName = "")
        {
            XFixedText xFixedText = null;

            try
            {
                // create a controlmodel at the multiservicefactory of the dialog model...
                Object            oFTModel      = OO.GetMultiServiceFactory().createInstance(OO.Services.AWT_CONTROL_TEXT_FIXED_MODEL);
                Object            xFTControl    = OO.GetMultiServiceFactory().createInstance(OO.Services.AWT_CONTROL_TEXT_FIXED);
                XMultiPropertySet xFTModelMPSet = (XMultiPropertySet)oFTModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!

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

                if (oFTModel != null && xFTControl != null && xFTControl is XControl)
                {
                    ((XControl)xFTControl).setModel(oFTModel as XControlModel);
                }

                xFixedText = xFTControl as XFixedText;
                if (_xMouseListener != null && xFTControl is XWindow)
                {
                    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);
        }
예제 #10
0
        /// <summary>
        /// Inserts the scroll bar.
        /// </summary>
        /// <param id="_nPosX">The X position.</param>
        /// <param id="_nPosY">The Y position.</param>
        /// <param id="_nHeight">Height of the Scrollbar.</param>
        /// <param id="_nWidth">Width of the Scrollbar.</param>
        /// <param id="sName">Name of the XControl - can be empty.</param>
        private XScrollBar insertScrollBar(XAdjustmentListener _xAdjustmentListener, int _nPosX, int _nPosY, int _nHeight, int _nWidth, int orientation = unoidl.com.sun.star.awt.ScrollBarOrientation.VERTICAL, String sName = "", bool liveScroll = true)
        {
            try
            {
                // create a unique id by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLBAR");
                }
                else
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
                }

                // create a control model at the multiservicefactory of the dialog model...
                Object            oSBModel = parentMCF.createInstanceWithContext(OO.Services.AWT_CONTROL_SCROLLBAR_MODEL, _mXContext);
                XMultiPropertySet xRBMPSet = (XMultiPropertySet)oSBModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xRBMPSet.setPropertyValues(
                    new String[] { "BlockIncrement", "Height", "LineIncrement", "LiveScroll", "Name", "Orientation", "PositionX", "PositionY", "Width" },
                    Any.Get(new Object[] { 30, _nHeight, 10, liveScroll, sName, orientation, _nPosX, _nPosY, _nWidth }));
                // add the model to the NameContainer of the dialog model
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oSBModel));

                XControl xSBControl = (parentCnt != null) ? parentCnt.getControl(sName) : null;

                if (xSBControl != null && xSBControl is XScrollBar && _xAdjustmentListener != null)
                {
                    ((XScrollBar)xSBControl).addAdjustmentListener(_xAdjustmentListener);
                }

                return(xSBControl as XScrollBar);
            }
            catch { }

            return(null);
        }
 /// <summary>
 /// Set the properties at the model - keep in mind to pass the property names in alphabetical order!
 /// </summary>
 /// <param name="xmps">The MultiPropertySet.</param>
 /// <param name="keys">The property names.</param>
 /// <param name="values">The property values.</param>
 public static void setPropertyValues(XMultiPropertySet xmps, String[] keys, Object[] values)
 {
     if (xmps != null && keys.Length > 0 && values.Length > 0 && keys.Length == values.Length)
     {
         // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
         xmps.setPropertyValues(keys, Any.Get(values));
     }
 }
        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);
        }
예제 #15
0
        public void CreateScrollableContainer(int _nPosX, int _nPosY, int _nWidth, int _nHeight, String sName)
        {
            try
            {
                // create a unique id by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLL_CONTAINER");
                }
                else
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
                }

                //XMultiServiceFactory _xMSF = OO.GetMultiServiceFactory(MXContext);
                XMultiComponentFactory _xMcf = OO.GetMultiComponentFactory(MXContext, true);

                #region Outer Container

                // create a UnoControlContainerModel. A thing which differs from other dialog-controls in many aspects
                // Position and size of the model have no effect, so we apply setPosSize() on it's view later.
                // Unlike a dialog-model the container-model can not have any control-models.
                // As an instance of a dialog-model it can have the property "Step"(among other things),
                // provided by service awt.UnoControlDialogElement, without actually supporting this service!

                // create a control model at the multi service factory of the dialog model...
                outerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel;
                OuterScrlContr      = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl;


                if (OuterScrlContr != null && outerScrlContrModel != null)
                {
                    OuterScrlContr.setModel(outerScrlContrModel);
                }

                XMultiPropertySet xoScrlContMPSet = outerScrlContrModel as XMultiPropertySet;

                if (xoScrlContMPSet != null)
                {
                    // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                    xoScrlContMPSet.setPropertyValues(
                        new String[] { "Height", "Name", "PositionX", "PositionY", "State", "Width" },
                        Any.Get(new Object[] { 0, sName, 0, 0, ((short)0), 0, 0 }));
                }

                //add to the dialog
                XControlContainer xCntrCont = parentCnt as XControlContainer;
                if (xCntrCont != null)
                {
                    xCntrCont.addControl(sName, OuterScrlContr as XControl);
                }

                #endregion

                #region Scroll bars

                //insert scroll bars
                HorizontalScrlBar = insertHorizontalScrollBar(this, _nPosX, _nPosY + _nHeight, _nWidth);
                VerticalScrlBar   = insertVerticalScrollBar(this, _nPosX + _nWidth, _nPosY, _nHeight);

                #endregion

                #region Set Size of outer Container

                //make the outer container pos and size via the pos and size of the scroll bars
                if (HorizontalScrlBar is XWindow)
                {
                    Rectangle hSBPos = ((XWindow)HorizontalScrlBar).getPosSize();
                    _width = hSBPos.Width;
                    _posX  = hSBPos.X;
                }
                if (VerticalScrlBar is XWindow)
                {
                    Rectangle vSBPos = ((XWindow)VerticalScrlBar).getPosSize();
                    _height = vSBPos.Height;
                    _posY   = vSBPos.Y;
                }

                // Set the size of the surrounding container
                if (OuterScrlContr is XWindow)
                {
                    ((XWindow)OuterScrlContr).setPosSize(PosX, PosY, Width, Height, PosSize.POSSIZE);
                    ((XWindow)OuterScrlContr).addMouseListener(this);
                }
                #endregion

                #region inner Container


                // create a control model at the multi service factory of the dialog model...
                innerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel;
                InnerScrlContr      = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl;


                if (InnerScrlContr != null && innerScrlContrModel != null)
                {
                    InnerScrlContr.setModel(innerScrlContrModel);
                }

                XMultiPropertySet xinnerScrlContMPSet = innerScrlContrModel as XMultiPropertySet;

                if (xinnerScrlContMPSet != null)
                {
                    xinnerScrlContMPSet.setPropertyValues(
                        new String[] { "Name", "State" },
                        Any.Get(new Object[] { sName + "_S", ((short)0) }));
                }

                //// FIXME: only for fixing

                //util.Debug.GetAllServicesOfObject(parentCnt);

                //Object oDialogModel = OO.GetMultiComponentFactory().createInstanceWithContext(OO.Services.AWT_CONTROL_DIALOG_MODEL, MXContext);

                //// The named container is used to insert the created controls into...
                //MXDlgModelNameContainer = (XNameContainer)oDialogModel;

                //System.Diagnostics.Debug.WriteLine("_________");

                //util.Debug.GetAllServicesOfObject(MXDlgModelNameContainer);

                //// END

                //add inner container to the outer scroll container
                XControlContainer outerCntrCont = OuterScrlContr as XControlContainer;
                if (outerCntrCont != null)
                {
                    outerCntrCont.addControl(sName + "_S", InnerScrlContr as XControl);

                    InnerWidth  = Width;
                    InnerHeight = Height;

                    // Set the size of the surrounding container
                    if (InnerScrlContr is XWindow)
                    {
                        ((XWindow)InnerScrlContr).setPosSize(0, 0, InnerWidth, InnerHeight, PosSize.POSSIZE);
                        ((XWindow)InnerScrlContr).addMouseListener(this);
                    }
                }

                #endregion
            }
            catch (System.Exception) { }
        }
        public void addTree(XSelectionChangeListener _xSelectionListener = null, String sName = "")
        {

            /*Selection
             *
             *   If you are interested in knowing when the selection changes implement a 
             *   ::com::sun::star::view::XSelectionChangeListener and add the instance 
             *   with the method ::com::sun::star::view::XSelectionSupplier::addSelectionChangeListener(). 
             *   You than will be notified for any selection change.
             *
             *  If you are interested in detecting either double-click events or when a user 
             *  clicks on a node, regardless of whether or not it was selected, you can get 
             *  the ::com::sun::star::awt::XWindow and add yourself as 
             *  a ::com::sun::star::awt::XMouseClickHandler. 
             *  You can use the method XTreeControl::getNodeForLocation() to retrieve the 
             *  node that was under the mouse at the time the event was fired. 
             */

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

                xDialogModelPropertySet = (XPropertySet)MXMsfDialogModel;

                // Similar to the office assistants the tree is adjusted to the height of the dialog
                // where a certain space is left at the bottom for the buttons...
                int nDialogHeight = (int)(xDialogModelPropertySet.getPropertyValue("Height").Value);

                // instantiate the treemodel...
                Object oTreeModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_TREE_MODEL, MXContext);

                // define the properties of the treemodel
                m_xTreePSet = (XMultiPropertySet)oTreeModel;
                m_xTreePSet.setPropertyValues(
                                        new String[] { "Height", "Name", "PositionX", "PositionY", "Width" },
                                        Any.Get(new Object[] { (nDialogHeight - 26), sName, 0, 0, 85 }));
                m_xRMPSet = (XPropertySet)oTreeModel;

                // add the treemodel to the dialog container..
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oTreeModel));

                oMutTreeModel = OO.GetMultiServiceFactory().createInstance(OO.Services.AWT_CONTROL_MUTABLETREE_MODEL) as XMutableTreeDataModel;

                //set the new DdataModel
                XPropertySet xTItemPSet = oTreeModel as XPropertySet;
                if (xTItemPSet != null)
                    xTItemPSet.setPropertyValue("DataModel", Any.Get(oMutTreeModel));

                // add the itemlistener to the control...
                XControl xTMControl = GetControlByName(sName);

                XSelectionSupplier selSupp = xTMControl as XSelectionSupplier;
                if (selSupp != null)
                {
                    selSupp.addSelectionChangeListener(_xSelectionListener);
                }

            }
            catch (System.Exception)
            {
                //jexception.printStackTrace(System.out);
            }
        }