Changeset 1917


Ignore:
Timestamp:
Sep 11, 2010, 5:10:41 PM (11 years ago)
Author:
Paul Lelgemann
Message:

o KeySearcher: fixed "+unendlich years" as estimated finish date display bug
o P2PEditor: fixed behavior of new button without p2p connection and participate button with not job selected
o P2PEditor: minor refactoring, removed unused code and classes

Location:
trunk/CrypPlugins
Files:
2 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/P2P/Presentation/StatisticsGenerator.cs

    r1860 r1917  
    146146
    147147            var totalAmountOfParticipants = currentChunkCalculated - HighestChunkCalculated;
     148            if (totalAmountOfParticipants == 0)
     149                totalAmountOfParticipants = 1;
     150           
    148151            status.TotalAmountOfParticipants = totalAmountOfParticipants;
     152
    149153
    150154            var timeUsedForLatestProgress = DateTime.Now.Subtract(lastDateOfGlobalStatistics);
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/ConnectTab.xaml.cs

    r1619 r1917  
    55namespace Cryptool.P2PEditor.GUI.Controls
    66{
    7     /// <summary>
    8     /// Interaction logic for ConnectTab.xaml
    9     /// </summary>
    107    public partial class ConnectTab
    118    {
     
    2825        }
    2926
    30         private void ConnectButtonClick(object sender, System.Windows.RoutedEventArgs e)
     27        private void ConnectButtonClick(object sender, RoutedEventArgs e)
    3128        {
    3229            if (!P2PManager.IsConnected)
    33             {
    3430                P2PManager.Connect();
    35             }
    3631
    3732            ((P2PEditorPresentation) P2PEditor.Presentation).UpdateConnectionState();
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/JobDisplay.xaml

    r1727 r1917  
    1515        <DockPanel Name="mainPane">
    1616            <Grid Background="White">
    17                 <ListBox x:Name="JobListBox" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Jobs, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ItemTemplate="{StaticResource jobDisplayTemplate}" Style="{StaticResource jobListDisplayStyle}" KeyUp="JobListBox_KeyUp" Margin="0,0,0,35">
     17                <ListBox x:Name="JobListBox" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Jobs, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ItemTemplate="{StaticResource jobDisplayTemplate}" Style="{StaticResource jobListDisplayStyle}" KeyUp="JobListBoxKeyUp" Margin="0,0,0,35">
    1818                    <ListBox.ItemContainerStyle>
    1919                        <Style TargetType="{x:Type ListBoxItem}">
     
    2323                </ListBox>
    2424                <Grid DataContext="{Binding SelectedItem,ElementName=JobListBox}">
    25                     <Button Content="Participate" HorizontalAlignment="Right" Margin="0,0,0,6" Name="ParticipateButton" Width="75" Height="23" VerticalAlignment="Bottom" Click="ParticipateButton_Click" />
    26                     <Button Content="Refresh" Click="RefreshButton_Click" Margin="0,0,0,6" Name="RefreshButton" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="75" />
    27                     <Button Content="Delete" Click="DeleteButton_Click" Margin="0,0,81,6" Name="DeleteButton" HorizontalAlignment="Right" Width="75" Height="23" VerticalAlignment="Bottom" />
     25                    <Button Content="Participate" HorizontalAlignment="Right" Margin="0,0,0,6" Name="ParticipateButton" Width="75" Height="23" VerticalAlignment="Bottom" Click="ParticipateButtonClick" />
     26                    <Button Content="Refresh" Click="RefreshButtonClick" Margin="0,0,0,6" Name="RefreshButton" Height="23" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="75" />
     27                    <Button Content="Delete" Click="DeleteButtonClick" Margin="0,0,81,6" Name="DeleteButton" HorizontalAlignment="Right" Width="75" Height="23" VerticalAlignment="Bottom" />
    2828                </Grid>
    2929            </Grid>
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/JobDisplay.xaml.cs

    r1727 r1917  
    6464        private void AttachLoadingAdorner()
    6565        {
    66             ParticipateAdorner participateAdorner = new ParticipateAdorner(mainPane);
    67            /* participateAdorner.FontSize = 15;
    68             loading.OverlayedText = "loading...";
    69             loading.Typeface = new Typeface(FontFamily, FontStyles.Italic,
    70                 FontWeights.Bold, FontStretch);*/
    71             Binding bind = new Binding("Participating");
     66            var participateAdorner = new ParticipateAdorner(mainPane);
     67            var bind = new Binding("Participating");
    7268            bind.Source = this;
    7369            bind.Converter = new TrueToVisibleOrCollapsedConverter();
     
    119115        }
    120116
    121         private void RefreshButton_Click(object sender, RoutedEventArgs e)
     117        private void RefreshButtonClick(object sender, RoutedEventArgs e)
    122118        {
    123119            UpdateJobList();
     
    148144        }
    149145
    150         private void ParticipateButton_Click(object sender, RoutedEventArgs e)
     146        private void ParticipateButtonClick(object sender, RoutedEventArgs e)
    151147        {
    152148            ParticipateInSelectedJob();
     
    160156        private void ParticipateInSelectedJob()
    161157        {
     158            var jobToParticipateIn = (DistributedJob) JobListBox.SelectedItem;
     159            if (jobToParticipateIn == null) return;
     160
    162161            Participating = true;
    163 
    164             var jobToParticipateIn = (DistributedJob) JobListBox.SelectedItem;
    165 
    166             if (jobToParticipateIn == null) return;
    167162
    168163            P2PEditor.GuiLogMessage(
     
    173168        }
    174169
    175         private void DeleteButton_Click(object sender, RoutedEventArgs e)
     170        private void DeleteButtonClick(object sender, RoutedEventArgs e)
    176171        {
    177172            DeleteSelectedJob();
    178173        }
    179174
    180         private void JobListBox_KeyUp(object sender, KeyEventArgs e)
     175        private void JobListBoxKeyUp(object sender, KeyEventArgs e)
    181176        {
    182177            switch (e.Key)
  • trunk/CrypPlugins/P2PEditor/GUI/P2PUserControl.cs

    r1527 r1917  
    1 using System;
    2 using System.Windows;
     1using System.Windows;
    32using System.Windows.Controls;
    43using Cryptool.P2PEditor.Distributed;
     
    3433        public P2PEditorPresentation P2PEditorPresentation
    3534        {
    36             get { return (P2PEditorPresentation)GetValue(P2PEditorPresentationProperty); }
     35            get { return (P2PEditorPresentation) GetValue(P2PEditorPresentationProperty); }
    3736            set { SetValue(P2PEditorPresentationProperty, value); }
    3837        }
  • trunk/CrypPlugins/P2PEditor/P2PEditor.cs

    r1611 r1917  
    2020using System.Windows.Controls;
    2121using Cryptool.Core;
     22using Cryptool.P2P;
    2223using Cryptool.P2PEditor.Distributed;
    2324using Cryptool.P2PEditor.GUI;
     
    3435    public class P2PEditor : IEditor
    3536    {
    36         private readonly JobListManager _jobListManager;
    37 
    38         private bool _initialNewHandled;
     37        private readonly JobListManager jobListManager;
     38
     39        private bool initialNewEventHandled;
    3940
    4041        public P2PEditor()
    4142        {
    42             _jobListManager = new JobListManager(this);
    43             _initialNewHandled = false;
    44 
    45             Presentation = new P2PEditorPresentation(this, _jobListManager);
     43            jobListManager = new JobListManager(this);
     44            initialNewEventHandled = false;
     45
     46            Presentation = new P2PEditorPresentation(this, jobListManager);
    4647            Settings = new P2PEditorSettings(this);
    4748        }
     
    6162        public void New()
    6263        {
    63             GuiLogMessage("P2PEditor: New()", NotificationLevel.Debug);
     64            if (OnSelectedPluginChanged != null)
     65                OnSelectedPluginChanged(this, new PluginChangedEventArgs(this, "P2P Configuration", DisplayPluginMode.Normal));
     66           
     67            if (!P2PManager.IsConnected)
     68            {
     69                GuiLogMessage("Cannot display new job form, no connection to p2p network.", NotificationLevel.Warning);
     70                return;
     71            }
    6472
    6573            // Avoid switching to the add view, but allow using the new button later
    66             if (!_initialNewHandled)
    67             {
    68                 _initialNewHandled = true;
    69             } else
    70             {
    71                 ((P2PEditorPresentation)Presentation).ShowJobCreation();
    72             }
    73 
    74             if (OnSelectedPluginChanged != null)
    75             {
    76                 OnSelectedPluginChanged(this, new PluginChangedEventArgs(this, "P2P Configuration", DisplayPluginMode.Normal));
    77             }
     74            if (!initialNewEventHandled)
     75                initialNewEventHandled = true;
     76            else
     77                ((P2PEditorPresentation) Presentation).ShowJobCreation();
    7878        }
    7979
  • trunk/CrypPlugins/P2PEditor/P2PEditor.csproj

    r1727 r1917  
    7272    <Compile Include="Converters\StatusToColorConverter.cs" />
    7373    <Compile Include="Converters\StringEmptyToVisibilityConverter.cs" />
    74     <Compile Include="Converters\StringNotEmptyToVisibilityConverter.cs" />
    7574    <Compile Include="Converters\UtcDateTimeToLocalConverter.cs" />
    76     <Compile Include="Converters\DateTimeConverter.cs" />
    7775    <Compile Include="Converters\TrueToVisibleOrCollapsedConverter.cs" />
    7876    <Compile Include="Distributed\DistributedJobSerializer.cs" />
  • trunk/CrypPlugins/P2PEditor/P2PEditorSettings.cs

    r1914 r1917  
    1616
    1717using System.ComponentModel;
     18using System.Windows;
    1819using Cryptool.P2P;
    1920using Cryptool.P2PEditor.GUI;
     
    3637            this.p2PEditor = p2PEditor;
    3738            settings = P2PSettings.Default;
    38         }
     39            UpdateSettings();
     40        }
     41
     42        #region Update visibility of server group
     43
     44        private void UpdateSettings()
     45        {
     46            if (TaskPaneAttributeChanged == null)
     47                return;
     48
     49            if (P2PSettings.Default.Architecture == P2PArchitecture.Server)
     50                UpdateServerOptionVisibilitySetting(Visibility.Visible);
     51            else
     52                UpdateServerOptionVisibilitySetting(Visibility.Hidden);
     53        }
     54
     55        private void UpdateServerOptionVisibilitySetting(Visibility newVisibility)
     56        {
     57            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("ServerHost", newVisibility)));
     58            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("ServerPort", newVisibility)));
     59        }
     60
     61        #endregion
     62
     63        #region Events
     64        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
     65        #endregion
    3966
    4067        #region ISettings Members
     
    200227                {
    201228                    settings.Architecture = (P2PArchitecture)value;
     229                    UpdateSettings();
    202230                    OnPropertyChanged("Architecture");
    203231                    HasChanges = true;
  • trunk/CrypPlugins/P2PEditor/Worker/JobCreationWorker.cs

    r1727 r1917  
    1414            this.jobToDistribute = jobToDistribute;
    1515
    16             DoWork += JobCreationWorker_DoWork;
     16            DoWork += JobCreationWorkerDoWork;
    1717        }
    1818
    19         private void JobCreationWorker_DoWork(object sender, DoWorkEventArgs e)
     19        private void JobCreationWorkerDoWork(object sender, DoWorkEventArgs e)
    2020        {
    2121            jobListManager.AddDistributedJob(jobToDistribute);
  • trunk/CrypPlugins/P2PEditor/Worker/JobDeletionWorker.cs

    r1727 r1917  
    1414            this.jobToDistribute = jobToDistribute;
    1515
    16             DoWork += JobCreationWorker_DoWork;
     16            DoWork += JobCreationWorkerDoWork;
    1717        }
    1818
    19         private void JobCreationWorker_DoWork(object sender, DoWorkEventArgs e)
     19        private void JobCreationWorkerDoWork(object sender, DoWorkEventArgs e)
    2020        {
    2121            jobListManager.DeleteDistributedJob(jobToDistribute);
  • trunk/CrypPlugins/P2PEditor/Worker/JobListDetailsUpdateWorker.cs

    r1733 r1917  
    1515            this.jobListManager = jobListManager;
    1616
    17             DoWork += JobListDetailsUpdateWorker_DoWork;
     17            DoWork += JobListDetailsUpdateWorkerDoWork;
    1818        }
    1919
    20         void JobListDetailsUpdateWorker_DoWork(object sender, DoWorkEventArgs e)
     20        void JobListDetailsUpdateWorkerDoWork(object sender, DoWorkEventArgs e)
    2121        {
    2222            if (distributedJobs == null) return;
  • trunk/CrypPlugins/P2PEditor/Worker/JobListUpdateWorker.cs

    r1727 r1917  
    1414            this.jobListManager = jobListManager;
    1515
    16             DoWork += JobCreationWorker_DoWork;
     16            DoWork += JobCreationWorkerDoWork;
    1717        }
    1818
    19         private void JobCreationWorker_DoWork(object sender, DoWorkEventArgs e)
     19        private void JobCreationWorkerDoWork(object sender, DoWorkEventArgs e)
    2020        {
    2121            RefreshedJobList = jobListManager.JobList();
  • trunk/CrypPlugins/P2PEditor/Worker/JobParticipationWorker.cs

    r1727 r1917  
    2121            this.dispatcher = dispatcher;
    2222
    23             DoWork += JobParticipationWorker_DoWork;
     23            DoWork += JobParticipationWorkerDoWork;
    2424        }
    2525
    26         private void JobParticipationWorker_DoWork(object sender, DoWorkEventArgs e)
     26        private void JobParticipationWorkerDoWork(object sender, DoWorkEventArgs e)
    2727        {
    2828            try
     
    4242                NotificationLevel.Info);
    4343
    44             try
    45             {
    46                 jobListManager.IncreaseDownloadCount(jobToParticipateIn);
    47             } catch(Exception)
    48             {
    49                
    50             }
     44            jobListManager.IncreaseDownloadCount(jobToParticipateIn);
    5145
    5246            dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(DispatchOpenFileEvent));
Note: See TracChangeset for help on using the changeset viewer.