/// <summary> /// Sets contents on information label /// </summary> private void _UpdateInfoLabel() { DB.Culture currentCulture = Program.ApplicationSettings.GetCurrentCulture(); _ResourceValue = _DbResource.GetEntryFromId(_ResourceId).value; resourceInfoLabel.Text = string.Format(_FORMAT_INFO_LABEL, _ResourceId, _DbResource.CurrentTopic, currentCulture, _ResourceValue); }
/// <summary> /// Returns final resource value from specified cell. /// Does not support cross reference still. /// </summary> /// <param name="cell">Cell to get value</param> /// <param name="topicResource">Resource file to get values (when valueType = ValueInResource)</param> /// <returns></returns> public static string GetResourceValueFromCell(DB.Cell cell, DBResource topicResource) { string result; // According to value type... switch (cell.valueType) { case DB.ValueType.ReferenceL: case DB.ValueType.ValueInResource: case DB.ValueType.ValueInResourceH: // Corresponding value must be found into resource file DBResource.Entry currentEntry = topicResource.GetEntryFromId(cell.value); result = currentEntry.value; break; default: result = cell.value; break; } // Failsafe operation if (result == null) { result = DatabaseConstants.DEFAULT_RESOURCE_VALUE; Log.Info("WARNING ! Resource with code " + cell.value + " was not found in " + topicResource.CurrentTopic + "-" + topicResource.CurrentCulture + ". Please fix it!"); } return(result); }
/// <summary> /// Returns track name from specified resource identifier /// </summary> /// <param name="trackNameDbResource"></param> /// <returns></returns> private string _GetNameFromResource(string trackNameDbResource) { string returnedName = TrackPackForm._DEFAULT_TRACK_NAME; if (_HousesResource != null && trackNameDbResource != null) { DBResource.Entry currentEntry = _HousesResource.GetEntryFromId(trackNameDbResource); returnedName = currentEntry.value; } return(returnedName); }
private void colorsLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { // Click on color/material link if (!string.IsNullOrEmpty(_InteriorSetId)) { try { string colorCode = _PickInteriorColor(sender == materialLinkLabel); if (colorCode != null) { Cursor = Cursors.WaitCursor; // Reloading string colorAcronym = _InteriorResource.GetEntryFromId(colorCode).value; string newColorLabel = _GetColorLabel(colorAcronym); if (sender == colorsMainLinkLabel) { _Color1Code = colorCode; colorsMainLinkLabel.Text = newColorLabel; } else if (sender == colorsSecondaryLinkLabel) { _Color2Code = colorCode; colorsSecondaryLinkLabel.Text = newColorLabel; } else if (sender == materialLinkLabel) { _MaterialCode = colorCode; materialLinkLabel.Text = newColorLabel; } } } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } finally { Cursor = Cursors.Default; } } }
/// <summary> /// Checks cell value for specified resource and updates issues list /// </summary> /// <param name="topic"></param> /// <param name="cell"></param> /// <param name="dbResource"></param> /// <param name="issues"></param> /// <returns></returns> private void _CheckResourceValue(DB.Topic topic, DB.Cell cell, DBResource dbResource, Collection <DatabaseFixer.Corruption> issues) { if (dbResource == null) { // Resource from another topic if (cell.optionalRef != null) { DB.Topic referencedTopic = DB.TopicPerTopicId[cell.optionalRef]; // Is topic to be loaded ? TduFile[] databaseItems = _LoadedData[referencedTopic]; dbResource = databaseItems[1] as DBResource; if (dbResource == null) { throw new Exception("Unable to get database resource information for referenced topic: " + referencedTopic); } } } if (dbResource == null) { throw new Exception("Unable to get database resource information for topic: " + topic); } if (!dbResource.GetEntryFromId(cell.value).isValid) { // Report missing resource DatabaseFixer.Corruption newCorruption = new DatabaseFixer.Corruption { corruptedCell = cell, corruptedValue = cell.value, culture = dbResource.CurrentCulture, entryId = cell.entryIndex, kind = DatabaseFixer.CorruptionKind.MissingResource, referencedTopic = dbResource.CurrentTopic, topic = topic }; issues.Add(newCorruption); } }
private void editOKButton_Click(object sender, EventArgs e) { // Clic sur le bouton 'OK' if (!_EditedEntry.isValid) { return; } // EVO_xx : line adding feature bool isAddingEntry = (_EditedEntry.id == null); // Prépare les données pour la mise à jour string newId = idTextBox.Text; string value = valueTextBox.Text; try { Cursor = Cursors.WaitCursor; // According to mode if (isAddingEntry) { // Add // Is this identifier a UID ? if (_LeDB.GetEntryFromId(newId).isValid) { idTextBox.Focus(); throw new Exception(_ERROR_ID_EXISTS); } // Identifier update if (!_EditedEntry.isComment) { _EditedEntry.id = new ResourceIdentifier(newId, _LeDB.CurrentTopic); } // Value update _EditedEntry.value = value; // Update file data _LeDB.InsertEntry(_EditedEntry); _LeDB.Save(); // List update _UpdateEntryList(true); // Signals if (_EditedFile == null) { StatusBarLogManager.ShowEvent(this, _STATUS_INS_SUCCESS_1); } else { StatusBarLogManager.ShowEvent(this, _STATUS_INS_SUCCESS_2); } } else { // Modify // Is update necessary ? if (!newId.Equals(_EditedEntry.id.Id) || !value.Equals(_EditedEntry.value)) { // Identifier update if (!_EditedEntry.isComment) { _EditedEntry.id = new ResourceIdentifier(newId, _LeDB.CurrentTopic); } // Value update _EditedEntry.value = value; // Met à jour les données du fichier DBResource.Entry entryAfterUpdate = _LeDB.UpdateEntry(_EditedEntry); _LeDB.Save(); // Met à jour la ligne dans le tableau _UpdateEntryFromLine(entryAfterUpdate); // Signals if (_EditedFile == null) { StatusBarLogManager.ShowEvent(this, _STATUS_MOD_SUCCESS_1); } else { StatusBarLogManager.ShowEvent(this, _STATUS_MOD_SUCCESS_2); } } else { StatusBarLogManager.ShowEvent(this, ""); } } // Clearing fields lineLabel.Text = ""; idTextBox.Clear(); valueTextBox.Clear(); Cursor = Cursors.Default; } catch (Exception ex) { MessageBoxes.ShowError(this, ex); } }