private void MenuFlyoutItem_Tapped(object sender, TappedRoutedEventArgs e) { var listItem = (sender as ListBoxItem).Name; if (listItem == "rotateItem") { imageState = 1; rotate = (rotate + 90) % 360; RotateTransform rotateTransform = new RotateTransform(); rotateTransform.Angle = rotate; rotateTransform.CenterX = editCanvas.Width / 2; rotateTransform.CenterY = editCanvas.Height / 2; editCanvas.RenderTransform = rotateTransform; editCanvas.Draw += editCanvas_Draw; } else if (listItem == "cutItem") { imageState = 2; if (cutmanage == null) { cutmanage = new CutManage() { cutPointX = editCanvas.Width / 4, cutPointY = editCanvas.Height / 4, cutWidth = 200, cutHeight = 200, editCanvas_Width = editCanvas.Width, editCanvas_Height = editCanvas.Height }; iscut = true; } } editCanvas.Invalidate(); editCanvas.Draw += editCanvas_Draw; }
private void editCanvas_Tapped(object sender, TappedRoutedEventArgs e) { var p = e.GetPosition(editCanvas); if (cutmanage != null) { if ((cutmanage as CutManage).LeftTopPoint.Contains(p)) //取消 { cutmanage = null; editCanvas.Invalidate(); return; } if ((cutmanage as CutManage).RightTopPoint.Contains(p)) //OK { // cutok = true; iscuted = true; editCanvas.Draw += editCanvas_Draw; return; } if ((cutmanage as CutManage).cutArea.Contains(p)) //点击的是 剪切对象 区域 { return; } } if (_wall_paperUI != null) { if ((_wall_paperUI as StickManage).RightTopRegion.Contains(p)) { _wall_paperUI = null; editCanvas.Invalidate(); return; } if ((_wall_paperUI as StickManage).Region.Contains(p)) { (_wall_paperUI as StickManage).Editing = !(_wall_paperUI as StickManage).Editing; editCanvas.Invalidate(); return; } } }
private void DrawBackImage(CanvasDrawingSession graphics, double scale) { if (editimage != null) { Rect des = GetImageDrawingRect(); des.X *= scale; des.Y *= scale; des.Width *= scale; des.Height *= scale; // 滤镜特效 //亮度 ICanvasImage image = GetBrightnessEffect(editimage); //对比度 image = GetContrastEffect(image); //饱和度 image = GetSaturationEffect(image); //锐化 image = GetSharpenEffect(image); //模糊 image = GetBlurEffect(image); ////应用滤镜模板 image = ApplyFilterTemplate(image); var width_scale = editimage.Bounds.Width / des.Width; var height_scale = editimage.Bounds.Height / des.Height; if (cutok) { left = (float)cutmanage.cutPointX; top = (float)cutmanage.cutPointY; descut.X = (cutmanage.cutPointX - des.X) * width_scale; descut.Y = (cutmanage.cutPointY - des.Y) * height_scale; descut.Width = cutmanage.cutWidth * width_scale; descut.Height = cutmanage.cutHeight * height_scale; cutok = false; cutmanage = null; } //des.Width = 100; //Vector2 vec = new Vector2(); if (iscuted) { //graphics.DrawImage(_image, left,top,descut); if (cuted) { //graphics.DrawImage(image, des, descut); //image = new AtlasEffect { Source = image, SourceRectangle = descut }; image = new CropEffect { Source = image, SourceRectangle = descut }; } else { //graphics.DrawImage(image, des, descut); //image = new AtlasEffect { Source = image, SourceRectangle = descut }; image = new CropEffect { Source = image, SourceRectangle = descut }; cuted = true; } } //else //{ // graphics.DrawImage(image, des, editimage.Bounds); //} graphics.DrawImage(image, des, editimage.Bounds); //if(cutok) //{ // image = new CropEffect { Source = image, SourceRectangle = new Rect(cutmanage.cutPointX, cutmanage.cutPointY, cutmanage.cutWidth, cutmanage.cutHeight) }; // //cutok = false; // cutmanage = null; //} //graphics.DrawImage(image, des, editimage.Bounds); } }