Пример #1
0
        private void BorrarMouseDown(object sender, RoutedEventArgs e)
        {
            ProductImageSet Image = new ProductImageSet();
            if(ImageList.SelectedItem!= null){
                try
                {
                    Image = ImageList.SelectedItem as ProductImageSet;

                    _dataDC.ProductImageSet.DeleteObject(Image);
                    _dataDC.SaveChanges();
                    ImageList.Items.Remove(Image);
                    System.IO.File.Delete(Image.Path);
                }
                catch(Exception ex) {
                    System.Windows.MessageBox.Show("Error Borrando la imagen " + Image.Name + ": " + ex.ToString());
                }
            }
        }
Пример #2
0
        private void BorrarMouseDown(object sender, RoutedEventArgs e)
        {
            ProductImageSet Image = new ProductImageSet();

            if (ImageList.SelectedItem != null)
            {
                try
                {
                    Image = ImageList.SelectedItem as ProductImageSet;

                    _dataDC.ProductImageSet.DeleteObject(Image);
                    _dataDC.SaveChanges();
                    ImageList.Items.Remove(Image);
                    System.IO.File.Delete(Image.Path);
                }
                catch (Exception ex) {
                    System.Windows.MessageBox.Show("Error Borrando la imagen " + Image.Name + ": " + ex.ToString());
                }
            }
        }
Пример #3
0
        private void OnDrop(object sender, DragEventArgs e)
        {
            var data = e.Data as DataObject;

            if (data.ContainsFileDropList())
            {
                var files = data.GetFileDropList();
                foreach (string file in files)
                {
                    string filename = System.IO.Path.GetFileName(file);
                    if (imagelist.Where(S => S.Name == filename).Count() == 0)
                    {
                        ProductImageSet newImage = new ProductImageSet();
                        newImage.ProducID = _productID;
                        newImage.Path     = file;
                        newImage.Name     = filename;
                        Ramdom r = new Ramdom();
                        newImage.ImageID = r.RandomString(32);
                        newImage.Order   = 0;
                        imagelist.Add(newImage);
                        _dataDC.ProductImageSet.AddObject(newImage);
                        _dataDC.SaveChanges();
                        string destinationFile = Properties.Settings.Default.ImagePath + "\\" + ProductID + "\\" + filename;
                        if (!System.IO.Directory.Exists(Properties.Settings.Default.ImagePath + "\\" + ProductID))
                        {
                            System.IO.Directory.CreateDirectory(Properties.Settings.Default.ImagePath + "\\" + ProductID);
                        }
                        System.IO.File.Copy(file, destinationFile);
                        imageViewer.Source    = LoadImageFromFile(destinationFile);
                        ImageList.ItemsSource = imagelist.Where(S => S.ProducID == _productID).ToList();
                    }
                    else
                    {
                        MessageBox.Show("La imagen" + filename + " ya ha sido añadida anteriormente");
                    }
                }
            }
        }
Пример #4
0
        private void ImageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ProductImageSet image = ImageList.SelectedItem as ProductImageSet;

            imageViewer.Source = LoadImageFromFile(image.Path);
        }
 public BaseResponse AddProductImage(ProductImageSet image)
 {
     return((BaseResponse)_businessOperation.AddProductImage(image));
 }
Пример #6
0
 private void OnDrop(object sender, DragEventArgs e)
 {
     var data = e.Data as DataObject;
     if (data.ContainsFileDropList())
     {
         var files = data.GetFileDropList();
         foreach (string file in files)
         {
             string filename = System.IO.Path.GetFileName(file);
             if (imagelist.Where(S => S.Name == filename).Count() == 0)
             {
                 ProductImageSet newImage = new ProductImageSet();
                 newImage.ProducID = _productID;
                 newImage.Path = file;
                 newImage.Name = filename;
                 Ramdom r = new Ramdom();
                 newImage.ImageID = r.RandomString(32);
                 newImage.Order = 0;
                 imagelist.Add(newImage);
                 _dataDC.ProductImageSet.AddObject(newImage);
                 _dataDC.SaveChanges();
                 string destinationFile = Properties.Settings.Default.ImagePath + "\\" + ProductID + "\\" + filename;
                 if(!System.IO.Directory.Exists(Properties.Settings.Default.ImagePath + "\\" + ProductID ))
                 {
                 System.IO.Directory.CreateDirectory(Properties.Settings.Default.ImagePath + "\\" + ProductID);
                 }
                 System.IO.File.Copy(file, destinationFile);
                 imageViewer.Source = LoadImageFromFile(destinationFile);
                 ImageList.ItemsSource = imagelist.Where(S => S.ProducID == _productID).ToList();
             }
             else
             {
                 MessageBox.Show("La imagen" + filename + " ya ha sido añadida anteriormente");
             }
         }
     }
 }