Changeset 1549


Ignore:
Timestamp:
Jun 1, 2010, 12:33:32 PM (12 years ago)
Author:
Paul Lelgemann
Message:

o P2PEditor: L&F improvements for the listbox containing distributed jobs
o Changed DistributedJob serialization strategy to built-in

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypP2P/Internal/P2PBase.cs

    r1545 r1549  
    304304                OnSystemLeft();
    305305
    306             // as an experiment
    307             _dht = null;
    308 
    309             _systemLeft.Set();
    310306            Started = false;
    311307            Initialized = false;
     308
     309            // Allow new connection to start and check for waiting / blocked tasks
     310            P2PManager.Instance.IsP2PConnecting = false;
     311            _systemLeft.Set();
     312            _systemJoined.Set();
    312313
    313314            LogToMonitor("CrypP2P left the system.");
  • trunk/CrypPlugins/P2PEditor/Distributed/DistributedJob.cs

    r1545 r1549  
    88{
    99    [Serializable]
    10     public class DistributedJob : INotifyPropertyChanged, ISerializable
     10    public class DistributedJob : INotifyPropertyChanged
    1111    {
    1212        [NonSerialized] private String _localFilePath;
    13 
    14         protected DistributedJob(SerializationInfo info, StreamingContext ctxt)
    15         {
    16             JobName = (string) info.GetValue("JobName", typeof (string));
    17             JobDescription = (string) info.GetValue("JobDescription", typeof (string));
    18             JobGuid = (Guid) info.GetValue("JobGuid", typeof (Guid));
    19             JobOwner = (string) info.GetValue("JobOwner", typeof (string));
    20             JobDate = (DateTime) info.GetValue("JobDate", typeof (DateTime));
    21             FileName = (string) info.GetValue("FileName", typeof (string));
    22         }
    2313
    2414        public DistributedJob()
     
    3727        public DateTime JobDate { get; set; }
    3828
    39         private String FileName { get; set; }
     29        public String FileName { get; private set; }
    4030
    4131        public String LocalFilePath
     
    4636                if (value == _localFilePath) return;
    4737                _localFilePath = value;
     38                FileName = Path.GetFileName(_localFilePath);
    4839                OnPropertyChanged("LocalFilePath");
    4940            }
    5041        }
    5142
    52         public String JobLabel
    53         {
    54             get { return JobName; }
    55         }
    56 
    5743        #region INotifyPropertyChanged Members
    5844
     45        [field: NonSerialized]
    5946        public event PropertyChangedEventHandler PropertyChanged;
    60 
    61         #endregion
    62 
    63         #region ISerializable Members
    64 
    65         public void GetObjectData(SerializationInfo info, StreamingContext context)
    66         {
    67             info.AddValue("JobName", JobName);
    68             info.AddValue("JobDescription", JobDescription);
    69             info.AddValue("JobGuid", JobGuid);
    70             info.AddValue("JobOwner", P2PSettings.Default.PeerName);
    71             info.AddValue("JobDate", DateTime.Now);
    72             info.AddValue("FileName", Path.GetFileName(LocalFilePath));
    73         }
    7447
    7548        #endregion
     
    8053            if (String.IsNullOrEmpty(workspacePath) || !Directory.Exists(workspacePath))
    8154            {
    82                 throw new ArgumentOutOfRangeException(workspacePath, "Configured workspace directory is null, empty or does not exist.");
     55                throw new ArgumentOutOfRangeException(workspacePath, "Configured local workspace directory is null, empty or does not exist.");
    8356            }
    8457
  • trunk/CrypPlugins/P2PEditor/Distributed/JobListManager.cs

    r1545 r1549  
    6868            P2PManager.Store(GenerateWorkspaceKey(distributedJob), workspaceData);
    6969
    70             _p2PEditor.GuiLogMessage("Distributed job " + distributedJob.JobLabel, NotificationLevel.Info);
     70            _p2PEditor.GuiLogMessage("Distributed job " + distributedJob.JobName, NotificationLevel.Info);
    7171        }
    7272
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/JobDisplay.xaml

    r1527 r1549  
    1 <GUI:P2PUserControl x:Class="Cryptool.P2PEditor.GUI.Controls.JobDisplay" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:GUI="clr-namespace:Cryptool.P2PEditor.GUI" mc:Ignorable="d" d:DesignHeight="227" d:DesignWidth="486">
    2     <Grid Background="White">
    3         <Grid.ColumnDefinitions>
    4             <ColumnDefinition Width="200*"></ColumnDefinition>
    5             <ColumnDefinition Width="5px"></ColumnDefinition>
    6             <ColumnDefinition Width="200*"></ColumnDefinition>
    7         </Grid.ColumnDefinitions>
    8         <ListBox x:Name="JobListBox" DisplayMemberPath="JobLabel" ItemsSource="{Binding Jobs,RelativeSource ={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Grid.Column="0" />
    9         <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
    10         <Border Grid.Column="2" BorderThickness="1px" BorderBrush="Gray">
    11             <Grid DataContext="{Binding SelectedItem,ElementName=JobListBox}">
    12                 <Label Content="Owner:" Height="28" HorizontalAlignment="Left" Margin="0,6,0,0" VerticalAlignment="Top"/>
    13                 <Label Content="{Binding JobOwner}" Height="28" Margin="74,6,6,0" VerticalAlignment="Top" />
    14                 <Label Content="Description:" Height="28" HorizontalAlignment="Left" Margin="0,74,0,0" VerticalAlignment="Top" />
    15                 <ScrollViewer Margin="74,74,6,35" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
    16                     <Label Content="{Binding JobDescription}" />
    17                 </ScrollViewer>
    18                 <Button Content="Participate" HorizontalAlignment="Right" Margin="0,0,6,6" Name="ParticipateButton" Width="75" Height="23" VerticalAlignment="Bottom" Click="ParticipateButton_Click" />
    19                 <Button Content="Refresh" Click="RefreshButton_Click" HorizontalAlignment="Left" Margin="6,0,0,6" Name="RefreshButton" Width="75" Height="23" VerticalAlignment="Bottom" />
    20                 <Label Content="Date:" Height="28" HorizontalAlignment="Left" Margin="0,40,0,0" VerticalAlignment="Top" />
    21                 <Label Content="{Binding JobDate}" Height="28" Margin="74,40,6,0" VerticalAlignment="Top" />
    22             </Grid>
    23         </Border>
     1<GUI:P2PUserControl x:Class="Cryptool.P2PEditor.GUI.Controls.JobDisplay" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:GUI="clr-namespace:Cryptool.P2PEditor.GUI" mc:Ignorable="d" d:DesignHeight="218" d:DesignWidth="416">
     2        <GUI:P2PUserControl.Resources>
     3        <ResourceDictionary>
     4            <ResourceDictionary.MergedDictionaries>
     5                <ResourceDictionary Source="JobDisplayTemplate.xaml" />
     6            </ResourceDictionary.MergedDictionaries>
     7            <Style x:Key="jobListDisplayStyle" TargetType="{x:Type ListBox}">
     8                <Style.Resources>
     9                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="AliceBlue" />
     10                </Style.Resources>
     11            </Style>
     12        </ResourceDictionary>
     13    </GUI:P2PUserControl.Resources>
     14        <Grid Background="White">
     15        <ListBox x:Name="JobListBox" ItemsSource="{Binding Jobs,RelativeSource ={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ItemTemplate="{StaticResource jobDisplayTemplate}" Style="{StaticResource jobListDisplayStyle}" Margin="0,0,0,35">
     16            <ListBox.ItemContainerStyle>
     17                <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
     18                    <EventSetter Event="MouseDoubleClick" Handler="ParticipateItemHandler"/>
     19                </Style>
     20            </ListBox.ItemContainerStyle>
     21        </ListBox>
     22        <Grid DataContext="{Binding SelectedItem,ElementName=JobListBox}">
     23            <Button Content="Participate" HorizontalAlignment="Right" Margin="0,0,0,6" Name="ParticipateButton" Width="75" Height="23" VerticalAlignment="Bottom" Click="ParticipateButton_Click" />
     24            <Button Content="Refresh" Click="RefreshButton_Click" HorizontalAlignment="Right" Margin="0,0,81,6" Name="RefreshButton" Width="75" Height="23" VerticalAlignment="Bottom" />
     25        </Grid>
    2426    </Grid>
    2527</GUI:P2PUserControl>
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/JobDisplay.xaml.cs

    r1527 r1549  
    33using System.ComponentModel;
    44using System.Windows;
     5using System.Windows.Input;
    56using System.Windows.Threading;
    67using Cryptool.P2PEditor.Distributed;
     
    5051        private void ParticipateButton_Click(object sender, RoutedEventArgs e)
    5152        {
     53            ParticipateInSelectedJob();
     54        }
     55
     56        private void ParticipateItemHandler(object sender, MouseButtonEventArgs e)
     57        {
     58            ParticipateInSelectedJob();
     59        }
     60
     61        private void ParticipateInSelectedJob()
     62        {
    5263            var jobToParticipateIn = (DistributedJob) JobListBox.SelectedItem;
    5364
     
    5869
    5970            P2PEditor.GuiLogMessage(
    60                 string.Format("Participating in job {0} ({1}).", jobToParticipateIn.JobLabel, jobToParticipateIn.JobGuid),
     71                string.Format("Participating in job {0} ({1}).", jobToParticipateIn.JobName, jobToParticipateIn.JobGuid),
    6172                NotificationLevel.Info);
    6273            new JobParticipationWorker(P2PEditor, JobListManager, jobToParticipateIn, Dispatcher).RunWorkerAsync();
  • trunk/CrypPlugins/P2PEditor/P2PEditor.cs

    r1545 r1549  
    3838        private readonly JobListManager _jobListManager;
    3939
     40        private bool _initialNewHandled;
     41
    4042        public P2PEditor()
    4143        {
    4244            _jobListManager = new JobListManager(this);
     45            _initialNewHandled = false;
    4346
    4447            Presentation = new P2PEditorPresentation(this, _jobListManager);
     
    6265            GuiLogMessage("P2PEditor: New()", NotificationLevel.Debug);
    6366
    64             ((P2PEditorPresentation) Presentation).ShowJobCreation();
     67            // Avoid switching to the add view, but allow using the new button later
     68            if (!_initialNewHandled)
     69            {
     70                _initialNewHandled = true;
     71            } else
     72            {
     73                ((P2PEditorPresentation)Presentation).ShowJobCreation();
     74            }
    6575
    6676            if (OnSelectedPluginChanged != null)
  • trunk/CrypPlugins/P2PEditor/P2PEditor.csproj

    r1527 r1549  
    144144      <Generator>MSBuild:Compile</Generator>
    145145    </Page>
     146    <Page Include="GUI\Controls\JobDisplayTemplate.xaml">
     147      <SubType>Designer</SubType>
     148      <Generator>MSBuild:Compile</Generator>
     149    </Page>
    146150    <Page Include="GUI\P2PEditorPresentation.xaml">
    147151      <SubType>Designer</SubType>
  • trunk/CrypPlugins/P2PEditor/Worker/JobParticipationWorker.cs

    r1530 r1549  
    3838            _p2PEditor.GuiLogMessage(
    3939                string.Format("Workspace {0} ready to participate, dispatching with CrypTool...",
    40                               _jobToParticipateIn.JobLabel),
     40                              _jobToParticipateIn.JobName),
    4141                NotificationLevel.Info);
    4242
Note: See TracChangeset for help on using the changeset viewer.