public Step3Sort() { var indexInfo = new TextBlock { Text = "0/" + Beard.KeysCount, FontSize = .3, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var indexBox = ShadowBox.SquareButton(indexInfo); indexBox.Height = indexBox.Width = r * 2; Content.Children.Add(indexBox); Moveable(indexBox); var points = Elements.Visual <Ellipse>(Beard.RawPoints, r); Elements.AddClick(indexBox, delegate { indexInfo.Text = "0/" + points.Count(); orderedPoints.Clear(); foreach (var item in points) { item.Fill = Brushes.pending; } for (int i = Content.Children.Count - 1; i >= 0; i--) { var c = Content.Children[i]; if (c is Grid && c != indexBox) { Content.Children.RemoveAt(i); } if (c is Ellipse) { (c as Ellipse).Fill = Brushes.pending; } } }, null); Action moveIndexInfo = () => { Content.Children.Remove(indexBox); Content.Children.Add(indexBox); }; EventHandler <TouchEventArgs> addTextTag = (s, e) => { var ell = s as Ellipse; var p = (Point)ell.Tag; if (orderedPoints.Contains(p)) { return; } orderedPoints.Add(p); ell.Fill = Brushes.picked; var index = orderedPoints.Count + string.Empty; indexInfo.Text = index + '/' + points.Count(); var g = Elements.Visual <Grid>(p, r); g.Children.Add(new TextBlock { Text = index, FontSize = Beard.Radius, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); Content.Children.Add(g); moveIndexInfo(); }; foreach (var item in points) { Content.Children.Add(item); item.Fill = Brushes.pending; item.TouchDown += addTextTag; } moveIndexInfo(); }
public Step1SetRadiusAndCount() { Content.Children.Add(effectPanel); Content.Children.Add(addPanel); Content.Children.Add(countPanel); countPanel.Children.Add(countGrid); for (var i = 0; i < Beard.KeysMax; i++) { countGrid.Children.Add(ShadowBox.SquareButton()); } setColor(); var fs = new List <finger>(); var d = default(InputDevice); var maxLeft = Width - countGrid.Width; countPanel.TouchLeave += (s, e) => { if (e.Device != d) { return; } d = null; }; countPanel.TouchMove += (s, e) => { e.Handled = true; if (d != null && d != e.Device) { return; } d = e.Device; var left = Inside(e, countGrid).X; countGrid.Margin = new Thickness { Left = left }; c = Beard.KeysMin + (int)(left / maxLeft * Beard.KeysRange); setColor(); }; addPanel.TouchMove += (s, e) => { var f0 = fs.FirstOrDefault(p => p.d == e.Device); if (f0 == null) { return; } f0.p = Inside(e, f0.e); if (fs.Count == 2) { var f1 = fs.First(f => f != f0); var _r = Min(MaxRadius, (f0.p - f1.p).Length / 2); if (_r > 0) { r = _r; } f0.e.Width = f1.e.Width = f0.e.Height = f1.e.Height = r * 2; setColor(); } f0.e.Margin = new Thickness { Left = f0.p.X, Top = f0.p.Y }; }; addPanel.TouchLeave += (s, e) => { var f = fs.FirstOrDefault(p => p.d == e.Device); if (f == null) { return; } fs.Remove(f); effectPanel.Children.Remove(f.e); }; addPanel.TouchDown += (s, e) => { if (fs.Count == 2) { return; } var p = e.GetTouchPoint(addPanel).Position; var ell = new Ellipse { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness { Left = p.X - r, Top = p.Y - r }, Width = r * 2, Height = r * 2, Fill = new SolidColorBrush(Colors.Black) }; fs.Add(new finger { d = e.Device, e = ell, p = p }); effectPanel.Children.Add(ell); }; }