public ImageIdentification() { InitializeComponent(); db_context = new PlasticDBContext(); List <Algorithm> alg_list = db_context.Algorithms.ToList(); AlgorithmListBox.DataSource = db_context.Algorithms.ToList(); AlgorithmListBox.DisplayMember = "Name"; Console.WriteLine("Identify Image Loaded!"); }
/* * This will add images specified in a directory * to a given DataSet in_dataset. Once the images * have compelted adding, it will copy the files * to a local file * * IN: * - file_path (Type: string): the path of the file directory * that contains the images to be added to the set * - in_dataset (Type: DataSet): the dataset to which the * images has to be added. */ public static void addImagesToSet(string file_path, DataSet in_dataset) { try { string[] fileEntries = Directory.GetFiles(file_path); List <Image> new_list = new List <Image>(); foreach (string fileName in fileEntries) { FileInfo file = new FileInfo(fileName); if (file.Extension != ".jpg") { continue; } new_list.Add(new Image { FileLocation = file.FullName, ImageSize = file.Length / 6, DataSetId = in_dataset.Id, IsPlastic = false }); } using (var db = new PlasticDBContext()) { in_dataset.Images = new_list; db.Images.AddRange(new_list); db.SaveChanges(); } copyToLocal(in_dataset); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public DataSetCreate() { InitializeComponent(); dataset_db = new PlasticDBContext(); Console.WriteLine("Create DataSet loaded"); }
public ObjectsView() { try { InitializeComponent(); /* * * var data = (from d in algorithm_db.Algorithms select d); * AlgorithmsDataGrid.DataSource = data.ToList(); */ db_context = new PlasticDBContext(); bindingSource_algorithms = new BindingSource(); bindingSource_algorithms.DataSource = (from r in db_context.Algorithms select new { AlgorithmId = r.AlgorithmId, Name = r.Name }).ToList(); AlgorithmsDataGrid.DataSource = bindingSource_algorithms; //Loads dataset data bindingSource_datasets = new BindingSource(); bindingSource_datasets.DataSource = (from r in db_context.DataSets select new { Id = r.Id, AlgorithmId = r.AlgorithmId, Algorithm = r.Algorithm.Name, NumImages = r.NumImages, NumImagesPlastic = r.NumImagesPlastic, NumImagesNotPlastic = r.NumImagesNotPlastic, Name = r.Name, Trained = r.Trained }).ToList(); DataSetsDataGrid.DataSource = bindingSource_datasets; //Load images data bindingsource_images = new BindingSource(); bindingsource_images.DataSource = (from r in db_context.Images select new { ImageId = r.Id, ImageSize = r.ImageSize, FileLocation = r.FileLocation, IsPlasic = r.IsPlastic, Id = r.Id }).ToList(); ImageDataGrid.DataSource = bindingsource_images; //Loads hardwareusage data bindingsource_hardwareusage = new BindingSource(); bindingsource_hardwareusage.DataSource = (from r in db_context.HardwareUsages select new { HardwareUsageId = r.Id, Si_Unit = r.SI_Unit, Id = r.Id }).ToList(); HardwareUsageDataGrid.DataSource = bindingsource_hardwareusage; AddAlgorithmBtn.Visible = false; AlgorithmInputField.Visible = false; Console.WriteLine("Objects view loaded"); } catch (Exception ex) { MessageBox.Show("An error occurrer while initiating objects view: " + ex.ToString()); Console.WriteLine(ex); System.Threading.Thread.CurrentThread.Abort(); } }