Esempio n. 1
0
 public static void SaveToFile(string fileName, BetaSimResults results)
 {
     System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(BetaSimResults));
     using (var stream = File.OpenWrite(fileName))
     {
         x.Serialize(stream, results);
     }
 }
Esempio n. 2
0
        public SimResultsNode(BlenXProjectNode root, ProjectElement element)
            : base(root, element)
        {
            simResultsFileName = root.ProjectFolder + Path.DirectorySeparatorChar + "Results.sim";
            package = root.BlenXPackage;
            bool simFilePresent = false;
            if (File.Exists(simResultsFileName))
            {
                try
                {
                    simResults = BetaSimResults.LoadFromFile(simResultsFileName);
                    if (simResults != null)
                        simFilePresent = true;
                }
                catch
                {
                    simFilePresent = false;
                }
            }
            if (!simFilePresent)
            {
                // create a new, empty one
                simResults = new BetaSimResults();
                BetaSimResults.SaveToFile(simResultsFileName, simResults);
            }

            Debug.Assert(simResults != null);

            // Refresh window
            var window = package.FindToolWindow(typeof(BetaSimToolWindow), 0, true) as BetaSimToolWindow;
            if (window != null)
            {
                // Add
                window.Update(simResults.ResultList);
            }
        }