Exemplo n.º 1
0
 protected void AdjustTextBoxHeight(CtrlTextBox tb)
 {
     if (ResizeTextBoxToFitText(tb))
     {
         AdjustHeightWithSuspendLayout(null);
     }
 }
Exemplo n.º 2
0
        protected void SetExegeticalHelpControls(VerseControl ctrlVerse,
                                                 ToolStripButton theAnchorButton, Font font, StringTransfer strQuote, ref int nNumRows)
        {
            int nLayoutRow = nNumRows++;

            Label labelExegeticalHelp = new Label
            {
                Anchor   = AnchorStyles.Left,
                AutoSize = true,
                Name     = CstrFieldNameExegeticalHelpLabel + nLayoutRow.ToString(),
                Text     = "cn:"
            };

            CtrlTextBox tb = new CtrlTextBox(
                CstrFieldNameExegeticalHelp + nLayoutRow, ctrlVerse, font, this, strQuote,
                labelExegeticalHelp.Text);

            // add the label and tool strip as a new row to the table layout panel
            InsertRow(nLayoutRow);
            tableLayoutPanel.Controls.Add(labelExegeticalHelp, 0, nLayoutRow);
            tableLayoutPanel.Controls.Add(tb, 1, nLayoutRow);

            // add this row to the list of exe help lines added for this anchor button (so
            //  we can gracefully remove them if the anchor is deleted.
            List <TextBox> lstTBs;

            if (!_mapAnchorsToTextBoxes.TryGetValue(theAnchorButton, out lstTBs))
            {
                lstTBs = new List <TextBox>();
                _mapAnchorsToTextBoxes.Add(theAnchorButton, lstTBs);
            }

            lstTBs.Add(tb);
        }
        protected void InitTextBox(VerseControl ctrlVerse, string strTbName,
                                   StringTransfer strTbText, ProjectSettings.LanguageInfo li, int nLayoutColumn)
        {
            CtrlTextBox tb = new CtrlTextBox(strTbName + CstrSuffixTextBox, ctrlVerse, this,
                                             strTbText, li, CstrTestQuestionsLabelFormat);

            tableLayoutPanel.Controls.Add(tb, nLayoutColumn, 1);
        }
Exemplo n.º 4
0
        protected void InitTextBox(VerseControl ctrlVerse, string strTbName, StringTransfer strTbText,
                                   ProjectSettings.LanguageInfo li, bool bDisableTabStop, int nLayoutColumn)
        {
            System.Diagnostics.Debug.Assert(!tableLayoutPanel.Controls.ContainsKey(strTbName + CstrSuffixTextBox), "otherwise, fix wrong assumption");
            CtrlTextBox tb = new CtrlTextBox(strTbName + CstrSuffixTextBox, ctrlVerse, this,
                                             strTbText, li, li.LangCode);

            tb.TabStop = !bDisableTabStop;
            tableLayoutPanel.Controls.Add(tb, nLayoutColumn, 1);
        }
Exemplo n.º 5
0
        public void textBox_TextChanged(object sender, EventArgs e)
        {
            CtrlTextBox tb = (CtrlTextBox)sender;

            AdjustTextBoxHeight(tb);

            // the 'Tag' of each text box contains a delegate to set the data item it is associated with
            var st = tb.MyStringTransfer;

            st.SetValue(tb.Text);
        }
Exemplo n.º 6
0
        protected static bool ResizeTextBoxToFitText(CtrlTextBox tb)
        {
            Size sz             = tb.GetPreferredSize(new Size(tb.Width, 1000));
            bool bHeightChanged = (sz.Height != tb.Size.Height);

            if (bHeightChanged)
            {
                tb.Height = sz.Height;
            }
            return(bHeightChanged);
        }
Exemplo n.º 7
0
        protected void KeepTrackOfLastTextBoxSelected()
        {
            _inTextBox = this;
            if (!String.IsNullOrEmpty(_strKeyboardName))
            {
                KeyboardController.ActivateKeyboard(_strKeyboardName);
            }

            if (_nLastVerse != _ctrlVerseParent.VerseNumber)
            {
                _nLastVerse = _ctrlVerseParent.VerseNumber;

                // start a timer that will wake up shortly and set the focus to the other panes as well.
                _ctrlVerseParent.TheSE.myFocusTimer.Tag = _ctrlVerseParent.VerseNumber;
                _ctrlVerseParent.TheSE.myFocusTimer.Start();
            }
        }
Exemplo n.º 8
0
        protected void InitRow(VerseControl ctrlVerse, string strLabelTextFormat,
                               Font font, StringTransfer strRowData, int nTest, ref int nNumRows)
        {
            Label label = new Label
            {
                Anchor   = AnchorStyles.Left,
                AutoSize = true,
                Name     = strLabelTextFormat + nTest,
                Text     = String.Format(strLabelTextFormat, nTest)
            };

            CtrlTextBox tb = new CtrlTextBox(
                strLabelTextFormat + CstrSuffixTextBox + nTest, ctrlVerse, font, this, strRowData,
                label.Text);

            // add the label and tool strip as a new row to the table layout panel
            int nLayoutRow = nNumRows++;

            InsertRow(nLayoutRow);
            tableLayoutPanel.Controls.Add(label, 0, nLayoutRow);
            tableLayoutPanel.Controls.Add(tb, 1, nLayoutRow);
        }
Exemplo n.º 9
0
 public void SetAssociation(CtrlTextBox tb)
 {
     _tb = tb;
     if (Transliterator != null)
     {
         try
         {
             tb.Text = Transliterator.Convert(Value);
         }
         catch
         {
             tb.Text = Value;
         }
         tb.ReadOnly = true;
     }
     else
     {
         tb.Text     = Value;
         tb.ReadOnly = false;
     }
     tb.Tag = this;
 }
Exemplo n.º 10
0
        protected void InitRow(VerseControl ctrlVerse, string strRowLabel, StringTransfer strRowData, Color clrText,
                               CtrlTextBox.ThrowIfNotCorrectEditor delegateCheckEditor, TeamMemberData.UserTypes eReqEditor, ref int nNumRows)
        {
            int nLayoutRow = nNumRows++;

            Label label = new Label();

            label.Anchor   = AnchorStyles.Left;
            label.AutoSize = true;
            label.Name     = strRowLabel + nNumRows;
            label.Text     = strRowLabel;

            CtrlTextBox tb = new CtrlTextBox(
                strRowLabel + CstrSuffixTextBox + nNumRows,
                ctrlVerse, this, strRowData, delegateCheckEditor, eReqEditor);

            tb.ForeColor = clrText;

            // add the label and tool strip as a new row to the table layout panel
            InsertRow(nLayoutRow);
            tableLayoutPanel.Controls.Add(label, 0, nLayoutRow);
            tableLayoutPanel.SetColumnSpan(tb, 2);
            tableLayoutPanel.Controls.Add(tb, 1, nLayoutRow);
        }
Exemplo n.º 11
0
 protected override void OnLeave(EventArgs e)
 {
     _inTextBox = null;
     KeyboardController.DeactivateKeyboard();
     base.OnLeave(e);
 }
Exemplo n.º 12
0
        public void DoFindNext()
        {
            string strToSearchFor = UpdateComboBox(comboBoxFindWhat);

            if (String.IsNullOrEmpty(strToSearchFor))
            {
                MessageBox.Show(Properties.Resources.IDS_NoSearchString, Properties.Resources.IDS_Caption);
                return;
            }

            if (FindProperties.UseRegex)
            {
                regex = GetRegex(strToSearchFor);
            }
            else
            {
                regex = null;
            }

            int nLastStoryIndex, nLastCtxBoxIndex, nLastCharIndex;

            InitSearchList(ref BoxesToSearch, out nLastStoryIndex, out nLastCtxBoxIndex, out nLastCharIndex);

            CtrlTextBox ctbStopWhereWeStarted = null;
            int         nStoryIndex           = nLastStoryIndex;
            int         nCtxBoxIndex          = nLastCtxBoxIndex;

            while (nStoryIndex < BoxesToSearch.Count)
            {
                StringTransferSearchIndex stsi = BoxesToSearch[nStoryIndex];
                for (; nCtxBoxIndex < stsi.Count; nCtxBoxIndex++)
                {
                    StringTransfer stringTransfer = stsi[nCtxBoxIndex].StringTransfer;
                    if (!stringTransfer.HasData)
                    {
                        continue;
                    }

                    string strValue = stringTransfer.ToString();

                    // check to see if we're wrapped around and are starting
                    //  back at the beginning
                    // note: that it's possible that this stringTransfer
                    //  does not have a TextBox (e.g. if it isn't visible) OR
                    //  if its in the ConNotes panes (which are HTML thingys)
                    CtrlTextBox ctrlTextBox = stringTransfer.TextBox;

                    // get the index *after* the selected text (our starting index
                    //  of the search)
                    int nStartIndex = 0;
                    if (ctrlTextBox != null)
                    {
                        // if the length of the text in the text box is not the same
                        //  length as the text in the StringTransfer, then this
                        //  assumption is probably no good
                        System.Diagnostics.Debug.Assert(ctrlTextBox.TextLength == strValue.Length);

                        if (ctbStopWhereWeStarted == ctrlTextBox)
                        {
                            ShowNotFound();
                            return;
                        }

                        nStartIndex = nLastCharIndex;
                        if (nLastCharIndex != 0)
                        {
                            nLastCharIndex = 0;                             // only do that once
                            ctrlTextBox.Select(0, 0);                       // don't leave it selected
                        }
                    }

                    int nFoundIndex = -1, nLengthToSelect = 0;
                    if (regex != null)
                    {
                        Match match = regex.Match(strValue, nStartIndex);
                        if (match.Success)
                        {
                            nFoundIndex     = match.Index;
                            nLengthToSelect = match.Length;
                        }
                    }
                    else
                    {
                        nFoundIndex     = strValue.IndexOf(strToSearchFor, nStartIndex);
                        nLengthToSelect = strToSearchFor.Length;
                    }

                    if (nFoundIndex != -1)
                    {
                        // found a match!
                        VerseString vs = stsi[nCtxBoxIndex];
                        System.Diagnostics.Debug.Assert(vs.StringTransfer == stringTransfer);
                        TheSE.NavigateTo(stsi.StoryName,
                                         vs.ViewToInsureIsOn,
                                         false,
                                         stringTransfer.TextBox);

                        // The navigation process should make it visible as well.
                        if (stringTransfer.TextBox != null)
                        {
                            stringTransfer.TextBox.Select(nFoundIndex, nLengthToSelect);
                            LastCharIndex = CaptureNextStartingCharIndex(stringTransfer.TextBox);
                        }
                        else if (stringTransfer.HtmlConNoteCtrl != null)
                        {
                            stringTransfer.HtmlConNoteCtrl.SelectFoundText(stringTransfer.HtmlElementId, nFoundIndex,
                                                                           nLengthToSelect);
                            LastCharIndex = nFoundIndex + nLengthToSelect;
                        }

                        LastStoryIndex        = nStoryIndex;
                        LastCtxBoxIndex       = nCtxBoxIndex;
                        buttonReplace.Enabled = true;
                        return;
                    }
                }

                // if we've reached the end of the verses in *this* story...
                if (!FindProperties.SearchAll)
                {
                    // if we were already searching from the beginning...
                    if (nLastCtxBoxIndex == 0)
                    {
                        // ... then we couldn't find it
                        ShowNotFound();
                        return;
                    }

                    // otherwise, see if the user wants to start over from 0
                    if (MessageBox.Show(Properties.Resources.IDS_StartFromBeginning,
                                        Properties.Resources.IDS_Caption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                    {
                        nCtxBoxIndex = 0;

                        // have it stop where we started
                        ctbStopWhereWeStarted = CtrlTextBox._inTextBox ?? stsi[0].StringTransfer.TextBox;
                    }
                    else
                    {
                        return;                         // user said *don't* start over
                    }
                }

                // otherwise, we're supposed to search the next story as well.
                else
                {
                    nStoryIndex++;
                    nCtxBoxIndex = 0;
                }
            }

            // if we reach here, it's because we were searching all the stories
            //  and we reached the end and couldn't find it
            // if we were already searching from the beginning...
            if ((nLastStoryIndex == 0) && (nLastCtxBoxIndex == 0))
            {
                // ... then we couldn't find it
                ShowNotFound();
                return;
            }

            // otherwise, see if the user wants to start over from 0.0
            if (MessageBox.Show(Properties.Resources.IDS_StartFromBeginning,
                                Properties.Resources.IDS_Caption, MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                LastStoryIndex = LastCtxBoxIndex = LastCharIndex = 0;
                DoFindNext();
            }
        }
Exemplo n.º 13
0
 protected int CaptureNextStartingCharIndex(CtrlTextBox ctb)
 {
     return(ctb.SelectionStart +
            ctb.SelectionLength);
 }