Exemple #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);
            }
        }
Exemple #2
0
        /// <summary>
        /// Saves the current State.
        /// <param name="designer">The designer to save from.</param>
        /// </summary>
        public static void Save(UcTreeDesigner designer)
        {
            //No designer, nothing to do.
            if (designer == null)
            {
                return;
            }

            var path = Path.Combine(WorkSpace.DIR, FileName);

            TreeSerilizer.Serialize(designer.Tree, path);
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        /// <summary>
        /// Saves the current state to a file.
        /// </summary>
        public void SaveToFile()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "All files|*";
            saveFileDialog.InitialDirectory = Environment.CurrentDirectory;

            //show the dialog and save the file
            if (saveFileDialog.ShowDialog() == true)
            {
                string name = saveFileDialog.SafeFileName;
                if (name.EndsWith(".SmaSTra"))
                {
                    name = name.Remove(".SmaSTra".Count());
                }

                string directory = System.IO.Path.GetDirectoryName(saveFileDialog.FileName);
                TreeSerilizer.Serialize(OutputNode.Tree, directory + "\\" + name + ".SmaSTra");
            }
        }