private void LbxSearchResultsSelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_lbxSearchResults.SelectedIndex == -1)
            {
                return;
            }

            var result = m_lbxSearchResults.SelectedItem as SearchResult;

            m_rtbResultDisplay.Text = string.Empty;
            var corsixString = new StringBuilder();

            for (int i = 0; i < result.ValuePaths.Count; i++)
            {
                corsixString.Append(result.ValuePaths[i].SubstringBeforeLast('\\', true));
                corsixString.Append(CorsixStyleConverter.ToCorsixStyle(result.Values[i]));
                corsixString.AppendLine().AppendLine();
            }
            m_rtbResultDisplay.Text = corsixString.ToString();
        }
Beispiel #2
0
        private void BtnDoneClick(object sender, EventArgs e)
        {
            char separator = m_cbxSeperator.Text == @"Tabstop (\t)" ? '\t' : '|';

            try
            {
                Output = CorsixStyleConverter.Parse(m_rtbInput.Lines, separator);
            }
            catch (Exception ex)
            {
                LoggingManager.SendMessage("Failed to parse RBFConv-style text!");
                LoggingManager.HandleException(ex);
                UIHelper.ShowError("Failed to parse RBFConv-style text: " + ex.Message);
                return;
            }

            if (OnSuccessfulParse != null)
            {
                OnSuccessfulParse();
            }
        }
Beispiel #3
0
        private void CopyAsCorsixstringToolStripMenuItemClick(object sender, EventArgs e)
        {
            if (m_trvTables.SelectedNode == null || (m_trvTables.SelectedNode.Tag == null && !m_collectionMode))
            {
                return;
            }
            var output = new StringBuilder(255);

            if (m_collectionMode && m_trvTables.SelectedNode.Tag == null)
            {
                foreach (AttributeValue value in m_collection)
                {
                    output.Append(CorsixStyleConverter.ToCorsixStyle(value));
                    output.Append('\n');
                }
            }
            else
            {
                var topNode = (AttributeValue)m_trvTables.SelectedNode.Tag;
                output.Append(CorsixStyleConverter.ToCorsixStyle(topNode));
            }
            Clipboard.SetText(output.ToString());
        }
        static void ReadLibraryLegacy(StreamReader reader)
        {
            string      line         = reader.ReadLine();
            string      value        = string.Empty;
            RBFLibEntry currentEntry = null;

            while (line != null)
            {
                if (line.StartsWith("//"))
                {
                }
                else if (line == string.Empty)
                {
                    if (value != string.Empty && currentEntry != null)
                    {
                        currentEntry.Values = CorsixStyleConverter.Parse(value);
                    }
                    value = string.Empty;
                }
                else if (line.StartsWith("[name="))
                {
                    line = line.Remove(line.Length - 1, 1).Remove(0, 6);
                    if (currentEntry != null)
                    {
                        if (currentEntry.TagGroups == null)
                        {
                            currentEntry.TagGroups = new string[0];
                        }
                        if (currentEntry.Tags == null)
                        {
                            currentEntry.Tags = new string[0];
                        }
                        s_values.Add(currentEntry.Name, currentEntry);
                    }

                    currentEntry = new RBFLibEntry {
                        Name = line
                    };
                }
                else if (line.StartsWith("[tags="))
                {
                    line = line.Remove(line.Length - 1, 1).Remove(0, 6);
                    if (line.Length > 0 && currentEntry != null)
                    {
                        currentEntry.Tags = line.Split(s_tagSeperator, StringSplitOptions.RemoveEmptyEntries);
                    }
                }
                else if (line.StartsWith("[taggroups="))
                {
                    line = line.RemoveLast(1).Remove(0, 11);
                    if (currentEntry != null)
                    {
                        currentEntry.TagGroups = line.Split(s_tagSeperator, StringSplitOptions.RemoveEmptyEntries);
                    }
                }
                else if (line.StartsWith("[sub="))
                {
                    line = line.Remove(line.Length - 1, 1).Remove(0, 5);
                    if (currentEntry != null)
                    {
                        currentEntry.Submenu = line;
                    }
                }
                else
                {
                    value += line;
                    value += '\n';
                }
                line = reader.ReadLine();
            }
            if (currentEntry != null)
            {
                if (value != string.Empty)
                {
                    currentEntry.Values = CorsixStyleConverter.Parse(value);
                }
                if (!s_values.ContainsKey(currentEntry.Name))
                {
                    s_values.Add(currentEntry.Name, currentEntry);
                }
            }
        }