예제 #1
0
        private void SetCommands()
        {
            this.ShowImageCommand = new RelayCommand(() =>
            {
                dynamic pars    = new DynamicNavigationParameters();
                pars.Attachment = this;
                (Window.Current.Content as Frame).Navigate(typeof(FeedbackImagePage), pars);
            });

            SaveImageCommand = new RelayCommand(async() =>
            {
                ImageBuffer  = await Canvas.SaveAsPngIntoBufferAsync();
                InitialImage = await ImageBuffer.AsBitmapImageAsync();
                (Window.Current.Content as Frame).Navigate(typeof(FeedbackFormPage), this);
            });
            DeleteImageCommand = new RelayCommand(() =>
            {
                MarkedAsDeleted = true;
                (Window.Current.Content as Frame).Navigate(typeof(FeedbackFormPage), this);
            });
            ResetImageCommand = new RelayCommand(() =>
            {
                Canvas.Children.Clear();
                Canvas.Background = InitialImage.AsImageBrush();
            });
            CloseImageCommand = new RelayCommand(() => { (Window.Current.Content as Frame).GoBack(); });
        }
예제 #2
0
        internal async void OrientationChanged(Canvas canvas, Image image)
        {
            if (this.IsReadOnly)
            {
                image.Height = ScreenResolution.HeightWithoutScale;
            }
            else
            {
                this.IsBusy = true;
                BitmapImage attachImage = this.InitialImage;
                double      width = attachImage.PixelWidth, height = attachImage.PixelHeight;
                if (Math.Max(attachImage.PixelWidth, attachImage.PixelHeight) > ScreenResolution.HeightWithoutScale)
                {
                    if (attachImage.PixelWidth > attachImage.PixelHeight)
                    {
                        width  = ScreenResolution.HeightWithoutScale;
                        height = ScreenResolution.HeightWithoutScale * ((double)attachImage.PixelHeight / attachImage.PixelWidth);
                    }
                    else
                    {
                        height = ScreenResolution.HeightWithoutScale;
                        width  = ScreenResolution.HeightWithoutScale * ((double)attachImage.PixelWidth / attachImage.PixelHeight);
                    }
                }
                if (canvas.Children.Any())
                {
                    this.ImageBuffer = await canvas.SaveAsPngIntoBufferAsync();

                    InitialImage = await ImageBuffer.AsBitmapImageAsync();

                    canvas.Background = this.InitialImage.AsImageBrush();
                    canvas.Children.Clear();
                }
                canvas.Width  = width;
                canvas.Height = height;
                this.IsBusy   = false;
            }
        }