Exemple #1
0
        // ========================================
        // method
        // ========================================
        public override void Execute()
        {
            var containerCtrl = _target.Controller as IContainerController;

            var clonings = new List <IEditor>();
            var copyReq  = new CopyRequest(_cloningEditors);

            foreach (var cloning in _cloningEditors)
            {
                if (cloning.CanUnderstand(copyReq))
                {
                    clonings.Add(cloning);
                }
            }

            var data = EditorFactory.CreateDataObject(clonings);

            _clonedEditors = EditorFactory.RestoreDataObject(data, _target.Site.ControllerFactory);

            _command = new AddEditorsCommand(_target, _clonedEditors, _moveDelta);
            _command.Execute();
        }
Exemple #2
0
        // ========================================
        // method
        // ========================================
        public override void Execute()
        {
            var container = _target.Controller as IContainerController;

            if (container == null)
            {
                return;
            }

            var data = Clipboard.GetDataObject();

            if (EditorFactory.CanRestoreDataObject(data))
            {
                /// Editorを復元
                _pastedEditors = EditorFactory.RestoreDataObject(data, _target.Site.ControllerFactory);

                /// 一番左上の位置計算
                var left = int.MaxValue;
                var top  = int.MaxValue;
                foreach (var editor in _pastedEditors)
                {
                    if (container.CanContainChild(editor.Controller.ModelDescriptor))
                    {
                        left = left < editor.Figure.Left? left: editor.Figure.Left;
                        top  = top < editor.Figure.Top? top: editor.Figure.Top;
                    }
                }

                /// 各editorの移動量
                var moveDelta = new Size(_location.X - left, _location.Y - top);

                /// _targetに追加
                foreach (var editor in _pastedEditors)
                {
                    if (container.CanContainChild(editor.Controller.ModelDescriptor))
                    {
                        editor.Figure.Location += moveDelta;
                        _target.AddChildEditor(editor);
                        container.InsertChild(editor.Model, container.ChildCount);
                        editor.Enable();
                    }
                }

                /// Route()だけやり直し
                foreach (var editor in _pastedEditors)
                {
                    if (editor.Figure is LineEdge)
                    {
                        var edge = editor.Figure as LineEdge;
                        edge.Route();
                    }
                }
            }
            else if (_format != null && _creator != null)
            {
                /// 一般的なフォーマットから復元
                var format = DataFormats.GetFormat(_format);
                if (data.GetDataPresent(format.Name))
                {
                    _pastedEditors = _creator(_target, _location, _description);
                }
            }
        }