/// <summary>
        /// Executes the command.
        /// Opens the properties window to edit the Active Load Case.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Canguro.Model.Load.LoadCase lCase = services.Model.ActiveLoadCase;
            string name = lCase.Name;
            //services.GetProperties(name, lCase, false);

            EditLoadCaseDialog dlg = new EditLoadCaseDialog(lCase);

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!name.Equals(lCase.Name))
                {
                    foreach (Canguro.Model.Load.AbstractCase aCase in services.Model.AbstractCases)
                    {
                        if (name.Equals(aCase.Name) && aCase is Canguro.Model.Load.AnalysisCase)
                        {
                            aCase.Name = lCase.Name;
                        }
                    }
                }

                services.Model.ChangeModel();
            }
            else
            {
                services.Model.Undo.Rollback();
            }
        }
Example #2
0
 private void CopyLoads(Canguro.Model.Model model, Element from, Element to)
 {
     from.Loads.Repair();
     Canguro.Model.Load.LoadCase active = model.ActiveLoadCase;
     foreach (Canguro.Model.Load.LoadCase lCase in model.LoadCases.Values)
     {
         ItemList <Canguro.Model.Load.Load> copy = from.Loads[lCase];
         ItemList <Canguro.Model.Load.Load> list = to.Loads[lCase];
         if (list != null && list.Count > 0)
         {
             for (int i = list.Count; i > 0; i--)
             {
                 list.RemoveAt(i - 1);
             }
         }
         if (copy != null)
         {
             foreach (Canguro.Model.Load.Load l in copy)
             {
                 if (l != null)
                 {
                     Canguro.Model.Load.Load nl = (Canguro.Model.Load.Load)l.Clone();
                     nl.Id = 0;
                     to.Loads.Add(nl, lCase);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Executes the command.
        /// Deletes the selected Items.
        /// If none is selected, it requests a selection.
        /// </summary>
        /// <param name="services">CommandServices object to interact with the system</param>
        public override void Run(Canguro.Controller.CommandServices services)
        {
            Canguro.Model.Model model = services.Model;
            if (model.LoadCases.Count > 1)
            {
                Canguro.Model.Load.LoadCase oldCase = model.ActiveLoadCase;

                // Remove associated AnalysisCase
                // Find the corresponding AbstractCase
                Canguro.Model.Load.AnalysisCase aCase = null;
                foreach (Canguro.Model.Load.AbstractCase ac in services.Model.AbstractCases)
                {
                    if (ac is Canguro.Model.Load.AnalysisCase && ac.Name.Equals(oldCase.Name))
                    {
                        aCase = (Canguro.Model.Load.AnalysisCase)ac;
                        break;
                    }
                }

                bool deleteLCase = true;
                // Now remove the AnalysisCase
                if (aCase != null)
                {
                    deleteLCase = services.Model.AbstractCases.Remove(aCase);
                }

                if (deleteLCase)
                {
                    services.Model.LoadCases.Remove(oldCase.Name);
                    services.Model.ChangeModel();
                }
            }
        }