Exemple #1
0
        public void DrawElement(string elementType, int containedDrawingId)
        {
            int?elementId = null;

            DrawingDTO drawing = drawingRepository.ReadDrawing(containedDrawingId);

            DrawingObjectDTO newElement = new DrawingObjectDTO();

            if (elementType == "bathElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Bath;
            }

            if (elementType == "lavatoryElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Lavatory;
            }

            if (elementType == "showerElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Shower;
            }

            if (elementType == "doorElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Door;
            }

            if (elementType == "wallElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Wall;
            }

            if (elementType == "windowElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Window;
            }

            if (elementType == "refrigeratorElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Refrigerator;
            }

            if (elementType == "sinkElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Sink;
            }

            if (elementType == "stoveElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Stove;
            }

            if (elementType == "sofaElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Sofa;
            }


            if (elementType == "tableElement")
            {
                newElement.DrawingObjectType = Domain.Enums.DrawingObjectTypeEnum.Table;
            }

            newElement.DrawingID = drawing.DrawingID;

            int newElementId = 0;

            newElementId = drawingObjectRepository.CreateDrawingObject(newElement);

            newElement.DrawingObjectID = newElementId;

            drawing.DrawingObjects.Add(newElement);

            elementId = newElement.DrawingObjectID;

            drawingRepository.UpdateDrawing(drawing);

            Clients.Group(containedDrawingId.ToString()).drawElementCallback(elementType, elementId);

            Clients.Group(containedDrawingId.ToString()).createNewMementoCallback(newElement.DrawingObjectType, newElement.DrawingObjectID, newElement.PositionTop, newElement.PositionLeft);
        }