Exemplo n.º 1
0
 public override void SelectionChanged()
 {
     ((ScaleControl)Control).ResetValue();
     if (MainTool.GetSelectedPoints().Any())
     {
         ResetOrigin(null);
     }
 }
Exemplo n.º 2
0
        public override void DragMove(Coordinate distance)
        {
            _state = VMState.Moving;
            // Move each selected point by the delta value
            foreach (var p in MainTool.GetSelectedPoints())
            {
                p.Move(distance);
            }

            //MainTool.SetDirty(false, false);
        }
Exemplo n.º 3
0
        private void MovePoints(decimal value)
        {
            var o = _origin.Coordinate;

            // Move each selected point by the computed offset from the origin
            foreach (var p in MainTool.GetSelectedPoints())
            {
                var orig = _originals[p];
                var diff = orig - o;
                var move = o + diff * value / 100;
                p.Move(move - p.Coordinate);
            }
            MainTool.SetDirty(false, true);
        }
Exemplo n.º 4
0
        private void MovePoints(decimal value, bool relative)
        {
            var o = _origin.Coordinate;

            // Move each selected point by the computed offset from the origin
            foreach (var p in MainTool.GetSelectedPoints())
            {
                var orig      = _originals[p];
                var diff      = orig - o;
                var direction = diff.Normalise();
                var move      = relative ? o + diff * value / 100 : orig + direction * value;
                p.Move(move - p.Coordinate);
            }
            MainTool.SetDirty(false, true);
        }
Exemplo n.º 5
0
        public override void KeyDown(ViewportBase viewport, ViewportEvent e)
        {
            var nudge = GetNudgeValue(e.KeyCode);
            var vp    = viewport as Viewport2D;
            var sel   = MainTool.GetSelectedPoints();

            if (nudge != null && vp != null && _state == VMState.None && sel.Any())
            {
                var translate = vp.Expand(nudge);
                foreach (var p in sel)
                {
                    p.Move(translate);
                }
                CheckMergedVertices();
            }
        }
Exemplo n.º 6
0
        private void ResetOrigin(object sender)
        {
            var points = MainTool.GetSelectedPoints().Select(x => x.Coordinate).ToList();

            if (!points.Any())
            {
                points = MainTool.Points.Where(x => !x.IsMidPoint).Select(x => x.Coordinate).ToList();
            }
            if (!points.Any())
            {
                _origin.Coordinate = Coordinate.Zero;
            }
            else
            {
                _origin.Coordinate = points.Aggregate(Coordinate.Zero, (a, b) => a + b) / points.Count;
            }
        }