예제 #1
0
 /// <summary>
 /// Triggers the <c>LayoutUpdated</c> event.
 /// </summary>
 /// <remarks>
 /// This method is called whenever there is a possibility that the size and/or position has been changed.
 /// </remarks>
 void NotifyOnLayout()
 {
     LayoutUpdated?.Invoke(this, new LayoutEventArgs()
     {
         Geometry = Geometry.ToCommon()
     });
 }
예제 #2
0
 void SendLayoutUpdated()
 {
     LayoutUpdated?.Invoke(this, new LayoutEventArgs
     {
         Geometry = new Rect(Position.X, Position.Y, Size.Width, Size.Height)
     });
 }
예제 #3
0
        void SendLayoutUpdated()
        {
            if (_disposed)
            {
                return;
            }

            if (this == null)
            {
                return;
            }

            var currentSize = Size2D;
            var needUpdate  = _cachedWidth != currentSize.Width || _cachedHeight != currentSize.Height || _markChanged;

            _cachedWidth  = currentSize.Width;
            _cachedHeight = currentSize.Height;
            _markChanged  = false;

            if (!needUpdate)
            {
                return;
            }

            LayoutUpdated?.Invoke(this, new LayoutEventArgs
            {
                Geometry = new Rect(Position.X, Position.Y, Size.Width, Size.Height)
            });
        }
예제 #4
0
        public virtual void ExecuteLayoutPass()
        {
            Dispatcher.UIThread.VerifyAccess();

            if (_disposed)
            {
                return;
            }

            if (!_running)
            {
                _running = true;

                Stopwatch?stopwatch = null;

                const LogEventLevel timingLogLevel = LogEventLevel.Information;
                bool captureTiming = Logger.IsEnabled(timingLogLevel, LogArea.Layout);

                if (captureTiming)
                {
                    Logger.TryGet(timingLogLevel, LogArea.Layout)?.Log(
                        this,
                        "Started layout pass. To measure: {Measure} To arrange: {Arrange}",
                        _toMeasure.Count,
                        _toArrange.Count);

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                }

                _toMeasure.BeginLoop(MaxPasses);
                _toArrange.BeginLoop(MaxPasses);

                for (var pass = 0; pass < MaxPasses; ++pass)
                {
                    InnerLayoutPass();

                    if (!RaiseEffectiveViewportChanged())
                    {
                        break;
                    }
                }

                _toMeasure.EndLoop();
                _toArrange.EndLoop();

                if (captureTiming)
                {
                    stopwatch !.Stop();

                    Logger.TryGet(timingLogLevel, LogArea.Layout)?.Log(this, "Layout pass finished in {Time}", stopwatch.Elapsed);
                }
            }

            _queued = false;
            LayoutUpdated?.Invoke(this, EventArgs.Empty);
        }
예제 #5
0
        public virtual void UpdateLayout()
        {
            if (_layoutState == LayoutState.Normal)
            {
                return;
            }

            if (_layoutState == LayoutState.Invalid)
            {
                // Full rearrange
                Point size;
                if (HorizontalAlignment != HorizontalAlignment.Stretch ||
                    VerticalAlignment != VerticalAlignment.Stretch)
                {
                    size = Measure(_containerBounds.Size());
                }
                else
                {
                    size = _containerBounds.Size();
                }

                if (size.X > _containerBounds.Width)
                {
                    size.X = _containerBounds.Width;
                }

                if (size.Y > _containerBounds.Height)
                {
                    size.Y = _containerBounds.Height;
                }

                // Align
                var controlBounds = LayoutUtils.Align(_containerBounds.Size(), size, HorizontalAlignment, VerticalAlignment);
                controlBounds.Offset(_containerBounds.Location);

                controlBounds.Offset(Left, Top);

                _bounds       = controlBounds;
                _actualBounds = CalculateClientBounds(controlBounds);

                Arrange();
            }
            else
            {
                // Only location
                MoveChildren(new Point(Left - _lastLocationHint.X, Top - _lastLocationHint.Y));
            }

            _lastLocationHint = new Point(Left, Top);
            _layoutState      = LayoutState.Normal;

            LayoutUpdated?.Invoke(this, EventArgs.Empty);
        }
예제 #6
0
        private void OnLayoutUpdated(int parent)
        {
#if DEBUG
            Console.WriteLine("OnLayoutUpdated - parent:{0}", parent);
#endif
            if (LayoutUpdated != null)
            {
                foreach (var method in LayoutUpdated.GetInvocationList())
                {
                    try {
                        method.DynamicInvoke(mRevision++, parent);
                    } catch (Exception ex) {
                        Debug.Fail(ex.ToString());
                    }
                }
            }
        }
        public void UpdatePipeline(PathPointLayout layout, Calculator calculator, float spacing)
        {
            bool layoutChanged = false;
            bool otherChange   = false;

            if ((Layout == null) || (layout.ChannelMask != Layout.ChannelMask))
            {
                Layout        = layout;
                layoutChanged = true;
            }

            if (mPathProducer == null || calculator != mPathProducer.PathPointCalculator || layoutChanged)
            {
                mPathProducer = new PathProducer(Layout, calculator, true);
                otherChange   = true;
            }

            if (mSmoothingFilter == null || layoutChanged)
            {
                mSmoothingFilter = new SmoothingFilter(Layout.Count)
                {
                    KeepAllData = true
                };
                otherChange = true;
            }

            if (SplineProducer == null || layoutChanged)
            {
                SplineProducer = new SplineProducer(Layout, true);
                otherChange    = true;
            }

            if (SplineInterpolator == null || layoutChanged)
            {
                SplineInterpolator = new DistanceBasedInterpolator(Layout, spacing, splitCount, true, true, true);
                otherChange        = true;
            }
            ((DistanceBasedInterpolator)SplineInterpolator).Spacing = spacing;

            if (layoutChanged || otherChange)
            {
                LayoutUpdated?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #8
0
        /// <summary>
        /// Arranges the control and its children.
        /// </summary>
        /// <param name="rect">The control's new bounds.</param>
        public void Arrange(Rect rect)
        {
            if (IsInvalidRect(rect))
            {
                throw new InvalidOperationException("Invalid Arrange rectangle.");
            }

            if (!IsMeasureValid)
            {
                Measure(_previousMeasure ?? rect.Size);
            }

            if (!IsArrangeValid || _previousArrange != rect)
            {
                Logger.Verbose(LogArea.Layout, this, "Arrange to {Rect} ", rect);

                IsArrangeValid = true;
                ArrangeCore(rect);
                _previousArrange = rect;

                LayoutUpdated?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #9
0
 internal void RaiseLayoutUpdated()
 {
     OnLayoutUpdated();
     LayoutUpdated.Raise(this, EventArgs.Empty);
 }
예제 #10
0
 //TODO: (might even want to include the origin sender)
 /// <summary>
 /// This is the event for a modification to the layout/elements requiring save and re-draw
 /// </summary>
 public void FireLayoutUpdatedEvent(bool bDataChanged)
 {
     LayoutUpdated?.Invoke(this, new LayoutEventArgs(ActiveLayout, ActiveDeck, bDataChanged));
 }
예제 #11
0
        public virtual void UpdateLayout()
        {
            if (_layoutState == LayoutState.Normal)
            {
                return;
            }

            if (_layoutState == LayoutState.Invalid)
            {
                // Full rearrange
                Point size;
                if (HorizontalAlignment != HorizontalAlignment.Stretch ||
                    VerticalAlignment != VerticalAlignment.Stretch)
                {
                    size = Measure(_containerBounds.Size());
                }
                else
                {
                    size = _containerBounds.Size();
                }

                if (size.X > _containerBounds.Width)
                {
                    size.X = _containerBounds.Width;
                }

                if (size.Y > _containerBounds.Height)
                {
                    size.Y = _containerBounds.Height;
                }

                // Resolve possible conflict beetween Alignment set to Streth and Size explicitly set
                var containerSize = _containerBounds.Size();

                if (!PrioritizeStrethOverSize)
                {
                    if (HorizontalAlignment == HorizontalAlignment.Stretch && Width != null && Width.Value < containerSize.X)
                    {
                        containerSize.X = Width.Value;
                    }

                    if (VerticalAlignment == VerticalAlignment.Stretch && Height != null && Height.Value < containerSize.Y)
                    {
                        containerSize.Y = Height.Value;
                    }
                }

                // Align
                var controlBounds = LayoutUtils.Align(containerSize, size, HorizontalAlignment, VerticalAlignment);
                controlBounds.Offset(_containerBounds.Location);

                controlBounds.Offset(Left, Top);

                _bounds       = controlBounds;
                _actualBounds = CalculateClientBounds(controlBounds);

                Arrange();
            }
            else
            {
                // Only location
                MoveChildren(new Point(Left - _lastLocationHint.X, Top - _lastLocationHint.Y));
            }

            _lastLocationHint = new Point(Left, Top);
            _layoutState      = LayoutState.Normal;

            LayoutUpdated.Invoke(this);
        }
예제 #12
0
파일: Interaction.cs 프로젝트: Egaros/lib
 private void OnFrameworkElementLayoutUpdated(object sender, EventArgs eventArgs)
 {
     LayoutUpdated?.Invoke(FrameworkElement, EventArgs.Empty);
 }
예제 #13
0
        public void ExecuteLayoutPass()
        {
            const int MaxPasses = 3;

            Dispatcher.UIThread.VerifyAccess();

            if (!_running)
            {
                _running = true;

                Stopwatch?stopwatch = null;

                const LogEventLevel timingLogLevel = LogEventLevel.Information;
                bool captureTiming = Logger.IsEnabled(timingLogLevel, LogArea.Layout);

                if (captureTiming)
                {
                    Logger.TryGet(timingLogLevel, LogArea.Layout)?.Log(
                        this,
                        "Started layout pass. To measure: {Measure} To arrange: {Arrange}",
                        _toMeasure.Count,
                        _toArrange.Count);

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                }

                _toMeasure.BeginLoop(MaxPasses);
                _toArrange.BeginLoop(MaxPasses);

                try
                {
                    for (var pass = 0; pass < MaxPasses; ++pass)
                    {
                        ExecuteMeasurePass();
                        ExecuteArrangePass();

                        if (_toMeasure.Count == 0)
                        {
                            break;
                        }
                    }
                }
                finally
                {
                    _running = false;
                }

                _toMeasure.EndLoop();
                _toArrange.EndLoop();

                if (captureTiming)
                {
                    stopwatch !.Stop();

                    Logger.TryGet(timingLogLevel, LogArea.Layout)?.Log(this, "Layout pass finished in {Time}", stopwatch.Elapsed);
                }
            }

            _queued = false;
            LayoutUpdated?.Invoke(this, EventArgs.Empty);
        }
예제 #14
0
 protected virtual void OnLayoutUpdated()
 {
     LayoutUpdated?.Invoke(this, EventArgs.Empty);
 }
예제 #15
0
 /// <summary>
 /// Called when the framework element layout is updated.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The <see cref="EventArgs"/> instance containing the event data.
 /// </param>
 public void OnLayoutUpdated(object sender, EventArgs e)
 {
     LayoutUpdated.SafeInvoke(this);
 }