private void AddValuesToRBFDictionaryToolStripMenuItemClick(object sender, EventArgs e) { if (m_trvTables.SelectedNode == null) { return; } if (m_collectionMode) { UIHelper.ShowError("Does not work in RBF-library."); return; } var rbfv = m_trvTables.SelectedNode.Tag as AttributeValue; if (rbfv.DataType == AttributeDataType.String) { RBFDictionary.AddDictEntry(rbfv.Key, rbfv.Data as string); } else if (rbfv.DataType == AttributeDataType.Table) { string key = rbfv.Key; foreach (var rbfData in (AttributeTable)rbfv.Data) { if (rbfData.DataType != AttributeDataType.String) { continue; } RBFDictionary.AddDictEntry(key, (string)rbfData.Data); } } }
private void TbxKeyTextChanged(object sender, EventArgs e) { if (m_trvTables.SelectedNode == null || m_trvTables.SelectedNode.Tag == null) { return; } var rbfv = (AttributeValue)m_trvTables.SelectedNode.Tag; var x = (TextBox)sender; string old = rbfv.Key; rbfv.Key = x.Text; if (old != rbfv.Key) { if (HasChangesChanged != null) { HasChangesChanged(this, true); } } m_cbxValue.Items.Clear(); if (!FillComboBoxByUserPath(m_cbxValue.Items, m_tbxKey.Text)) { m_cbxValue.Items.AddRange(RBFDictionary.GetDictEntries(m_tbxKey.Text)); } }
private void AddValueToolStripMenuItemClick(object sender, EventArgs e) { if (m_dgvValues.SelectedRows.Count <= 0 || (string)m_dgvValues.SelectedRows[0].Cells[2].Value != "string") { return; } RBFDictionary.AddDictEntry((string)m_dgvValues.SelectedRows[0].Cells[0].Value, (string)m_dgvValues.SelectedRows[0].Cells[1].Value); }
private void BtnCopyIntoDictionaryClick(object sender, EventArgs e) { foreach (var tmpEntry in m_chklbxEntries.CheckedItems) { DictEntry entry = tmpEntry as DictEntry; if (RBFDictionary.HasSearchpath(entry.Key)) { if (UIHelper.ShowYNQuestion("Question", "There already exists a searchpath for key '" + entry.Key + "', remove it and replace it with regular a RBF dictionary entry?") == DialogResult.No) { continue; } RBFDictionary.RemoveSearchpath(entry.Key); } RBFDictionary.AddDictEntry(entry.Key, entry.Options); } }
public override void Init(PluginEnvironment env) { LoggingManager.SendMessage("RBFPlugin - Setup started"); RBFSettings.Instance = this; // adding stuff to the menu ToolStripItem openRBFLib = new ToolStripMenuItem("Open RBF-Library") { Name = "openRBFLib" }; openRBFLib.Click += OpenRBFLibClick; ToolStripItem options = new ToolStripMenuItem("Options") { Name = "options" }; options.Click += OptionsClick; ToolStripItem search = new ToolStripMenuItem("RBF-Search") { Name = "RBFSearch" }; search.Click += SearchClick; ToolStripItem openDictionaryCrawler = new ToolStripMenuItem("Open Dictionary Builder") { Name = "dictCrawler" }; openDictionaryCrawler.Click += OpenDictionaryCrawlerClick; ToolStripItem openLibraryCrawler = new ToolStripMenuItem("Open Library Builder") { Name = "libraryCrawler" }; openLibraryCrawler.Click += OpenLibraryCrawlerClick; env.PluginSubMenu.Add(openRBFLib); env.PluginSubMenu.Add(openDictionaryCrawler); env.PluginSubMenu.Add(openLibraryCrawler); env.PluginSubMenu.Add(options); env.PluginSubMenu.Add(search); RBFLibrary.Init(); RBFDictionary.Init(); LoggingManager.SendMessage("RBFPlugin - Setup finished"); }
private static bool FillComboBoxByUserPath(object o, string key) { var c = o as ComboBox.ObjectCollection; var c2 = o as DataGridViewComboBoxCell.ObjectCollection; HashSet <SearchPathInfo> paths = RBFDictionary.GetPaths(key); if (paths != null && paths.Count > 0) { foreach (var spi in paths) { string[] values = null; string removeFromFront = spi.RemoveFromFront ?? string.Empty; switch (spi.Root) { case SearchPathRoot.Attrib: values = GetAttribFilesAbs(spi.Path, removeFromFront, spi.ExtensionsToInclude, spi.EndingsToExclude); break; case SearchPathRoot.Data: values = GetDataFilesAbs(spi.Path, removeFromFront, spi.ExtensionsToInclude, spi.EndingsToExclude); break; } if (values == null) { continue; } if (c == null) { c2.AddRange(values); } else { c.AddRange(values); } } return(true); } return(false); }
private void DgvValuesCellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } DataGridViewRow row = m_dgvValues.Rows[e.RowIndex]; DataGridViewCell cell = row.Cells[e.ColumnIndex]; var attribValue = (AttributeValue)row.Tag; if (attribValue == null) { return; } // key if (e.ColumnIndex == 0) { if (HasChangesChanged != null) { HasChangesChanged(this, true); } attribValue.Key = cell.Value.ToString(); if (cell is DataGridViewComboBoxCell) { var combo = row.Cells[1] as DataGridViewComboBoxCell; string value = combo.Value.ToString(); for (int i = 0; i < combo.Items.Count; i++) { if (combo.Items[i].ToString() != value) { combo.Items.RemoveAt(i--); } } if (!FillComboBoxByUserPath(combo.Items, cell.Value.ToString())) { combo.Items.AddRange(RBFDictionary.GetDictEntries(cell.Value.ToString())); } } } // value else if (e.ColumnIndex == 1) { if (HasChangesChanged != null) { HasChangesChanged(this, true); } if (cell == null || cell.Value == null) { attribValue.Data = AttributeValue.ConvertStringToData(string.Empty, attribValue.DataType); return; } object oldData = attribValue.Data; try { attribValue.Data = AttributeValue.ConvertStringToData(cell.Value.ToString(), attribValue.DataType); } catch (Exception ex) { attribValue.Data = oldData; UIHelper.ShowError("Invalid value!"); } if (cell is DataGridViewComboBoxCell) { var combo = cell as DataGridViewComboBoxCell; string value = combo.Value.ToString(); for (int i = 0; i < combo.Items.Count; i++) { if (combo.Items[i].ToString() != value) { combo.Items.RemoveAt(i--); } } if (value.Contains('\\')) { string relativePath = value.SubstringBeforeLast('\\'); string[] files = GetAttribFiles(relativePath); if (files != null) { combo.Items.AddRange(files); } files = GetDataFiles(relativePath); if (files != null) { combo.Items.AddRange(files); } } } } // type else if (e.ColumnIndex == 2) { if (HasChangesChanged != null) { HasChangesChanged(this, true); } attribValue.DataType = AttributeValue.ConvertStringToType(cell.Value.ToString()); } }
private void UpdateDataGrid(AttributeValue current) { m_dgvValues.Rows.Clear(); m_cbxValue.Items.Clear(); m_tbxKey.Text = current.Key; m_cbxValue.Text = AttributeValue.ConvertDataToString(current); m_cbxDataType.Text = s_typeNames[(int)current.DataType]; if (current.DataType == AttributeDataType.Table) { m_dgvValues.AllowUserToAddRows = true; int index = -1; foreach (AttributeValue attribValue in (current.Data as AttributeTable)) { var currentRow = (DataGridViewRow)m_dgvValues.RowTemplate.Clone(); // setting up the cells var keyCell = new DataGridViewTextBoxCell { Value = attribValue.Key }; currentRow.Cells.Add(keyCell); DataGridViewCell value; switch (attribValue.DataType) { case AttributeDataType.Boolean: value = new DataGridViewCheckBoxCell { Value = (bool)attribValue.Data }; break; case AttributeDataType.String: // filling the dropdown boxes value = new DataGridViewComboxCell(); var cell = (DataGridViewComboxCell)value; cell.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; cell.Sorted = true; if (index != -1 && m_dgvValues.Rows[index].Cells[0].Value.Equals(attribValue.Key)) { var upperCell = m_dgvValues.Rows[index].Cells[1] as DataGridViewComboBoxCell; if (upperCell != null) { cell.Items.AddRange(upperCell.Items); } } if (cell.Items.Count == 0) { // get preset-entries from the dictionary cell.Items.AddRange(RBFDictionary.GetDictEntries(attribValue.Key)); // try to get strings from userpath -- else go search for paths on our own GetPathsForComboBox(cell, attribValue.Key, attribValue.Data as string); } if (!cell.Items.Contains(attribValue.Data as string)) { cell.Items.Add(attribValue.Data); } value.Value = AttributeValue.ConvertDataToString(attribValue); break; default: value = new DataGridViewTextBoxCell { Value = AttributeValue.ConvertDataToString(attribValue) }; break; } currentRow.Cells.Add(value); var type = new DataGridViewComboBoxCell(); type.Items.AddRange(new[] { "float", "int", "bool", "table", "string" }); type.Value = s_typeNames[(int)attribValue.DataType]; currentRow.Cells.Add(type); type.ReadOnly = true; index = m_dgvValues.Rows.Add(currentRow); m_dgvValues.Rows[index].Tag = attribValue; } } else if (current.DataType == AttributeDataType.Boolean) { m_cbxValue.Items.Add("true"); m_cbxValue.Items.Add("false"); } m_dgvValues.Sort(m_dgvValues.Columns[0], ListSortDirection.Ascending); }