示例#1
0
 /// <summary>
 /// Sets a named property of an XNameAccess object.
 /// </summary>
 /// <param name="obj">The obj.</param>
 /// <param name="propName">Name of the property.</param>
 /// <param name="value">The new value.</param>
 public static void SetNamedProperty(XNameContainer obj, String propName, Object value)
 {
     if (obj != null)
     {
         if (obj.hasByName(propName))
         {
             obj.replaceByName(propName, Any.Get(value));
         }
         else
         {
             obj.insertByName(propName, new uno.Any(value.ToString()));
         }
     }
 }
示例#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);
        }
 /// <summary>
 /// Sets a named property of an XNameAccess object.
 /// </summary>
 /// <param name="obj">The obj.</param>
 /// <param name="propName">Name of the property.</param>
 /// <param name="value">The new value.</param>
 public static void SetNamedProperty(XNameContainer obj, String propName, Object value)
 {
     if (obj != null)
     {
         if (obj.hasByName(propName))
         {
             obj.replaceByName(propName, Any.Get(value));
         }
         else
         {
             obj.insertByName(propName, new uno.Any(value.ToString()));
         }
     }
 }