Example #1
0
        private async void ChannelBtn_Click(object sender, RoutedEventArgs e)
        {
            string      tag         = ((Button)sender).Tag.ToString();
            ImageSource imageSource = null;

            OpenFileDialog file = new OpenFileDialog
            {
                Filter = Helpers.ImagesFilter()
            };

            file.ShowDialog();

            if (!String.IsNullOrEmpty(file.FileName))
            {
                MagickImage img = new MagickImage(file.FileName);
                if (!img.CheckGrayscale())
                {
                    await this.ShowMessageAsync("Error!", "This image isn't grayscale!");

                    return;
                }

                imageSource = new BitmapImage(new Uri(file.FileName));
            }

            switch (tag.ToLower())
            {
            case "r":
                _channelPaths[0] = file.FileName;
                redPath.Text     = file.FileName;
                if (imageSource != null)
                {
                    RedImage.Source = imageSource;
                }
                break;

            case "g":
                _channelPaths[1] = file.FileName;
                greenPath.Text   = file.FileName;
                if (imageSource != null)
                {
                    GreenImage.Source = imageSource;
                }
                break;

            case "b":
                _channelPaths[2] = file.FileName;
                bluePath.Text    = file.FileName;
                if (imageSource != null)
                {
                    BlueImage.Source = imageSource;
                }
                break;

            case "a":
                _channelPaths[3] = file.FileName;
                alphaPath.Text   = file.FileName;
                if (imageSource != null)
                {
                    AlphaImage.Source = imageSource;
                }
                break;

            default:
                throw new ArgumentException("How? Just... how?");
            }
        }