/// <summary> /// Gets a resource string from the ResourceManager /// /// You can bind to this property using the .[KEY] syntax e.g.: /// /// {Binding Source={StaticResource localisation}, Path=.[MainScreenResources.IntroTextLine1]} /// </summary> /// <param name="key">Key to retrieve in the format [ManagerName].[ResourceKey]</param> /// <returns></returns> public string this[string key] { get { if (key is null) { throw new ArgumentNullException(nameof(key)); } bool isValidKey = ValidKey(key); if (!isValidKey && String.IsNullOrEmpty(DefaultManager)) { throw new ArgumentException("Key cannot be empty, and must be in the valid [ManagerName].[ResourceKey] format. Key = \"" + key + "\""); } if (DesignHelpers.IsInDesignModeStatic) { return(key); //throw new Exception("Design mode is not supported."); } if (isValidKey) { return(ResourceManagerService.GetResourceString(GetManagerKey(key), GetResourceKey(key))); } else { return(ResourceManagerService.GetResourceString(DefaultManager, key)); } } }
private void EndGame() { _isPlaying = false; IsEnabled = false; _model.Game.RightPlayer.TransferMove -= _model.Game.Transfer_Move; _model.Game.LeftPlayer.TransferMove -= _model.Game.Transfer_Move; UnsubscriptionOponentField(); _model.Game.LeftPlayer.OponentChanged -= Oponent_Changed; _model.Game.GameOver(_model.Game.LeftStatistics, _model.Game.RightStatistics); AddOrEditPlayer(); SetLeftFieldCells(); foreach (var child in Grid.Children) { UpdateCommand.Execute(child); } MessageBox.Show(_model.Game.CountWin != 0 ? ResourceManagerService.GetResourceString("MainWindowRes", "Winner_message") : ResourceManagerService.GetResourceString("MainWindowRes", "Loser_message")); IsEndButton = true; _model.Game.ResetStatistics(_model.Game.RightStatistics); _model.Game.ResetStatistics(_model.Game.LeftStatistics); ShipAmountLeft = _model.Game.RightStatistics.CountShips + " "; ShotAmountLeft = _model.Game.RightStatistics.CountLeftShot + " "; ShipAmountRight = _model.Game.LeftStatistics.CountShips + " "; ShotAmountRight = _model.Game.LeftStatistics.CountLeftShot + " "; ResetRightField(); foreach (var child in GridR.Children) { UpdateCommand.Execute(child); } }
public static string L(string resourceKey) { var value = ResourceManagerService.GetResourceString("XbimPresentationResource", resourceKey); return(string.IsNullOrWhiteSpace(value) ? resourceKey : value); }
public static string L(string managerName, string resourceKey) { var value = ResourceManagerService.GetResourceString(managerName, resourceKey); return(string.IsNullOrWhiteSpace(value) ? resourceKey : value); }
/// <summary> /// Shows childs windows /// </summary> /// <param name="pViewIndex"></param> /// <param name="pDataContext"></param> /// <param name="playerName"></param> public static void Show(int pViewIndex, object pDataContext, ref string playerName) { ResourceManagerService.RegisterManager("MainWindowRes", MainWindowRes.ResourceManager, true); Window window; switch (pViewIndex) { case 0: { window = new GeetingWindow(); { window.DataContext = new GreetingViewModel(); window.ShowDialog(); var panel = (Panel)window.Content; foreach (var child in panel.Children) { if (child is TextBox) { playerName = (child as TextBox).Text; } } } break; } case 1: { window = new RatingWindow(); { var panel = (Panel)window.Content; foreach (var child in panel.Children) { var textColumn = new DataGridTextColumn(); var textColumn1 = new DataGridTextColumn(); if (!(child is DataGrid)) { continue; } var childGrid = child as DataGrid; IEnumerable players = (IEnumerable)pDataContext; (child as DataGrid).ItemsSource = players; textColumn.Header = ResourceManagerService.GetResourceString("MainWindowRes", "Name_Lbl"); textColumn.Binding = new Binding("Name"); childGrid.Columns.Add(textColumn); textColumn1.Header = ResourceManagerService.GetResourceString("MainWindowRes", "Rating_Lbl"); textColumn1.Binding = new Binding("Rating"); childGrid.Columns.Add(textColumn1); } window.ShowDialog(); } break; } default: throw new ArgumentOutOfRangeException(nameof(pViewIndex), @"Index out of range"); } }
public static void ErrorResource(this Logger logger, string resoureKey) { logger.Error(ResourceManagerService.GetResourceString("LogResources", resoureKey)); }
private void Information(object obj) { var str = ResourceManagerService.GetResourceString("MainWindowRes", "Inform_message"); MessageBox.Show(str.Replace(@"{\n}", Environment.NewLine)); }