Exemplo n.º 1
0
 /// <summary>
 /// Event handler for preferences class if any property was changed.
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">changed property arguments</param>
 private void m_OnPropertyChanged(object sender, PropertyEventArgs e)
 {
     //TO DO
 }
Exemplo n.º 2
0
 protected void OnPropertyChanged(PropertyEventArgs e)
 {
     if (PropertyChanged != null)
     {
     PropertyChanged(this, e);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the property <code>key</code> to the value <code>val</code>.
 /// If <code>val</code> is null, the property will be taken out from the
 /// properties.
 /// </summary>
 /// <param name="key">
 /// The name of the property.
 /// </param>
 /// <param name="val">
 /// The value of the property.
 /// </param>
 public void SetProperty(string key, object val)
 {
     object oldValue = _preferences[key];
     if (!val.Equals(oldValue))
     {
     _preferences[key] = val;
     PropertyEventArgs e = new PropertyEventArgs(key, oldValue, val);
     OnPropertyChanged(e);
     if (e.NewValue != oldValue)
     {
         _preferences[key] = e.NewValue;
     }
     }
 }
Exemplo n.º 4
0
 public void SetRuntimeProperty(string key, object val, bool raise)
 {
     _runtimePrefs.Add(key);
     object oldValue = _preferences[key];
     if (!val.Equals(oldValue))
     {
     _preferences[key] = val;
     if (raise)
     {
         PropertyEventArgs e = new PropertyEventArgs(key, oldValue, val);
         OnPropertyChanged(e);
         if (e.NewValue != oldValue)
         {
             _preferences[key] = e.NewValue;
         }
     }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Event handler for preferences class if any property was changed.
 /// </summary>
 /// <param name="sender">sender</param>
 /// <param name="e">changed property arguments</param>
 internal void OnPropertyChanged(object sender, PropertyEventArgs e)
 {
     if (e.Key=="MaxDownloadRate")
     {
     float upRate=Preferences.GetFloat("MaxUploadRate");
     float downRate=(float)e.NewValue;
     if ((upRate*4.0F<downRate)&&(upRate<10))
     {
         e.NewValue = upRate*4.0F;
     }
     else
     {
         // do nothing
     }
     }
     if (e.Key=="MaxUploadRate")
     {
     float upRate=(float)e.NewValue;
     float downRate=Preferences.GetFloat("MaxDownloadRate");
     if ((upRate*4.0F<downRate)&&(upRate<10))
     {
         Preferences.SetProperty("MaxDownloadRate", upRate*4.0F, false);
     }
     else
     {
         // do nothing
     }
     }
     if (e.Key=="RemotePassword")
     {
     System.Security.Cryptography.MD5 crypto=System.Security.Cryptography.MD5.Create();
     byte [] c=null;
     string clearPass=(string)e.NewValue;
     c=new byte[clearPass.Length];
     for (int i=0; i < clearPass.Length; i++)
     {
         c[i]=System.Convert.ToByte(clearPass[i]);
     }
     byte[] res=crypto.ComputeHash(c);
     e.NewValue=CKernel.HashToString(res);
     }
     if (e.Key=="Language")
     {
     Globalization.Language = e.NewValue.ToString();
     }
     if (e.Key=="IPFilterEnabled")
     {
     bool enabled=(bool)e.NewValue;
     if (enabled)
     {
         IPFilter = new CIPFilter();
         IPFilter.LoadIPFilter(DllDirectory,"ipfilter.dat",128);
     }
     else
         IPFilter=null;
     }
     if (e.Key=="TCPPort")
     {
     m_PortChanged=true;
     if (e.NewValue!=e.OldValue)
     {
         CKernel.Listener.Stop();
         CKernel.Listener=new CListener((ushort)e.NewValue);
         CKernel.Listener.Start();
         CKernel.ServersList.ConnectToAnyServer();//first call disconnects
         CKernel.ServersList.ConnectToAnyServer();//secons call connects
     }
     }
     if (e.Key=="UDPPort")
     {
     if (e.NewValue!=e.OldValue)
     {
         CKernel.UDPListener.Close();
         CKernel.UDPListener=new CUDPListener();
     }
     }
     if (e.Key=="TempFolders")
     {
     ArrayList newFolders=new ArrayList((Array)e.NewValue);
     ArrayList oldFolders=new ArrayList((Array)e.OldValue);
     foreach (string oldfolder in (Array)e.OldValue)
     {
         if (!newFolders.Contains(oldfolder))
         {
             //remove files from folder
             CKernel.FilesList.RemoveIncompleteFolder(oldfolder);
         }
     }
     foreach (string newfolder in (Array)e.NewValue)
     {
         if (!oldFolders.Contains(newfolder))
         {
             //remove files from folderadd new temp folder
             CKernel.FilesList.AddNewIncompleteFolder(newfolder);
         }
     }
     }
     if (e.Key=="SharedFolders")
     {
     string sharedOld="";
     string sharedNew="";
     foreach (string oldfolder in (Array)e.OldValue)
     {
         sharedOld+=oldfolder;
     }
     foreach (string newfolder in (Array)e.NewValue)
     {
         sharedNew+=newfolder;
     }
     if (sharedOld!=sharedNew) CKernel.FilesList.RefreshSharedList();
     }
 }