Exemplo n.º 1
0
        /// <summary>
        /// File > Restore Plans...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miRestorePlans_Click(object sender, EventArgs e)
        {
            // Prompt the user to select a file
            using (OpenFileDialog restorePlansDialog = new OpenFileDialog())
            {
                restorePlansDialog.Title  = @"Restore from File";
                restorePlansDialog.Filter = @"EVEMon Plans Backup Format (*.epb)|*.epb";
                DialogResult dr = restorePlansDialog.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Load from file and returns if an error occurred (user has already been warned)
                IEnumerable <SerializablePlan> serial = PlanIOHelper.ImportPlansFromXML(restorePlansDialog.FileName);
                if (serial == null)
                {
                    return;
                }

                // Imports the plans
                IEnumerable <Plan> loadedPlans = serial.Select(plan => new Plan(m_character, plan));
                m_character.Plans.AddRange(loadedPlans);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handler for a context menu item click on a skill.
        /// Add the entire skill queue to a plan.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void tsmiCreatePlanFromSkillQueue_Click(object sender, EventArgs e)
        {
            if (Character == null)
            {
                return;
            }

            // Create new plan
            Plan newPlan = PlanWindow.CreateNewPlan(Character, EveMonConstants.CurrentSkillQueueText);

            if (newPlan == null)
            {
                return;
            }

            // Add skill queue to new plan and insert it on top of the plans
            bool planCreated = PlanIOHelper.CreatePlanFromCharacterSkillQueue(newPlan, Character);

            // Show the editor for this plan
            if (planCreated)
            {
                PlanWindow.ShowPlanWindow(plan: newPlan);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// File > Import Plan from File...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miImportPlanFromFile_Click(object sender, EventArgs e)
        {
            // Prompt the user to select a file
            DialogResult dr = ofdOpenDialog.ShowDialog();

            if (dr == DialogResult.Cancel)
            {
                return;
            }

            // Load from file and returns if an error occurred (user has already been warned)
            SerializablePlan serial = PlanIOHelper.ImportFromXML(ofdOpenDialog.FileName);

            if (serial == null)
            {
                return;
            }

            // Imports the plan
            Plan loadedPlan = new Plan(m_character, serial);

            // Prompt the user for the plan name
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                npw.PlanName = Path.GetFileNameWithoutExtension(ofdOpenDialog.FileName);
                DialogResult xdr = npw.ShowDialog();
                if (xdr == DialogResult.Cancel)
                {
                    return;
                }

                loadedPlan.Name        = npw.PlanName;
                loadedPlan.Description = npw.PlanDescription;
                m_character.Plans.Add(loadedPlan);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Outputs a plan or shopping list for a given character to a stream writer.
        /// </summary>
        /// <param name="context">context of the request</param>
        /// <param name="requestPath">url of the request</param>
        /// <param name="sw">stream writer to output to</param>
        /// <param name="character">character to use</param>
        private static void GeneratePlanOrShoppingOutput(string context, string requestPath, TextWriter sw, Character character)
        {
            sw.WriteLine("<h1>Hello, {0}</h1>", HttpUtility.HtmlEncode(character.Name));
            sw.WriteLine("<a href=\"/characters\">List all characters</a><hr/>");
            sw.WriteLine("<a href=\"{0}\">Character overview</a>", context);

            Regex regex =
                new Regex(
                    @"\/(owned\/(?'skillId'[^\/]+)\/(?'markOwned'[^\/]+)\/)?(?'requestType'shopping|plan)\/(?'planName'[^\/]+)(.*)",
                    RegexOptions.CultureInvariant | RegexOptions.Compiled);
            Match match = regex.Match(requestPath);

            if (match.Success)
            {
                string requestType = match.Groups["requestType"].Value;
                bool   shopping    = requestType.Equals("shopping", StringComparison.OrdinalIgnoreCase);
                string planName    = HttpUtility.UrlDecode(match.Groups["planName"].Value);

                int  skillId;
                bool setAsOwned;
                if (match.Groups["skillId"].Success &&
                    match.Groups["markOwned"].Success &&
                    Int32.TryParse(match.Groups["skillId"].Value, out skillId) &&
                    Boolean.TryParse(match.Groups["markOwned"].Value, out setAsOwned))
                {
                    Skill skill = character.Skills.FirstOrDefault(x => x.ID == skillId);
                    if (skill != null)
                    {
                        sw.WriteLine("<h2>Skillbook shopping result</h2>");
                        skill.IsOwned = setAsOwned;
                        sw.WriteLine("<a href=\"\" onclick=\"CCPEVE.showInfo({0})\">{1}</a> is now marked as {2} owned.", skill.ID,
                                     HttpUtility.HtmlEncode(skill.Name), skill.IsOwned ? String.Empty : "not");
                    }
                    else
                    {
                        // Display an error message
                        sw.WriteLine("<h2>Error Message</h2>");
                        sw.WriteLine("Skill with id '{0}' could not be found", skillId);
                    }
                    sw.WriteLine("<hr/>");
                }

                Plan plan = character.Plans[planName];
                if (plan == null)
                {
                    // Display an error message
                    sw.WriteLine("<h2>Error Message</h2>");
                    sw.WriteLine("A plan named \"{0}\" does not exist.", HttpUtility.HtmlEncode(planName));
                }
                else
                {
                    sw.WriteLine("<h2>Plan: {0}</h2>", HttpUtility.HtmlEncode(plan.Name));

                    PlanExportSettings x = new PlanExportSettings
                    {
                        // Only if not shopping
                        EntryTrainingTimes = !shopping,
                        // Only if not shopping
                        EntryStartDate = !shopping,
                        // Only if not shopping
                        EntryFinishDate = !shopping,
                        // Only if not shopping
                        FooterTotalTime = !shopping,
                        // Only if not shopping
                        FooterDate   = !shopping,
                        FooterCount  = true,
                        ShoppingList = shopping,
                        EntryCost    = true,
                        FooterCost   = true,
                        Markup       = MarkupType.Html
                    };

                    sw.Write(PlanIOHelper.ExportAsText(plan, x, ExportActions(context, requestType, plan)));
                }
            }
            else
            {
                sw.WriteLine("<h2>Error Message</h2>");
                sw.WriteLine("Invalid request");
            }

            sw.WriteLine("<br/><br/><a href=\"{0}\">Character overview</a>", context);
            sw.WriteLine("<hr/><a href=\"/characters\">List all characters</a>");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Occurs when an option change.
 /// </summary>
 private void OptionChange()
 {
     UpdateOptions();
     tbPreview.Text = PlanIOHelper.ExportAsText(m_plan, m_planTextOptions);
 }