コード例 #1
0
        private void VisualizeOtherAffectedObjects()
        {
            var IncludeOriginatedSubtree = (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
            var IncludeTargetedSubtree   = (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl));
            var OtherAffectedObjects     = OwnerManager.OwnerView.GetCurrentManipulableObjects(IncludeOriginatedSubtree, IncludeTargetedSubtree, true)
                                           .Select(obj => obj.Item1).Distinct()         // Notice that duplicates are informed, so they must be excluded
                                           .Except(ManipulatedObject.IntoEnumerable()); // Exclude current object to avoid visual interference in resizing

            foreach (var AffectedObject in OtherAffectedObjects)
            {
                var DeltaX      = 0.0;
                var DeltaY      = 0.0;
                var DeltaWidth  = 0.0;
                var DeltaHeight = 0.0;

                // Do not consider other intention, particularly resizing (due to its implicit move)
                if (IntendedAction == ESymbolManipulationAction.Move)
                {
                    DeltaX = ManipulatingHeadingRectangle.X - ManipulatedSymbol.BaseArea.X;
                    DeltaY = ManipulatingHeadingRectangle.Y - ManipulatedSymbol.BaseArea.Y;
                }

                // Only the manipulated symbol show a change in size
                // (because multi-resize is postponed due to difficulty)
                if (ManipulatedSymbol == AffectedObject)
                {
                    DeltaWidth  = ManipulatingHeadingRectangle.Width - ManipulatedSymbol.BaseArea.Width;
                    DeltaHeight = ManipulatingHeadingRectangle.Height - ManipulatedSymbol.BaseArea.Height;
                }

                Rect SelectionZone = AffectedObject is VisualSymbol symbol && symbol.IsHidden
                                 ? new Rect(AffectedObject.BaseCenter.X - 4, AffectedObject.BaseCenter.Y - 4,
                                            8, 8)
                                 : new Rect(AffectedObject.BaseLeft + DeltaX,
                                            AffectedObject.BaseTop + DeltaY,
                                            (AffectedObject.BaseWidth + DeltaWidth).EnforceMinimum(4),
                                            (AffectedObject.TotalArea.Height + DeltaHeight).EnforceMinimum(4));
                var SelectionGeom = (SelectionZone.Width > 8 && SelectionZone.Height > 8
                                 ? new CombinedGeometry(GeometryCombineMode.Exclude,
                                                        new RectangleGeometry(SelectionZone),
                                                        new RectangleGeometry(new Rect(SelectionZone.X + 4, SelectionZone.Y + 4,
                                                                                       (SelectionZone.Width - 8).EnforceMinimum(4),
                                                                                       (SelectionZone.Height - 8).EnforceMinimum(4))))
                                 : (new RectangleGeometry(SelectionZone)) as Geometry);
                var SelectionDrawing = new GeometryDrawing(FrmStroke, FrmPencil, SelectionGeom);
                var SelectionVisual  = SelectionDrawing.RenderToDrawingVisual();

                SelectionVisual.Opacity = (AffectedObject.IsIn(OwnerManager.OwnerView.SelectedObjects)
                                       ? FrmOpacity : FrmOpacity / 2.0);
                Indicators.Add(SelectionVisual);
            }
        }