private void ScanForServer() { //Mouse.OverrideCursor = Cursors.Wait; try { IsScanForServerEnabled = false; IsProgressBarVisible = true; List <string> servers = WCFProxy.DiscoverHosts(); ExecuteOnUIThread.Invoke(() => { Servers.Clear(); if (servers == null || !servers.Any()) { Servers.Add("No server found"); } else { foreach (string s in servers) { Servers.Add(s); } } }); } catch { ExecuteOnUIThread.Invoke(() => Servers.Add("Error while scanning")); } finally { IsProgressBarVisible = false; IsScanForServerEnabled = true; //Mouse.OverrideCursor = null; } }
private void OnGameStarted() { //_displayDropLocation = ClientOptionsViewModel.Instance.DisplayDropLocation; _pieceHint = null; // reset hint ExecuteOnUIThread.Invoke(DesactivateContinuousSpecials); ExecuteOnUIThread.Invoke(() => PauseText.Visibility = Visibility.Hidden); }
private void OnContinuousEffectToggled(Specials special, bool active, double duration) { if (active) { ContinuousEffect effect = Effects.FirstOrDefault(x => x.Special == special); if (effect != null) { effect.TotalSeconds = duration; ExecuteOnUIThread.Invoke(EffectsView.Refresh); } else { effect = new ContinuousEffect { Special = special, TotalSeconds = duration }; Effects.Add(effect); ExecuteOnUIThread.Invoke(EffectsView.Refresh); } } else { ContinuousEffect effect = Effects.FirstOrDefault(x => x.Special == special); if (effect != null) { Effects.Remove(effect); ExecuteOnUIThread.Invoke(EffectsView.Refresh); } } }
private void Reset() { Client.ResetAchievements(); Settings.Default.Achievements.Save(Client.Achievements.ToList()); Settings.Default.Save(); ExecuteOnUIThread.Invoke(() => Achievements = BuildAchievementList(Client.Achievements.ToList())); }
private void AddSpectatorEntry(int spectatorId, string spectatorName) { ExecuteOnUIThread.Invoke(() => SpectatorList.Add(new SpectatorData { SpectatorId = spectatorId, SpectatorName = spectatorName, })); }
private void OnGameStarted() { ExecuteOnUIThread.Invoke(() => { SetInventoryLength(); DrawInventory(); }); }
private void ClearEntries() { ExecuteOnUIThread.Invoke(() => { PlayerList.Clear(); SpectatorList.Clear(); }); }
private void SetConnectionResultMessage(ChatColor color, string format, params object[] args) { ExecuteOnUIThread.Invoke(() => { ConnectionResult = String.Format(format, args); ConnectionResultColor = color; }); }
private void OnGameStarted() { ExecuteOnUIThread.Invoke(() => { ClearGrid(); ResetImmunity(); }); }
private void AddPlayerEntry(int playerId, string playerName, string team) { ExecuteOnUIThread.Invoke(() => PlayerList.Add(new PlayerData { RealPlayerId = playerId, PlayerName = playerName, Team = team, IsServerMaster = false, })); }
private void SetTeam(int playerId, string team) { ExecuteOnUIThread.Invoke(() => { foreach (PlayerData p in PlayerList.Where(x => x.RealPlayerId == playerId)) { p.Team = team; } }); }
private void SetServerMaster(int serverMasterId) { ExecuteOnUIThread.Invoke(() => { foreach (PlayerData p in PlayerList) { p.IsServerMaster = p.RealPlayerId == serverMasterId; } }); }
private void OnAchievementEarned(IAchievement achievement, bool firstTime) { Log.Default.WriteLine(LogLevels.Info, "Achievement: {0} {1} {2:dd/MM/yyyy HH:mm:ss}", achievement.Title, firstTime, achievement.LastTimeAchieved); Settings.Default.Achievements.Save(Client.Achievements.ToList()); Settings.Default.Save(); ExecuteOnUIThread.Invoke(() => Achievements = BuildAchievementList(Client.Achievements.ToList())); // RefreshAchievementsStats(); }
public void AddEntry(InGameChatEntry entry) { ExecuteOnUIThread.Invoke(() => { Entries.Add(entry); if (Entries.Count > MaxEntries) { Entries.RemoveAt(0); } }); }
protected void AddEntry(ChatEntry entry) { ExecuteOnUIThread.Invoke(() => { ChatEntries.Add(entry); if (ChatEntries.Count > MaxEntries) { ChatEntries.RemoveAt(0); } }); }
private void OnContinuousEffectToggled(Specials special, bool active, double duration) { if (special == Specials.Immunity) { ExecuteOnUIThread.Invoke(() => ActivateImmunity(active)); } else if (special == Specials.Darkness) { ExecuteOnUIThread.Invoke(() => ActivateDarkness(active)); } }
private void OnGameFinished(GameStatistics statistics) { // RefreshResetEnable(); // ExecuteOnUIThread.Invoke(() => Achievements = BuildAchievementList(Client.Achievements.ToList())); // Settings.Default.Achievements.Save(Client.Achievements.ToList()); Settings.Default.Save(); // RefreshAchievementsStats(); }
private void DeleteSpectatorEntry(int spectatorId, string spectatorName) { ExecuteOnUIThread.Invoke(() => { SpectatorData s = SpectatorList.FirstOrDefault(x => x.SpectatorId == spectatorId); if (s != null) { SpectatorList.Remove(s); } else { Log.Default.WriteLine(LogLevels.Warning, "Trying to delete unknown spectator {0}[{1}] from spectator list", spectatorId, spectatorName); } }); }
private void OnContinuousSpecialFinished(int playerId, Specials special) { ExecuteOnUIThread.Invoke(() => { OpponentViewModel vm = DataContext as OpponentViewModel; if (vm == null) { return; } if (playerId == vm.PlayerId && special == Specials.Immunity) { ResetImmunity(); } }); }
private void OnSpecialUsed(int playerId, string playerName, int targetId, string targetName, int specialId, Specials special) { ExecuteOnUIThread.Invoke(() => { OpponentViewModel vm = DataContext as OpponentViewModel; if (vm == null) { return; } if (targetId == vm.PlayerId && special == Specials.Immunity && (vm.Client.IsPlaying || vm.Client.IsSpectator || ClientOptionsViewModel.Instance.DisplayOpponentsFieldEvenWhenNotPlaying)) { SetImmunity(); } }); }
private void DeletePlayerEntry(int playerId, string playerName) { ExecuteOnUIThread.Invoke(() => { PlayerData p = PlayerList.FirstOrDefault(x => x.RealPlayerId == playerId); if (p != null) { PlayerList.Remove(p); } else { Log.Default.WriteLine(LogLevels.Warning, "Trying to delete unknown player {0}[{1}] from player list", playerId, playerName); } }); }
private void OnRedrawBoard(int playerId, IBoard board) { ExecuteOnUIThread.Invoke(() => { OpponentViewModel vm = DataContext as OpponentViewModel; // <-- this may cause cross-thread exception if (vm == null) { return; } if (playerId == vm.PlayerId && (vm.Client.IsPlaying || vm.Client.IsSpectator || ClientOptionsViewModel.Instance.DisplayOpponentsFieldEvenWhenNotPlaying)) { DrawGrid(board); } }); }
private void OnPlayerUnregistered() { ExecuteOnUIThread.Invoke(ResetImmunity); }
private void ClearEntries() { ExecuteOnUIThread.Invoke(Entries.Clear); }
public void AddServerToLatest(string address) { ExecuteOnUIThread.Invoke(() => AddServerToLatestInner(address)); }
private void OnInventoryChanged() { ExecuteOnUIThread.Invoke(DrawInventory); }
protected override void OnStartup(StartupEventArgs e) { // ExecuteOnUIThread.Initialize(); // Initialize Log string logFilename = "WPF_" + Guid.NewGuid().ToString().Substring(0, 5) + ".log"; Log.Default.Initialize(ConfigurationManager.AppSettings["logpath"], logFilename); //// Log user settings path //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); //Log.Default.WriteLine(LogLevels.Info, "Local user config path: {0}", config.FilePath); //// TODO: if PortableSettingsProvider file doesn't exist, copy config.FilePath to PortableSettingsProvider path if (!Directory.Exists(PortableSettingsProvider.SettingsPath)) { Directory.CreateDirectory(PortableSettingsProvider.SettingsPath); } // If new config file doesn't exist, rename user.config or copy old one try { string newPath = Path.Combine(PortableSettingsProvider.SettingsPath, PortableSettingsProvider.SettingsFilename); if (!File.Exists(newPath)) { // string oldPath = Path.Combine(PortableSettingsProvider.SettingsPath, "user.config"); if (File.Exists(oldPath)) { Log.Default.WriteLine(LogLevels.Info, @"User settings file not found. Rename {0} to {1}", oldPath, newPath); File.Move(oldPath, newPath); } else { // Original config file path Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); if (File.Exists(config.FilePath)) { Log.Default.WriteLine(LogLevels.Info, "User settings file not found. Copy {0} to {1}", config.FilePath, newPath); File.Copy(config.FilePath, newPath); } } } } catch (Exception ex) { Log.Default.WriteLine(LogLevels.Error, "Error while creating new config file from old one. Exception: {0}", ex.ToString()); } //ExtractTetrinetTextures(); // Get textures string textureFilepath = ConfigurationManager.AppSettings["texture"]; bool isDirectory = false; try { FileAttributes attr = File.GetAttributes(textureFilepath); isDirectory = (attr & FileAttributes.Directory) == FileAttributes.Directory; } catch { } if (isDirectory) { TextureManager.TextureManager.Instance.ReadFromPath(textureFilepath); } else { TextureManager.TextureManager.Instance.ReadFromFile(textureFilepath); } // base.OnStartup(e); }
private void OnPieceMoved() { ExecuteOnUIThread.Invoke(DrawInventory); }
private void OnGameFinished(GameStatistics statistics) { SelectedPlayer = null; // reset ExecuteOnUIThread.Invoke(() => AddStatistics(statistics)); SelectedGameStatistics = statistics; }
private void OnConnectionLost(ConnectionLostReasons reason) { ExecuteOnUIThread.Invoke(ResetImmunity); }