Canguro.Model.Model.Reset C# (CSharp) Method

Reset() public method

Destruye todo el modelo y lo deja limpio
public Reset ( ) : void
return void
        public void Reset()
        {
            try
            {
                this.undoManager = new UndoManager(this);
                undoManager.Enabled = false;
                this.abstractCases = new ManagedList<Canguro.Model.Load.AbstractCase>();
                abstractCases.ElementRemoved += new ManagedList<AbstractCase>.ListChangedEventHandler(abstractCases_ElementRemoved);
                this.activeLoadCase = null;
                this.areaList = new ItemList<AreaElement>();
                this.constraintList = new ManagedList<Constraint>();
                this.isLocked = false;
                this.jointList = new ItemList<Joint>();
                this.layers = new ItemList<Layer>();
                layers.ElementRemoved += new ManagedList<Layer>.ListChangedEventHandler(layers_ElementRemoved);
                this.lineList = new ItemList<LineElement>();
                this.loadCases = new ManagedDictionary<string, LoadCase>();
                loadCases.ElementRemoved += new ManagedDictionary<string, LoadCase>.ListChangedEventHandler(loadCases_ElementRemoved);
                this.summary = new ModelSummary(this);

                this.designOptions = new List<DesignOptions>();
                designOptions.Add(NoDesign.Instance);
                designOptions.Add(new LRFD99());
                designOptions.Add(new ACI318_02());
                designOptions.Add(new ASD01());
                designOptions.Add(new RCDF2001());
                designOptions.Add(new UBC97_ASD());
                designOptions.Add(new UBC97_LRFD());
                designOptions.Add(new UBC97_Conc());
                steelDesignOptions = NoDesign.Instance;
                concreteDesignOptions = NoDesign.Instance;
                coldFormedDesignOptions = NoDesign.Instance;
                aluminumDesignOptions = NoDesign.Instance;

                this.results = new Canguro.Model.Results.Results(0);

                // Layer es un Item y todos los Items asignan su propiedad layer
                // de acuerdo a ActiveLayer, por lo que hay que asignarla en null
                // antes de crear el primer Layer, root de todos los demás
                activeLayer = null;
                Layer rootLayer = new Layer(Culture.Get("defaultLayerName"));
                ActiveLayer = rootLayer;

                activeLoadCase = new LoadCase(Culture.Get("defaultLoadCase"), LoadCase.LoadCaseType.Dead);
                activeLoadCase.SelfWeight = 1.0f;
                loadCases.Add(activeLoadCase.Name, activeLoadCase);

                AnalysisCase anc = new Canguro.Model.Load.AnalysisCase(Culture.Get("defaultLoadCase"));
                AbstractCases.Add(anc);
                if (anc != null)
                {
                    StaticCaseProps props = anc.Properties as StaticCaseProps;
                    if (props != null)
                    {
                        List<StaticCaseFactor> list = props.Loads;
                        list.Add(new StaticCaseFactor(ActiveLoadCase));
                        props.Loads = list;
                    }
                }

                MaterialManager.Instance.Initialize();
                SectionManager.Instance.Initialize(ref sections);
                sections.ElementRemoved += new Catalog<Canguro.Model.Section.Section>.ListChangedEventHandler(sections_ElementRemoved);
                this.currentPath = "";
                foreach (Canguro.Model.UnitSystem.UnitSystem us in UnitSystemsManager.Instance.UnitSystems)
                    if (Properties.Settings.Default.UnitSystem.Equals(us.GetType().Name))
                        UnitSystemsManager.Instance.CurrentSystem = us;

                viewManager = Canguro.View.GraphicViewManager.Instance;
                modified = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw e;
            }
            finally
            {
                if (ModelReset != null)
                    ModelReset(this, EventArgs.Empty);
                undoManager.Enabled = true;
            }
        }

Usage Example

示例#1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Windows Vista Virtualization Problem FIX
            if (fixVistaVirtualizationError())
            {
                return;
            }
            // End of Windows Vista FIX

            Utility.Updater updater = new Utility.Updater();
            if (updater.Update())
            {
                return;
            }

            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;

            Splash.Show(3000);
            Model.Model             model      = Model.Model.Instance;
            Controller.Controller   controller = Controller.Controller.Instance;
            View.GraphicViewManager view       = View.GraphicViewManager.Instance;
            model.Reset();
            //TestModel(model);

            using (MainFrm frm = new MainFrm())
            {
                frm.Show();

                try
                {
                    view.InitializeGraphics(frm.ScenePanel, frm);

                    controller.MainFrm = frm;

                    if (args.Length > 0)
                    {
                        controller.LoadModel(args[0]);
                    }

                    //////// TESTS /////////////
                    //TestView(view);
                    //model.AbstractCases.Add(new Canguro.Model.Load.AnalysisCase("aCase1"));
                    //Model.Load.AnalysisCase anc = model.AbstractCases[0] as Model.Load.AnalysisCase;
                    //if (anc != null)
                    //{
                    //    Model.Load.StaticCaseProps props = anc.Properties as Model.Load.StaticCaseProps;
                    //    if (props != null)
                    //    {
                    //        List<Model.Load.StaticCaseFactor> list = props.Loads;
                    //        list.Add(new Canguro.Model.Load.StaticCaseFactor(model.ActiveLoadCase));
                    //        props.Loads = list;
                    //    }
                    //}
                    ////////// END TESTS /////////////
                    Application.Run(frm);
                    //              Model.Model.Instance.Save();
                    controller.Execute("cancel");
                    updater.CancelDownload();
                    updater.InstallUpdate();
                }

#if DEBUG
                catch (View.NoDirectXSupportException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError") + "\n" + ex.ToString(), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Microsoft.DirectX.DirectXException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError") + "\n" + ex.ToString(), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (NotSupportedException ex)
                {
                    MessageBox.Show(ex.Message, Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
#else
                catch (View.NoDirectXSupportException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError"), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Microsoft.DirectX.DirectXException ex)
                {
                    MessageBox.Show(Culture.Get("strDirectXFatalError"), Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (NotSupportedException ex)
                {
                    MessageBox.Show(ex.Message, Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Culture.Get("strFatalError"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
#endif
            }
        }