예제 #1
0
        /// <summary>
        /// Copies the text.
        /// </summary>
        /// <param name="xDialog">The x dialog.</param>
        /// <param name="aEvent">A event object.</param>
        public void CopyText(XDialog xDialog, Object aEvent)
        {
            XControlContainer xControlContainer = (XControlContainer)xDialog;

            String        aTextPropertyStr   = "Text";
            String        aText              = "";
            XControl      xTextField1Control = xControlContainer.getControl("TextField1");
            XControlModel xControlModel1     = xTextField1Control.getModel();
            XPropertySet  xPropertySet1      = (XPropertySet)xControlModel1;

            try
            {
                aText = (String)xPropertySet1.getPropertyValue(aTextPropertyStr).Value;
            }
            catch (unoidl.com.sun.star.uno.Exception e)
            {
                Console.WriteLine("copyText caught exception! " + e);
            }

            XControl      xTextField2Control = xControlContainer.getControl("TextField2");
            XControlModel xControlModel2     = xTextField2Control.getModel();
            XPropertySet  xPropertySet2      = (XPropertySet)xControlModel2;

            try
            {
                xPropertySet2.setPropertyValue(aTextPropertyStr, new uno.Any(aText));
            }
            catch (unoidl.com.sun.star.uno.Exception e)
            {
                Console.WriteLine("copyText caught exception! " + e);
            }

            global::System.Windows.Forms.MessageBox.Show("DialogComponent", "copyText() called");
        }
예제 #2
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);
        }