Exemplo n.º 1
0
        /// <summary>
        /// Builds the tree view.
        /// </summary>
        private void BuildTreeView()
        {
            m_objects.Clear();
            ResultsTreeView.Nodes.Clear();

            // Decode EFT format
            if (m_loadoutFormat == LoadoutFormat.EFT)
            {
                m_loadoutInfo = LoadoutHelper.DeserializeEftFormat(m_clipboardText);
            }

            // Decode XML format
            if (m_loadoutFormat == LoadoutFormat.XML)
            {
                m_loadoutInfo = LoadoutHelper.DeserializeXmlFormat(m_clipboardText);
            }

            // Decode DNA format
            if (m_loadoutFormat == LoadoutFormat.DNA)
            {
                m_loadoutInfo = LoadoutHelper.DeserializeDnaFormat(m_clipboardText);
            }

            // Decode CLF format
            if (m_loadoutFormat == LoadoutFormat.CLF)
            {
                m_loadoutInfo = LoadoutHelper.DeserializeClfFormat(m_clipboardText);
            }

            if (m_loadoutInfo == null || !m_loadoutInfo.Loadouts.Any())
            {
                return;
            }

            LoadoutNameLabel.Text = $"Name: {m_loadoutInfo.Loadouts.First().Name}{(m_loadoutFormat == LoadoutFormat.DNA ? " - DNA loadout" : String.Empty)}"
                                    .WordWrap(55);

            ShipTypeNameLabel.Text = $"Ship: {(m_loadoutInfo.Ship?.Name ?? String.Empty)}"
                                     .WordWrap(55);

            DescriptionLabel.Text = $"Description: {m_loadoutInfo.Loadouts.First().Description}"
                                    .WordWrap(55);

            m_objects.Add(m_loadoutInfo.Ship);

            BuildTreeNodes(m_loadoutInfo.Loadouts.First().Items);

            // Order the nodes
            TreeNode[] orderNodes = ResultsTreeView.Nodes.Cast <TreeNode>().OrderBy(
                node => LoadoutHelper.OrderedSlotNames.IndexOf(String.Intern(node.Text))).ToArray();
            ResultsTreeView.Nodes.Clear();
            ResultsTreeView.Nodes.AddRange(orderNodes);

            // Update the controls
            UpdatePlanStatus();
            ResultsTreeView.ExpandAll();
            ResultsTreeView.Enabled = true;
            Cursor        = Cursors.Default;
            m_allExpanded = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserializes the loadout.
        /// </summary>
        /// <param name="loadout">The loadout.</param>
        /// <param name="feed">The feed.</param>
        /// <exception cref="System.ArgumentNullException">
        /// loadout
        /// or
        /// feed
        /// </exception>
        public override void DeserializeLoadout(Loadout loadout, object feed)
        {
            loadout.ThrowIfNull(nameof(loadout));

            feed.ThrowIfNull(nameof(feed));

            loadout.Items = LoadoutHelper.DeserializeEftFormat(feed as string).Loadouts.First().Items;
        }