コード例 #1
0
ファイル: SaveLoad.cs プロジェクト: ebosscha/RailML-Neural
 public static void ProtoSaveToFile(object sender, DoWorkEventArgs e)
 {
     try
     {
         worker = sender as BackgroundWorker;
         string       filename = e.Argument as string;
         SaveLoadData data     = new SaveLoadData();
         data.railml = XML.ToXElement <railml>(Data.DataContainer.model).ToString();
         data.NN     = DataContainer.NeuralNetwork;
         if (DataContainer.NeuralNetwork.Network != null)
         {
             data.network = SerializeNetwork();
         }
         if (DataContainer.NeuralNetwork.Data != null)
         {
             data.trainingset = SerializeDataSet();
         }
         MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);
         stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
         Serializer.Serialize(stream, data);
         stream.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex + "      Inner Exception: " + ex.InnerException);
         worker.ReportProgress(1, ex + "      Inner Exception: " + ex.InnerException);
     }
 }
コード例 #2
0
ファイル: SaveLoad.cs プロジェクト: ebosscha/RailML-Neural
        public static void LoadFile(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;
            string   filename = e.Argument as string;
            MyStream stream   = new MyStream(filename, FileMode.Open, FileAccess.Read);

            stream.ProgressChanged += new ProgressChangedEventHandler(Load_ProgressChanged);
            IFormatter   formatter = new BinaryFormatter();
            SaveLoadData data      = (SaveLoadData)formatter.Deserialize(stream);
            XElement     elem      = XElement.Parse(data.railml);

            DataContainer.model         = XML.FromXElement <railml>(elem);
            DataContainer.NeuralNetwork = data.NN;
            stream.Close();
        }
コード例 #3
0
ファイル: SaveLoad.cs プロジェクト: ebosscha/RailML-Neural
        public static void SaveToFile(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;
            string       filename = e.Argument as string;
            SaveLoadData data     = new SaveLoadData();

            data.railml = XML.ToXElement <railml>(Data.DataContainer.model).ToString();
            data.NN     = DataContainer.NeuralNetwork;
            MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);

            stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
            IFormatter formatter = new BinaryFormatter();

            formatter.Serialize(stream, data);
            stream.Close();
        }
コード例 #4
0
ファイル: SaveLoad.cs プロジェクト: ebosscha/RailML-Neural
        public static void ProtoLoadFile(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;
            string   filename = e.Argument as string;
            MyStream stream   = new MyStream(filename, FileMode.Open, FileAccess.Read);

            stream.ProgressChanged += new ProgressChangedEventHandler(Load_ProgressChanged);
            SaveLoadData data = Serializer.Deserialize <SaveLoadData>(stream);
            XElement     elem = XElement.Parse(data.railml);

            DataContainer.model         = XML.FromXElement <railml>(elem);
            DataContainer.NeuralNetwork = data.NN;
            if (data.trainingset != null)
            {
                DataContainer.NeuralNetwork.Data = DeserializeDataSet(data.trainingset);
            }
            if (data.network != null)
            {
                DataContainer.NeuralNetwork.Network = DeserializeNetwork(data.network);
            }
            stream.Close();
        }
コード例 #5
0
ファイル: SaveLoad.cs プロジェクト: ebosscha/RailML-Neural
 public static void SaveToFile(object sender, DoWorkEventArgs e )
 {
     worker = sender as BackgroundWorker;
     string filename = e.Argument as string;
     SaveLoadData data = new SaveLoadData();
     data.railml = XML.ToXElement<railml>(Data.DataContainer.model).ToString();
     data.NN = DataContainer.NeuralNetwork;
     MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);
     stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
     IFormatter formatter = new BinaryFormatter();
     formatter.Serialize(stream, data);
     stream.Close();
 }
コード例 #6
0
ファイル: SaveLoad.cs プロジェクト: ebosscha/RailML-Neural
 public static void ProtoSaveToFile(object sender, DoWorkEventArgs e)
 {
     try
     {
         worker = sender as BackgroundWorker;
         string filename = e.Argument as string;
         SaveLoadData data = new SaveLoadData();
         data.railml = XML.ToXElement<railml>(Data.DataContainer.model).ToString();
         data.NN = DataContainer.NeuralNetwork;
         if (DataContainer.NeuralNetwork.Network != null) { data.network = SerializeNetwork(); }
         if (DataContainer.NeuralNetwork.Data != null) { data.trainingset = SerializeDataSet(); }
         MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);
         stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
         Serializer.Serialize(stream, data);
         stream.Close();
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex + "      Inner Exception: " + ex.InnerException);
         worker.ReportProgress(1, ex + "      Inner Exception: " + ex.InnerException);
     }
 }