/// <summary> /// 布局命令 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LayoutCommand_Tapped(object sender, TappedRoutedEventArgs e) { var layout_command = sender as GridViewItem; if (layout_command == LayoutCommand1) //白边 填充 { _stretch = (_stretch == Stretch.Uniform) ? Stretch.UniformToFill : Stretch.Uniform; (LayoutCommand1_Panel.Children[1] as TextBlock).Text = (_stretch == Stretch.Uniform) ? "填充" : "白边"; } else if (layout_command == LayoutCommand2) //黑底 白底 { _back_color = (_back_color == Colors.White) ? Colors.Black : Colors.White; (LayoutCommand2_Panel.Children[1] as TextBlock).Text = (_back_color == Colors.White) ? "黑底" : "白底"; } else if (layout_command == LayoutCommand3) //画布比例 { _size_mode = (_size_mode + 1) % 3; var t = ""; if (_size_mode == 0) { t = "4:3"; } else if (_size_mode == 1) { t = "3:4"; } else { t = "1:1"; } (LayoutCommand3_Panel.Children[1] as TextBlock).Text = t; } else if (layout_command == LayoutCommand4) //旋转 { _rotate = (_rotate + 90) % 360; } else if (layout_command == LayoutCommand5) //剪切 { if (_cropUI == null) { _cropUI = new CropUI() { Top = 20, Left = 20, Height = 100, Width = 100, DrawColor = Colors.Orange }; } } else if (layout_command == LayoutCommand6) //重选底图 { SelectImage(); } MainCanvas.Invalidate(); SetCanvas(); }
private void ResetControls() { EditionValue.Copy(DefaultValue); CropUI.ResetCrop(); CropUI.SetThumbAsync(null); rawImage?.ResetCrop(); SetImageSizeText(); ImageBoxPlain.Visibility = Visibility.Collapsed; ResetButtonVisibility.Value = false; BeforeToggle.IsChecked = false; HideCropUI(); //reset color picker ColorPickerShadow.Color = ColorPickerHighlight.Color = Colors.White; }
//Always call in the UI thread private void EmptyImage() { //empty the previous image data rawImage = null; ImageBoxPlain.Source = null; CropUI.SetThumbAsync(null); //empty the image display ImageBox.Source = null; //empty the exif data History?.Clear(); ExifSource.Source = null; //empty the histogram ControlVisibilty.Value = false; ResetControls(); DisplayImage(null, false); ; Histo.ClearAsync(); GC.Collect(); }
private async void CropButton_TappedAsync(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { if (rawImage?.fullSize != null) { CropUI.SetThumbAsync(null); Load.Show(); // Blur(true); ControlVisibilty.Value = false; //display the crop UI CropGrid.Visibility = Visibility.Visible; //wait for accept or reset pressed uint h, w; if (EditionValue.Rotation == 1 || EditionValue.Rotation == 3) { h = rawImage.preview.UncroppedDim.width; w = rawImage.preview.UncroppedDim.height; } else { h = rawImage.preview.UncroppedDim.height; w = rawImage.preview.UncroppedDim.width; } double factor; if (w > h) { factor = ImageDisplay.ActualWidth / (w); } else { factor = ImageDisplay.ActualHeight / (h + 160); } CropUI.SetSize((int)(w * factor * 0.7), (int)(h * factor * 0.7), EditionValue.Rotation); ImageComponent<ushort> img = new ImageComponent<ushort>(rawImage.preview) { offset = new Point2D(), dim = new Point2D(rawImage.preview.UncroppedDim) }; rawImage.preview.dim = new Point2D(rawImage.preview.UncroppedDim); //create a preview of the image SoftwareBitmap image = await Task.Run(() => { return ApplyImageEffect8bitsNoHistoAsync(img, EditionValue); }); //display the preview CropUI.SetThumbAsync(image); } }