Ejemplo n.º 1
0
        private void reset1button_Click(object sender, RoutedEventArgs e)
        {
            if (orginalPhoto != null)
            {
                image.Source           = orginalPhoto;
                bufferredPhoto         = orginalPhoto;
                currentPhoto           = orginalPhoto;
                myConversion           = new AllConversions(orginalPhoto);
                hueSlider.Value        = 0;
                brightnessSlider.Value = 0;
                saturationSlider.Value = 1;
                contrastSlider.Value   = 1;
                thresholdSlider.Value  = 50;
                currentPhoto           = orginalPhoto;
                deleteShapes();
                selectionPowerChbx.IsChecked = false;
                changeChbxState(false);
            }
            else
            {
                showMessageBox();
            }

            checkIfHistogramOpen();
        }
Ejemplo n.º 2
0
        private void openButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect = false;
            openFileDialog.Filter      = "(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp";
            openFileDialog.Title       = "Otwórz wybrany plik w aplikacji PhotoApplication";

            if (openFileDialog.ShowDialog() == true)
            {
                orginalPhotoName = openFileDialog.FileName;
                try
                {
                    orginalPhoto                 = new BitmapImage(new Uri(orginalPhotoName));
                    currentPhoto                 = orginalPhoto;
                    bufferredPhoto               = currentPhoto;
                    image.Source                 = orginalPhoto;
                    myConversion                 = new AllConversions(orginalPhoto);
                    hueSlider.Value              = 0;
                    brightnessSlider.Value       = 0;
                    saturationSlider.Value       = 1;
                    contrastSlider.Value         = 1;
                    thresholdSlider.Value        = 50;
                    saveButton.IsEnabled         = true;
                    histogramButton.IsEnabled    = true;
                    hueSlider.IsEnabled          = true;
                    saturationSlider.IsEnabled   = true;
                    brightnessSlider.IsEnabled   = true;
                    contrastSlider.IsEnabled     = true;
                    selectionPowerChbx.IsEnabled = true;
                    selectionPowerChbx.IsChecked = false;
                    changeChbxState(false);
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                    MessageBox.Show(this, "Wybrane zdjęcie jest uszkodzone! \nWybierz inne", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None);
                }

                checkIfHistogramOpen();

                if (WindowState == WindowState.Normal)
                {
                    wndSize.Width  = ActualWidth;
                    wndSize.Height = ActualHeight;
                    WindowState    = WindowState.Maximized;
                    WindowState    = WindowState.Normal;
                }
                if (WindowState == WindowState.Maximized)
                {
                    ifMaximizedWhileOpen = true;
                    WindowState          = WindowState.Minimized;
                    WindowState          = WindowState.Minimized;
                    ifMaximizedWhileOpen = false;
                }
                deleteShapes();
            }
        }
 private void mySliders_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (bufferredPhoto != null)
     {
         myConversion = new AllConversions(bufferredPhoto);
         myConversion.doConversion1(hueSlider.Value, saturationSlider.Value, brightnessSlider.Value);
         myConversion.doConversion2(contrastSlider.Value);
         setNewImage();
     }
     checkIfHistogramOpen();
 }
 private void apply1button_Click(object sender, RoutedEventArgs e)
 {
     if (myConversion != null)
     {
         checkIfPixelsAreSet();
         bufferredPhoto         = currentPhoto;
         myConversion           = new AllConversions(bufferredPhoto);
         hueSlider.Value        = 0;
         brightnessSlider.Value = 0;
         saturationSlider.Value = 1;
         contrastSlider.Value   = 1;
     }
     else
     {
         showMessageBox();
     }
     checkIfHistogramOpen();
 }
 private void reset1button_Click(object sender, RoutedEventArgs e)
 {
     if (orginalPhoto != null)
     {
         image.Source           = orginalPhoto;
         bufferredPhoto         = orginalPhoto;
         currentPhoto           = orginalPhoto;
         myConversion           = new AllConversions(orginalPhoto);
         hueSlider.Value        = 0;
         brightnessSlider.Value = 0;
         saturationSlider.Value = 1;
         contrastSlider.Value   = 1;
         currentPhoto           = orginalPhoto;
     }
     else
     {
         showMessageBox();
     }
     checkIfHistogramOpen();
 }
        private void histogramButton_Click(object sender, RoutedEventArgs e)
        {
            if (!isHistogramOpen)
            {
                isHistogramOpen = true;
                histogramWindow = new MyHistogramWindow();

                if (myConversion != null)
                {
                    checkIfPixelsAreSet();
                }
                else
                {
                    myConversion = new AllConversions(currentPhoto);
                }

                histogramWindow.setMyPixelData(myConversion.getPixelDataRGB(), currentPhoto);
                histogramWindow.drawHistogram();
                histogramWindow.Show();
            }
        }
        private void openButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Multiselect = false;
            openFileDialog.Filter      = "(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp";
            openFileDialog.Title       = "Otwórz wybrany plik w aplikacji PhotoApplication";

            if (openFileDialog.ShowDialog() == true)
            {
                orginalPhotoName = openFileDialog.FileName;
                try
                {
                    orginalPhoto               = new BitmapImage(new Uri(orginalPhotoName));
                    currentPhoto               = orginalPhoto;
                    bufferredPhoto             = currentPhoto;
                    image.Source               = orginalPhoto;
                    myConversion               = new AllConversions(orginalPhoto);
                    hueSlider.Value            = 0;
                    brightnessSlider.Value     = 0;
                    saturationSlider.Value     = 1;
                    contrastSlider.Value       = 1;
                    thresholdSlider.Value      = 50;
                    saveButton.IsEnabled       = true;
                    histogramButton.IsEnabled  = true;
                    hueSlider.IsEnabled        = true;
                    saturationSlider.IsEnabled = true;
                    brightnessSlider.IsEnabled = true;
                    contrastSlider.IsEnabled   = true;
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                    MessageBox.Show(this, "Wybrane zdjęcie jest uszkodzone! \nWybierz inne", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.None);
                }

                checkIfHistogramOpen();
            }
        }