Changeset 2624


Ignore:
Timestamp:
Feb 8, 2011, 2:20:15 PM (11 years ago)
Author:
nolte
Message:

Latest PP Date is now shown in the User-Bar.
(+Feature: Glowing TopUser/TopMachine)

Location:
trunk/CrypPlugins/KeySearcher/Presentation/Controls
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/Presentation/Controls/StatisticsPresentation.xaml

    r2620 r2624  
    1010        <Controls:InformationToProgressConverter x:Key="InformationToProgressConverter"/>
    1111        <Controls:InformationToProgressConverter2 x:Key="InformationToProgressConverter2"/>
     12        <Controls:MaxDateConverter x:Key="MaxDateConverter"/>
    1213        <Controls:MachineSumToProgressConverter x:Key="MachineSumToProgressConverter"/>
    1314        <Controls:ChunkSumConverter x:Key="ChunkSumConverter"/>
     
    3031        </Style>
    3132
    32     </UserControl.Resources>       
     33        <Storyboard x:Key="BestGlow" RepeatBehavior="Forever">
     34            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="BestUser">
     35                <EasingColorKeyFrame KeyTime="0:0:1" Value="DarkGoldenrod"/>
     36                <EasingColorKeyFrame KeyTime="0:0:2" Value="Black"/>
     37            </ColorAnimationUsingKeyFrames>
     38            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="BestMachine">
     39                <EasingColorKeyFrame KeyTime="0:0:1" Value="DarkGoldenrod"/>
     40                <EasingColorKeyFrame KeyTime="0:0:2" Value="Black"/>
     41            </ColorAnimationUsingKeyFrames>
     42        </Storyboard>
     43
     44    </UserControl.Resources>
     45    <UserControl.Triggers>
     46        <EventTrigger RoutedEvent="Loaded">
     47            <BeginStoryboard Storyboard="{StaticResource BestGlow}" />
     48        </EventTrigger>
     49    </UserControl.Triggers>
     50   
    3351        <TabControl>
    3452            <TabItem Header="{Loc _Information_}">
     
    8199                                    <Grid.ColumnDefinitions>
    82100                                        <ColumnDefinition Width="26" />
    83                                         <ColumnDefinition Width="*" />
    84                                     </Grid.ColumnDefinitions>
     101                                        <ColumnDefinition Width="188*" />
     102                                    <ColumnDefinition Width="189" />
     103                                </Grid.ColumnDefinitions>
    85104                                    <Border BorderThickness="1" BorderBrush="Black" LayoutTransform="{StaticResource HeaderRotate}" Grid.Column="0" Grid.RowSpan="6" Background="#FF099BA7">
    86105                                        <Label Content="{Loc AdditionalInformation_}" FontSize="11" HorizontalAlignment="Center" Foreground="White" />
    87106                                    </Border>
    88                                     <Label Content=" Average rate: - key/sec" Name="Rate" VerticalAlignment="Center" Grid.Row="0" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" />
    89                                 <Label Content=" Top user: -" Name="BestUser" VerticalAlignment="Bottom" Grid.Row="1" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" />
    90                                 <Label Content=" - users are working on this job." Name="UserCount" VerticalAlignment="Top"  Grid.Row="2" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" />
    91                                     <Label Content=" Top machine: -" Name="BestMachine" VerticalAlignment="Bottom" Grid.Row="3" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" />
    92                                     <Label Content=" - machines are working on this job." Name="MachineCount" VerticalAlignment="Top"  Grid.Row="4" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" />                               
     107                                    <Label Content=" Average rate: - key/sec" Name="Rate" VerticalAlignment="Center" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" Grid.ColumnSpan="2" Margin="0,7,-2,7" />
     108                                    <Label Content="Top user: "  VerticalAlignment="Bottom" HorizontalContentAlignment="Right"  Grid.Row="1" Grid.Column="1" Margin="0,0,185,0" Grid.ColumnSpan="2" />
     109                                    <Label Content="" Name="BestUser" VerticalAlignment="Bottom" Grid.Row="1" Grid.Column="1" HorizontalContentAlignment="Left" Margin="185,0,-2,0" Grid.ColumnSpan="2" />
     110                                    <Label Content=" - users are working on this job." Name="UserCount" VerticalAlignment="Top"  Grid.Row="2" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" Grid.ColumnSpan="2" Margin="0,0,-2,0" />
     111                                    <Label Content="Top machine: "  VerticalAlignment="Bottom" HorizontalContentAlignment="Right"  Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,0,185,0" />
     112                                    <Label Content="" Name="BestMachine" VerticalAlignment="Bottom" Grid.Row="3" Grid.Column="1" HorizontalContentAlignment="Left" Margin="185,0,-2,0" Grid.ColumnSpan="2" />
     113                                <Label Content=" - machines are working on this job." Name="MachineCount" VerticalAlignment="Top"  Grid.Row="4" Grid.Column="1" HorizontalContentAlignment="Center" Padding="5,5,20,5" Grid.ColumnSpan="2" Margin="0,0,-2,0" />                               
    93114                                </Grid>
    94115                            </Border>
     
    146167                                    </Grid>
    147168                                    <Grid>
    148                                         <ProgressBar x:Name="Bar" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}},Path=(ItemsControl.AlternationIndex),Converter={StaticResource ResourceKey=TeamsBackgroundConverter}}" Value="{Binding Path=Value, Mode=OneTime, Converter={StaticResource ResourceKey=InformationToProgressConverter}}" Width="{Binding ElementName=statisticsTree, Path=ActualWidth, Converter={StaticResource ResourceKey=WidthConverter}}" Maximum="1" />
     169                                    <ProgressBar x:Name="Bar" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}},Path=(ItemsControl.AlternationIndex),Converter={StaticResource ResourceKey=TeamsBackgroundConverter}}" Value="{Binding Path=Value, Mode=OneTime, Converter={StaticResource ResourceKey=InformationToProgressConverter}}" Width="{Binding ElementName=statisticsTree, Path=ActualWidth, Converter={StaticResource ResourceKey=WidthConverter}}" Maximum="1" ToolTip="{Binding Path=Key, Converter={StaticResource ResourceKey=MaxDateConverter}}" />
    149170                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
    150171                                            <TextBlock Text="{Binding Path=Key, Converter={StaticResource ResourceKey=ChunkSumConverter}, StringFormat=\{0\,-5\}}"/>
  • trunk/CrypPlugins/KeySearcher/Presentation/Controls/StatisticsPresentation.xaml.cs

    r2620 r2624  
    3636            ((StringLengthConverter)Resources["StringLengthConverter"]).StatisticsPresentation = this;
    3737            ((MachineSumToProgressConverter)Resources["MachineSumToProgressConverter"]).StatisticsPresentation = this;
     38            ((MaxDateConverter)Resources["MaxDateConverter"]).StatisticsPresentation = this;
    3839        }
    3940
     
    248249                Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    249250                {
    250                     BestUser.Content = " Top user: " + beeusers;
     251                    BestUser.Content = beeusers;
    251252                }, null);
    252253            }
     
    284285                Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    285286                {
    286                     BestMachine.Content = " Top machine: " + beemachines;
     287                    BestMachine.Content = beemachines;
    287288                }, null);
    288289            }
     
    496497    }
    497498
     499    [ValueConversion(typeof(String), typeof(DateTime))]
     500    class MaxDateConverter : IValueConverter
     501    {
     502        public StatisticsPresentation StatisticsPresentation { get; set; }
     503
     504        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
     505        {
     506            if (StatisticsPresentation != null && StatisticsPresentation.Statistics != null)
     507            {
     508                lock (StatisticsPresentation)
     509                {
     510                    var max = DateTime.MinValue;
     511                    var machines = StatisticsPresentation.Statistics[(string) value];
     512                    foreach (var id in machines.Keys.Where(id => machines[id].Date > max))
     513                    {
     514                        max = machines[id].Date;
     515                    }
     516                    return max;
     517                }
     518            }
     519            else
     520            {
     521                return 0;
     522            }
     523        }
     524
     525        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
     526        {
     527            throw new NotImplementedException();
     528        }
     529    }
     530
    498531    public class ColorToDateConverter : IMultiValueConverter
    499532    {
Note: See TracChangeset for help on using the changeset viewer.