public LocalizationSettingWindow(Dictionary <string, XmlObjectsListWrapper> loadedListWrappers) { InitializeComponent(); Closing += new CancelEventHandler(LocalizatonSettingWindow_Closing); AddTooltips(); StartingMod = Properties.Settings.Default.ModTagSetting; WindowTitle = StartingMod.ToString(); this.Title = GetTitleForWindow(); this.LoadedListWrappers = loadedListWrappers; string pathToModLocalizationFile = XmlFileManager.ModConfigOutputPath + LocalizationFileObject.LOCALIZATION_FILE_NAME; ModLocalizationGridUserControl = new LocalizationGridUserControl(pathToModLocalizationFile); GridAsCSVAfterUpdate = ModLocalizationGridUserControl.Maingrid.GridAsCSV(); List <string> allCustomTagDirectories = XmlFileManager.GetCustomModFoldersInOutput(); foreach (string nextModTag in allCustomTagDirectories) { ModSelectionComboBox.AddUniqueValueTo(nextModTag); } ModSelectionComboBox.SelectedItem = Properties.Settings.Default.ModTagSetting; ModSelectionComboBox.DropDownClosed += ModSelectionComboBox_DropDownClosed; ModLocalizationScrollViewer.Content = ModLocalizationGridUserControl; string pathToGameLocalizationFile = XmlFileManager.LoadedFilesPath + LocalizationFileObject.LOCALIZATION_FILE_NAME; GameLocalizationFile = new LocalizationFileObject(pathToGameLocalizationFile); TextEditorOptions newOptions = new TextEditorOptions { EnableRectangularSelection = true, EnableTextDragDrop = true, HighlightCurrentLine = true, ShowTabs = true }; LocalizationPreviewBox.ShowLineNumbers = true; LocalizationPreviewBox.TextArea.Options = newOptions; LocalizationPreviewBox.Text = ModLocalizationGridUserControl.Maingrid.GridAsCSV(); LocalizationPreviewBox.LostFocus += LocalizationPreviewBox_LostFocus; SearchPanel.Install(LocalizationPreviewBox); ModLocalizationScrollViewer.GotFocus += Maingrid_GotOrLostFocus; ModLocalizationScrollViewer.LostFocus += Maingrid_GotOrLostFocus; SortedSet <string> gameFileKeysSorted = GameLocalizationFile.HeaderKeyToCommonValuesMap.GetValueOrDefault(GameLocalizationFile.KeyColumn); List <string> gameFileKeys = new List <string>(gameFileKeysSorted); GameKeySelectionComboBox.SetComboBox(gameFileKeys); GameKeySelectionComboBox.IsEditable = true; GameKeySelectionComboBox.DropDownClosed += GameKeySelectionComboBox_DropDownClosed; GameKeySelectionComboBox.PreviewKeyDown += GameKeySelectionComboBox_PreviewKeyDown; SetBackgroundColor(); }
public LocalizationGridUserControl(string pathToFile, bool IsSingleRecord = false) { InitializeComponent(); LocalizationFileObject = new LocalizationFileObject(pathToFile); TextBoxRowDictionary = new Dictionary <int, List <Control> >(); if (IsSingleRecord) { GenerateSigleRecordGrid(); } else { GenerateLocalizationGrid(); } this.Maingrid = topGrid; GridHasChanged = false; }
private void ReloadModLocalizationGrid(ComboBox modSelectionComboBox) { string modOutptPath = XmlFileManager.Get_ModOutputPath(modSelectionComboBox.SelectedItem.ToString()); string pathToModLocalizationFile = modOutptPath + LocalizationFileObject.LOCALIZATION_FILE_NAME; LocalizationFileObject testParse = new LocalizationFileObject(pathToModLocalizationFile); if (testParse.PARSING_ERROR) { ShowLocalizationParsingError(); } else { ModLocalizationGridUserControl = new LocalizationGridUserControl(pathToModLocalizationFile); ModLocalizationScrollViewer.Content = ModLocalizationGridUserControl; string currentGridAsCSV = ModLocalizationGridUserControl.Maingrid.GridAsCSV(); LocalizationPreviewBox.Text = currentGridAsCSV; StartingMod = ModSelectionComboBox.SelectedItem.ToString(); WindowTitle = StartingMod.ToString(); this.Title = GetTitleForWindow(); } }
private void ReloadModLocalizationGrid(string pathToLocalizatioFile, bool deleteFileAfterLoadingGrid = true) { LocalizationFileObject testParse = new LocalizationFileObject(pathToLocalizatioFile); if (testParse.PARSING_ERROR) { ShowLocalizationParsingError(); } else { ModLocalizationGridUserControl = new LocalizationGridUserControl(pathToLocalizatioFile); ModLocalizationScrollViewer.Content = ModLocalizationGridUserControl; string currentGridAsCSV = ModLocalizationGridUserControl.Maingrid.GridAsCSV(); LocalizationPreviewBox.Text = currentGridAsCSV; if (deleteFileAfterLoadingGrid) { File.Delete(pathToLocalizatioFile); } GridAsCSVAfterUpdate = LocalizationPreviewBox.Text; ModLocalizationGridUserControl.SetGridChangedToTrue(); } }
private Control AddGameFileColumn(int lastRowPlusOne, int columnCount, string headerKey, LocalizationFileObject gameLocalizationFile) { SortedSet <string> allCommonValuesSorted = gameLocalizationFile.HeaderKeyToCommonValuesMap.GetValueOrDefault(headerKey); List <string> allCommonValues = new List <string>(allCommonValuesSorted); if (allCommonValues == null) { allCommonValues = new List <string>(); } topGrid.ColumnDefinitions.Add(new ColumnDefinition()); ComboBox newCommonValuesBox = new ComboBox { FontSize = 18, IsEditable = true, Background = BackgroundColorController.GetBackgroundColor() }; newCommonValuesBox.Resources.Add(SystemColors.WindowBrushKey, BackgroundColorController.GetBackgroundColor()); newCommonValuesBox.AddToolTip(headerKey); newCommonValuesBox.DropDownClosed += NewCommonValuesBox_DropDownClosed; newCommonValuesBox.LostFocus += NewCommonValuesBox_LostFocus; newCommonValuesBox.SetComboBox(allCommonValues); Grid.SetRow(newCommonValuesBox, lastRowPlusOne); Grid.SetColumn(newCommonValuesBox, columnCount); topGrid.Children.Add(newCommonValuesBox); return(newCommonValuesBox); }
public void AddEmptyRow(XmlObjectsListWrapper selectedModItemsWrapper, XmlObjectsListWrapper selectedModBlocksWrapper, LocalizationFileObject gameLocalizationFile) { int lastRowPlusOne = TextBoxRowDictionary.Keys.Count + 1; List <Control> controlsAddedInRow = new List <Control>(); RowDefinition rowDefinition = new RowDefinition(); topGrid.RowDefinitions.Add(rowDefinition); int columnCount = 0; AddNumberColumn(lastRowPlusOne, columnCount); columnCount++; AddClearButton(lastRowPlusOne, columnCount); columnCount++; AddModKeysColumn(lastRowPlusOne, columnCount, selectedModItemsWrapper, selectedModBlocksWrapper); columnCount++; //In the game file it is file, in the mod file it is source string headerKey = "file"; controlsAddedInRow.Add(AddGameFileColumn(lastRowPlusOne, columnCount, headerKey, gameLocalizationFile)); columnCount++; headerKey = "type"; controlsAddedInRow.Add(AddGameFileColumn(lastRowPlusOne, columnCount, headerKey, gameLocalizationFile)); columnCount++; controlsAddedInRow.Add(AddChangesColumn(lastRowPlusOne, columnCount)); columnCount++; List <string> emptyRecord = new List <string>(); for (int textBoxCount = 0; textBoxCount < LocalizationFileObject.HeaderKeyToCommonValuesMap.Keys.Count; textBoxCount++) { //This means there was not a row to mimic, increase the count by one to avoid that. emptyRecord.Add(""); } int skipHeadersCount = 4; AddFieldColumns(lastRowPlusOne, columnCount, emptyRecord, controlsAddedInRow, skipHeadersCount); }
public void AddEmptyRow(List <XmlObjectsListWrapper> allWrappersToUseForKeys, LocalizationFileObject gameLocalizationFile) { int lastRowPlusOne = TextBoxRowDictionary.Keys.Count + 1; List <Control> controlsAddedInRow = new List <Control>(); RowDefinition rowDefinition = new RowDefinition(); topGrid.RowDefinitions.Add(rowDefinition); int columnCount = 0; AddNumberColumn(lastRowPlusOne, columnCount); columnCount++; AddClearButton(lastRowPlusOne, columnCount); columnCount++; AddModKeysColumn(lastRowPlusOne, columnCount, allWrappersToUseForKeys); columnCount++; //In the game file it is file, in the mod file it is source string headerKey = "file"; controlsAddedInRow.Add(AddGameFileColumn(lastRowPlusOne, columnCount, headerKey, gameLocalizationFile)); columnCount++; headerKey = "type"; controlsAddedInRow.Add(AddGameFileColumn(lastRowPlusOne, columnCount, headerKey, gameLocalizationFile)); columnCount++; controlsAddedInRow.Add(AddChangesColumn(lastRowPlusOne, columnCount)); columnCount++; List <string> emptyRecord = new List <string>(); //Count the Headers to set an empty row for (int textBoxCount = 0; textBoxCount < LocalizationFileObject.HeaderKeyToCommonValuesMap.Keys.Count; textBoxCount++) { emptyRecord.Add(""); } //This is used to skip the first 4 headers int skipHeadersCount = 4; AddFieldColumns(lastRowPlusOne, columnCount, emptyRecord, controlsAddedInRow, skipHeadersCount); }