public ResizeVIewModel(MyImage mainImage) { _imageToResize = mainImage; Width = _imageToResize.BitmapImage.Width; Height = _imageToResize.BitmapImage.Height; PreserveAspectRatio = true; _save = new RelayCommand(this.SaveOverImage, this.CanSaveOverImage); }
private void ProcessImageFolder() { try { string imagePath = args[args.Length - 1]; string folderPath = ""; int lastIndexOf = (imagePath.LastIndexOf("\\")); folderPath = imagePath.Substring(0, lastIndexOf + 1); _images = GetImages(@folderPath); MainMyImage = new MyImage(_images.ElementAt(currentIndex)); } catch (NotSupportedException) { try { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\ITVC\TImageViewer\ErrorLog.txt", true)) { DateTime localDate = DateTime.Now; file.WriteLine(localDate.ToString() + " " + "Nije se moglo NotSupportedException"); } } catch (DirectoryNotFoundException) { DirectoryInfo di = Directory.CreateDirectory("C:\\Users\\Public\\ITVC\\TImageViewer"); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\ITVC\TImageViewer\ErrorLog.txt", true)) { DateTime localDate = DateTime.Now; file.WriteLine(localDate.ToString() + " " + "Nije se moglo NotSupportedException"); } } } catch (NullReferenceException) { try { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\ITVC\TImageViewer\ErrorLog.txt", true)) { DateTime localDate = DateTime.Now; file.WriteLine(localDate.ToString() + " " + "Nije se moglo NullReferenceException"); } } catch (DirectoryNotFoundException) { DirectoryInfo di = Directory.CreateDirectory("C:\\Users\\Public\\ITVC\\TImageViewer"); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\ITVC\TImageViewer\ErrorLog.txt", true)) { DateTime localDate = DateTime.Now; file.WriteLine(localDate.ToString() + " " + "Nije se moglo NullReferenceException"); } } } }
private void AddPhotosToView() // za tipku za dodavanje slika -> dodaje samo označene slike { var photoFileDialog = new Microsoft.Win32.OpenFileDialog { Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.exif|Joint Photographic Expert Group (*.jpg, *.jpeg)|*.jpg;*.jpeg|Portable Network Graphics (*.png)|*.png|Bitmap (*.bmp)|*.bmp|Graphics Interchange Format (*.gif)|*.gif|Exchangable Image File Format (*.exif)|*.exif", InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), Title = "Select Images to View", Multiselect = true }; if (photoFileDialog.ShowDialog() == true) { ObservableCollection <string> images = new ObservableCollection <string>(); foreach (String file in photoFileDialog.FileNames) { images.Add(file); } _images = images; currentIndex = 0; MainMyImage = new MyImage(_images.ElementAt(currentIndex)); } }
public FullScreenViewModel(MyImage mainImage, ObservableCollection <string> images, int imageIndex) { _mainMyImage = mainImage; _images = images; currentIndex = imageIndex; _playerVisibility = Visibility.Collapsed; _menuVisibility = Visibility.Collapsed; _cmdPreviousImage = new RelayCommand(this.PreviousImage_Executed, this.PreviousImage_CanExecute); _cmdNextImage = new RelayCommand(this.NextImage_Executed, this.NextImage_CanExecute); _closeWidnow = new RelayCommand(this.CloseWindow_Execute, this.CanCloseWindow); _closeApplication = new RelayCommand(this.CloseApplication_Executed, this.CanCloseApplication); _runSlideShow = new RelayCommand(this.SlideShow_Execute, this.CanRunSlideShow); _StopSlideShow = new RelayCommand(this.StopSlideShow_Execute, this.CanStopSlideShow); _mouseMove = new RelayCommand(this.MoveMouse_Executed, this.CanMoveMouse); MoveMouseCommand = new RelayCommand <MouseEventArgs>(e => { var element = e.OriginalSource as UIElement; //var point = e.GetPosition(element); Window currWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); var point = Mouse.GetPosition(currWindow); double difference = (currWindow.ActualHeight * 0.10f); double borderHeight = currWindow.ActualHeight - difference; if (point.Y >= borderHeight) { PlayerVisibility = Visibility.Visible; } else if (point.Y < borderHeight) { PlayerVisibility = Visibility.Collapsed; if (point.Y < difference) { MenuVisibility = Visibility.Visible; } else { MenuVisibility = Visibility.Collapsed; } } Console.WriteLine("Position: {0}x{1}", point.X, point.Y); }); }
private void NextImage_Executed() { MainMyImage = new MyImage(_images.ElementAt(++currentIndex)); }
private void PreviousImage_Executed() { MainMyImage = new MyImage(_images.ElementAt(--currentIndex)); }
public FullScreenWindow(MyImage mainImage, ObservableCollection <string> images, int imageIndex) { InitializeComponent(); DataContext = new FullScreenViewModel(mainImage, images, imageIndex); }
public ResizeWindow(MyImage mainImage) { InitializeComponent(); DataContext = new ResizeVIewModel(mainImage); }
void ChangeMetadata(MyImage currentImage) { // mjenja metadatau za trenutnu sliku ExIfMain = new ExIfMetadata(currentImage.ImagePath, currentImage.BitmapImage); }