public override void Undo() { var model = _target.Model; var parentCtrl = _oldParent.Controller as IContainerController; _target.Controller.RestoreModel(model); _oldParent.InsertChildEditor(_target, _oldEditorIndex); parentCtrl.InsertChild(model, _oldModelIndex); _target.Enable(); _disconnCommand.Undo(); }
// ======================================== // method // ======================================== public override void Execute() { var model = _modelFactory.CreateModel(); _createdEditor = _target.AddChild(model); _createdEditor.Figure.Bounds = _bounds; _createdEditor.Enable(); var select = new SelectRequest(); select.DeselectOthers = true; select.Value = SelectKind.True; _createdEditor.PerformRequest(select); }
public override void Redo() { var containerCtrl = _target.Controller as IContainerController; _createdEditor.Controller.RestoreModel(_createdEditor.Model); _createdEditor.Figure.Bounds = _bounds; _target.AddChildEditor(_createdEditor); containerCtrl.InsertChild(_createdEditor.Model, containerCtrl.ChildCount); _createdEditor.Enable(); var select = new SelectRequest(); select.DeselectOthers = true; select.Value = SelectKind.True; _createdEditor.PerformRequest(select); }
// ======================================== // method // ======================================== public override void Execute() { var model = _modelFactory.CreateModel(); _createdEditor = _target.AddChild(model); var freehand = _createdEditor.Figure as FreehandFigure; freehand.SetPoints(_points); freehand.BorderWidth = _width; freehand.Foreground = _color; _createdEditor.Enable(); //var select = new SelectRequest(); //select.DeselectOthers = true; //select.Value = SelectKind.True; //_createdEditor.PerformRequest(select); }
public override void Redo() { var containerCtrl = _target.Controller as IContainerController; _createdEditor.Controller.RestoreModel(_createdEditor.Model); var freehand = _createdEditor.Figure as FreehandFigure; freehand.SetPoints(_points); freehand.BorderWidth = _width; freehand.Foreground = _color; _target.AddChildEditor(_createdEditor); containerCtrl.InsertChild(_createdEditor.Model, containerCtrl.ChildCount); _createdEditor.Enable(); var select = new SelectRequest(); select.DeselectOthers = true; select.Value = SelectKind.True; _createdEditor.PerformRequest(select); }
private void SetUp(IEditor createdEditor, object model) { _newStyledText = null; _oldStyledText = null; /// 親controllerへの通知 var containerCtrl = _target.Controller as IContainerController; Contract.Requires( containerCtrl != null && containerCtrl.CanContainChild(_modelFactory.ModelDescriptor) ); var createdConnectionCtrl = createdEditor.Controller as IConnectionController; var createdEdge = createdEditor.Figure as IEdge; if (createdEditor == null || createdConnectionCtrl == null || createdEdge == null) { /// rollback containerCtrl.RemoveChild(model); _target.RemoveChildEditor(createdEditor); throw new ArgumentException(); } var srcConnectableCtrl = _edgeSourceEditor == null? null: _edgeSourceEditor.Controller as IConnectableController; var srcConnectableFig = _edgeSourceEditor == null? null: _edgeSourceEditor.Figure as IConnectable; var tgtConnectableCtrl = _edgeTargetEditor == null? null: _edgeTargetEditor.Controller as IConnectableController; var tgtConnectableFig = _edgeTargetEditor == null? null: _edgeTargetEditor.Figure as IConnectable; /// パラメタの妥当性検査 var isValidSrcConnect = _edgeSourceEditor != null && srcConnectableFig != null && createdConnectionCtrl.CanConnectSource(_edgeSourceEditor.Model); var isValidSrcDisconnect = (_edgeSourceEditor == null || srcConnectableCtrl == null || !createdConnectionCtrl.CanConnectSource(_edgeSourceEditor.Model) ) && createdConnectionCtrl.CanDisconnectSource; var isValidSrc = isValidSrcConnect || isValidSrcDisconnect; var isValidTgtConnect = _edgeTargetEditor != null && tgtConnectableCtrl != null && createdConnectionCtrl.CanConnectTarget(_edgeTargetEditor.Model); var isValidTgtDisconnect = (_edgeTargetEditor == null || tgtConnectableCtrl == null || !createdConnectionCtrl.CanConnectTarget(_edgeTargetEditor.Model) ) && createdConnectionCtrl.CanDisconnectTarget; var isValidTgt = isValidTgtConnect || isValidTgtDisconnect; if (!isValidSrc || !isValidTgt) { /// rollback containerCtrl.RemoveChild(model); _target.RemoveChildEditor(createdEditor); throw new ArgumentException(); } /// controllerの通知 if (isValidSrcConnect) { createdConnectionCtrl.ConnectSource(_edgeSourceEditor.Model); srcConnectableCtrl.ConnectOutgoing(model); } if (isValidTgtConnect) { createdConnectionCtrl.ConnectTarget(_edgeTargetEditor.Model); tgtConnectableCtrl.ConnectIncoming(model); var node = _edgeTargetEditor.Figure as INode; var mtext = _edgeTargetEditor.Model as MemoText; _oldStyledText = mtext.StyledText.CloneDeeply() as StyledText.Core.StyledText; _newStyledText = mtext.StyledText; var charIndex = node.GetCharIndexAt(_edgePoints.Last()); var inline = node.StyledText.GetInlineAt(charIndex); var anc = default(Anchor); if (inline.IsAnchorCharacter) { anc = inline as Anchor; } else { /// nodeのcharIndex位置にAnchor追加 anc = new Anchor(); var insertAnchorCommand = new InsertInlineCommand(_newStyledText, charIndex, anc); insertAnchorCommand.Execute(); } var edge = createdEdge; _newTargetAnchorId = anc.Id; _oldTargetAnchorId = edge.TargetConnectionOption as string; edge.TargetConnectionOption = _newTargetAnchorId; var connectCommand = new ConnectCommand(createdEditor, createdEdge.TargetAnchor, _edgeTargetEditor, _edgePoints.Last()); connectCommand.Execute(); } /// figureの編集 createdEdge.SetEdgePoints(_edgePoints); createdEdge.Route(); if (isValidSrcConnect) { createdEdge.Source = srcConnectableFig; } if (isValidTgtConnect) { createdEdge.Target = tgtConnectableFig; } createdEditor.Enable(); }
private void SetUp(IEditor createdEditor, object model) { /// 親controllerへの通知 var containerCtrl = _target.Controller as IContainerController; Contract.Requires( containerCtrl != null && containerCtrl.CanContainChild(_modelFactory.ModelDescriptor) ); var createdConnectionCtrl = createdEditor.Controller as IConnectionController; var createdEdge = createdEditor.Figure as IEdge; if (createdEditor == null || createdConnectionCtrl == null || createdEdge == null) { /// rollback containerCtrl.RemoveChild(model); _target.RemoveChildEditor(createdEditor); throw new ArgumentException(); } var srcConnectableCtrl = _edgeSourceEditor == null? null: _edgeSourceEditor.Controller as IConnectableController; var srcConnectableFig = _edgeSourceEditor == null? null: _edgeSourceEditor.Figure as IConnectable; var tgtConnectableCtrl = _edgeTargetEditor == null? null: _edgeTargetEditor.Controller as IConnectableController; var tgtConnectableFig = _edgeTargetEditor == null? null: _edgeTargetEditor.Figure as IConnectable; /// パラメタの妥当性検査 var isValidSrcConnect = _edgeSourceEditor != null && srcConnectableFig != null && createdConnectionCtrl.CanConnectSource(_edgeSourceEditor.Model); var isValidSrcDisconnect = (_edgeSourceEditor == null || srcConnectableCtrl == null || !createdConnectionCtrl.CanConnectSource(_edgeSourceEditor.Model) ) && createdConnectionCtrl.CanDisconnectSource; var isValidSrc = isValidSrcConnect || isValidSrcDisconnect; var isValidTgtConnect = _edgeTargetEditor != null && tgtConnectableCtrl != null && createdConnectionCtrl.CanConnectTarget(_edgeTargetEditor.Model); var isValidTgtDisconnect = (_edgeTargetEditor == null || tgtConnectableCtrl == null || !createdConnectionCtrl.CanConnectTarget(_edgeTargetEditor.Model) ) && createdConnectionCtrl.CanDisconnectTarget; var isValidTgt = isValidTgtConnect || isValidTgtDisconnect; if (!isValidSrc || !isValidTgt) { /// rollback containerCtrl.RemoveChild(model); _target.RemoveChildEditor(createdEditor); throw new ArgumentException(); } /// controllerの通知 if (isValidSrcConnect) { createdConnectionCtrl.ConnectSource(_edgeSourceEditor.Model); srcConnectableCtrl.ConnectOutgoing(model); } if (isValidTgtConnect) { createdConnectionCtrl.ConnectTarget(_edgeTargetEditor.Model); tgtConnectableCtrl.ConnectIncoming(model); } /// figureの編集 createdEdge.SetEdgePoints(_edgePoints); createdEdge.Route(); if (isValidSrcConnect) { createdEdge.Source = srcConnectableFig; } if (isValidTgtConnect) { createdEdge.Target = tgtConnectableFig; } createdEditor.Enable(); }