summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:56:14 +0000
committerfcolin2007-02-01 09:56:14 +0000
commit683fa99d6ccdba424a659892bc7cf39bee7ac7ad (patch)
tree371c4e1de099e0f9bc5c0f71bbd6481adfaef51a /CSharp/Ivy/IvyPPC
parentdf898a41f338af6b69b7cc03de9c71bc3e79d8ca (diff)
downloadivy-csharp-683fa99d6ccdba424a659892bc7cf39bee7ac7ad.zip
ivy-csharp-683fa99d6ccdba424a659892bc7cf39bee7ac7ad.tar.gz
ivy-csharp-683fa99d6ccdba424a659892bc7cf39bee7ac7ad.tar.bz2
ivy-csharp-683fa99d6ccdba424a659892bc7cf39bee7ac7ad.tar.xz
Utilisateur : Fcolin Date : 30/06/06 Heure : 14:37 Archivé dans $/CSharp/Ivy/Ivy Commentaire: (vss 69)
Diffstat (limited to 'CSharp/Ivy/IvyPPC')
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs82
1 files changed, 57 insertions, 25 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs
index c58fd42..5ae69d6 100644
--- a/CSharp/Ivy/IvyPPC/Ivy.cs
+++ b/CSharp/Ivy/IvyPPC/Ivy.cs
@@ -221,34 +221,30 @@ namespace IvyBus
set { ready_message = value; }
}
-#if (!Mono)
+
#if (!PocketPC)
[Category("Ivy")]
#endif
+ [DefaultValue(null)]
+ public System.Windows.Forms.ContainerControl ContainerControl
+ {
+ get { return parentControl; }
+ set
+ {
+ parentControl = value;
+ }
+ }
+#if (!PocketPC)
+ [Category("Ivy")]
+#endif
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
- //[Editor(typeof(IvyBindingCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public List<IvyApplicationBinding> Bindings
{
get { return app_bindings; }
}
- //create a collection editor class
-
- //private class IvyBindingCollectionEditor : CollectionEditor
- //{
- // public IvyBindingCollectionEditor(Type type)
- // : base(type)
- // {
- // }
-
- // //Over ride the function which will return the STYLES collection
- // protected override System.Type[] CreateNewItemTypes()
- // {
- // return new Type[] { typeof(IvyApplicationBinding) };
- // }
- //}
-#endif
+
internal class MyTcpListener : TcpListener
{
public MyTcpListener(IPAddress address, int port)
@@ -288,13 +284,18 @@ namespace IvyBus
private string ready_message;
private CultureInfo culture = new CultureInfo("en-us");
// for synchronous event
+#if (SyncContext)
private readonly SynchronizationContext syncContext;
-
+#else
+ private System.Windows.Forms.ContainerControl parentControl;
+#endif
public Ivy()
{
+#if (SynContext)
syncContext = SynchronizationContext.Current;
+#endif
clients = new List<IvyClient>();
bindings = new Dictionary<int, IvyApplicationBinding>();
app_bindings = new List<IvyApplicationBinding>();
@@ -304,10 +305,10 @@ namespace IvyBus
protocolVersion = Properties.Settings.Default.IvyProtocolVersion;
#endif
}
- public Ivy(IContainer container)
+ public Ivy(System.Windows.Forms.ContainerControl parentControl)
: this()
{
- container.Add(this);
+ this.parentControl = parentControl;
}
/// <summary> Readies the structures for the software bus connexion.
/// </summary>
@@ -745,7 +746,7 @@ namespace IvyBus
v[i].stream.TokenPing(message);
return v.Count;
}
-
+#if (SyncContext)
internal virtual void FireEvent(EventHandler<IvyEventArgs> ev, IvyEventArgs e)
{
if (ev != null)
@@ -763,6 +764,20 @@ namespace IvyBus
ev(this, e);
}
}
+#else
+ internal virtual void FireEvent(EventHandler<IvyEventArgs> ev, IvyEventArgs e)
+ {
+ if (ev != null)
+ {
+ if (parentControl != null)
+ {
+ parentControl.Invoke(ev, this, e);
+ }
+ else
+ ev(this, e);
+ }
+ }
+#endif
internal virtual void OnDirectMessage(IvyEventArgs e)
{
// Copy to a temporary variable to be thread-safe.
@@ -813,6 +828,7 @@ namespace IvyBus
EventHandler<IvyEventArgs> temp = ErrorMessage;
FireEvent(temp, e);
}
+#if (SyncContext)
internal virtual void OnDie(IvyDieEventArgs e)
{
// Copy to a temporary variable to be thread-safe.
@@ -832,7 +848,22 @@ namespace IvyBus
temp(this, e);
}
}
-
+#else
+ internal virtual void OnDie(IvyDieEventArgs e)
+ {
+ // Copy to a temporary variable to be thread-safe.
+ EventHandler<IvyDieEventArgs> temp = DieReceived;
+ if (temp != null)
+ {
+ if (parentControl != null)
+ {
+ parentControl.Invoke(temp, this, e);
+ }
+ else
+ temp(this, e);
+ }
+ }
+#endif
internal void OnMessage(IvyMessageEventArgs e)
{
IvyApplicationBinding bind = bindings[e.Id];
@@ -841,7 +872,7 @@ namespace IvyBus
{
throw new IvyException("(callCallback) Not regexp matching id " + e.Id);
}
- bind.Firevent(syncContext,e);
+ bind.Firevent(parentControl, e);
}
/*
@@ -1104,7 +1135,8 @@ namespace IvyBus
public void EndInit()
{
//TODO Autobinding attribute
- //if (syncControl != null)
+ if (parentControl != null)
+ AutoBinding(parentControl);
AutoBinding(Assembly.GetCallingAssembly());
// TODO ugly should be added directly the bindings Dictionary !
foreach (IvyApplicationBinding bind in app_bindings)