Exemplo n.º 1
0
        public static MemoryList Restore()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                          + "\\FlexRadio Systems\\";
            string file_name = path + "memory.xml";

            MemoryList mem_list = new MemoryList();

            if (!File.Exists(file_name))
            {
                return(mem_list);                         // no file, just return an empty list
            }
            StreamReader reader = new StreamReader(file_name);

            try
            {
                XmlSerializer ser = new XmlSerializer(typeof(MemoryList),
                                                      new Type[] { typeof(MemoryRecord), typeof(SortableBindingList <MemoryRecord>), typeof(int) });
                mem_list = (MemoryList)ser.Deserialize(reader);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            reader.Close();

            return(mem_list);
        }
Exemplo n.º 2
0
        //======================================================================================================================
        public static MemoryList Restore()
        {
            string path          = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FlexRadio Systems\\";
            string file_name     = path + "memory.xml";
            string bak_file_name = path + "memory_bak.xml";

            MemoryList mem_list = new MemoryList();

            StreamReader reader;

            try
            {
                if (!File.Exists(file_name))
                {
                    throw new FileNotFoundException();
                }

                reader = new StreamReader(file_name);

                XmlSerializer ser = new XmlSerializer(typeof(MemoryList), new Type[] { typeof(MemoryRecord), typeof(SortableBindingList <MemoryRecord>), typeof(int) });

                mem_list = (MemoryList)ser.Deserialize(reader);

                // save backup file
                mem_list.Save(bak_file_name);
            }
            catch (Exception ex1)
            {
                Debug.WriteLine(ex1);
                // check to see if backup file exists
                // if so, try to deserialize it
                if (!File.Exists(bak_file_name))
                {
                    return(mem_list);                             // no memory, no backup
                }
                reader = new StreamReader(bak_file_name);

                try
                {
                    XmlSerializer ser = new XmlSerializer(typeof(MemoryList),
                                                          new Type[] { typeof(MemoryRecord), typeof(SortableBindingList <MemoryRecord>), typeof(int) });
                    mem_list = (MemoryList)ser.Deserialize(reader);
                }
                catch (Exception ex2)
                {
                    Debug.WriteLine(ex2);
                }
            }

            reader.Close();

            return(mem_list);  // return memory listing to memory form window datagridview1
        } // restore
Exemplo n.º 3
0
        public static MemoryList Restore()
        {
            // DG8MG
            // string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
            //         + "\\FlexRadio Systems\\";

            // Changed the path variable for the memory list,
            // to use the same application data base directory as the rest of PowerSDR mRX PS Charly 25 HAMlab edition
            // and avoid incompatibility with other PowerSDR versions
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                          + "\\Red Pitaya\\PowerSDR mRX PS Charly25 HAMlab\\";
            // DG8MG

            string file_name = path + "memory.xml";

            MemoryList mem_list = new MemoryList();

            if (!File.Exists(file_name))
            {
                return(mem_list);                         // no file, just return an empty list
            }
            StreamReader reader = new StreamReader(file_name);

            try
            {
                XmlSerializer ser = new XmlSerializer(typeof(MemoryList),
                                                      new Type[] { typeof(MemoryRecord), typeof(SortableBindingList <MemoryRecord>), typeof(int) });
                mem_list = (MemoryList)ser.Deserialize(reader);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            reader.Close();

            return(mem_list);
        }
Exemplo n.º 4
0
        public static MemoryList Restore()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FlexRadio Systems\\";
            string file_name = path + "memory.xml";
            string bak_file_name = path + "memory_bak.xml";

            MemoryList mem_list = new MemoryList();
            StreamReader reader;

            try
            {
                if (!File.Exists(file_name))
                {
                    throw new FileNotFoundException();
                }

                reader = new StreamReader(file_name);

                XmlSerializer ser = new XmlSerializer(typeof(MemoryList),
                    new Type[] { typeof(MemoryRecord), typeof(SortableBindingList<MemoryRecord>), typeof(int) });
                mem_list = (MemoryList)ser.Deserialize(reader);

                // save backup file
                mem_list.Save(bak_file_name);
            }
            catch (Exception ex1)
            {
                Debug.WriteLine(ex1);
                // check to see if backup file exists
                // if so, try to deserialize it
                if(!File.Exists(bak_file_name)) return mem_list;  // no memory, no backup

                reader = new StreamReader(bak_file_name);

                try
                {
                    XmlSerializer ser = new XmlSerializer(typeof(MemoryList),
                    new Type[] { typeof(MemoryRecord), typeof(SortableBindingList<MemoryRecord>), typeof(int) });
                    mem_list = (MemoryList)ser.Deserialize(reader);
                }
                catch (Exception ex2)
                {
                 Debug.WriteLine(ex2); 
                }
            }

            reader.Close();

            return mem_list;
        }