Пример #1
0
        /// <summary>
        /// Edit > Rename
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miRename_Click(object sender, EventArgs e)
        {
            // Quit if none selected
            if (lbPlanList.SelectedItems.Count == 0)
            {
                return;
            }

            // Prompts the user for a new name
            var plan = lbPlanList.SelectedItems[0].Tag as Plan;

            using (NewPlanWindow f = new NewPlanWindow())
            {
                f.Text     = "Rename Plan";
                f.PlanName = plan.Name;
                DialogResult dr = f.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Change the name
                plan.Name = f.Result;
                UpdateContent(true);
            }
        }
Пример #2
0
        /// <summary>
        /// Edit > Rename...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miRenameEdit_Click(object sender, EventArgs e)
        {
            // Quit if none selected
            if (lbPlanList.SelectedItems.Count == 0)
            {
                return;
            }

            // Prompts the user for a new name
            Plan plan = (Plan)lbPlanList.SelectedItems[0].Tag;

            using (NewPlanWindow f = new NewPlanWindow())
            {
                f.Text            = @"Rename Plan or Edit Description";
                f.PlanName        = plan.Name;
                f.PlanDescription = plan.Description;
                DialogResult dr = f.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Change the name
                plan.Name        = f.PlanName;
                plan.Description = f.PlanDescription;
                UpdateContent(true);
            }
        }
Пример #3
0
        /// <summary>
        /// Merge the selected plans.
        /// </summary>
        private void MergePlans()
        {
            // Build the merge plan
            var result = new Plan(m_character);

            using (result.SuspendingEvents())
            {
                // Merge the plans
                foreach (ListViewItem item in lbPlanList.SelectedItems)
                {
                    Plan plan = (Plan)item.Tag;
                    foreach (PlanEntry entry in plan)
                    {
                        // If not planned yet, we add the new entry
                        if (!result.IsPlanned(entry.Skill, entry.Level))
                        {
                            result.PlanTo(entry.Skill, entry.Level, entry.Priority, entry.Notes);
                        }

                        // Then we update the entry's groups
                        var newEntry = result.GetEntry(entry.Skill, entry.Level);

                        // The entry may be null if the character already knows it.
                        if (newEntry != null)
                        {
                            newEntry.PlanGroups.Add(plan.Name);
                        }
                    }
                }
            }

            // Request a new name for this plan
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Change the plan's name and add it
                result.Name = npw.Result;
                m_character.Plans.Add(result);
            }
        }
Пример #4
0
        /// <summary>
        /// Occurs when the user clicks one of the children of the "Plans" menu.
        /// The item may be an existing plan or the "New plan" item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsddbPlans_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Tag == m_plan)
            {
                return;
            }

            // Is it another plan ?
            if (e.ClickedItem.Tag != null)
            {
                var plan   = (Plan)e.ClickedItem.Tag;
                var window = WindowsFactory <PlanWindow> .GetByTag(plan);

                // Opens the existing window when there is one, or switch to this plan when no window opened.
                if (window != null)
                {
                    window.BringToFront();
                }
                else
                {
                    Plan = plan;
                }

                return;
            }

            // So it is "new plan"
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                var plan = new Plan(Character)
                {
                    Name = npw.Result
                };
                Character.Plans.Add(plan);
                Plan = plan;
            }
        }
Пример #5
0
        /// <summary>
        /// File > Load plan from file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miLoadPlanFromFile_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 occured (user has already been warned)
            var serial = PlanExporter.ImportFromXML(ofdOpenDialog.FileName);

            if (serial == null)
            {
                return;
            }

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

            loadedPlan.Import(serial);

            // Cleans any obsolete entries and fixes the prerequisites
            loadedPlan.CleanObsoleteEntries();
            loadedPlan.Fix();

            // 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.Result;
                m_character.Plans.Add(loadedPlan);
            }
        }
Пример #6
0
        /// <summary>
        /// File > New plan.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miNewPlan_Click(object sender, EventArgs e)
        {
            // Request a new name for this plan
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Create the plan and add it
                var plan = new Plan(m_character);
                plan.Name = npw.Result;
                m_character.Plans.Add(plan);

                // Open a window for this plan
                WindowsFactory <PlanWindow> .ShowByTag(plan);
            }

            this.Close();
        }
Пример #7
0
        /// <summary>
        /// File > Load plan from character.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miLoadPlanFromCharacter_Click(object sender, EventArgs e)
        {
            // Prompt the user to choose the source character and plan.
            using (PlanImportationFromCharacterForm cps = new PlanImportationFromCharacterForm(m_character))
            {
                DialogResult dr = cps.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Retrieves the cloned plan
                var plan = cps.TargetPlan;

                // Cleans any obsolete entries and fixes the prerequisites
                plan.CleanObsoleteEntries();
                plan.Fix();

                // Prompt the user for the new plan's name
                using (NewPlanWindow f = new NewPlanWindow())
                {
                    f.PlanName = m_character.Name + "-" + plan.Name;
                    f.Text     = "Save Plan As";

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

                    plan.Name = f.Result;
                }

                // Add the plan to the character's list
                m_character.Plans.Add(plan);
            }
        }
Пример #8
0
        /// <summary>
        /// File > Import Plan from Character....
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miImportPlanFromCharacter_Click(object sender, EventArgs e)
        {
            // Prompt the user to choose the source character and plan.
            using (PlanImportationFromCharacterWindow cps = new PlanImportationFromCharacterWindow(m_character))
            {
                DialogResult dr = cps.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Retrieves the cloned plan
                Plan plan = cps.TargetPlan;

                // Adds and fixes the prerequisites order
                plan.FixPrerequisites();

                // Prompt the user for the new plan's name
                using (NewPlanWindow f = new NewPlanWindow())
                {
                    f.PlanName = $"{m_character.Name}-{plan.Name}";
                    f.Text     = @"Save Plan As";

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

                    plan.Name        = f.PlanName;
                    plan.Description = f.PlanDescription;
                }

                // Add the plan to the character's list
                m_character.Plans.Add(plan);
            }
        }
Пример #9
0
        /// <summary>
        /// File > New plan...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miNewPlan_Click(object sender, EventArgs e)
        {
            // Request a new name for this plan
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                {
                    return;
                }

                // Create the plan and add it
                Plan plan = new Plan(m_character)
                {
                    Name = npw.PlanName, Description = npw.PlanDescription
                };
                m_character.Plans.Add(plan);

                // Open a window for this plan
                PlanWindow.ShowPlanWindow(plan: plan);
            }

            Close();
        }
Пример #10
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);
            }
        }
Пример #11
0
        /// <summary>
        /// File > Load plan from file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miLoadPlanFromFile_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)
            var serial = PlanExporter.ImportFromXML(ofdOpenDialog.FileName);
            if (serial == null)
                return;

            // Imports the plan
            Plan loadedPlan = new Plan(m_character);
            loadedPlan.Import(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.Result;
                m_character.Plans.Add(loadedPlan);
            }
        }
Пример #12
0
        /// <summary>
        /// Merge the selected plans.
        /// </summary>
        private void MergePlans()
        {
            // Build the merge plan
            var result = new Plan(m_character);
            using (result.SuspendingEvents())
            {
                // Merge the plans
                foreach (ListViewItem item in lbPlanList.SelectedItems)
                {
                    Plan plan = (Plan)item.Tag;
                    foreach (PlanEntry entry in plan)
                    {
                        // If not planned yet, we add the new entry
                        if (!result.IsPlanned(entry.Skill, entry.Level))
                            result.PlanTo(entry.Skill, entry.Level, entry.Priority, entry.Notes);

                        // Then we update the entry's groups
                        var newEntry = result.GetEntry(entry.Skill, entry.Level);

                        // The entry may be null if the character already knows it.
                        if (newEntry != null)
                            newEntry.PlanGroups.Add(plan.Name);
                    }
                }
            }

            // Request a new name for this plan
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Change the plan's name and add it
                result.Name = npw.Result;
                m_character.Plans.Add(result);
            }
        }
Пример #13
0
        /// <summary>
        /// File > Load plan from character.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miLoadPlanFromCharacter_Click(object sender, EventArgs e)
        {
            // Prompt the user to choose the source character and plan.
            using (PlanImportationFromCharacterForm cps = new PlanImportationFromCharacterForm(m_character))
            {
                DialogResult dr = cps.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Retrieves the cloned plan
                var plan = cps.TargetPlan;

                // Adds and fixes the prerequisites order
                plan.Fix();

                // Prompt the user for the new plan's name
                using (NewPlanWindow f = new NewPlanWindow())
                {
                    f.PlanName = m_character.Name + "-" + plan.Name;
                    f.Text = "Save Plan As";

                    dr = f.ShowDialog();
                    if (dr == DialogResult.Cancel)
                        return;

                    plan.Name = f.Result;
                }

                // Add the plan to the character's list
                m_character.Plans.Add(plan);
            }
        }
Пример #14
0
        /// <summary>
        /// Context > Copy to new plan...
        /// Opens a dialog to prompt the user for a name and create a plan with the selected entries.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miCopyToNewPlan_Click(object sender, EventArgs e)
        {
            IList<PlanEntry> entries = SelectedEntries.ToList();
            if (!entries.Any())
                return;

            // Ask the user for a new name
            string planName,
                   planDescription;
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;
                planName = npw.PlanName;
                planDescription = npw.PlanDescription;
            }

            // Create a new plan
            Plan newPlan = new Plan(m_character) { Name = planName, Description = planDescription };
            IPlanOperation operation = newPlan.TryAddSet(entries, $"Exported from {m_plan.Name}");
            operation.Perform();

            // Add plan and save
            m_character.Plans.Add(newPlan);
        }
Пример #15
0
        /// <summary>
        /// File > New plan...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miNewPlan_Click(object sender, EventArgs e)
        {
            // Request a new name for this plan
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Create the plan and add it
                Plan plan = new Plan(m_character) { Name = npw.PlanName, Description = npw.PlanDescription };
                m_character.Plans.Add(plan);

                // Open a window for this plan
                PlanWindow.ShowPlanWindow(plan: plan);
            }

            Close();
        }
Пример #16
0
        /// <summary>
        /// Plans > New Plan...
        /// Displays the "New Plan" window.
        /// </summary>
        /// <param name="sender">menu item clicked</param>
        /// <param name="e"></param>
        private void tsmiNewPlan_Click(object sender, EventArgs e)
        {
            Character character = GetCurrentCharacter();
            if (character == null)
                return;

            // Ask the user for a new name
            Plan newPlan;
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Create a new plan
                newPlan = new Plan(character)
                {
                    Name = npw.PlanName,
                    Description = npw.PlanDescription
                };
            }

            // Add plan and save
            character.Plans.Add(newPlan);

            // Show the editor for this plan
            PlanWindow.ShowPlanWindow(plan: newPlan);
        }
Пример #17
0
        /// <summary>
        /// Occurs when the user clicks one of the children of the "Plans" menu.
        /// The item may be an existing plan or the "New plan" item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsddbPlans_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Tag == m_plan)
                return;

            // Is it another plan ?
            if (e.ClickedItem.Tag != null)
            {
                var plan = (Plan)e.ClickedItem.Tag;
                var window = WindowsFactory<PlanWindow>.GetByTag(plan);

                // Opens the existing window when there is one, or switch to this plan when no window opened.
                if (window != null)
                {
                    window.BringToFront();
                }
                else
                {
                    Plan = plan;
                }

                return;
            }

            // So it is "new plan"
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                var plan = new Plan(Character)
                {
                    Name = npw.Result
                };
                Character.Plans.Add(plan);
                Plan = plan;
            }
        }
Пример #18
0
        /// <summary>
        /// Edit > Rename...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miRenameEdit_Click(object sender, EventArgs e)
        {
            // Quit if none selected
            if (lbPlanList.SelectedItems.Count == 0)
                return;

            // Prompts the user for a new name
            Plan plan = (Plan)lbPlanList.SelectedItems[0].Tag;
            using (NewPlanWindow f = new NewPlanWindow())
            {
                f.Text = @"Rename Plan or Edit Description";
                f.PlanName = plan.Name;
                f.PlanDescription = plan.Description;
                DialogResult dr = f.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Change the name
                plan.Name = f.PlanName;
                plan.Description = f.PlanDescription;
                UpdateContent(true);
            }
        }
Пример #19
0
        /// <summary>
        /// Plans > New Plan...
        /// Displays the "New Plan" window.
        /// </summary>
        /// <param name="sender">menu item clicked</param>
        /// <param name="e"></param>
        private void newPlanMenuItem_Click(object sender, EventArgs e)
        {
            Character character = GetCurrentCharacter();
            if (character == null)
                return;

            // Ask the user for a new name
            string planName;
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                planName = npw.Result;
            }

            // Create a new plan
            Plan newPlan = new Plan(character) { Name = planName };

            // Add plan and save
            character.Plans.Add(newPlan);

            // Show the editor for this plan
            WindowsFactory<PlanWindow>.ShowByTag(newPlan);
        }
Пример #20
0
        /// <summary>
        /// File > New plan.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miNewPlan_Click(object sender, EventArgs e)
        {
            // Request a new name for this plan
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Create the plan and add it
                var plan = new Plan(m_character);
                plan.Name = npw.Result;
                m_character.Plans.Add(plan);

                // Open a window for this plan
                WindowsFactory<PlanWindow>.ShowByTag(plan);
            }

            this.Close();
        }
Пример #21
0
        /// <summary>
        /// Edit > Rename
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miRename_Click(object sender, EventArgs e)
        {
            // Quit if none selected
            if (lbPlanList.SelectedItems.Count == 0)
                return;

            // Prompts the user for a new name
            var plan = lbPlanList.SelectedItems[0].Tag as Plan;
            using (NewPlanWindow f = new NewPlanWindow())
            {
                f.Text = "Rename Plan";
                f.PlanName = plan.Name;
                DialogResult dr = f.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;

                // Change the name
                plan.Name = f.Result;
                UpdateContent(true);
            }
        }
Пример #22
0
        /// <summary>
        /// Context > Copy to new plan...
        /// Opens a dialog to prompt the user for a name and create a plan with the selected entries.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miCopyToNewPlan_Click(object sender, EventArgs e)
        {
            var entries = SelectedEntries;
            if (entries.IsEmpty())
                return;

            // Ask the user for a new name
            string planName;
            using (NewPlanWindow npw = new NewPlanWindow())
            {
                DialogResult dr = npw.ShowDialog();
                if (dr == DialogResult.Cancel)
                    return;
                planName = npw.Result;
            }

            // Create a new plan
            Plan newPlan = new Plan(Character);
            newPlan.Name = planName;
            var operation = newPlan.TryAddSet(entries, "Exported from " + m_plan.Name);
            operation.Perform();

            // Add plan and save
            Character.Plans.Add(newPlan);
        }