public void initializeVueModele() { //this.IsOffline = false; this.Canvas = new CustomInkCanvas(); FormConnectorManager = new FormConnectorManager(); SocketManager = new SocketManager(this.IsOffline); PlayerManager = new PlayerManager(); //SocketManager.JoinDrawingSession("MockSessionID"); ChatManager.socket = SocketManager.Socket; //SocketManager.UserName = "******";<<<<<<< HEAD // SocketManager.UserName = this.Username; //editeur.initializeSocketEvents(); //SocketManager.JoinDrawingSession("MockSessionID"); if (!this.IsOffline) { //chatManager = new ChatManager(); //this.Username = "******"; //SocketManager.UserName = this.Username; //this.SessionId = "MockSessionId"; editeur.initializeSocketEvents(); //SocketManager.JoinDrawingSession("MockSessionID"); this.SendLocalCanvas(); } else { this.PlayerManager.AddPlayer(this.SocketManager.UserName); } // On écoute pour des changements sur le modèle. Lorsqu'il y en a, EditeurProprieteModifiee est appelée. editeur.PropertyChanged += new PropertyChangedEventHandler(EditeurProprieteModifiee); // On initialise les attributs de dessin avec les valeurs de départ du modèle. AttributsDessin = new DrawingAttributes(); AttributsDessin.Color = (Color)ColorConverter.ConvertFromString(editeur.CouleurSelectionnee); AjusterPointe(); Traits = editeur.traits; StylusPointCollection pts = new StylusPointCollection(); //editeur.traits.Add(new Stroke(pts)); SelectedStrokes = editeur.selectedStrokes; this.IndexBeingDragged = -1; // Pour chaque commande, on effectue la liaison avec des méthodes du modèle. Empiler = new RelayCommand <object>(editeur.Empiler); //, editeur.PeutEmpiler); Depiler = new RelayCommand <object>(editeur.Depiler); //, editeur.PeutDepiler); //AddForm = new RelayCommand<string>(editeur.AddForm); RotateForm = new RelayCommand <object>(editeur.RotateForm); // Pour les commandes suivantes, il est toujours possible des les activer. // Donc, aucune vérification de type Peut"Action" à faire. ChoisirOutil = new RelayCommand <string>(editeur.ChoisirOutil); Reinitialiser = new RelayCommand <object>(editeur.Reinitialiser); HandleDuplicate = new RelayCommand <object>(editeur.HandleDuplicate); if (!this.IsOffline) { SocketManager.Socket.On("InvitedToConversation", (data) => { var dataFormat = new { username = "", invitedUsername = "", conversationId = "" }; var formatedData = JsonConvert.DeserializeAnonymousType(data.ToString(), dataFormat); if (formatedData.conversationId == ChatManager.RoomID) { return; } string text = formatedData.username + (this.Localization == "fr" ? " vous invite à joindre la discussion " : " invited you to join the chatroom ") + formatedData.conversationId; string captation = "Invitation"; if (MessageBox.Show(text, captation, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { Application.Current.Dispatcher.Invoke(() => { var res = new { username = formatedData.username, invitedUsername = formatedData.invitedUsername, conversationId = formatedData.conversationId, response = true }; SocketManager.Socket.Emit("RespondToConversationInvite", JsonConvert.SerializeObject(res)); if (!ChatManager.RoomsID.Contains(formatedData.conversationId)) { ChatManager.RoomsID.Add(formatedData.conversationId); } ChatManager.RoomID = formatedData.conversationId; ChatManager.JoinChannel(Localization); }); } else { var res = new { username = formatedData.username, invitedUsername = formatedData.invitedUsername, conversationId = formatedData.conversationId, response = false }; SocketManager.Socket.Emit("RespondToConversationInvite", JsonConvert.SerializeObject(res)); } }); SocketManager.Socket.On("InvitedToDrawingSession", (data) => { var dataFormat = new { username = "", invitedUsername = "", imageId = "" }; var formatedData = JsonConvert.DeserializeAnonymousType(data.ToString(), dataFormat); if (formatedData.imageId == SocketManager.SessionID) { return; } string text = formatedData.username + (this.Localization == "fr" ? " vous invite à joindre sa session de dessin" : " invited you to join his drawing session"); string captation = "Invitation"; string shapes = ""; string sh = ""; if (MessageBox.Show(text, captation, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { var res = new { username = formatedData.username, invitedUsername = formatedData.invitedUsername, imageId = formatedData.imageId, response = true }; SocketManager.Socket.Emit("RespondToDrawingInvite", JsonConvert.SerializeObject(res)); SocketManager.UserName = Username; Application.Current.Dispatcher.Invoke(async() => { shapes = await networkManager.LoadShapesAsync(Username, SessionId, formatedData.imageId); sh = await networkManager.LoadImageData(Username, SessionId, formatedData.imageId); editeur.LoadFromServer(shapes, sh); }); SocketManager.JoinDrawingSession(formatedData.imageId); SwitchView = 5; } else { var res = new { username = formatedData.username, invitedUsername = formatedData.invitedUsername, imageId = formatedData.imageId, response = false }; SocketManager.Socket.Emit("RespondToDrawingInvite", JsonConvert.SerializeObject(res)); } }); } }