예제 #1
0
        /// <summary>
        /// Gets the page number.
        /// </summary>
        /// <returns>The current number of this page (Numbers are starting with 1)</returns>
        /// <remarks>This function is time limited to 100 ms.</remarks>
        public int GetPageNum()
        {
            TimeLimitExecutor.WaitForExecuteWithTimeLimit(
                100,
                new Action(() => { CachedPageNum = OoUtils.GetIntProperty(DrawPage, "Number"); })
                , "PageObserver-GetPageNum");

            return(CachedPageNum);
        }
예제 #2
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);
            }
        }
예제 #3
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);
        }
예제 #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 int getIntProperty(string name)
 {
     return(OoUtils.GetIntProperty(Shape as XPropertySet, name));
 }