diff options
author | fcolin | 2007-02-01 09:56:33 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 09:56:33 +0000 |
commit | 4fc629dc1600f24549b0e1f68a8bb7ad5841820c (patch) | |
tree | fb4856fb6990bbb62d4e3e80a36ba3a4b930e2de /CSharp/Ivy/IvyPPC | |
parent | 5cdc1fb12fced4a0e3765426c3f75a9156f0e164 (diff) | |
download | ivy-csharp-4fc629dc1600f24549b0e1f68a8bb7ad5841820c.zip ivy-csharp-4fc629dc1600f24549b0e1f68a8bb7ad5841820c.tar.gz ivy-csharp-4fc629dc1600f24549b0e1f68a8bb7ad5841820c.tar.bz2 ivy-csharp-4fc629dc1600f24549b0e1f68a8bb7ad5841820c.tar.xz |
Utilisateur : Fcolin Date : 30/06/06 Heure : 13:40 Archivé dans $/CSharp/Ivy/Ivy Commentaire: gestion designer (vss 2)
Diffstat (limited to 'CSharp/Ivy/IvyPPC')
-rw-r--r-- | CSharp/Ivy/IvyPPC/IvyApplicationBinding.cs | 98 |
1 files changed, 88 insertions, 10 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyApplicationBinding.cs b/CSharp/Ivy/IvyPPC/IvyApplicationBinding.cs index 637d627..d76e4a4 100644 --- a/CSharp/Ivy/IvyPPC/IvyApplicationBinding.cs +++ b/CSharp/Ivy/IvyPPC/IvyApplicationBinding.cs @@ -1,7 +1,9 @@ using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Text;
using System.ComponentModel;
+using System.Threading;
namespace IvyBus
{
@@ -9,10 +11,10 @@ namespace IvyBus /* association of a generated Key and a delegate and the expression */
/* this is SEND to other client */
+ [PropertyTab(typeof(System.Windows.Forms.Design.EventsTab), PropertyTabScope.Component)]
[DefaultEvent("Callback")]
[DesignerCategory("Component")]
- [DesignTimeVisible(true)]
- [ToolboxItem(false)] /* should be added via Ivy component */
+ [DesignTimeVisible(false)] /* should be added via Ivy component */
public class IvyApplicationBinding : System.ComponentModel.Component
{
private BindingType binding;
@@ -52,24 +54,100 @@ namespace IvyBus get { return expression; }
set { expression = value; }
}
+ private string formated_expression;
+ public string FormatedExpression
+ {
+ get
+ {
+ FormatExpression();
+ return formated_expression;
+ }
+ }
- [Browsable(true)]
+ private StringCollection arguments;
+ ///<summary>SentMessageClasses the first word token of sent messages
+ ///<remarks> optimise the parsing process when sending messages </remarks>
+ ///</summary>
+#if (!PocketPC)
+ [Category("Ivy")]
+#endif
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ // sinon bug System.String constructor not found !
+ [Editor(
+ "System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
+ "System.Drawing.Design.UITypeEditor,System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
+ )]
+ [Description("Arguments used when formating the expression")]
+ public StringCollection Arguments
+ {
+ get
+ {
+ return arguments;
+ }
+ }
+
+#if (!PocketPC)
+ [Category("Ivy")]
+#endif
+ [Description("Event fired when Message Matching expression received")]
public event EventHandler<IvyMessageEventArgs> Callback;
public IvyApplicationBinding()
{
+ arguments = new StringCollection();
}
-
- [Browsable(false)]
- public EventHandler<IvyMessageEventArgs> CallbackHandler
+ public IvyApplicationBinding(IContainer container)
+ : this()
{
- get
+ container.Add(this);
+ }
+ // translate part of expression to object property
+ public void FormatExpression()
+ {
+ if (Callback != null)
+ {
+ object target = Callback.Target;
+ if (args == null)
+ {
+ args = new object[arguments.Count];
+ for (int i = 0; i < arguments.Count; i++)
+ {
+ System.Reflection.PropertyInfo prop = target.GetType().GetProperty(arguments[i]);
+ if (prop != null)
+ args[i] = prop.GetValue(target, null);
+ else //TODO what else BUG msgbox in desing mode !!!
+ args[i] = arguments[i];
+ }
+ }
+ formated_expression = string.Format(expression, args);
+ }
+ else //TODO Abnormal condition Design Time
+ formated_expression = expression;
+
+ }
+
+
+ internal void Firevent(System.Threading.SynchronizationContext syncContext, IvyMessageEventArgs e)
+ {
+ //// Safely invoke an event:
+ EventHandler<IvyMessageEventArgs> temp = Callback;
+
+ if (temp == null)
+ {
+ throw new IvyException("(callCallback) Not callback for id " + e.Id);
+ }
+ if (syncContext != null)
{
- EventHandler<IvyMessageEventArgs> temp = Callback;
- return temp;
+ SendOrPostCallback update = delegate(object state)
+ {
+ IvyMessageEventArgs args = (IvyMessageEventArgs)state;
+ temp(this, args);
+ };
+ syncContext.Send(update, e);
}
+ else
+ temp(this, e);
}
-
}
}
|