Changeset 1284


Ignore:
Timestamp:
Apr 8, 2010, 5:19:28 PM (12 years ago)
Author:
weyers
Message:

TranspositionAnalyserQuickWatchPresentation reacts on doubleclick. scaling optmized

Location:
trunk/CrypPlugins/TranspositionAnalyser
Files:
3 edited

Legend:

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

    r1194 r1284  
    2929        private Queue valuequeue;
    3030        LinkedList<ValueKey> list1;
     31        private TranspositionAnalyserQuickWatchPresentation myPresentation;
    3132
    3233        TranspositionAnalyserSettings settings;
     
    7273        {
    7374            settings = new TranspositionAnalyserSettings();
    74             QuickWatchPresentation = new TranspositionAnalyserQuickWatchPresentation();
     75            myPresentation = new TranspositionAnalyserQuickWatchPresentation();
     76            QuickWatchPresentation = myPresentation;
     77            myPresentation.doppelClick += new EventHandler(this.doppelClick);
     78        }
     79       
     80        private void doppelClick(object sender, EventArgs e)
     81        {
     82            ListViewItem lvi = sender as ListViewItem;
     83            ResultEntry rse = lvi.Content as ResultEntry;
     84            Output = System.Text.Encoding.GetEncoding(1252).GetBytes(rse.Text);
    7585        }
    7686
     
    755765
    756766                        String dec = System.Text.Encoding.ASCII.GetString(linkedListNode.Value.decryption);
    757                         if (dec.Length > 25) // Short strings need not to be cut off
     767                        if (dec.Length > 2500) // Short strings need not to be cut off
    758768                        {
    759                             dec = dec.Substring(0, 25) + "...";
     769                            dec = dec.Substring(0, 2500) ;
    760770                        }
    761771                        entry.Text = dec;
  • trunk/CrypPlugins/TranspositionAnalyser/TranspositionAnalyserQuickWatchPresentation.xaml

    r1123 r1284  
    55    VerticalAlignment="Stretch"
    66    Background="White">
    7     <Canvas Name="Canvas">
    8     <Grid Background="White" Width="300" Name="Grid">
    9         <Grid.RowDefinitions>
    10             <RowDefinition/>
    11             <RowDefinition/>
    12             <RowDefinition/>
    13             <RowDefinition Height="80pt"/>           
    14         </Grid.RowDefinitions>
    15         <Grid.ColumnDefinitions>
    16             <ColumnDefinition/>
    17             <ColumnDefinition/>
    18         </Grid.ColumnDefinitions>
     7   
     8    <Canvas>
     9        <Grid>
     10            <Grid.RowDefinitions>
     11                <RowDefinition Height="80"/>
     12                <RowDefinition Height="*"/>
     13            </Grid.RowDefinitions>
     14            <Grid.ColumnDefinitions>
     15                <ColumnDefinition/>
     16            </Grid.ColumnDefinitions>
    1917
    20         <Label Grid.Row="0" Grid.Column="0" FontSize="12" Background="White" VerticalAlignment="Top" Height="28" Width="AUTO">Probable time left :</Label>
    21         <Label Grid.Row="0" Grid.Column="1" FontSize="12" Background="White" VerticalAlignment="Top" Height="28" Width="AUTO">Estimated end time :</Label>
     18            <Canvas>
     19                <Grid Background="White" Width="300" Name="Grid" Grid.Row="0" Grid.Column="0">
     20                    <Grid.RowDefinitions>
     21                        <RowDefinition/>
     22                        <RowDefinition/>
     23                        <RowDefinition/>
     24                    </Grid.RowDefinitions>
     25                    <Grid.ColumnDefinitions>
     26                        <ColumnDefinition/>
     27                        <ColumnDefinition/>
     28                    </Grid.ColumnDefinitions>
    2229
    23         <TextBox Name="timeLeft" Grid.Row="1" Grid.Column="0"
    24                  TextAlignment="Center" IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" Height="28" FontSize="10" BorderThickness="1" />
    25         <TextBox Name="endTime" Grid.Row="1" Grid.Column="1"
    26                  TextAlignment="Center" IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" Height="28" FontSize="10" BorderThickness="1" />
     30                    <Label Grid.Row="0" Grid.Column="0" FontSize="12" Background="White" VerticalAlignment="Top" Height="28" Width="AUTO">Probable time left :</Label>
     31                    <Label Grid.Row="0" Grid.Column="1" FontSize="12" Background="White" VerticalAlignment="Top" Height="28" Width="AUTO">Estimated end time :</Label>
    2732
    28         <Label Grid.Row="2" FontSize="12" Background="White">Keys pers second :</Label>
     33                    <TextBox Name="timeLeft" Grid.Row="1" Grid.Column="0"
     34                     TextAlignment="Center" IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" Height="28" FontSize="10" BorderThickness="1" />
     35                    <TextBox Name="endTime" Grid.Row="1" Grid.Column="1"
     36                     TextAlignment="Center" IsReadOnly="True" TextWrapping="WrapWithOverflow" VerticalAlignment="Top" Height="28" FontSize="10" BorderThickness="1" />
    2937
    30         <TextBox x:Name="keysPerSecond" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
    31                  TextAlignment="Left"  IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="10" BorderThickness="1" HorizontalContentAlignment="Center" />
    32        <!-- <ListBox Name="listbox" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="3" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="10" /> -->
    33        
    34         <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="10" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2">
     38                    <Label Grid.Row="2" Grid.Column="0" FontSize="12" Grid.ColumnSpan="1" Background="White" Width="AUTO">Keys per second :</Label>
     39
     40                    <TextBox x:Name="keysPerSecond" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
     41                     TextAlignment="Left"  IsReadOnly="True" TextWrapping="WrapWithOverflow" FontSize="10" BorderThickness="1" HorizontalContentAlignment="Center" />
     42                </Grid>
     43            </Canvas>
     44           
     45            <ListView Name="ListView" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="10" Grid.Row="1" Grid.Column="0"  >
     46                <ListView.ItemContainerStyle>
     47                <Style TargetType="{x:Type ListViewItem}">
     48                    <EventSetter Event="MouseDoubleClick" Handler="HandleDoubleClick" />
     49                </Style>
     50                </ListView.ItemContainerStyle>
     51
    3552                <ListView.View>
    3653                    <GridView>
  • trunk/CrypPlugins/TranspositionAnalyser/TranspositionAnalyserQuickWatchPresentation.xaml.cs

    r1123 r1284  
    2222    {
    2323        public ObservableCollection<ResultEntry> entries = new ObservableCollection<ResultEntry>();
     24        public event EventHandler doppelClick;
    2425
    2526        public TranspositionAnalyserQuickWatchPresentation()
     
    2829            SizeChanged += sizeChanged;
    2930            this.DataContext = entries;
     31         
    3032        }
    3133
    3234        public void sizeChanged(Object sender, EventArgs eventArgs)
    3335        {
    34             this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
    35                                                        this.ActualHeight / this.Grid.ActualHeight);
     36            double height = this.ActualHeight - this.Grid.ActualHeight;
     37            if (height < 0)
     38            {
     39                height = 0;
     40            }
     41            this.ListView.Height = height;
     42            this.ListView.Width = this.ActualWidth;
     43
     44            double heightTransform = (this.ActualHeight - height) / this.Grid.ActualHeight;
     45            double widthTransform = this.ActualWidth / this.Grid.ActualWidth;
     46
     47            if (widthTransform > heightTransform)
     48            {
     49                widthTransform = heightTransform;
     50            }
     51
     52
     53            this.Grid.RenderTransform = new ScaleTransform(widthTransform, heightTransform);
     54        }
     55
     56        public void HandleDoubleClick(Object sender, EventArgs eventArgs)
     57        {
     58               doppelClick(sender,eventArgs);
    3659        }
    3760    }
Note: See TracChangeset for help on using the changeset viewer.