Пример #1
0
        public bool TextareaOnKeyUp(string strId, string strText)
        {
            StoryEditor theSE;

            if (!CheckForProperEditToken(out theSE))
            {
                return(false);
            }

            int nVerseIndex, nConversationIndex;

            if (!GetIndicesFromId(strId, out nVerseIndex, out nConversationIndex))
            {
                return(false);
            }

            ConsultNoteDataConverter theCNDC = DataConverter(nVerseIndex, nConversationIndex);

            System.Diagnostics.Debug.Assert((theCNDC != null) && (theCNDC.Count > 0));
            CommInstance aCI = theCNDC[theCNDC.Count - 1];

            aCI.SetValue(strText);

            // indicate that the document has changed
            theSE.Modified = true;

            // update the status bar (in case we previously put an error there
            StoryStageLogic.StateTransition st = StoryStageLogic.stateTransitions[theSE.theCurrentStory.ProjStage.ProjectStage];
            theSE.SetStatusBar(String.Format("{0}  Press F1 for instructions", st.StageDisplayString));

            return(true);
        }
Пример #2
0
        protected bool GetDataConverters(string strId, out int nVerseIndex, out int nConversationIndex,
                                         out ConsultNotesDataConverter theCNsDC, out ConsultNoteDataConverter theCNDC)
        {
            theCNsDC = null;
            theCNDC  = null;

            if (!GetIndicesFromId(strId, out nVerseIndex, out nConversationIndex))
            {
                return(false);
            }

            StoryEditor theSE;

            if (!CheckForProperEditToken(out theSE))
            {
                return(false);
            }

            theCNsDC = DataConverter(nVerseIndex);
            System.Diagnostics.Debug.Assert((theCNsDC != null) && (theCNsDC.Count > nConversationIndex));
            theCNDC = theCNsDC[nConversationIndex];

            // this always leads to the document being modified
            theSE.Modified = true;

            return(true);
        }
Пример #3
0
        /* doesn't seem to work... the 'value' member isn't updated until *after*
         * keyPress is executed. I could use event.keyCode to get the latest key
         * pressed, but that's not what I want. So have to use onKeyUp
         * public bool TextareaOnKeyPress(string strId, string strText)
         * {
         *      StoryEditor theSE;
         *      if (!CheckForProperEditToken(out theSE))
         *              return false;
         *
         *      int nVerseIndex, nConversationIndex;
         *      if (!GetIndicesFromId(strId, out nVerseIndex, out nConversationIndex))
         *              return false;
         *
         *      ConsultNoteDataConverter theCNDC = DataConverter(nVerseIndex, nConversationIndex);
         *      System.Diagnostics.Debug.Assert((theCNDC != null) && (theCNDC.Count > 0));
         *      CommInstance aCI = theCNDC[theCNDC.Count - 1];
         *      System.Diagnostics.Debug.WriteLine(String.Format("Was: {0}, now: {1}",
         *              aCI, strText));
         *      aCI.SetValue(strText);
         *
         *      // indicate that the document has changed
         *      theSE.Modified = true;
         *      return true;
         * }
         */

        public void CopyScriptureReference(string strId)
        {
            int nVerseIndex, nConversationIndex;

            if (!GetIndicesFromId(strId, out nVerseIndex, out nConversationIndex))
            {
                return;
            }

            ConsultNoteDataConverter theCNDC = DataConverter(nVerseIndex, nConversationIndex);

            System.Diagnostics.Debug.Assert((theCNDC != null) && (theCNDC.Count > 0));
            CommInstance aCI = theCNDC[theCNDC.Count - 1];

            if (Document != null)
            {
                HtmlDocument doc  = Document;
                HtmlElement  elem = doc.GetElementById(strId);
                if (elem != null)
                {
                    System.Diagnostics.Debug.Assert(elem.InnerText == aCI.ToString());
                    elem.InnerText += TheSE.GetNetBibleScriptureReference;
                    aCI.SetValue(elem.InnerText);
                    elem.Focus();
                }
            }
        }
Пример #4
0
        public bool OnClickHide(string strId)
        {
            int nVerseIndex, nConversationIndex;
            ConsultNotesDataConverter theCNsDC;
            ConsultNoteDataConverter  theCNDC;

            if (!GetDataConverters(strId, out nVerseIndex, out nConversationIndex,
                                   out theCNsDC, out theCNDC))
            {
                return(false);
            }

            // if there's only one and it's empty, then just delete it
            if (!theCNDC.HasData)
            {
                OnClickDelete(strId);
            }

            theCNDC.Visible = (theCNDC.Visible) ? false : true;

            if (TheSE.hiddenVersesToolStripMenuItem.Checked)
            {
                // then we just swap the text on the button
                if (Document != null)
                {
                    // repaint the button to be 'hide'
                    // since the strId might be from a Delete request (where the user
                    //  said "yes" to our request to hide it instead), we have to
                    //  rebuild the ID for the Hide button, which is:
                    strId = ConsultNoteDataConverter.ButtonId(nVerseIndex,
                                                              nConversationIndex, ConsultNoteDataConverter.CnBtnIndexHide);
                    HtmlElement elemButtonHide = Document.GetElementById(strId);
                    if (elemButtonHide != null)
                    {
                        elemButtonHide.InnerText = (theCNDC.Visible)
                                                                                                           ? ConsultNoteDataConverter.CstrButtonLabelHide
                                                                                                           : ConsultNoteDataConverter.CstrButtonLabelUnhide;
                        return(true);
                    }
                }
            }
            // otherwise remove the row of buttons and the embedded conversation table
            // if it's not invisible (but only if it's the last conversation... if it
            //  isn't the last one, then just hiding it won't work, because the subsequent
            //  conversations will have the wrong index (so we *must* do LoadDoc)
            else if (!theCNDC.Visible &&
                     (theCNsDC.Count == (nConversationIndex - 1)) &&
                     RemoveHtmlNodeById(ConsultNoteDataConverter.ButtonRowId(nVerseIndex, nConversationIndex)) &&
                     RemoveHtmlNodeById(ConsultNoteDataConverter.ConversationTableRowId(nVerseIndex, nConversationIndex)))
            {
                return(true);
            }

            // otherwise, we have to reload the document
            LoadDocument();
            return(true);
        }
Пример #5
0
        public bool OnAddNote(int nVerseIndex, string strNote)
        {
            ConsultNotesDataConverter aCNsDC = DataConverter(nVerseIndex);
            ConsultNoteDataConverter  aCNDC  = DoAddNote(strNote, aCNsDC);

            if (aCNDC != null)
            {
                StrIdToScrollTo = ConsultNoteDataConverter.TextareaId(nVerseIndex, aCNsDC.IndexOf(aCNDC));
            }
            return(true);
        }
        protected ConsultNoteDataConverter(ConsultNoteDataConverter rhs)
        {
            RoundNum = rhs.RoundNum;

            // the guid shouldn't be replicated
            guid       = Guid.NewGuid().ToString();         // rhs.guid;
            Visible    = rhs.Visible;
            IsFinished = rhs.IsFinished;

            foreach (CommInstance aCI in rhs)
            {
                Add(new CommInstance(aCI));
            }
        }
        void buttonDragDropHandle_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(ConsultNoteControl)))
            {
                ConsultNoteControl theCNC = (ConsultNoteControl)e.Data.GetData(typeof(ConsultNoteControl));
                System.Diagnostics.Debug.Assert((sender is Button) && (sender == buttonDragDropHandle) && (theCNC.ParentControl != null) && (theCNC.ParentControl is ConsultNotesControl));
                ConsultNoteDataConverter theMovingCNDC = theCNC._myCNDC;
                theCNC._myCollection.Remove(theMovingCNDC);
                _theCNsDC.Insert(0, theMovingCNDC);

                StoryEditor theSE = (StoryEditor)FindForm();
                theSE.ReInitConsultNotesPane(_theCNsDC);
            }
        }
Пример #8
0
        public bool OnClickDelete(string strId)
        {
            int nVerseIndex, nConversationIndex;
            ConsultNotesDataConverter theCNsDC;
            ConsultNoteDataConverter  theCNDC;

            if (!GetDataConverters(strId, out nVerseIndex, out nConversationIndex,
                                   out theCNsDC, out theCNDC))
            {
                return(false);
            }

            if (theCNDC.HasData)
            {
                DialogResult res = MessageBox.Show(
                    Properties.Resources.IDS_NoteNotEmptyHideQuery,
                    Properties.Resources.IDS_Caption, MessageBoxButtons.YesNoCancel);

                if (res == DialogResult.Yes)
                {
                    return(OnClickHide(strId));
                }

                if (res == DialogResult.Cancel)
                {
                    return(true);
                }
            }

            bool bRemovedLast = (theCNsDC.IndexOf(theCNDC) == (theCNsDC.Count - 1));

            theCNsDC.Remove(theCNDC);

            // remove the HTML elements for the row of buttons and the conversation table
            //  (but only if it was the last conversation. If it wasn't, then the other
            //  conversations will have out of sequence ids, so we'll just *have* to do
            //  LoadDoc
            if (bRemovedLast
                &&
                RemoveHtmlNodeById(ConsultNoteDataConverter.ButtonRowId(nVerseIndex, nConversationIndex))
                &&
                RemoveHtmlNodeById(ConsultNoteDataConverter.ConversationTableRowId(nVerseIndex, nConversationIndex)))
            {
                return(true);
            }

            LoadDocument();
            return(true);
        }
        public StringTransfer DoAddNote(string strNote)
        {
            // the only function of the button here is to add a slot to type a con note
            StoryEditor theSE;

            if (!CheckForProperEditToken(out theSE))
            {
                return(null);
            }

            // if we're not given anything to put in the box, at least put in the logged
            //  in member's initials and re
            if (String.IsNullOrEmpty(strNote) && (theSE.LoggedOnMember != null))
            {
                strNote = StoryEditor.GetInitials(theSE.LoggedOnMember.Name) + ": Re: ";
            }

            // 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)
            if (!_theCNsDC.CheckAddNotePrivilege(theSE, theSE.LoggedOnMember.MemberType))
            {
                return(null);
            }

            StoryStageLogic.ProjectStages eCurState = theSE.theCurrentStory.ProjStage.ProjectStage;
            int round = 1;

            if (eCurState > StoryStageLogic.ProjectStages.eProjFacOnlineReview1WithConsultant)
            {
                round = 2;
                if (eCurState > StoryStageLogic.ProjectStages.eProjFacOnlineReview2WithConsultant)
                {
                    round = 3;
                }
            }

            ConsultNoteDataConverter cndc =
                _theCNsDC.Add(round, theSE.LoggedOnMember.MemberType, strNote);

            System.Diagnostics.Debug.Assert(cndc.Count == 1);

            theSE.ReInitConsultNotesPane(_theCNsDC);

            // return the StringTransfer we just created
            return(cndc[0]);
        }
Пример #10
0
        public ConsultNoteControl(VerseControl ctrlVerse, StoryStageLogic storyStageLogic, ConsultNotesDataConverter theCollection,
                                  ConsultNoteDataConverter aCNDC, TeamMemberData.UserTypes eLoggedOnMemberType)
            : base(storyStageLogic)
        {
            _myCNDC       = aCNDC;
            _myCollection = theCollection;

            m_nRoundNum = aCNDC.RoundNum;
            InitializeComponent();

            tableLayoutPanel.SuspendLayout();
            SuspendLayout();

            InsertColumn(2);

            labelRound.Text = CstrRoundLabel + m_nRoundNum.ToString();
            tableLayoutPanel.SetColumnSpan(labelRound, 2);
            tableLayoutPanel.Controls.Add(labelRound, 0, 0);
            tableLayoutPanel.Controls.Add(buttonDragDropHandle, 1, 0);

            System.Diagnostics.Debug.Assert(tableLayoutPanel.RowCount == 1, "otherwise, fix this assumption: ConsultNoteControl.cs.28");

            // finally populate the buttons on that tool strip
            theCollection.InsureExtraBox(aCNDC, eLoggedOnMemberType);
            int nNumRows = 1;

            foreach (CommInstance aCI in aCNDC)
            {
                if ((aCI.Direction == ConsultNoteDataConverter.CommunicationDirections.eConsultantToProjFac) ||
                    (aCI.Direction == ConsultNoteDataConverter.CommunicationDirections.eCoachToConsultant))
                {
                    InitRow(ctrlVerse, aCNDC.MentorLabel, aCI, aCNDC.CommentColor, aCNDC.ThrowIfWrongEditor,
                            aCNDC.MentorRequiredEditor, ref nNumRows);
                }
                else
                {
                    InitRow(ctrlVerse, aCNDC.MenteeLabel, aCI, aCNDC.ResponseColor, aCNDC.ThrowIfWrongEditor,
                            aCNDC.MenteeRequiredEditor, ref nNumRows);
                }
            }

            tableLayoutPanel.ResumeLayout(false);
            ResumeLayout(false);
        }
Пример #11
0
        public bool OnClickEndConversation(string strId)
        {
            int nVerseIndex, nConversationIndex;
            ConsultNotesDataConverter theCNsDC;
            ConsultNoteDataConverter  theCNDC;

            if (!GetDataConverters(strId, out nVerseIndex, out nConversationIndex,
                                   out theCNsDC, out theCNDC))
            {
                return(false);
            }

            System.Diagnostics.Debug.Assert(Document != null);
            HtmlElement elemButton = Document.GetElementById(strId);

            System.Diagnostics.Debug.Assert(elemButton != null);

            if (theCNDC.IsFinished)
            {
                theCNDC.IsFinished   = false;
                elemButton.InnerText = ConsultNoteDataConverter.CstrButtonLabelConversationEnd;
            }
            else
            {
                theCNDC.IsFinished   = true;
                elemButton.InnerText = ConsultNoteDataConverter.CstrButtonLabelConversationReopen;
            }

            if (theCNDC.IsFinished)
            {
                if (Document != null)
                {
                    HtmlElement elem =
                        Document.GetElementById(ConsultNoteDataConverter.TextareaId(nVerseIndex, nConversationIndex));
                    if (elem != null)
                    {
                        if (String.IsNullOrEmpty(elem.InnerText))
                        {
                            theCNDC.RemoveAt(theCNDC.Count - 1);
                            if (RemoveHtmlNodeById(ConsultNoteDataConverter.TextareaRowId(nVerseIndex,
                                                                                          nConversationIndex)))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            else
            {
                // just in case we need to have an open box now
                theCNsDC.InsureExtraBox(theCNDC, TheSE.theCurrentStory.ProjStage,
                                        TheSE.LoggedOnMember.MemberType);
            }

            if (theCNDC.IsEditable(TheSE.theCurrentStory.ProjStage, theCNDC.Count - 1, TheSE.LoggedOnMember,
                                   theCNDC[theCNDC.Count - 1]))
            {
                StrIdToScrollTo = ConsultNoteDataConverter.TextareaId(nVerseIndex, nConversationIndex);
            }
            else
            {
                StrIdToScrollTo = ConsultNoteDataConverter.TextareaReadonlyRowId(nVerseIndex, nConversationIndex,
                                                                                 theCNDC.Count - 1);
            }

            LoadDocument();
            return(true);
        }
 public CoachNoteData(ConsultNoteDataConverter rhs)
     : base(rhs)
 {
 }
Пример #13
0
        static void DoConsultData(string[] astrFile, ref int nIndexLine, bool bUsingStoryProject,
                                  ConsultNotesDataConverter theCNsD, string strMentorSfm, string strMentorInitials, List <string> astrMenteeSfms,
                                  ConsultNoteDataConverter.CommunicationDirections eMentorToMentee, ConsultNoteDataConverter.CommunicationDirections eMenteeToMentor)
        {
            if (++nIndexLine >= astrFile.Length)
            {
                return;
            }

            int    nConvNumber = 0, nNoteNumber = 0;
            string strMarker, strData;

            ParseLine(astrFile[nIndexLine], out strMarker, out strData);
            if (strMarker == @"\ln")
            {
                return;
            }

            while ((strMarker != @"\ln") && (strMarker != @"\c"))
            {
                ConsultNoteDataConverter con = null;
                if (theCNsD.Count > nConvNumber)
                {
                    con = theCNsD[nConvNumber];
                }

                int nRound = 1;
                if (strMarker == strMentorSfm)
                {
                    try
                    {
                        char chRound = (strData.Substring(0, 2) == strMentorInitials) ? strData[2] : '1';
                        nRound = Convert.ToInt32(chRound.ToString());
                    }
                    catch { }

                    if (con == null)
                    {
                        con = theCNsD.AddEmpty(nRound);
                    }

                    if (con.Count > nNoteNumber)
                    {
                        CommInstance aCI = con[nNoteNumber];
                        System.Diagnostics.Debug.Assert((aCI.ToString() == strData) && (aCI.Direction == eMentorToMentee));
                        aCI.SetValue(strData);
                        aCI.Direction = eMentorToMentee;
                    }
                    else
                    {
                        con.Add(new CommInstance(strData, eMentorToMentee, Guid.NewGuid().ToString()));
                    }

                    nNoteNumber++;
                }
                else if (astrMenteeSfms.Contains(strMarker))
                {
                    // sometimes the CIT has a comment for the coach
                    if (con == null)
                    {
                        con = theCNsD.AddEmpty(nRound);
                    }

                    if (con.Count > nNoteNumber)
                    {
                        CommInstance aCI = con[nNoteNumber];
                        System.Diagnostics.Debug.Assert((aCI.ToString() == strData) && (aCI.Direction == eMenteeToMentor));
                        aCI.SetValue(strData);
                        aCI.Direction = eMenteeToMentor;
                    }
                    else
                    {
                        con.Add(new CommInstance(strData, eMenteeToMentor, Guid.NewGuid().ToString()));
                    }

                    // for now, we just do two per conversation (or maybe 3 if the mentee started the conversation)
                    if (++nNoteNumber >= 2)
                    {
                        nConvNumber++;
                        nNoteNumber = 0;
                    }
                }
                else if (lstSfmsToIgnore.Contains(strMarker))
                {
                    Console.WriteLine("Found, but don't care about marker:" + strMarker);
                }
                else if (!String.IsNullOrEmpty(strMarker) && !String.IsNullOrEmpty(strData))
                {
                    System.Diagnostics.Debug.Assert(false, String.Format("not handling the '{0}' marker", strMarker));
                }

                if (++nIndexLine < astrFile.Length)
                {
                    ParseLine(astrFile[nIndexLine], out strMarker, out strData);
                }
                else
                {
                    break;
                }
            }
        }