private String getStringProperty(string name)
        {
            Object prop  = OoUtils.GetProperty(Shape as XPropertySet, name);
            string sProp = prop != null?prop.ToString() : String.Empty;

            return(sProp);
        }
        /// <summary>
        /// Gets the property of a PropertySet or a XControl.
        /// </summary>
        /// <param name="propertySet">The property set or the control.</param>
        /// <param name="propName">Name of the property.</param>
        /// <returns>the value of the Any Object returned from the PropertySet</returns>
        public static Object GetProperty(Object propertySet, String propName)
        {
            if (propertySet != null && !String.IsNullOrWhiteSpace(propName))
            {
                XPropertySet ps = null;
                if (propertySet is XPropertySet)
                {
                    ps = propertySet as XPropertySet;
                }
                else if (propertySet is XControl)
                { // for a XControll you have to get the model to change or get the properties
                    XControlModel model = ((XControl)propertySet).getModel();
                    if (model != null && model is XPropertySet)
                    {
                        ps = model as XPropertySet;
                    }
                }

                if (ps != null)
                {
                    return(OoUtils.GetProperty(ps, propName));
                }
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// is invoked when the adjustment has changed.
        /// </summary>
        /// <param id="rEvent">The r event.</param>
        void XAdjustmentListener.adjustmentValueChanged(AdjustmentEvent rEvent)
        {
            if (rEvent != null && rEvent.Source is XControl)
            {
                XControlModel sbModel     = ((XControl)rEvent.Source).getModel();
                var           Orientation = OoUtils.GetProperty(rEvent.Source, "Orientation");
                int           o           = (Orientation is int) ? (int)Orientation : -1;

                // the value of a scroll bar is the topmost point of the
                // scroller. That means the size of the scroller (VisibleSize)
                // is some kind of margin to the bottom of the scroll region.
                // Is is not possible to scroll down to the ScrollValueMax.
                // The maximum value that is reachable is
                // ScrollValueMax - VisibleSize !
                // so the unreachable rest rest (VisibleSize) has to be
                // distributed proportionally to the already traveled
                // scroll way (ScrollValue)
                int    step            = OoUtils.GetIntProperty(sbModel, "ScrollValue");
                int    vissize         = OoUtils.GetIntProperty(sbModel, "VisibleSize");
                int    max             = OoUtils.GetIntProperty(sbModel, "ScrollValueMax");
                int    scrollable_size = max - vissize;
                double scrolledRatio   = (double)step / (double)scrollable_size;
                double offset          = (double)vissize * scrolledRatio;
                step += (int)offset;

                switch (o)
                {
                case 0:     // horizontal
                    scrollHorizontal(step);
                    break;

                case 1:     // vertical
                    scrollVertical(step);
                    break;

                default:
                    break;
                }

                //switch (rEvent.Type)
                //{
                //    case AdjustmentType.ADJUST_ABS:
                //        System.Diagnostics.Debug.WriteLine("The event has been triggered by dragging the thumb...");
                //        break;
                //    case AdjustmentType.ADJUST_LINE:
                //        System.Diagnostics.Debug.WriteLine("The event has been triggered by a single line move..");
                //        break;
                //    case AdjustmentType.ADJUST_PAGE:
                //        System.Diagnostics.Debug.WriteLine("The event has been triggered by a block move...");
                //        break;
                //}
                //System.Diagnostics.Debug.WriteLine("The value of the scrollbar is: " + rEvent.Value);
            }
        }
Example #4
0
        /// <summary>
        /// DonĀ“t useful function, because the size you have to set is a relative value
        /// </summary>
        /// <param name="table">Table you want to resize </param>
        /// <param name="size">relative size you want to set, look for the actual TableColumnSeparators you want to fit.</param>
        /// <param name="index">index of the column you want to resize. From left to right column. if you want to fit the first you have to set the index 0. The rightest column cant resize, you have to set the column before smaller </param>
        public void SetColSize(ref XTextTable table, int size, int index)
        {
            XTableColumns columns  = table.getColumns();
            int           colCount = columns.getCount();

            if (index > colCount)
            {
                System.Console.WriteLine("index was to big");
                return;
            }

            int iWidth = (int)OoUtils.GetIntProperty(table, "Width");

            short sTableColumnRelativeSum = (short)OoUtils.GetProperty(table, "TableColumnRelativeSum");

            double dRatio         = (double)sTableColumnRelativeSum / (double)iWidth;
            double dRelativeWidth = (double)2000 * dRatio;
            double dposition      = sTableColumnRelativeSum - dRelativeWidth;

            TableColumnSeparator[] a = OoUtils.GetProperty(table, "TableColumnSeparators") as TableColumnSeparator[];
            if (a != null)
            {
                System.Console.WriteLine(a[index].Position.ToString() + "was the position before");
                a[index].Position = (short)size;

                //for (int i = a.Length - 1; i >= 0; i--)
                //{
                //    a[i].Position = (short)Math.Ceiling(dposition);
                //    System.Console.WriteLine(dposition);
                //    dposition -= dRelativeWidth;

                //}
                OoUtils.SetProperty(table, "TableColumnSeparators", a);
            }

            //if (column != null)
            //{

            //    //OoUtils.SetIntProperty(column, "Width", size);
            //}
        }
        private bool getBoolProperty(string name)
        {
            Object prop = OoUtils.GetProperty(Shape as XPropertySet, name);

            return(prop != null && prop is bool?(bool)prop : false);
        }
 /// <summary>
 /// Try to return the value of the requested property.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns>the value as object</returns>
 public Object GetProperty(string name)
 {
     return(OoUtils.GetProperty(Shape as XPropertySet, name));
 }
Example #7
0
        /// <summary>
        /// Updates the page properties.
        /// </summary>
        /// <param name="forceUpdate">if set to <c>true</c> to force an update even if the page is currently not the active one.</param>
        /// <returns>
        ///   <c>true</c> if the update was successfully fulfilled.
        /// </returns>
        /// <remarks>This function is time limited to 200 ms.</remarks>
        public bool updatePageProperties(bool forceUpdate = false)
        {
            if (!forceUpdate && !IsActive())
            {
                return(true);
            }

            DateTime now = DateTime.Now;

            if (now - _lastPagePropertyUpdate < _propertyUpdateTimespan)
            {
                return(false);
            }

            //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " +++++++++ Update page properties REQUEST ["+this.GetHashCode()+"] +++++++++");
            bool successs = false;

            lock (this.PagesObserver.DocWnd.SynchLock)
            {
                try
                {
                    if (!_propertyUpdating && DrawPage != null)
                    {
                        _propertyUpdating = true;
                        try
                        {
                            successs = TimeLimitExecutor.WaitForExecuteWithTimeLimit(200, new Action(() =>
                            {
                                Width        = OoUtils.GetIntProperty(DrawPage, "Width");
                                Height       = OoUtils.GetIntProperty(DrawPage, "Height");
                                BorderBottom = OoUtils.GetIntProperty(DrawPage, "BorderBottom");
                                BorderLeft   = OoUtils.GetIntProperty(DrawPage, "BorderLeft");
                                BorderRight  = OoUtils.GetIntProperty(DrawPage, "BorderRight");
                                BorderTop    = OoUtils.GetIntProperty(DrawPage, "BorderTop");
                                Orientation  = (tud.mci.tangram.util.OO.PaperOrientation)OoUtils.GetProperty(DrawPage, "Orientation");
                            }), "UpdatePageProperties");
                        }
                        catch (NullReferenceException) { ((IDisposable)this).Dispose(); }
                        catch (DisposedException)
                        {
                            ((IDisposable)this).Dispose();
                        }
                        _lastPagePropertyUpdate = now;
                        return(successs);
                    }
                }
                catch { }
                finally { _propertyUpdating = false; }
            }
            return(successs);
        }