Changeset 1619


Ignore:
Timestamp:
Jun 10, 2010, 5:45:26 PM (12 years ago)
Author:
Paul Lelgemann
Message:

+ P2PEditor: new tab, which "invites" to connect to the network

Location:
trunk/CrypPlugins/P2PEditor
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/JobDisplay.xaml

    r1563 r1619  
    1313    </GUI:P2PUserControl.Resources>
    1414        <Grid Background="White">
    15         <ListBox x:Name="JobListBox" ItemsSource="{Binding Jobs,RelativeSource ={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ItemTemplate="{StaticResource jobDisplayTemplate}" Style="{StaticResource jobListDisplayStyle}" KeyUp="JobListBox_KeyUp" Margin="0,0,0,35">
     15        <ListBox x:Name="JobListBox" ItemsSource="{Binding Jobs, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ItemTemplate="{StaticResource jobDisplayTemplate}" Style="{StaticResource jobListDisplayStyle}" KeyUp="JobListBox_KeyUp" Margin="0,0,0,35">
    1616            <ListBox.ItemContainerStyle>
    1717                <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
  • trunk/CrypPlugins/P2PEditor/GUI/P2PEditorPresentation.xaml

    r1563 r1619  
    1 <GUI:P2PUserControl x:Class="Cryptool.P2PEditor.GUI.P2PEditorPresentation" 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:controls="clr-namespace:Cryptool.P2PEditor.GUI.Controls" xmlns:GUI="clr-namespace:Cryptool.P2PEditor.GUI" mc:Ignorable="d" d:DesignHeight="278" d:DesignWidth="656" x:Name="P2PEditorControl">
     1<GUI:P2PUserControl x:Class="Cryptool.P2PEditor.GUI.P2PEditorPresentation" 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:controls="clr-namespace:Cryptool.P2PEditor.GUI.Controls" xmlns:GUI="clr-namespace:Cryptool.P2PEditor.GUI" xmlns:Converters="clr-namespace:Cryptool.P2PEditor.Converters" mc:Ignorable="d" d:DesignHeight="278" d:DesignWidth="656" x:Name="P2PEditorControl">
     2        <GUI:P2PUserControl.Resources>
     3        <Converters:ConnectivityToVisibilityConverter x:Key="ConnectivityToVisibilityConverter" />
     4        </GUI:P2PUserControl.Resources>
    25        <Grid>
    3                 <TabControl TabStripPlacement="Top" Name="JobTabControl" IsEnabled="{Binding IsP2PConnected, ElementName=P2PEditorControl}">
    4                         <TabItem Header="Active jobs" Name="ActiveJobsTab">
    5                                 <controls:JobDisplay x:Name="ActiveJobsControl" Jobs="{Binding Jobs,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
     6                <TabControl TabStripPlacement="Top" Name="JobTabControl">
     7            <TabItem Header="Active jobs" Name="ActiveJobsTab" IsEnabled="{Binding IsP2PConnected, ElementName=P2PEditorControl}">
     8                <controls:JobDisplay x:Name="ActiveJobsControl" Jobs="{Binding Jobs, ElementName=P2PEditorControl}" />
    69                        </TabItem>
    7                         <TabItem Header="New job" Name="JobCreationTab">
     10            <TabItem Header="New job" Name="JobCreationTab" IsEnabled="{Binding IsP2PConnected, ElementName=P2PEditorControl}">
    811                                <controls:JobCreation />
    912                        </TabItem>
    10                 </TabControl>
     13            <TabItem Header="Connect" Name="ConnectTab" Visibility="{Binding IsP2PConnected, ElementName=P2PEditorControl, Converter={StaticResource ConnectivityToVisibilityConverter}}">
     14                <controls:ConnectTab IsP2PConnecting="{Binding IsP2PConnecting, ElementName=P2PEditorControl}" />
     15            </TabItem>
     16        </TabControl>
    1117        </Grid>
    1218</GUI:P2PUserControl>
  • trunk/CrypPlugins/P2PEditor/GUI/P2PEditorPresentation.xaml.cs

    r1616 r1619  
    1717using System;
    1818using System.Collections.Generic;
    19 using System.ComponentModel;
    2019using System.Windows;
    2120using System.Windows.Threading;
     
    4342                                            P2PEditorPresentation), new PropertyMetadata(false));
    4443
     44        public static readonly DependencyProperty IsP2PConnectingProperty =
     45            DependencyProperty.Register("IsP2PConnecting",
     46                                        typeof(
     47                                            Boolean),
     48                                        typeof(
     49                                            P2PEditorPresentation), new PropertyMetadata(false));
     50
    4551        public P2PEditorPresentation(P2PEditor p2PEditor, JobListManager jobListManager)
    4652        {
     
    5460
    5561            UpdateDisplay();
     62
     63            if (!P2PManager.IsConnected)
     64            {
     65                ShowConnectTab();
     66            }
    5667        }
    5768
     
    5970        {
    6071            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateConnectionState));
     72
     73            if (P2PManager.IsConnected)
     74            {
     75                ShowActiveJobs();
     76            }
     77            else
     78            {
     79                ShowConnectTab();
     80            }
    6181        }
    6282
     
    7393        }
    7494
    75 
    76         internal void ConnectionWorkerCompleted(object sender, bool newState)
     95        public Boolean IsP2PConnecting
    7796        {
    78             UpdateDisplay();
     97            get { return (Boolean)GetValue(IsP2PConnectingProperty); }
     98            set { SetValue(IsP2PConnectingProperty, value); }
    7999        }
    80100
     
    85105        }
    86106
    87         private void UpdateConnectionState()
     107        internal void UpdateConnectionState()
    88108        {
    89109            IsP2PConnected = P2PManager.IsConnected;
     110            IsP2PConnecting = P2PManager.IsConnecting;
    90111        }
    91112
     
    100121            JobTabControl.SelectedItem = ActiveJobsTab;
    101122        }
     123
     124        internal void ShowConnectTab()
     125        {
     126            JobTabControl.SelectedItem = ConnectTab;
     127        }
    102128    }
    103129}
  • trunk/CrypPlugins/P2PEditor/P2PEditor.csproj

    r1616 r1619  
    6969  </ItemGroup>
    7070  <ItemGroup>
     71    <Compile Include="Converters\ConnectivityToVisibilityConverter.cs" />
     72    <Compile Include="GUI\Controls\ConnectTab.xaml.cs">
     73      <DependentUpon>ConnectTab.xaml</DependentUpon>
     74    </Compile>
    7175    <Compile Include="GUI\P2PUserControl.cs" />
    7276    <Compile Include="P2PEditorSettings.cs" />
     
    138142      <Generator>MSBuild:Compile</Generator>
    139143    </Resource>
     144    <Page Include="GUI\Controls\ConnectTab.xaml">
     145      <SubType>Designer</SubType>
     146      <Generator>MSBuild:Compile</Generator>
     147    </Page>
    140148    <Page Include="GUI\Controls\JobCreation.xaml">
    141149      <SubType>Designer</SubType>
     
    155163    </Page>
    156164  </ItemGroup>
    157   <ItemGroup />
     165  <ItemGroup>
     166    <Resource Include="images\connected.png" />
     167    <Resource Include="images\disconnected.png" />
     168  </ItemGroup>
    158169  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    159170  <PropertyGroup>
  • trunk/CrypPlugins/P2PEditor/P2PEditorSettings.cs

    r1616 r1619  
    1717using System.ComponentModel;
    1818using Cryptool.P2P;
    19 using Cryptool.P2P.Worker;
    20 using Cryptool.P2PEditor.GUI;
    2119using Cryptool.PluginBase;
    2220using Cryptool.Plugins.PeerToPeer.Internal;
     
    10199            if (!P2PManager.IsConnected)
    102100            {
    103                 P2PManager.ConnectionManager.OnP2PConnectionStateChangeOccurred += ((P2PEditorPresentation)_p2PEditor.Presentation).ConnectionWorkerCompleted;
    104101                P2PManager.Connect();
    105102                OnPropertyChanged("ButtonStart");
     
    116113            if (P2PManager.IsConnected)
    117114            {
    118                 P2PManager.ConnectionManager.OnP2PConnectionStateChangeOccurred += ((P2PEditorPresentation)_p2PEditor.Presentation).ConnectionWorkerCompleted;
    119115                P2PManager.Disconnect();
    120116                OnPropertyChanged("ButtonStop");
Note: See TracChangeset for help on using the changeset viewer.