示例#1
0
        private void SetSettings(SigabaSettings settings)
        {
            _pri0.SetType(settings.IndexRotor1);
            _pri1.SetType(settings.IndexRotor2);
            _pri2.SetType(settings.IndexRotor3);
            _pri3.SetType(settings.IndexRotor4);
            _pri4.SetType(settings.IndexRotor5);

            _pr0.Index = settings.CipherRotor1;
            _pr1.Index = settings.CipherRotor2;
            _pr2.Index = settings.CipherRotor3;
            _pr3.Index = settings.CipherRotor4;
            _pr4.Index = settings.CipherRotor5;

            _pr10.Index = settings.ControlRotor1;
            _pr11.Index = settings.ControlRotor2;
            _pr12.Index = settings.ControlRotor3;
            _pr13.Index = settings.ControlRotor4;
            _pr14.Index = settings.ControlRotor5;

            _pr0.Reverse(settings.CipherRotor1Reverse);
            _pr1.Reverse(settings.CipherRotor2Reverse);
            _pr2.Reverse(settings.CipherRotor3Reverse);
            _pr3.Reverse(settings.CipherRotor4Reverse);
            _pr4.Reverse(settings.CipherRotor5Reverse);

            _pr10.Reverse(settings.ControlRotor5Reverse);
            _pr11.Reverse(settings.ControlRotor4Reverse);
            _pr12.Reverse(settings.ControlRotor3Reverse);
            _pr13.Reverse(settings.ControlRotor2Reverse);
            _pr14.Reverse(settings.ControlRotor1Reverse);

            _pri0.Reverse(settings.IndexRotor1Reverse);
            _pri1.Reverse(settings.IndexRotor2Reverse);
            _pri2.Reverse(settings.IndexRotor3Reverse);
            _pri3.Reverse(settings.IndexRotor4Reverse);
            _pri4.Reverse(settings.IndexRotor5Reverse);

            _pr0.SetPosition(settings.CipherKey[0]);
            _pr1.SetPosition(settings.CipherKey[1]);
            _pr2.SetPosition(settings.CipherKey[2]);
            _pr3.SetPosition(settings.CipherKey[3]);
            _pr4.SetPosition(settings.CipherKey[4]);

            _pr14.SetPosition(settings.ControlKey[4]);
            _pr13.SetPosition(settings.ControlKey[3]);
            _pr12.SetPosition(settings.ControlKey[2]);
            _pr11.SetPosition(settings.ControlKey[1]);
            _pr10.SetPosition(settings.ControlKey[0]);

            _pri0.SetPosition(settings.IndexKey[0] - 48);
            _pri1.SetPosition(settings.IndexKey[1] - 48);
            _pri2.SetPosition(settings.IndexKey[2] - 48);
            _pri3.SetPosition(settings.IndexKey[3] - 48);
            _pri4.SetPosition(settings.IndexKey[4] - 48);
        }
示例#2
0
        public SigabaCore(Sigaba facade, SigabaPresentation sigpa)
        {
            _sigpa    = sigpa;
            _facade   = facade;
            _settings = (SigabaSettings)_facade.Settings;

            CodeWheels = new Rotor[15];

            CipherRotors  = new Rotor[5];
            ControlRotors = new Rotor[5];
            IndexRotors   = new Rotor[5];
        }
示例#3
0
 public SigabaPresentation(Sigaba facade, SigabaSettings settings)
 {
     InitializeComponent();
     _settings    = settings;
     SizeChanged += sizeChanged;
     AddRotors(settings);
     ClearPresentation();
     _rarray[0] = mark1;
     _rarray[1] = mark2;
     _rarray[2] = mark3;
     _rarray[3] = mark4;
     _rarray[4] = mark5;
 }
示例#4
0
        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);
        }