Changeset 651 for trunk/CrypPlugins/CLK


Ignore:
Timestamp:
Oct 5, 2009, 1:50:26 PM (12 years ago)
Author:
Sören Rinne
Message:
  • modified CubeAttack-Trivium672-Sample.cte
  • CLK now fires an output on mouse click in QuickWatchPresentation
  • LFSR and NLFSR QuickWatch can now be drawn before going into play mode
Location:
trunk/CrypPlugins/CLK
Files:
4 edited

Legend:

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

    r645 r651  
    1919
    2020using System.Windows;
     21// for setting image uri programmatically
     22using System.Windows.Media.Imaging;
    2123//using System.Windows.Data;
    2224//using System.IO;
     
    5052
    5153        cLKPresentation.CLKButtonImage.MouseLeftButtonUp += cLKButton_MouseLeftButtonUp;
    52         cLKPresentation.myTextBox.TextChanged += textchanged;
    53         //cLKPresentation.CLKButtonImage.MouseEnter += mousenter;
     54        cLKPresentation.CLKButtonImage.MouseLeftButtonDown += cLKButton_MouseLeftButtonUp;
    5455
    5556        // set picture according to settings value
     
    5960    }
    6061
    61     void mousenter(object sender, MouseEventArgs e)
    62     {
    63         GuiLogMessage("mouse event is coming", NotificationLevel.Info);
     62    void cLKButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
     63    {
    6464        OnPropertyChanged("Output");
    65     }
    66 
    67     void textchanged(object sender, TextChangedEventArgs e)
    68     {
    69         GuiLogMessage("text event is coming", NotificationLevel.Info);
    70         OnPropertyChanged("Output");
    71     }
    72 
    73     void cLKButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    74     {
    75         GuiLogMessage("mouse event is coming", NotificationLevel.Info);
    76         if (e.LeftButton == MouseButtonState.Released)
    77         {
    78             GuiLogMessage("Left Mouse Button released", NotificationLevel.Info);
    79             OnPropertyChanged("Output");
    80         }
    8165    }
    8266
     
    8670      {
    8771        output = settings.SetClockToTrue;
    88         if (output) StatusChanged((int)CLKImage.True);
    89         else StatusChanged((int)CLKImage.False);
     72        if (output)
     73        {
     74            StatusChanged((int)CLKImage.True);
     75            cLKPresentation.setImageTrue();
     76        }
     77        else
     78        {
     79            StatusChanged((int)CLKImage.False);
     80            cLKPresentation.setImageFalse();
     81        }
    9082      }
    9183      if (e.PropertyName == "CLKTimeout")
     
    153145    public void PreExecution()
    154146    {
    155         if (settings.SetClockToTrue) StatusChanged((int)CLKImage.True);
    156         else StatusChanged((int)CLKImage.False);
     147        if (settings.SetClockToTrue)
     148        {
     149            StatusChanged((int)CLKImage.True);
     150            cLKPresentation.setImageTrue();
     151        }
     152        else
     153        {
     154            StatusChanged((int)CLKImage.False);
     155            cLKPresentation.setImageFalse();
     156        }
    157157
    158158        myRounds = settings.Rounds;
     
    199199    private void process(int timeout)
    200200    {
    201         // first fire up an event, then get the timer to handle that for us
    202         OnPropertyChanged("Output");
    203         myRounds--;
    204 
    205         // Hook up the Elapsed event for the timer.
    206         aTimer.Elapsed += new ElapsedEventHandler(sendCLKSignal);
    207 
    208         // Set the Interval to 'timeout' seconds (in milliseconds).
    209         aTimer.Interval = timeout;
    210         aTimer.Enabled = true;
    211 
    212         // Keep the timer alive until the end of Main.
    213         //GC.KeepAlive(aTimer);
     201        // check if rounds are more than zero
     202        if (myRounds != 0)
     203        {
     204            // first fire up an event, then get the timer to handle that for us
     205            OnPropertyChanged("Output");
     206            myRounds--;
     207
     208            // Hook up the Elapsed event for the timer.
     209            aTimer.Elapsed += new ElapsedEventHandler(sendCLKSignal);
     210
     211            // Set the Interval to 'timeout' seconds (in milliseconds).
     212            aTimer.Interval = timeout;
     213            aTimer.Enabled = true;
     214
     215            // Keep the timer alive until the end of Main.
     216            //GC.KeepAlive(aTimer);
     217        }
    214218    }
    215219
  • trunk/CrypPlugins/CLK/CLKPresentation.xaml

    r647 r651  
    66        <Grid.RowDefinitions>
    77            <RowDefinition Height="1*" />
    8             <RowDefinition Height="Auto" />
    98        </Grid.RowDefinitions>
    10         <Button Width="32" Height="32" PreviewMouseLeftButtonUp="CLKButtonImage_MouseLeftButtonUp">
    11         <Image Source="icon.png" Stretch="None" Name="CLKButtonImage" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Grid.Row="0" PreviewMouseLeftButtonUp="CLKButtonImage_MouseLeftButtonUp" />
    12             </Button>
    13         <TextBox Name="myTextBox" Grid.Row="1" />
     9       
     10        <!--<Button Width="35" Height="35" Name="CLKButton">
     11            <Image Source="icon.png" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Grid.Row="0" />
     12        </Button>-->
     13       
     14        <Image Source="icon.png" Stretch="Fill" Name="CLKButtonImage" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand" Grid.Row="0" Width="32" Height="32" />
     15
    1416    </Grid>
    1517</UserControl>
  • trunk/CrypPlugins/CLK/CLKPresentation.xaml.cs

    r645 r651  
    225225  public partial class CLKPresentation : UserControl
    226226  {
    227     public CLKPresentation()
    228     {
    229       InitializeComponent();
    230       Height = double.NaN;
    231       Width = double.NaN;
    232       myTextBox.Text = "1";
    233     }
    234 
    235     private void CLKButtonImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    236     {
    237         myTextBox.Text = "blah";
    238     }
     227      public CLKPresentation()
     228      {
     229          InitializeComponent();
     230          Height = double.NaN;
     231          Width = double.NaN;
     232      }
     233
     234      public void setImageTrue()
     235      {
     236          Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     237          {
     238              BitmapImage png = new BitmapImage();
     239              png.BeginInit();
     240              png.UriSource = new Uri("Images/true.png", UriKind.Relative);
     241              png.EndInit();
     242              CLKButtonImage.Source = png;
     243          }, null);
     244      }
     245
     246      public void setImageFalse()
     247      {
     248          Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     249          {
     250              BitmapImage png = new BitmapImage();
     251              png.BeginInit();
     252              png.UriSource = new Uri("Images/false.png", UriKind.Relative);
     253              png.EndInit();
     254              CLKButtonImage.Source = png;
     255          }, null);
     256      }
    239257  }
    240258}
  • trunk/CrypPlugins/CLK/CLKSettings.cs

    r645 r651  
    9999        set
    100100        {
    101             if (value <= 0) this.rounds = 1;
    102             else this.rounds = value;
     101            /*if (value <= 0)
     102                this.rounds = 1;
     103            else*/
     104                this.rounds = value;
    103105            OnPropertyChanged("Rounds");
    104106            HasChanges = true;
Note: See TracChangeset for help on using the changeset viewer.