コード例 #1
0
ファイル: DiagramSetController.cs プロジェクト: stewmc/vixen
		/// <ToBeCompleted></ToBeCompleted>
		public void Paste(Diagram destination, LayerIds activeLayers, int offsetX, int offsetY)
		{
			if (destination == null) throw new ArgumentNullException("destination");
			if (!editBuffer.IsEmpty) {
				++editBuffer.pasteCount;

				// Check if there are connections to restore
				if (editBuffer.connections.Count > 0) {
					// Restore connections of cut shapes at first paste action.
					for (int i = editBuffer.connections.Count - 1; i >= 0; --i) {
						editBuffer.connections[i].ConnectorShape.Connect(
							editBuffer.connections[i].GluePointId,
							editBuffer.connections[i].TargetShape,
							editBuffer.connections[i].TargetPointId);
					}
					// After the paste action, the (then connected) shapes are cloned 
					// with their connections, so we can empty the buffer here.
					editBuffer.connections.Clear();
				}

				// Create command
				ICommand cmd = new CreateShapesCommand(
					destination,
					activeLayers,
					editBuffer.shapes,
					editBuffer.withModelObjects,
					(editBuffer.action == EditAction.Cut),
					offsetX,
					offsetY);
				// Execute InsertCommand and select inserted shapes
				Project.ExecuteCommand(cmd);

				// Clone shapes for another paste operation
				// We have to copy the shapes immediately because shapes (and/or model objects) may 
				// be deleted after they are copied to 'clipboard'.
				editBuffer.shapes = editBuffer.shapes.Clone(editBuffer.withModelObjects);
				if (editBuffer.action == EditAction.Cut) editBuffer.action = EditAction.Copy;
			}
		}
コード例 #2
0
ファイル: DiagramSetController.cs プロジェクト: stewmc/vixen
		/// <ToBeCompleted></ToBeCompleted>
		public void InsertShapes(Diagram diagram, IEnumerable<Shape> shapes, LayerIds activeLayers, bool withModelObjects)
		{
			if (diagram == null) throw new ArgumentNullException("diagram");
			if (shapes == null) throw new ArgumentNullException("shapes");
			ICommand cmd = new CreateShapesCommand(diagram, activeLayers, shapes, withModelObjects, true);
			Project.ExecuteCommand(cmd);
		}