Exemplo n.º 1
0
        /// <summary>
        /// Processes the images and updates the views
        /// </summary>
        private void UpdateImages()
        {
            try
            {
                Updated = true;
                // Validating views
                ValidateViewsEnablity();
                // Validating the number of image in case changing of marker type
                NumberOfCurrentImage = clamp(CurrentImageNumber, 1, UserData.GetCountOfParcedImages(MarkerType));
                // updating data if have parced images
                if (UserData.GetCountOfParcedImages(MarkerType) > 0)
                {
                    // Getting source image
                    string      pathToSource = UserData.GetPathToImage(NumberOfCurrentImage - 1, MarkerType);
                    BitmapImage sourceImage  = new BitmapImage(new Uri(pathToSource));

                    // Setting images depending on marker type
                    if (MarkerType == UserData.MARKER_TYPE_FRAME)
                    {
                        // Setting the <Image> views
                        MainImageSource = sourceImage;
                        // Here we getting image with drawn frames
                        ChangedImage1Source = ImageCollection.GetFramed(NumberOfCurrentImage - 1);
                        // Empty image
                        ChangedImage2Source = null;
                    }
                    else
                    {
                        // Getting collection of masked images
                        List <BitmapImage> maskedImages = new List <BitmapImage>();
                        maskedImages.AddRange(ImageCollection.GetMasks(NumberOfCurrentImage - 1, UserData.CroppingType));
                        // Setting the <Image> views
                        MainImageSource = sourceImage;
                        // Here is two source images croppes by two marker-symbols from .csv file
                        ChangedImage1Source = maskedImages[0];
                        ChangedImage2Source = maskedImages[1];
                    }
                    // Setting the path to lable
                    PathToCurrentImage = pathToSource;

                    // Disposing the memory
                    GC.Collect();
                }
            }
            catch (Exception e)
            {
                string           messageBoxText = e.Message;
                string           caption        = "Couldn't open image";
                MessageBoxButton button         = MessageBoxButton.OK;
                MessageBoxImage  icon           = MessageBoxImage.Warning;
                MessageBox.Show(messageBoxText, caption, button, icon);
                ResetViews();
            }
        }
Exemplo n.º 2
0
        private void UpdateImages()
        {
            try
            {
                ValidateViewsEnablity();
                // updating data if have parced images
                if (GetCountOfParcedImages(MarkerType) > 0)
                {
                    // Getting source image
                    string      pathToSource = GetPathToImage(CurrentImageNumber - 1, MarkerType);
                    BitmapImage sourceImage  = new BitmapImage(new Uri(pathToSource));

                    // Drawing markers
                    BitmapImage markedImage;
                    if (MarkerType == MARKER_TYPE_FRAME)
                    {
                        markedImage = ImageCollection.GetFramed(CurrentImageNumber - 1);
                    }
                    else
                    {
                        markedImage = ImageCollection.GetMasks(CurrentImageNumber - 1, UserData.CroppingType)[0];
                    }
                    // Processing effcts
                    BitmapImage processedImage = ImageCollection.GetProcessed(markedImage, Effects);

                    PathToCurrentImage = pathToSource;
                    MainImageSource    = sourceImage;
                    EditedImageSource  = processedImage;

                    // Disposing the memory
                    GC.Collect();
                }
            }
            catch (Exception e)
            {
                string           messageBoxText = e.Message;
                string           caption        = "Couldn't open image";
                MessageBoxButton button         = MessageBoxButton.OK;
                MessageBoxImage  icon           = MessageBoxImage.Error;
                System.Windows.MessageBox.Show(messageBoxText, caption, button, icon);
                ResetViews();
            }
        }