Exemple #1
0
        private void CreateShape(IDiagramPresenter diagramPresenter, Template template)
        {
            // create shape
            Shape shape = template.Shape.Clone();

            if (template.Shape.ModelObject != null)
            {
                shape.ModelObject = template.Shape.ModelObject.Clone();
            }

            int x, y, width, height;

            GetStrokeSetBounds(out x, out y, out width, out height);
            shape.Fit(x, y, width, height);

            ICommand cmd = new InsertShapeCommand(diagramPresenter.Diagram, diagramPresenter.ActiveLayers, shape, true, false);

            project.ExecuteCommand(cmd);
        }
		/// <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;

				// create command
				ICommand cmd = new InsertShapeCommand(
					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;
			}
		}
        private void CreateShape(IDiagramPresenter diagramPresenter, Template template)
        {
            // create shape
            Shape shape = template.Shape.Clone();
            if (template.Shape.ModelObject != null)
                shape.ModelObject = template.Shape.ModelObject.Clone();

            int x, y, width, height;
            GetStrokeSetBounds(out x, out y, out width, out height);
            shape.Fit(x, y, width, height);

            ICommand cmd = new InsertShapeCommand(diagramPresenter.Diagram, diagramPresenter.ActiveLayers, shape, true, false);
            project.ExecuteCommand(cmd);
        }
		/// <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 InsertShapeCommand(diagram, activeLayers, shapes, withModelObjects, true);
			Project.ExecuteCommand(cmd);
		}