Exemple #1
0
        private void экспортИзБазыДанныхToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BinaryFormatter bf = new BinaryFormatter();
            //OpenFileDialog openDlg = new OpenFileDialog();
            LoadMenu loadMenu = new LoadMenu();

            loadMenu.indexSave = 2;
            loadMenu.ShowDialog();

            Database databaseSQLite = new Database();

            if (loadMenu.fileName != null)
            {
                string query = "select File from SaveFilesClassification where Name=" + "\"" + loadMenu.fileName + "\"";
                databaseSQLite.OpenConnection();
                SQLiteCommand    myCommand = new SQLiteCommand(query, databaseSQLite.myConnection);
                List <SaveFiles> list      = new List <SaveFiles>();

                using (SQLiteDataReader reader = myCommand.ExecuteReader())
                {
                    if (reader.HasRows)       // если есть данные
                    {
                        while (reader.Read()) // построчно считываем данные
                        {
                            byte[]    data      = (byte[])reader.GetValue(0);
                            SaveFiles saveFile1 = new SaveFiles(data);
                            list.Add(saveFile1);
                        }
                    }
                }
                databaseSQLite.CloseConnection();
                using (FileStream fd = new FileStream("temp.dat", FileMode.OpenOrCreate))
                {
                    fd.Write(list[0].File, 0, list[0].File.Length);
                }

                FileStream fs = new FileStream("temp.dat", FileMode.Open, FileAccess.Read);
                currentClass = (ObjectClass)bf.Deserialize(fs);
                classes      = currentClass.listBrushes;
                foreach (ObjectClass brushes in classes)
                {
                    brushes.brush = ObjectClass.brushes[brushes.id];
                }
                currentClass.brush        = ObjectClass.brushes[currentClass.id];
                ObjectClass.singleValueID = classes.Last().ids.Last() + 1;
                //net.AccessChangeNet = true;
                fs.Close();
                DrawGraphics();
                DrawObjects();
                Refresh();
            }
        }
Exemple #2
0
        //Загрузка
        private void DeserializeNet(object sender, EventArgs e)
        {
            BinaryFormatter bf = new BinaryFormatter();
            //OpenFileDialog openDlg = new OpenFileDialog();
            LoadMenu loadMenu = new LoadMenu();

            loadMenu.indexSave = 0;
            loadMenu.ShowDialog();
            if (loadMenu.fileName != null)
            {
                string query = "select File from SaveFiles where Name=" + "\"" + loadMenu.fileName + "\"";
                databaseSQLite.OpenConnection();
                SQLiteCommand    myCommand = new SQLiteCommand(query, databaseSQLite.myConnection);
                List <SaveFiles> list      = new List <SaveFiles>();

                using (SQLiteDataReader reader = myCommand.ExecuteReader())
                {
                    if (reader.HasRows)       // если есть данные
                    {
                        while (reader.Read()) // построчно считываем данные
                        {
                            byte[]    data      = (byte[])reader.GetValue(0);
                            SaveFiles saveFile1 = new SaveFiles(data);
                            list.Add(saveFile1);
                        }
                    }
                }
                databaseSQLite.CloseConnection();
                using (FileStream fd = new FileStream("temp.dat", FileMode.OpenOrCreate))
                {
                    fd.Write(list[0].File, 0, list[0].File.Length);
                }

                FileStream fs = new FileStream("temp.dat", FileMode.Open, FileAccess.Read);
                Net = (NeuronNet)bf.Deserialize(fs);
                net.AccessChangeNet = true;
                fs.Close();
            }
        }