import { ActionDeserializer } from './ActionDeserializer' ; import { MagnetTextManager } from './MagnetTextManager' ; import { ActionMagnetNew } from './ActionMagnetNew' ; import { MagnetMovementRecorder } from './MagnetMovementRecorder' ; import { Wallpaper } from './Wallpaper' ; import { UserListComponent } from './UserListComponent' ; import { ErrorMessage } from './ErrorMessage' ; import { BackgroundTexture } from './BackgroundTexture' ; import { Share } from './share' ; import { LoadSave } from './LoadSave' ; import { Layout } from './Layout' ; import { BackgroundDocuments } from './BackgroundDocuments' ; import { MagnetManager } from './magnetManager' ; import { BoardManager } from './boardManager' ; import { UserManager } from './UserManager' ; import { Discussion } from './Discussion' ; import { Menu } from './Menu' ; import { Drawing } from './Drawing' ; import { ToolArc } from './ToolArc' ; /**
 * this class contains the events that are shared with other users connected to the same tableaunoir
 * */ export class ShareEvent { /** mouse events */ static mousedown ( userId , evt ) { UserManager . users [ userId ] . mousedown ( evt ) ; } static mousemove ( userId , evt ) { if ( UserManager . users [ userId ] == undefined ) console . log ( "why is " + userId + " not declared?" ) ; UserManager . users [ userId ] . mousemove ( evt ) ; } static mouseup ( userId , evt ) { UserManager . users [ userId ] . mouseup ( evt ) ; } /**tools */ static setCurrentColor ( userId , color ) { UserManager . users [ userId ] . setCurrentColor ( color ) ; } static switchErase ( userId ) { UserManager . users [ userId ] . switchErase ( ) ; } static switchChalk ( userId ) { UserManager . users [ userId ] . switchChalk ( ) ; } static switchLine ( userId ) { UserManager . users [ userId ] . switchLine ( ) ; } static switchRectangle ( userId ) { UserManager . users [ userId ] . switchRectangle ( ) ; } static switchEllipseByBorder ( userId ) { UserManager . users [ userId ] . switchEllipseByBorder ( ) ; } static switchEllipseByCenter ( userId ) { UserManager . users [ userId ] . switchEllipseByCenter ( ) ; } static switchArc ( userId ) { UserManager . users [ userId ] . switchArc ( ) ; } static toolArcSetAttributes ( userId , center , radiusHandlePosition ) { console . log ( userId ) ; const tool = UserManager . users [ userId ] . tool ; if ( ! ( tool instanceof ToolArc ) ) ErrorMessage . show ( "the tool should be ToolArc" ) ; ( < ToolArc > tool ) . setAttributes ( center , radiusHandlePosition ) ; } /**users */ static setCanWriteValueByDefault ( bool ) { Share . canWriteValueByDefault = bool ; } static setUserCanWrite ( userId , bool ) { UserManager . setUserCanWrite ( userId , bool ) ; } static setUserName ( userid , name ) { UserManager . users [ userid ] . name = name ; UserListComponent . updateGUIUser ( userid ) ; } /** board */ /**
     * reset the board: it means
     * - we clear the board
     * - we clear the timeline
     * - we clear the cancel stack
     */ static boardReset ( ) { BoardManager . _reset ( ) ; Menu . hide ( ) ; } /**
     * clear the board
     * - we clear the board
     * - we add the action "clear the board" in the timeline
     */ static boardClear ( ) { BoardManager . newSlideAndClear ( UserManager . me . userID ) ; } param atLeastWidth description static setWidthAtLeast ( atLeastWidth ) { BoardManager . setWidthAtLeast ( atLeastWidth ) ; } param userid param x description static divideScreen ( userid , x ) { Drawing . divideScreen ( userid , x ) ; } /**questions */ static questionAdd ( userID , idquestion , question ) { Discussion . addQuestion ( userID , idquestion , question ) ; } param userid description static setRoot ( userid ) { Share . setRoot ( userid ) ; } static questionRemove ( questionID ) { Discussion . removeQuestion ( questionID ) ; } /** magnets */ static magnetize ( userID , cut , removeContour ) { UserManager . users [ userID ] . lastDelineation . magnetize ( userID , cut , removeContour ) ; } static clearPolygon ( points ) { Drawing . clearPolygon ( points ) ; } static printMagnet ( magnetID ) { MagnetManager . printMagnet ( document . getElementById ( magnetID ) ) ; } static magnetChange ( userid , idMagnet , outerHTML ) { const magnet = document . getElementById ( idMagnet ) ; if ( magnet . outerHTML != outerHTML ) { magnet . outerHTML = outerHTML ; MagnetManager . installMagnets ( ) ; } if ( MagnetTextManager . isTextMagnet ( magnet ) ) { const action = BoardManager . getLastAction ( ) ; if ( action instanceof ActionMagnetNew ) action . setMagnet ( magnet ) ; else BoardManager . addAction ( new ActionMagnetNew ( userid , magnet ) ) ; } else BoardManager . addAction ( new ActionMagnetNew ( userid , magnet ) ) ; } static magnetMoveStart ( idMagnet ) { MagnetMovementRecorder . start ( idMagnet ) ; } static magnetMove ( idMagnet , x , y ) { const ix = parseInt ( x ) ; const iy = parseInt ( y ) ; MagnetMovementRecorder . move ( idMagnet , ix , iy ) ; } static magnetMoveStop ( idMagnet ) { MagnetMovementRecorder . stop ( idMagnet ) ; } static magnetsClear ( ) { MagnetManager . clearMagnet ( ) ; } static magnetRemove ( idMagnet ) { MagnetManager . magnetRemove ( idMagnet ) ; } static timelineAddAction ( t , actionSerialized ) { BoardManager . timeline . insertAction ( ActionDeserializer . deserialize ( JSON . parse ( actionSerialized ) ) , t ) ; } static timelineRemoveAction ( t ) { BoardManager . timeline . deleteAction ( t ) ; } /**backgrounds */ static backgroundClear ( ) { Wallpaper . clear ( ) ; } static backgroundMusicScore ( ) { Wallpaper . musicScore ( ) ; } static backgroundGrid ( ) { Wallpaper . grid ( ) ; } static backgroundSeyes ( ) { Wallpaper . seyes ( ) ; } /**documents */ static documentsRemoveAll ( ) { BackgroundDocuments . getDocumentPanel ( ) . innerHTML = "" ; } static insertDocumentImage ( dataURL , x ) { const img = document . createElement ( "img" ) ; img . src = dataURL ; img . style . position = "absolute" ; img . style . left = x + "px" ; img . style . top = "0px" ; img . style . height = Layout . STANDARDHEIGHT + "px" ; BackgroundDocuments . getDocumentPanel ( ) . appendChild ( img ) ; } param data descripttion static loadBoard ( data ) { LoadSave . loadJSON ( JSON . parse ( data ) ) ; } static setBackgroundColor ( color ) { BackgroundTexture . switchTo ( color ) ; } }