summaryrefslogtreecommitdiff
path: root/Ivy/IvyEventArgs.cs
blob: f9f6e73774c5d3da844c46876f9143cfa742eff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

namespace IvyBus
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections.ObjectModel;
    
    /// <summary> The EventArgs Classes
    /// </summary>
    /// 
    public class IvyEventArgs : EventArgs
    {
        private IvyClient client;
        private int id;
        private string arg;

        /// <summary>
        /// the client who raise the event
        /// </summary>
        public IvyClient Client
        {
            get { return client; }
        }

        /// <summary>
        /// the id argument of the message
        /// </summary>
        public int Id
        {
            get { return id; }
        }

        /// <summary>
        /// the general purpose argument of the event
        /// </summary>
        public string Argument
        {
            get { return arg; }
        }
        /// <summary>
        /// Args of Ivy generated  events
        /// </summary>
        internal IvyEventArgs(IvyClient app, int id, string arg)
        {
            this.client = app;
            this.id = id;
            this.arg = arg;
        }
    }
    public class IvyDieEventArgs : IvyEventArgs
    {
        /* return value for Die Event */
        private bool forceExit;

        /// <summary>
        /// should  we exit
        /// </summary>
        /// <remarks>
        /// by default the Ivy bus will make a call to Exit
        /// set this flags to false if you wan't your application to survive
        /// </remarks>
        /// <value>true</value>
        public bool ForceExit
        {
            get { return forceExit; }
            set { forceExit = value; }
        }
        /// <summary>
        /// Arg of the Die Event
        /// </summary>
        internal IvyDieEventArgs(IvyClient app, int id, string arg)
            : base(app, id, arg)
        {
            forceExit = true;
        }
    }
    public class IvyMessageEventArgs : IvyEventArgs
    {
        private string[] arg_list;

        /// <summary>
        /// retreive all the arguments
        /// </summary>
        /// <returns></returns>
        public string[] GetArguments()
        {
            return (string[])arg_list.Clone();
        }
        
        /// <summary>
        /// retreive the argument at specified index
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public string this[int index]
        {
            get { return arg_list[index]; }
        }
        /// <summary>
        /// Arg for the Normal Ivy Message received
        /// </summary>
        internal IvyMessageEventArgs(IvyClient app, int id, string[] args)
            : base( app, id, null)
        {
            this.arg_list = args;
        }
    }
}