Esempio n. 1
0
        // The event handler.
        private void TheProject_ReviewEventHandler(
            SoftwareProject project, ReviewEventArgs args)
        {
            string message = "Priority " + args.Priority.ToString() +
                             "\n\nYes to Approve\nNo to Reject\nCancel for Pending";

            switch (MessageBox.Show(message, "Review",
                                    MessageBoxButtons.YesNoCancel))
            {
            case DialogResult.Yes:
                args.Project.Status = ReviewStatus.Approved;
                break;

            case DialogResult.No:
                args.Project.Status = ReviewStatus.Rejected;
                break;
            }
        }
        // Raise the event on the registered handlers
        // until one of them sets a project status.
        public void OnReviewEvent()
        {
            // Make the basic ReviewEventArgs object.
            ReviewEventArgs args = new ReviewEventArgs()
            {
                Project = this
            };

            foreach (ReviewHandlerInfo info in ReviewHandlers)
            {
                // If the status has been assigned, we're done.
                if (this.Status != ReviewStatus.Pending)
                {
                    break;
                }

                // Save the event handler's priority in the
                // ReviewEventArgs and call the event handler.
                args.Priority = info.Priority;
                info.Handler(this, args);
            }
        }