// void Released(object sender, ManipulationDeltaRoutedEventArgs e) // { // if (e.IsInertial) e.Complete(); // // setColor(Color.FromArgb(CA.Value, CR.Value, CG.Value, CB.Value)); // // setColor(Color.FromArgb(255, CR.Value, CG.Value, CB.Value)); // } // public SolidColorBrush BrushDef // { // get { return ColorDef.Background as SolidColorBrush; } // set { ColorDef.Background = value; setColor(value.Color); } // } // public SolidColorBrush BrushSel // { // get { return ColorSel.Background as SolidColorBrush; } // set { ColorSel.Background = value; } // } public void set(LayerPaint.Color c, float h, float s, float b) { // BrushSel.Color = c; // //CA.Value = c.A; // CR.Value = c.R; // CG.Value = c.G; // CB.Value = c.B; int cr = (r - (int)SlideSel.Width) / 2; //修改角度 var vp = LayerPaint.Vec2.forAngle(90 - h, cr); //SlideSel.Margin = new Thickness(vp.X, vp.Y, 0, 0); SlideSel.SetValue(Canvas.LeftProperty, (vp.X) + cr); SlideSel.SetValue(Canvas.TopProperty, (vp.Y) + cr); //修改坐标 PickSel.SetValue(Canvas.LeftProperty, (s) * W - f); PickSel.SetValue(Canvas.TopProperty, (1 - b) * W - f); angle = (int)h; (PickSel.Fill as SolidColorBrush).Color = c; /* * g.Color = c; * g.fillRect(0, 0, 10, 10); * g.Invalidate(); */ drawPick(); }
public void init() { // CA.ManipulationDelta += Released; // CR.ManipulationDelta += Released; // CG.ManipulationDelta += Released; // CB.ManipulationDelta += Released; Pick.PointerPressed += (s, e) => { if (e.Pointer.IsInContact) { if (HoverElement == null) { HoverElement = Pick; Point p = e.GetCurrentPoint(Pick).Position; p.X = Math.Max(Math.Min(p.X, W), 0); p.Y = Math.Max(Math.Min(p.Y, W), 0); setColor(angle, p.X / W, 1 - p.Y / W); } } }; Slide.PointerPressed += (s, e) => { if (e.Pointer.IsInContact) { if (HoverElement == null) { HoverElement = Slide; Point p = e.GetCurrentPoint(Slide).Position;//圈圈坐标 double x = (double)PickSel.GetValue(Canvas.LeftProperty) + f; double y = (double)PickSel.GetValue(Canvas.TopProperty) + f; setColor(LayerPaint.Vec2.getAngle(p.X - W, p.Y - W), x / W, 1 - y / W); } } }; PointerReleased += (s, e) => { MainBrush.Color = (PickSel.Fill as SolidColorBrush).Color; HoverElement = null; }; PointerMoved += (s, e) => { if (HoverElement == Slide) //圈圈 { Point p = e.GetCurrentPoint(Slide).Position; //圈圈坐标 double x = (double)PickSel.GetValue(Canvas.LeftProperty) + f; double y = (double)PickSel.GetValue(Canvas.TopProperty) + f; setColor(LayerPaint.Vec2.getAngle(p.X - W, p.Y - W), x / W, 1 - y / W); } ; if (HoverElement == Pick)//方方 { Point p = e.GetCurrentPoint(Pick).Position; p.X = Math.Max(Math.Min(p.X, W), 0); p.Y = Math.Max(Math.Min(p.Y, W), 0); setColor(angle, p.X / W, 1 - p.Y / W); } if (HoverElement != null && !loc) { loc = true; Dispatcher.RunIdleAsync(ss => { MainBrush.Color = (PickSel.Fill as SolidColorBrush).Color; loc = false; }).ToString(); } }; }