protected bool CheckForProperEditToken(out StoryEditor theSE)
        {
            theSE = TheSE;              // (StoryEditor)FindForm();
            try
            {
                if (theSE == null)
                {
                    throw new ApplicationException(
                              "Unable to edit the file! Restart the program and if it persists, contact [email protected]");
                }

                if (!theSE.IsInStoriesSet)
                {
                    throw theSE.CantEditOldStoriesEx;
                }

                if (!theSE.theCurrentStory.ProjStage.IsEditAllowed(theSE.LoggedOnMember.MemberType))
                {
                    throw theSE.theCurrentStory.ProjStage.WrongMemberTypeEx;
                }
            }
            catch (Exception ex)
            {
                if (theSE != null)
                {
                    theSE.SetStatusBar(String.Format("Error: {0}", ex.Message));
                }
                return(false);
            }

            return(true);
        }
 // if the coach tries to add a note in the consultant's pane, that should fail.
 // (but it's okay for a project facilitator to add one if they have a question
 //  for the consultant)
 public bool CheckAddNotePrivilege(StoryEditor theSE,
                                   TeamMemberData.UserTypes eLoggedOnMember)
 {
     if (!HasAddNotePrivilege(eLoggedOnMember))
     {
         theSE.SetStatusBar("Error: " + String.Format("You must be logged in as a '{0}' or a '{1}' to add a note here",
                                                      TeamMemberData.GetMemberTypeAsDisplayString(MentorType),
                                                      TeamMemberData.GetMemberTypeAsDisplayString(MenteeType)));
         return(false);
     }
     return(true);
 }
        protected override void OnKeyDown(KeyEventArgs e)
        {
            Console.WriteLine(String.Format("KeyCode: {0}; KeyData: {1}, KeyValue: {2}",
                                            e.KeyCode,
                                            e.KeyData,
                                            e.KeyValue));

            StoryEditor theSE = (StoryEditor)_ctrlVerseParent.FindForm();

            try
            {
                if (theSE == null)
                {
                    throw new ApplicationException(
                              "Unable to edit the file! Try rebooting and if it persists, contact [email protected]");
                }

                // certain keys (like arrow keys), we just want to allow in any case.
                if (!IsKeyAutomaticallyAllowed(theSE, e))
                {
                    if (!theSE.IsInStoriesSet)
                    {
                        throw theSE.CantEditOldStoriesEx;
                    }

                    // if the creator has defined a particular required editor (e.g. for consultant notes,
                    //  the *mentor* must be a *consultant*), then throw if we don't have one and always
                    //  allow the edit otherwise (since no one else can, we don't have to worry about conflicts).
                    if (_delegateRequiredEditorCheck != null)                        // ... i.e. a req. editor checking delegate is defined
                    {
                        // throws if failure
                        _delegateRequiredEditorCheck(theSE.LoggedOnMember.MemberType, _eRequiredEditor);
                    }

                    // finally, the last possible blockage is if the currently logged on member isn't the
                    //  right editor for the state we are in (which has to do with who has the edit token)
                    if (!_stageLogic.IsEditAllowed(theSE.LoggedOnMember.MemberType))
                    {
                        throw _stageLogic.WrongMemberTypeEx;
                    }
                }

                // if we get here, we're all good!
                base.OnKeyDown(e);
                theSE.Modified = true;                  // to trigger save if exit.

                // update the status bar (in case we previously put an error there
                StoryStageLogic.StateTransition st = StoryStageLogic.stateTransitions[_stageLogic.ProjectStage];
                theSE.SetStatusBar(String.Format("{0}  Press F1 for instructions", st.StageDisplayString));
            }
            catch (Exception ex)
            {
                Console.Beep();
                if (theSE != null)
                {
                    theSE.SetStatusBar(String.Format("Error: {0}", ex.Message));
                }
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
        }