Changeset 1477


Ignore:
Timestamp:
May 25, 2010, 4:08:54 PM (12 years ago)
Author:
Paul Lelgemann
Message:

+ Added early version of P2P editor interface

override-bad-extension: CrypWin.exe
override-bad-extension: P2PEditor.dll

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypP2P/CrypP2P.csproj

    r1474 r1477  
    7676    <Reference Include="Bootstrapper">
    7777      <HintPath>..\AppReferences\Bootstrapper.dll</HintPath>
    78       <Private>False</Private>
    79     </Reference>
    80     <Reference Include="DevComponents.WpfRibbon">
    81       <HintPath>..\AppExternalReferences\DevComponents.WpfRibbon.dll</HintPath>
    8278      <Private>False</Private>
    8379    </Reference>
  • trunk/CrypP2P/Internal/P2PBase.cs

    r1458 r1477  
    3030using Gears4Net;
    3131using Cryptool.Plugins.PeerToPeer.Internal;
     32using PeersAtPlay.Util.Threading;
    3233
    3334/* TODO:
     
    471472        public bool SynchStore(string sKey, byte[] byteData)
    472473        {
    473             LogToMonitor("Begin: SynchStore. Key: " + sKey + ", Data: " + Encoding.UTF8.GetString(byteData));
     474            LogToMonitor("Begin: SynchStore. Key: " + sKey + ", " + byteData.Length + " bytes of data: " + Encoding.UTF8.GetString(byteData) + " [" + byteData.Length + " bytes]");
    474475            AutoResetEvent are = new AutoResetEvent(false);
    475476            // this method returns always a GUID to distinguish between asynchronous actions
  • trunk/CrypP2P/P2PManager.cs

    r1458 r1477  
    2222using Cryptool.PluginBase.Miscellaneous;
    2323using Cryptool.Plugins.PeerToPeer.Internal;
    24 using DevComponents.WpfRibbon;
    2524
    2625namespace Cryptool.P2P
     
    4544        # endregion
    4645
    47         #region Private variables
     46        #region Variables
    4847
    4948        public P2PBase P2PBase { get; set; }
    50         private P2PSettings P2PSettings { get; set; }
    51         private ButtonDropDown P2PButton { get; set; }
     49        public P2PSettings P2PSettings { get; set; }
    5250
    5351        #endregion
     
    6664        /// regarding certificates.
    6765        /// </summary>
    68         /// <param name="p2PButton">Button that can change the connection state
    69         /// and displays it by showing different images.</param>
    70         public void Initialize(ButtonDropDown p2PButton)
     66        public void Initialize()
    7167        {
    72             P2PButton = p2PButton;
    7368            P2PBase = new P2PBase();
    7469            P2PSettings = new P2PSettings();
     
    8378            // TODO check if this is correct, should be - but handler is not called (and application does not shut down), probably unrelated to this problem
    8479            Application.ApplicationExit += HandleDisconnectByApplicationShutdown;
    85         }
    86 
    87         /// <summary>
    88         /// Changes the current connection state to the P2P network.
    89         /// If there is currently no connection, it will try to connect.
    90         /// If a connection is present, it will disconnect.
    91         /// The actual work will be done asynchronous.
    92         /// </summary>
    93         public void ToggleConnectionState()
    94         {
    95             new ConnectionWorker(P2PBase, P2PSettings, P2PButton).Start();
    9680        }
    9781
     
    126110            if (P2PConnected())
    127111            {
    128                 new ConnectionWorker(P2PBase, P2PSettings, P2PButton).Start();
     112                new ConnectionWorker(P2PBase, P2PSettings).Start();
    129113            }
    130114        }
  • trunk/CrypP2P/Worker/ConnectionWorker.cs

    r1458 r1477  
    1515*/
    1616
    17 using System;
    1817using System.ComponentModel;
    19 using System.Windows.Controls;
    20 using System.Windows.Media;
    21 using System.Windows.Media.Imaging;
    2218using Cryptool.P2P.Helper;
    2319using Cryptool.P2P.Internal;
    2420using Cryptool.PluginBase;
    25 using DevComponents.WpfRibbon;
    2621
    2722namespace Cryptool.P2P.Worker
    2823{
    29     internal class ConnectionWorker : WorkerBase
     24    public class ConnectionWorker : WorkerBase
    3025    {
    3126        private readonly P2PBase _p2PBase;
    32         private readonly ButtonDropDown _p2PButton;
    3327        private readonly P2PSettings _p2PSettings;
    3428
    35         public ConnectionWorker(P2PBase p2PBase, P2PSettings p2PSettings, ButtonDropDown p2PButton)
     29        public ConnectionWorker(P2PBase p2PBase, P2PSettings p2PSettings)
    3630        {
    3731            _p2PBase = p2PBase;
    3832            _p2PSettings = p2PSettings;
    39             _p2PButton = p2PButton;
     33        }
     34
     35        protected override void WorkComplete(object sender, RunWorkerCompletedEventArgs e)
     36        {
     37            P2PManager.Instance.GuiLogMessage(
     38                P2PManager.Instance.P2PConnected()
     39                    ? "Connection to P2P network established."
     40                    : "Connection to P2P network terminated.", NotificationLevel.Info);
    4041        }
    4142
    4243        protected override void PerformWork(object sender, DoWorkEventArgs e)
    4344        {
    44             //p2pButton.IsEnabled = false;
    45 
    4645            if (!_p2PBase.Started)
    4746            {
     
    6665        }
    6766
    68         protected override void WorkComplete(object sender, RunWorkerCompletedEventArgs e)
    69         {
    70             // Update image according to new state
    71             var newImage = new Image();
    72 
    73             if (P2PManager.Instance.P2PConnected())
    74             {
    75                 P2PManager.Instance.GuiLogMessage("Connection to P2P network established.", NotificationLevel.Info);
    76                 P2PManager.Instance.GuiLogMessage("P2P user info: " + P2PManager.Instance.UserInfo(),
    77                                                   NotificationLevel.Debug);
    78                 newImage.Source = new BitmapImage(new Uri(P2PManager.P2PDisconnectImageUri, UriKind.RelativeOrAbsolute));
    79             }
    80             else
    81             {
    82                 P2PManager.Instance.GuiLogMessage("Connection to P2P network terminated.", NotificationLevel.Info);
    83                 newImage.Source = new BitmapImage(new Uri(P2PManager.P2PConnectImageUri, UriKind.RelativeOrAbsolute));
    84             }
    85 
    86             newImage.Stretch = Stretch.Uniform;
    87             newImage.Width = 40;
    88             newImage.Height = 40;
    89             _p2PButton.Image = newImage;
    90 
    91             _p2PButton.IsEnabled = true;
    92         }
    93 
    9467        protected override void PrePerformWork()
    9568        {
    96             _p2PButton.IsEnabled = false;
    9769        }
    9870    }
  • trunk/CrypP2P/Worker/WorkerBase.cs

    r1458 r1477  
    1919namespace Cryptool.P2P.Worker
    2020{
    21     internal abstract class WorkerBase
     21    public abstract class WorkerBase
    2222    {
    23         protected BackgroundWorker BackgroundWorker;
     23        public readonly BackgroundWorker BackgroundWorker;
    2424
    2525        protected WorkerBase()
Note: See TracChangeset for help on using the changeset viewer.