public void OnOwnerSelectionChanged()
            {
                if (StyledText == null)
                {
                    return;
                }

                /// OnOwnerCaretMoved()のタイミングだけでは
                /// ・範囲選択なしの状態から
                ///   カーソルが行頭ちょうどでSelection.Range.Endも行頭ちょうどになったときに
                ///   カーソル行がInvalidatePaint()されない
                /// ・カーソルが行頭ちょうどでSelection.Range.Endも行頭ちょうどを範囲選択している状態から
                ///   カーソルを右に移動したときにカーソル行がInvalidatePaint()されない
                /// のでこのタイミングでもInvalidatePaint()する

                if (!InUpdatingStyledText)
                {
                    /// CutRegion()のBeginUpdateStyledText()中に呼ばれると
                    /// GetVisualLineBounds()の呼び出しでキャッシュがおかしくなる
                    using (DirtManager.BeginDirty()) {
                        var newVisLineBounds = GetVisualLineBounds(_owner.Referer.CaretIndex);
                        var r = newVisLineBounds;
                        r = new Rectangle(Left, r.Top, Width, r.Height);
                        InvalidatePaint(r);
                    }
                }
            }
Beispiel #2
0
        // ------------------------------
        // private
        // ------------------------------
        private void HandleTableDataRowAndColumnChanged(object sender, EventArgs e)
        {
            if (_isInBoundsChange)
            {
                return;
            }
            if (_suppressInvalidation)
            {
                return;
            }
            using (DirtManager.BeginDirty()) {
                if (_tableData.Size != Size)
                {
                    Size = _tableData.Size;
                }

                if (_tableData.MinSize != MinSize)
                {
                    MinSize = _tableData.MinSize;
                }

                InvalidateLayout();
                InvalidatePaint();
            }
        }
Beispiel #3
0
 public virtual void Route()
 {
     if (_router != null && IsValidEdge)
     {
         using (DirtManager.BeginDirty()) {
             _router.Route(this);
         }
     }
 }
            public void OnOwnerCaretMoved(CaretMovedEventArgs e)
            {
                if (StyledText == null)
                {
                    return;
                }

                /// 現在行色付けのためのInvalidatePaint()処理
                using (DirtManager.BeginDirty()) {
                    var len = _owner.Referer.Target.Length;
                    if (e.OldIndex < len)
                    {
                        if (e.NewIndex < len)
                        {
                            var oldVisLineBounds = GetVisualLineBounds(e.OldIndex);
                            var newVisLineBounds = GetVisualLineBounds(e.NewIndex);
                            if (newVisLineBounds != oldVisLineBounds)
                            {
                                var r = oldVisLineBounds;
                                r = new Rectangle(Left, r.Top, Width, r.Height);
                                InvalidatePaint(r);
                                r = newVisLineBounds;
                                r = new Rectangle(Left, r.Top, Width, r.Height);
                                InvalidatePaint(r);
                            }
                        }
                        else
                        {
                            Logger.Warn(
                                "Illegal caret move: StyledTextLength=" + len +
                                ",NewIndex=" + e.NewIndex + ",OldIndex=" + e.OldIndex
                                );
                            InvalidatePaint();
                        }
                    }
                    else
                    {
                        if (e.NewIndex < len)
                        {
                            var newVisLineBounds = GetVisualLineBounds(e.NewIndex);
                            var r = new Rectangle(Left, newVisLineBounds.Top, Width, Bottom);
                            InvalidatePaint(r);
                        }
                        else
                        {
                            Logger.Warn(
                                "Illegal caret move: StyledTextLength=" + len +
                                ",NewIndex=" + e.NewIndex + ",OldIndex=" + e.OldIndex
                                );
                            InvalidatePaint();
                        }
                    }
                }
            }
Beispiel #5
0
 protected virtual void OnNodeMaxSizeChanged()
 {
     if (_router != null && IsValidEdge)
     {
         if (_behaviorOptions.RouteOnNodeMaxSizeChanged)
         {
             using (DirtManager.BeginDirty()) {
                 _router.Route(this);
             }
         }
     }
 }
Beispiel #6
0
 // --- event ---
 protected virtual void OnConnectableBoundsChanged(BoundsChangedEventArgs e)
 {
     if (_router != null && IsValidEdge)
     {
         if (e.MovingFigures == null || !e.MovingFigures.Contains(this))
         {
             using (DirtManager.BeginDirty()) {
                 _router.Route(this);
             }
         }
     }
 }
Beispiel #7
0
 public void UpdateFocusLayer()
 {
     using (DirtManager.BeginDirty()) {
         FocusLayer.Children.Clear();
         if (
             FocusManager.FocusedEditor != null &&
             FocusManager.FocusedEditor.Focus != null &&
             FocusManager.FocusedEditor.Focus.Figure != null
             )
         {
             FocusLayer.Children.Add(FocusManager.FocusedEditor.Focus.Figure);
         }
     }
 }
Beispiel #8
0
        // ========================================
        // method
        // ========================================
        public void UpdateHandleLayer()
        {
            if (_suppressUpdateHandleLayer)
            {
                return;
            }

            using (DirtManager.BeginDirty()) {
                ShowOnPointHandleLayer.Children.Clear();
                HandleLayer.Children.Clear();

                _owner.RootEditor.Accept(_updateHandleLayerVisitor);
            }
        }
Beispiel #9
0
        // === AbstractConnection ==========
        protected override void OnConnectableChanged(ConnectableChangedEventArgs e)
        {
            base.OnConnectableChanged(e);

            if (e.OldValue != null)
            {
                e.OldValue.BoundsChanged -= HandleConnectableBoundsChanged;

                var oldNode = e.OldValue as INode;
                if (oldNode != null)
                {
                    oldNode.MaxSizeChanged -= HandleNodeMaxSizeChanged;
                }
            }
            if (e.NewValue != null)
            {
                e.NewValue.BoundsChanged += HandleConnectableBoundsChanged;

                var newNode = e.NewValue as INode;
                if (newNode != null)
                {
                    newNode.MaxSizeChanged += HandleNodeMaxSizeChanged;
                }
            }

            if (
                _router == null &&
                e.NewValue != null &&
                (
                    (e.Kind == ConnectionAnchorKind.Source && e.NewValue == Target) ||
                    (e.Kind == ConnectionAnchorKind.Target && e.NewValue == Source)
                )
                )
            {
                SetEdgePoints(EdgeUtil.GetLoopPoints(Source.Bounds));
            }

            if (_router != null && IsValidEdge)
            {
                using (DirtManager.BeginDirty()) {
                    _router.Route(this);
                }
            }
        }
Beispiel #10
0
        protected virtual void OnChildrenChanged(DetailedPropertyChangedEventArgs e)
        {
            using (DirtManager.BeginDirty()) {
                switch (e.Kind)
                {
                case PropertyChangeKind.Add: {
                    var child = e.NewValue as IFigure;
                    child.DescendantChanged += HandleChildrenDescendantChanged;
                    child.InvalidatePaint();
                    child.InvalidateLayout();
                    break;
                }

                case PropertyChangeKind.Remove: {
                    var child = e.OldValue as IFigure;
                    if (_layoutConstraints != null && _layoutConstraints.ContainsKey(child))
                    {
                        _layoutConstraints.Remove(child);
                    }
                    child.DescendantChanged -= HandleChildrenDescendantChanged;
                    InvalidatePaint();
                    break;
                }

                case PropertyChangeKind.Clear: {
                    var children = e.OldValue as IFigure[];
                    if (_layoutConstraints != null)
                    {
                        _layoutConstraints.Clear();
                    }
                    foreach (var child in children)
                    {
                        child.DescendantChanged -= HandleChildrenDescendantChanged;
                    }
                    InvalidatePaint();
                    break;
                }

                case PropertyChangeKind.Set: {
                    var oldChild = e.OldValue as IFigure;
                    var newChild = e.NewValue as IFigure;
                    if (_layoutConstraints != null && _layoutConstraints.ContainsKey(oldChild))
                    {
                        _layoutConstraints.Remove(oldChild);
                    }
                    oldChild.DescendantChanged -= HandleChildrenDescendantChanged;
                    newChild.DescendantChanged += HandleChildrenDescendantChanged;
                    oldChild.InvalidatePaint();
                    newChild.InvalidatePaint();
                    newChild.InvalidateLayout();
                    break;
                }

                default: {
                    throw new ArgumentException("kind");
                }
                }

                InvalidateLayout();

                var handler = ChildrenChanged;
                if (handler != null)
                {
                    handler(this, e);
                }

                OnDescendantChanged(e);
            }
        }