Пример #1
0
        public void SetAdapter(MainFormController controller)
        {
            _controller = controller;

            // Classical .NET controls like a WinForm button
            // expose event delegates, like a ".Load or .Click event", that you can subscribe to.
            // We subscribe to some of those low-level .NET events here and convert them into
            // more meaningful "UI domain" events that we care about.
            // We then send/publish them to our own custom event handling system
            // (to our in-memory queue->to potentially the UI message bus, etc.).

            Load += (sender, args) => _controller.Publish(new FormLoading());

            _menuCaptureThought.Click += (sender, args) => _controller.Publish(new UI.AddStuffClicked());
            _menuDefineProject.Click += (sender, args) => _controller.Publish(new UI.DefineProjectClicked());
            _menuGoToInbox.Click += (sender, args) => _controller.Publish(new UI.DisplayInbox());

            _filter.SelectedIndexChanged += (sender, args) =>
                {
                    var item = (FilterDisplay) _filter.SelectedItem;
                    _controller.Publish(new UI.ActionFilterChanged(item.Criteria));
                };
        }