Ignore:
Timestamp:
Feb 23, 2011, 12:46:33 PM (11 years ago)
Author:
weyers
Message:

EnigmaPresentation - EnigmaSettings synchronisation, EnigmaPresentation input management updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/Enigma/Enigma.cs

    r2701 r2801  
    1717
    1818using System;
     19using System.Windows;
    1920using System.Collections.Generic;
    2021using System.Linq;
     
    6162        private EnigmaSettings settings;
    6263        private EnigmaPresentation myPresentation;
     64        private AutoResetEvent ars;
    6365        private EnigmaCore core;
    6466        private EnigmaAnalyzer analyzer;
     
    9092        {
    9193            String input = preFormatInput(text);
    92             myPresentation.setinput(input);
    93             myPresentation.playClick(null, EventArgs.Empty);
    94             return postFormatOutput(core.Encrypt(rotor1Pos, rotor2Pos, rotor3Pos, rotor4Pos, input));
     94            if (Presentation.IsVisible)
     95            {
     96               
     97                String output = core.Encrypt(rotor1Pos, rotor2Pos, rotor3Pos, rotor4Pos, input);
     98               
     99                myPresentation.output = output;
     100                myPresentation.setinput(input);
     101                //myPresentation.playClick(null, EventArgs.Empty);
     102                //return postFormatOutput(output);
     103                return "";
     104            }
     105            else
     106                return postFormatOutput(core.Encrypt(rotor1Pos, rotor2Pos, rotor3Pos, rotor4Pos, input));
    95107        }
    96108
     
    276288            this.analyzer.OnIntermediateResult += new EventHandler<IntermediateResultEventArgs>(analyzer_OnIntermediateResult);
    277289            this.statistics = new Dictionary<int, IDictionary<string, double[]>>();
    278             myPresentation = new EnigmaPresentation(this.settings);
     290           
     291            this.ars = new AutoResetEvent(false);
     292            this.myPresentation = new EnigmaPresentation(this);
    279293            this.Presentation = myPresentation;
     294            //this.Presentation.IsVisibleChanged += presentation_isvisibleChanged;
    280295            this.settings.PropertyChanged += myPresentation.settings_OnPropertyChange;
    281296            this.settings.PropertyChanged += settings_OnPropertyChange;
    282         }
     297            this.myPresentation.fireLetters += fireLetters;
     298
     299           
     300            }
    283301
    284302        #endregion
     
    291309        public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
    292310        public event PluginProgressChangedEventHandler OnPluginProgressChanged;
     311
     312        private void fireLetters(object sender, EventArgs args) 
     313        {
     314            Object[] carrier = sender as Object[];
     315
     316            OutputString = (String)carrier[0] ;
     317            int x = (int)carrier[1];
     318            int y = (int)carrier[2];
     319            ShowProgress(x,y);
     320
     321        }
     322
     323        private void presentation_isvisibleChanged(object sender, DependencyPropertyChangedEventArgs args)
     324        {
     325            LogMessage("Here we go " + args.NewValue, NotificationLevel.Debug);
     326            Boolean visible = (Boolean) args.NewValue ;
     327            if (visible)
     328            {
     329             
     330            }
     331
     332            else
     333            {
     334               
     335            }
     336        }
    293337
    294338        private void settings_OnPropertyChange(object sender, PropertyChangedEventArgs e)
     
    370414        public void PreExecution()
    371415        {
     416            myPresentation.stopclick(this, EventArgs.Empty);
    372417            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Preparing enigma for operation..", this,  NotificationLevel.Info));
    373418
Note: See TracChangeset for help on using the changeset viewer.