void Pr0MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var canv = sender as Canvas; var pr = new PresentationRotor(); if (canv != null) { foreach (UIElement ui in canv.Children) { if (ui is PresentationRotor) { pr = ui as PresentationRotor; } } } if (!MainCanvas.Children.Contains(_toro)) { _toro = new Rotor3(new Rotor(SigabaConstants.ControlCipherRotors[pr.Index], pr.Position - 65, pr.Reversed), true); _toro.RenderTransform = new ScaleTransform(0.6, 0.6); MainCanvas.Children.Add(_toro); } else { MainCanvas.Children.Remove(_toro); _toro = new Rotor3(new Rotor(SigabaConstants.ControlCipherRotors[pr.Index], pr.Position - 65, pr.Reversed), true); _toro.RenderTransform = new ScaleTransform(0.6, 0.6); MainCanvas.Children.Add(_toro); } Canvas.SetRight(_toro, 525); Canvas.SetTop(_toro, 20); if (MainCanvas.Children.Contains(_toro2)) { MainCanvas.Children.Remove(_toro2); } if (MainCanvas.Children.Contains(_oro)) { MainCanvas.Children.Remove(_oro); } if (MainCanvas.Children.Contains(_oro2)) { MainCanvas.Children.Remove(_oro2); } _toro.MouseLeftButtonUp += ToroMouseLeftButtonUp; }
private void AddRotors(SigabaSettings settings) { _pr0 = new PresentationRotor(); _pr1 = new PresentationRotor(); _pr2 = new PresentationRotor(); _pr3 = new PresentationRotor(); _pr4 = new PresentationRotor(); canvas1.Children.Add(_pr0); canvas2.Children.Add(_pr1); canvas3.Children.Add(_pr2); canvas4.Children.Add(_pr3); canvas5.Children.Add(_pr4); canvas1.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas2.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas3.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas4.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas5.MouseLeftButtonDown += Pr0MouseLeftButtonDown; textBlock60.MouseLeftButtonDown += Oring0MouseLeftButtonDown; textBlock61.MouseLeftButtonDown += Oring1MouseLeftButtonDown; Canvas.SetLeft(_pr0, 7); Canvas.SetLeft(_pr1, 7); Canvas.SetLeft(_pr2, 7); Canvas.SetLeft(_pr3, 7); Canvas.SetLeft(_pr4, 7); _pr0.RenderTransform = new ScaleTransform(1.2, 1.2); _pr1.RenderTransform = new ScaleTransform(1.2, 1.2); _pr2.RenderTransform = new ScaleTransform(1.2, 1.2); _pr3.RenderTransform = new ScaleTransform(1.2, 1.2); _pr4.RenderTransform = new ScaleTransform(1.2, 1.2); _pri0 = new PresentationIndex(1); _pri1 = new PresentationIndex(2); _pri2 = new PresentationIndex(3); _pri3 = new PresentationIndex(4); _pri4 = new PresentationIndex(5); canvas7.MouseLeftButtonDown += Pri0MouseLeftButtonDown; canvas8.MouseLeftButtonDown += Pri0MouseLeftButtonDown; canvas9.MouseLeftButtonDown += Pri0MouseLeftButtonDown; canvas10.MouseLeftButtonDown += Pri0MouseLeftButtonDown; canvas11.MouseLeftButtonDown += Pri0MouseLeftButtonDown; Canvas.SetLeft(_pri0, 6); Canvas.SetLeft(_pri1, 6); Canvas.SetLeft(_pri2, 6); Canvas.SetLeft(_pri3, 6); Canvas.SetLeft(_pri4, 6); _pri0.RenderTransform = new ScaleTransform(1.2, 1.2); _pri1.RenderTransform = new ScaleTransform(1.2, 1.2); _pri2.RenderTransform = new ScaleTransform(1.2, 1.2); _pri3.RenderTransform = new ScaleTransform(1.2, 1.2); _pri4.RenderTransform = new ScaleTransform(1.2, 1.2); canvas7.Children.Add(_pri0); canvas8.Children.Add(_pri1); canvas9.Children.Add(_pri2); canvas10.Children.Add(_pri3); canvas11.Children.Add(_pri4); _pr10 = new PresentationRotor(); _pr11 = new PresentationRotor(); _pr12 = new PresentationRotor(); _pr13 = new PresentationRotor(); _pr14 = new PresentationRotor(); canvas6.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas12.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas13.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas14.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas15.MouseLeftButtonDown += Pr0MouseLeftButtonDown; canvas6.Children.Add(_pr14); canvas12.Children.Add(_pr13); canvas13.Children.Add(_pr12); canvas14.Children.Add(_pr11); canvas15.Children.Add(_pr10); _pr10.RenderTransform = new ScaleTransform(1.2, 1.2); Canvas.SetLeft(_pr10, 7); _pr11.RenderTransform = new ScaleTransform(1.2, 1.2); Canvas.SetLeft(_pr11, 7); _pr12.RenderTransform = new ScaleTransform(1.2, 1.2); Canvas.SetLeft(_pr12, 7); _pr13.RenderTransform = new ScaleTransform(1.2, 1.2); Canvas.SetLeft(_pr13, 7); _pr14.RenderTransform = new ScaleTransform(1.2, 1.2); Canvas.SetLeft(_pr14, 7); SetSettings(settings); }