コード例 #1
0
ファイル: Example2.cs プロジェクト: tuita520/sharpy
        public static void Main(string[] args)
        {
            // Create event manager
            var events = new Sharpy.EventManager();


            // Register callback on event: "myEvent"
            // If you want to pass data, define your event class (see example event)
            events.On("myEvent", (e) => {
                // Cast event argrument to your event object
                var obj = (MyEvent)e;

                // Get (set) your event object data
                if (obj.x == 42)
                {
                    obj.title = "This is the right answer!";
                }

                // Other code
            });


            // Somewhere in code, trigger your event
            // Create and pass event
            events.Trigger("myEvent", new MyEvent(42));
        }
コード例 #2
0
ファイル: Example1.cs プロジェクト: NoxCaos/sharpy
        public static void Main(string[] args)
        {
            // Create event manager
            var events = new Sharpy.EventManager();

            // Register callback on event: "myEvent"
            events.On("myEvent", (e) => {
                // Your code here
            });

            // Somewhere in code, trigger your event
            events.Trigger("myEvent");
        }
コード例 #3
0
ファイル: Example1.cs プロジェクト: tuita520/sharpy
        public static void Main(string[] args)
        {
            // Create event manager
            var events = new Sharpy.EventManager();


            // Register callback on event: "myEvent"
            events.On("myEvent", (e) => {
                // Your code here
            });


            // Somewhere in code, trigger your event
            events.Trigger("myEvent");
        }
コード例 #4
0
ファイル: Example2.cs プロジェクト: NoxCaos/sharpy
        public static void Main(string[] args)
        {
            // Create event manager
            var events = new Sharpy.EventManager();

            // Register callback on event: "myEvent"
            // If you want to pass data, define your event class (see example event)
            events.On("myEvent", (e) => {
                // Cast event argrument to your event object
                var obj = (MyEvent) e;

                // Get (set) your event object data
                if (obj.x == 42) {
                    obj.title = "This is the right answer!";
                }

                // Other code
            });

            // Somewhere in code, trigger your event
            // Create and pass event
            events.Trigger("myEvent", new MyEvent(42));
        }