示例#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;
        }
示例#2
0
        /// <summary>
        /// Extracts the properties.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="items">The items.</param>
        private static void ExtractProperties(ILoadoutInfo loadoutInfo, IDictionary<string, List<string>> items)
        {
            // Add "empty slot" mentions for every slot type
            foreach (EvePropertyValue prop in loadoutInfo.Ship.Properties.Where(prop => prop.Property != null))
            {
                // High Slots
                if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[0]))
                {
                    int highSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                        CultureConstants.InvariantCulture);

                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[0]) && items[LoadoutHelper.OrderedSlotNames[0]].Count < highSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[0]].Add("[empty high slot]");
                    }
                }
                // Medium Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[1]))
                {
                    int medSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                        CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[1]) && items[LoadoutHelper.OrderedSlotNames[1]].Count < medSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[1]].Add("[empty med slot]");
                    }
                }
                // Low Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[2]))
                {
                    int lowSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                        CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[2]) && items[LoadoutHelper.OrderedSlotNames[2]].Count < lowSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[2]].Add("[empty low slot]");
                    }
                }
                // Rig Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[3]))
                {
                    int rigsSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                        CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[3]) && items[LoadoutHelper.OrderedSlotNames[3]].Count < rigsSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[3]].Add("[empty rig slot]");
                    }
                }
                // Subsystem Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[4]))
                {
                    int subSysSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                        CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[4]) && items[LoadoutHelper.OrderedSlotNames[4]].Count < subSysSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[4]].Add(String.Empty);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Extracts the properties.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="items">The items.</param>
        private static void ExtractProperties(ILoadoutInfo loadoutInfo, IDictionary <string, List <string> > items)
        {
            // Add "empty slot" mentions for every slot type
            foreach (EvePropertyValue prop in loadoutInfo.Ship.Properties.Where(prop => prop.Property != null))
            {
                // High Slots
                if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[0]))
                {
                    int highSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                                                CultureConstants.InvariantCulture);

                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[0]) && items[LoadoutHelper.OrderedSlotNames[0]].Count < highSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[0]].Add("[empty high slot]");
                    }
                }
                // Medium Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[1]))
                {
                    int medSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                                               CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[1]) && items[LoadoutHelper.OrderedSlotNames[1]].Count < medSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[1]].Add("[empty med slot]");
                    }
                }
                // Low Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[2]))
                {
                    int lowSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                                               CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[2]) && items[LoadoutHelper.OrderedSlotNames[2]].Count < lowSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[2]].Add("[empty low slot]");
                    }
                }
                // Rig Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[3]))
                {
                    int rigsSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                                                CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[3]) && items[LoadoutHelper.OrderedSlotNames[3]].Count < rigsSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[3]].Add("[empty rig slot]");
                    }
                }
                // Subsystem Slots
                else if (prop.Property.Name.Contains(LoadoutHelper.OrderedSlotNames[4]))
                {
                    int subSysSlots = Int32.Parse(Regex.Replace(prop.Value, @"[^\d]", String.Empty),
                                                  CultureConstants.InvariantCulture);
                    while (items.ContainsKey(LoadoutHelper.OrderedSlotNames[4]) && items[LoadoutHelper.OrderedSlotNames[4]].Count < subSysSlots)
                    {
                        items[LoadoutHelper.OrderedSlotNames[4]].Add(String.Empty);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Exports to clipboard.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="loadout">The loadout.</param>
        public static void ExportToClipboard(ILoadoutInfo loadoutInfo, Loadout loadout)
        {
            Dictionary<string, List<string>> items = GetItemsBySlots(loadout.Items);
            ExtractProperties(loadoutInfo, items);
            string exportText = SerializeToEFTFormat(loadoutInfo, loadout, items);

            // Copy to clipboard
            try
            {
                Clipboard.Clear();
                Clipboard.SetText(exportText);
            }
            catch (ExternalException ex)
            {
                // There is a bug that results in an exception being
                // thrown when the clipboard is in use by another process
                ExceptionHandler.LogException(ex, true);
            }
        }
示例#5
0
        /// <summary>
        /// Exports to clipboard.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="loadout">The loadout.</param>
        public static void ExportToClipboard(ILoadoutInfo loadoutInfo, Loadout loadout)
        {
            Dictionary <string, List <string> > items = GetItemsBySlots(loadout.Items);

            ExtractProperties(loadoutInfo, items);
            string exportText = SerializeToEFTFormat(loadoutInfo, loadout, items);

            // Copy to clipboard
            try
            {
                Clipboard.Clear();
                Clipboard.SetText(exportText);
            }
            catch (ExternalException ex)
            {
                // There is a bug that results in an exception being
                // thrown when the clipboard is in use by another process
                ExceptionHandler.LogException(ex, true);
            }
        }
示例#6
0
 /// <summary>
 /// Extracts the properties.
 /// </summary>
 /// <param name="loadoutInfo">The loadout information.</param>
 /// <param name="items">The items.</param>
 private static void ExtractProperties(ILoadoutInfo loadoutInfo, IDictionary <string, List <string> > items)
 {
     // Add "empty slot" mentions for every slot type
     foreach (EvePropertyValue prop in loadoutInfo.Ship.Properties.Where(prop => prop.Property != null))
     {
         for (int i = 0; i < 5; i++)
         {
             string slotName = LoadoutHelper.OrderedSlotNames[i], empty;
             // Fill slots by type
             if (prop.Property.Name.Contains(slotName))
             {
                 int slots;
                 NOT_DIGITS.Replace(prop.Value, string.Empty).TryParseInv(out slots);
                 empty = EMPTY_SLOTS[i];
                 while (items.ContainsKey(slotName) && items[slotName].Count < slots)
                 {
                     items[slotName].Add(empty);
                 }
                 break;
             }
         }
     }
 }
示例#7
0
        /// <summary>
        /// Serializes to EFT format.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="loadout">The loadout.</param>
        /// <param name="items">The items.</param>
        /// <returns></returns>
        private static string SerializeToEFTFormat(ILoadoutInfo loadoutInfo, Loadout loadout,
                                                   IDictionary <string, List <string> > items)
        {
            string name;
            // Build the output format for EFT
            StringBuilder exportText = new StringBuilder();

            exportText.AppendLine($"[{loadoutInfo.Ship.Name}, {loadout.Name} (EVEMon)]");

            // Slots in order: Low, Medium, High, Rig, Subsystem
            foreach (int index in SLOT_ORDER)
            {
                name = LoadoutHelper.OrderedSlotNames[index];
                if (items.ContainsKey(name))
                {
                    // Same function as appending the joined string, but faster
                    foreach (string slotItem in items[name])
                    {
                        exportText.AppendLine(slotItem);
                    }
                    exportText.AppendLine();
                }
            }

            // Drones need quantity
            name = LoadoutHelper.OrderedSlotNames[6];
            if (items.ContainsKey(name))
            {
                foreach (var itemName in items[name].GroupBy(itemName => itemName))
                {
                    exportText.AppendLine($"{itemName.Key} x{itemName.Count()}");
                }
            }

            return(exportText.ToString());
        }
        /// <summary>
        /// Updates the loadout feed information.
        /// </summary>
        /// <param name="e">The <see cref="LoadoutFeedEventArgs"/> instance containing the event data.</param>
        private void UpdateLoadoutFeedInfo(LoadoutFeedEventArgs e)
        {
            if (IsDisposed)
            {
                return;
            }

            // Restore the default cursor instead of the waiting one
            Cursor          = Cursors.Default;
            btnPlan.Enabled = false;

            if (Settings.LoadoutsProvider.Provider == null)
            {
                return;
            }

            // Was there an error ?
            if (e.HasError)
            {
                throbberLoadouts.State = ThrobberState.Strobing;
                lblLoadouts.Text       = $"There was a problem connecting to {Settings.LoadoutsProvider.Provider.Name}, " +
                                         $"it may be down for maintainance.{Environment.NewLine}{e.Error.Message}";

                return;
            }

            m_loadoutInfo = Settings.LoadoutsProvider.Provider.DeserializeLoadoutsFeed(m_ship, e.LoadoutFeed);

            // Are there no feeds ?
            if (!m_loadoutInfo.Loadouts.Any())
            {
                throbberLoadouts.State = ThrobberState.Strobing;
                lblLoadouts.Text       = $"There are no loadouts for {m_ship.Name}, " +
                                         $"why not submit one to {Settings.LoadoutsProvider.Provider.Name}?";
                return;
            }

            // Add the listview items for every loadout
            foreach (Loadout loadout in m_loadoutInfo.Loadouts)
            {
                ListViewItem lvi = new ListViewItem(loadout.Name)
                {
                    Text = loadout.Name, Tag = loadout
                };
                lvi.SubItems.Add(loadout.Author);
                lvi.SubItems.Add(loadout.Rating.ToString(CultureConstants.DefaultCulture));
                lvi.SubItems.Add(loadout.SubmissionDate.ToString("G"));
                lvLoadouts.Items.Add(lvi);
            }

            // Update the header
            lblLoadouts.Text = $"Found {lvLoadouts.Items.Count} loadouts";

            // Update the listview's comparer and sort
            lvLoadouts.Sort();
            UpdateSortVisualFeedback();

            // Adjust the size of the columns
            AdjustColumns();

            throbberLoadouts.State           = ThrobberState.Stopped;
            persistentSplitContainer.Visible = lvLoadouts.Items.Count > 0;
        }
        /// <summary>
        /// Updates the loadout feed information.
        /// </summary>
        /// <param name="e">The <see cref="LoadoutFeedEventArgs"/> instance containing the event data.</param>
        private void UpdateLoadoutFeedInfo(LoadoutFeedEventArgs e)
        {
            if (IsDisposed)
                return;

            // Restore the default cursor instead of the waiting one
            Cursor = Cursors.Default;
            btnPlan.Enabled = false;

            if (Settings.LoadoutsProvider.Provider == null)
                return;

            // Was there an error ?
            if (e.HasError)
            {
                throbberLoadouts.State = ThrobberState.Strobing;
                lblLoadouts.Text = $"There was a problem connecting to {Settings.LoadoutsProvider.Provider.Name}, " +
                                   $"it may be down for maintainance.{Environment.NewLine}{e.Error.Message}";

                return;
            }

            m_loadoutInfo = Settings.LoadoutsProvider.Provider.DeserializeLoadoutsFeed(m_ship, e.LoadoutFeed);

            // Are there no feeds ?
            if (!m_loadoutInfo.Loadouts.Any())
            {
                throbberLoadouts.State = ThrobberState.Strobing;
                lblLoadouts.Text = $"There are no loadouts for {m_ship.Name}, " +
                                   $"why not submit one to {Settings.LoadoutsProvider.Provider.Name}?";
                return;
            }

            // Add the listview items for every loadout
            foreach (Loadout loadout in m_loadoutInfo.Loadouts)
            {
                ListViewItem lvi = new ListViewItem(loadout.Name) { Text = loadout.Name, Tag = loadout };
                lvi.SubItems.Add(loadout.Author);
                lvi.SubItems.Add(loadout.Rating.ToString(CultureConstants.DefaultCulture));
                lvi.SubItems.Add(loadout.SubmissionDate.ToString("G"));
                lvLoadouts.Items.Add(lvi);
            }

            // Update the header
            lblLoadouts.Text = $"Found {lvLoadouts.Items.Count} loadouts";

            // Update the listview's comparer and sort
            lvLoadouts.Sort();
            UpdateSortVisualFeedback();

            // Adjust the size of the columns
            AdjustColumns();

            throbberLoadouts.State = ThrobberState.Stopped;
            persistentSplitContainer.Visible = lvLoadouts.Items.Count > 0;
        }
示例#10
0
        /// <summary>
        /// Serializes to EFT format.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="loadout">The loadout.</param>
        /// <param name="items">The items.</param>
        /// <returns></returns>
        private static string SerializeToEFTFormat(ILoadoutInfo loadoutInfo, Loadout loadout,
                                                   IDictionary <string, List <string> > items)
        {
            // Build the output format for EFT
            StringBuilder exportText = new StringBuilder();

            exportText
            .AppendLine($"[{loadoutInfo.Ship.Name}, {loadout.Name} (EVEMon)]");

            // Low Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[2]))
            {
                exportText
                .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[2]].ToArray()))
                .AppendLine();
            }

            // Medium Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[1]))
            {
                exportText
                .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[1]].ToArray()))
                .AppendLine();
            }

            // High Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[0]))
            {
                exportText
                .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[0]].ToArray()))
                .AppendLine();
            }

            // Rig Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[3]))
            {
                exportText
                .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[3]].ToArray()))
                .AppendLine();
            }

            // Subsystem Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[4]))
            {
                exportText
                .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[4]].ToArray()))
                .AppendLine();
            }

            // Drones
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[6]))
            {
                foreach (IGrouping <string, string> itemName in items[LoadoutHelper.OrderedSlotNames[6]]
                         .GroupBy(itemName => itemName))
                {
                    exportText
                    .AppendLine($"{itemName.Key} x{itemName.Count()}");
                }
            }

            return(exportText.ToString());
        }
示例#11
0
        /// <summary>
        /// Serializes to EFT format.
        /// </summary>
        /// <param name="loadoutInfo">The loadout information.</param>
        /// <param name="loadout">The loadout.</param>
        /// <param name="items">The items.</param>
        /// <returns></returns>
        private static string SerializeToEFTFormat(ILoadoutInfo loadoutInfo, Loadout loadout,
            IDictionary<string, List<string>> items)
        {
            // Build the output format for EFT
            StringBuilder exportText = new StringBuilder();
            exportText
                .AppendLine($"[{loadoutInfo.Ship.Name}, {loadout.Name} (EVEMon)]");

            // Low Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[2]))
            {
                exportText
                    .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[2]].ToArray()))
                    .AppendLine();
            }

            // Medium Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[1]))
            {
                exportText
                    .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[1]].ToArray()))
                    .AppendLine();
            }

            // High Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[0]))
            {
                exportText
                    .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[0]].ToArray()))
                    .AppendLine();
            }

            // Rig Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[3]))
            {
                exportText
                    .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[3]].ToArray()))
                    .AppendLine();
            }

            // Subsystem Slots
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[4]))
            {
                exportText
                    .AppendLine(String.Join(Environment.NewLine, items[LoadoutHelper.OrderedSlotNames[4]].ToArray()))
                    .AppendLine();
            }

            // Drones
            if (items.ContainsKey(LoadoutHelper.OrderedSlotNames[6]))
            {
                foreach (IGrouping<string, string> itemName in items[LoadoutHelper.OrderedSlotNames[6]]
                    .GroupBy(itemName => itemName))
                {
                    exportText
                        .AppendLine($"{itemName.Key} x{itemName.Count()}");
                }
            }

            return exportText.ToString();
        }
        /// <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;
        }