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

Load() public method

Reads a file with a serialized model.
public Load ( string path ) : void
path string Path to the .tsm file
return void
        public void Load(string path)
        {
            Stream stream = null;
            try
            {
                if (ModelReset != null)
                    ModelReset(this, EventArgs.Empty);
                new Serializer.Deserializer(this).Deserialize(path);
            //    stream = File.Open(path, FileMode.Open);
            //    BinaryFormatter bformatter = new BinaryFormatter();
            //    undoManager.Enabled = false;
            //    string version = (string)bformatter.Deserialize(stream);
            //    uint activeLayerID = (uint)bformatter.Deserialize(stream);
            //    this.layers = (ItemList<Layer>)bformatter.Deserialize(stream);
            //    activeLayer = layers[activeLayerID];

            //    this.sections = SectionManager.Instance["modelCatalog"];
            //    this.sections.Load(stream, bformatter);
            //    if (sections.Count == 0)
            //        sections[SectionManager.Instance.DefaultSection.Name] = SectionManager.Instance.DefaultSection;

            //    Dictionary<string, LoadCase> lcTemp = (Dictionary<string, LoadCase>)bformatter.Deserialize(stream);
            //    this.loadCases = new ManagedDictionary<string, LoadCase>(lcTemp);

            //    List<AbstractCase> acList = (List<AbstractCase>)bformatter.Deserialize(stream);
            //    this.abstractCases = new ManagedList<AbstractCase>(acList);
            //    abstractCases.ElementRemoved += new ManagedList<AbstractCase>.ListChangedEventHandler(abstractCases_ElementRemoved);

            //    this.jointList = (ItemList<Joint>)bformatter.Deserialize(stream);
            //    List<Constraint> conList = (List<Constraint>)bformatter.Deserialize(stream);
            //    this.constraintList = new ManagedList<Constraint>(conList);

            //    this.lineList = (ItemList<LineElement>)bformatter.Deserialize(stream);
            //    this.areaList = (ItemList<AreaElement>)bformatter.Deserialize(stream);

            //    this.isLocked = (bool)bformatter.Deserialize(stream);
            //    this.results = (Canguro.Model.Results.Results)bformatter.Deserialize(stream);

            //    if (stream.Position < stream.Length)
            //    {
            //        designOptions = (List<DesignOptions>)bformatter.Deserialize(stream);

            //        string steel = (string)bformatter.Deserialize(stream);
            //        string conc = (string)bformatter.Deserialize(stream);
            //        string alum = (string)bformatter.Deserialize(stream);
            //        string cold = (string)bformatter.Deserialize(stream);
            //        foreach (DesignOptions opt in designOptions)
            //        {
            //            if (opt.ToString().Equals(steel))
            //                steelDesignOptions = opt;
            //            else if (opt.ToString().Equals(conc))
            //                concreteDesignOptions = opt;
            //            else if (opt.ToString().Equals(alum))
            //                aluminumDesignOptions = opt;
            //            else if (opt.ToString().Equals(cold))
            //                coldFormedDesignOptions = opt;
            //        }
            //    }

            //    foreach (LoadCase current in loadCases.Values)
            //    {
            //        activeLoadCase = current;
            //        break;
            //    }

                new Canguro.Model.Serializer.ModelRepairer().Repair(this);

                currentPath = path;
                ChangeModel();
                undoManager = new UndoManager(this);
                undoManager.Enabled = true;

                // If Results exists and there's no ModelCommand currently in execution, run GetResultsCmd
                // If a ModelCommand called Load, then it's the responsibility of that command to call GetResultsCommand
                if (results.AnalysisID != 0 && !results.Finished && Controller.Controller.Instance.ModelCommand == null)
                    Controller.Controller.Instance.Execute("getresults");

                this.modified = false;
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(Culture.Get("fileNotFound") + ": '" + path + "'");
                throw e;
            }
            finally
            {
                if (stream != null)
                    stream.Close();
            }
        }