예제 #1
0
        /// <summary>
        /// Loads the last known state and restores it.
        /// <param name="designer">The designer to load into</param>
        /// </summary>
        public static void TryLoad(UcTreeDesigner designer)
        {
            //No designer, nothing to do.
            if (designer == null)
            {
                return;
            }

            //If loading is disabled by config -> do not load.
            var load = true;

            bool.TryParse(Singleton <SmaSTraConfiguration> .Instance.GetConfigOption(SmaSTraConfiguration.LoadLastStatePath, "true"), out load);
            if (!load)
            {
                return;
            }

            //Finally load if we have a file!
            var path = Path.Combine(WorkSpace.DIR, FileName);

            if (File.Exists(path))
            {
                TreeSerilizer.Deserialize(designer.Tree, path);
            }
        }
예제 #2
0
        /// <summary>
        /// Loads a saved state and restores it.
        /// </summary>
        public void LoadFromFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "SmaSTra Save file|*.SmaSTra";
            openFileDialog.InitialDirectory = Environment.CurrentDirectory;

            //show the dialog and save the file
            if (openFileDialog.ShowDialog() == true)
            {
                TreeSerilizer.Deserialize(OutputNode.Tree, openFileDialog.FileName);
            }
        }