public void Reconnecter() { if (this.joystickManager != null) { this.joystickManager.BoutonEvent -= this.JoystickManager_BoutonEvent; this.joystickManager.JoyStickError -= this.JoystickManager_JoyStickError; this.joystickManager = null; } this.joystickManager = new JoyStickManager(); this.joystickManager.BoutonEvent += this.JoystickManager_BoutonEvent; this.joystickManager.JoyStickError += this.JoystickManager_JoyStickError; this.TexteEtat = ChronoStick_Input.Properties.Resources.EtatMsgCon; // "Connecté"; this.ConnectVisible = Visibility.Collapsed; this.CouleurEtat = new SolidColorBrush(Colors.Green); this.joystickManager.CaptureJoyStick(); }
private ChronostickInputViewModel() { System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; this.TitreFenetre = string.Format("{1} {0}", version, ChronoStick_Input.Properties.Resources.NomLog); this.joystickManager = new JoyStickManager(); this.joystickManager.BoutonEvent += JoystickManager_BoutonEvent; this.joystickManager.JoyStickError += JoystickManager_JoyStickError; this.TexteEtat = ChronoStick_Input.Properties.Resources.EtatMsgCon; // "Connecté"; this.CouleurEtat = new SolidColorBrush(Colors.Green); this.ConnectVisible = Visibility.Collapsed; this.joystickManager.CaptureJoyStick(); string nbSecPing = System.Configuration.ConfigurationManager.AppSettings["NbSecPing"]; int delais = this.delais; int.TryParse(nbSecPing, out delais); string nbPatineur = System.Configuration.ConfigurationManager.AppSettings["NbPatineur"]; int nbPatineurDep = this.nbPatineurDep; int.TryParse(nbPatineur, out nbPatineurDep); this.NbPatineurDep = nbPatineurDep; string noPortMessages = System.Configuration.ConfigurationManager.AppSettings["NoPortMessages"]; int noPort = this.noPort; int.TryParse(noPortMessages, out noPort); this.NoPort = noPort; string hostsMessages = System.Configuration.ConfigurationManager.AppSettings["HostMessages"]; this.HostMessages = hostsMessages; string noPortConfig = System.Configuration.ConfigurationManager.AppSettings["NoPortConfig"]; noPort = this.noPortConfig; int.TryParse(noPortConfig, out noPort); this.NoPortConfig = noPort; string nbSecTourMinCfg = System.Configuration.ConfigurationManager.AppSettings["NbSecTourMin"]; noPort = this.nbSecTourMin; int.TryParse(nbSecTourMinCfg, out noPort); this.NbSecTourMin = noPort; string nbSecDepMinCfg = System.Configuration.ConfigurationManager.AppSettings["NbSecDepMin"]; noPort = this.nbSecDepMin; int.TryParse(nbSecDepMinCfg, out noPort); this.NbSecDepMin = noPort; if (delais > 0) { this.intervale = this.delais * 1000; aTimer = new Timer(); aTimer.Interval = this.intervale; aTimer.Elapsed += aTimer_Elapsed; aTimer.AutoReset = true; aTimer.Enabled = true; } bTimer = new Timer(); bTimer.Interval = 3000; bTimer.Elapsed += BTimer_Elapsed; bTimer.AutoReset = false; bTimer.Enabled = false; //this.journal.CollectionChanged += journal_CollectionChanged; // Initialiser la réception de configuraiton UdpClient udpClient = new UdpClient(); udpClient.Client.Bind(new IPEndPoint(IPAddress.Any, this.NoPortConfig)); var from = new IPEndPoint(0, 0); Task.Run(() => { while (true) { var recvBuffer = udpClient.Receive(ref from); this.TraiterMessage(recvBuffer); } }); }