Beispiel #1
0
        /// <summary>
        /// Load a file into memory.
        /// </summary>
        ///
        /// This function will load a file into memory replacing
        /// whatever is already loaded.
        ///
        /// <param name="filename">The name and path of the file to load</param>
        /// <returns>Returns true if the file was successfully loaded,
        /// otherwise false is returned.</returns>
        ///
        private bool LoadFile(String filename)
        {
            bool retval = false;

            try
            {
                Autonomous_x.RouteGroup programList = null;
                programList = Autonomous_x.RouteGroup.Load(filename);

                if (programList != null)
                {
                    SaveFilename = filename;
                    AddNewRoute(programList);
                }

                retval = true;
            }
            catch (Exception ex)
            {
                String msg = String.Format("Unable to load JSON file\n{0}", ex.Message);
                MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                retval = false;
            }

            return(retval);
        }
Beispiel #2
0
        /// <summary>
        /// Kick off the process to load the data structure.
        /// </summary>
        ///
        /// See Save for a little bit more information on the process.
        /// See also the JsonConvert class for more detailed information
        /// on its workings.
        ///
        /// <param name="filepath">The name of the file to load</param>
        ///
        /// <returns>Returns true if the load is successful, otherwise false is
        /// returned.</returns>
        ///
        public static RouteGroup Load(String filepath)
        {
            RouteGroup retval = null;

            using (StreamReader sr = new StreamReader(filepath))
            {
                String json;

                json   = sr.ReadToEnd();
                retval = JsonConvert.DeserializeObject <RouteGroup>(json);
            }

            return(retval);
        }
Beispiel #3
0
 /// <summary>
 /// Create a new empty route and add it to the program list.
 /// </summary>
 ///
 /// This function sets the program modes to be the provided
 /// program list.
 ///
 /// <param name="programList">The new program list to use</param>
 ///
 private void AddNewRoute(Autonomous_x.RouteGroup programList)
 {
     mProgramModes = programList;
     UpdateRouteList();
     ProgramModeLB.SelectedIndex = 0;
 }