Ejemplo n.º 1
0
        public void FindNextBackTrans_TitleToSectionHead_SectionHeadChecked()
        {
            CheckDisposed();

            IScrSection    section = m_book.SectionsOS[0];
            ICmTranslation trans   = new CmTranslation(Cache,
                                                       ((StTxtPara)section.HeadingOA.ParagraphsOS[0]).TranslationsOC.HvoArray[0]);

            m_btDraftView.SetTransStatus(trans, BackTranslationStatus.Checked);

            m_btDraftView.SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, 0, 0);

            m_btDraftView.CallNextUnfinishedBackTrans();
            SelectionHelper helper = m_btDraftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(0, helper.IchAnchor);
            Assert.AreEqual(0, m_btDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(0, m_btDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_btDraftView.ParagraphIndex);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidContent,
                            m_btDraftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsFalse(m_btDraftView.TeEditingHelper.InBookTitle);
        }
Ejemplo n.º 2
0
        public void GoToNextPara_NextInstanceOfSameParaContents()
        {
            ShowForm(Lng.English, SimpleViewVc.DisplayType.kNormal |
                     SimpleViewVc.DisplayType.kDuplicateParagraphs);
            m_basicView.Show();
            m_basicView.RefreshDisplay();

            m_SelectionHelper = new DummySelectionHelper(null, m_basicView);
            SetSelection(0, 0, 0, 0, 1, 6, 6, true);
            IVwSelection vwsel = m_SelectionHelper.SetSelection(true);

            Assert.IsNotNull(vwsel, "No selection made");
            Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection is not visible");
            m_basicView.EditingHelper.GoToNextPara();

            // We expect that the selection will be at the start of the next paragraph.
            SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView);

            Assert.IsFalse(selectionHelper.IsRange);
            CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0,
                                       2, 0, 0, false, 2, SimpleRootsiteTestsConstants.kflidDocFootnotes, 0, 0,
                                       SimpleRootsiteTestsConstants.kflidTextParas, 0, 0);
        }
Ejemplo n.º 3
0
        public void FindPrevBackTrans_SectionParaToPara_PrevParaFinished()
        {
            CheckDisposed();

            IScrSection    section = m_book.SectionsOS[1];
            ICmTranslation trans   = new CmTranslation(Cache,
                                                       ((StTxtPara)section.ContentOA.ParagraphsOS[0]).TranslationsOC.HvoArray[0]);

            m_btDraftView.SetTransStatus(trans, BackTranslationStatus.Finished);

            m_btDraftView.SetInsertionPoint(0, 1, 1, 0, false);

            m_btDraftView.CallPrevUnfinishedBackTrans();
            SelectionHelper helper = m_btDraftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(0, helper.IchAnchor);
            Assert.AreEqual(0, m_btDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(1, m_btDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_btDraftView.ParagraphIndex);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            m_btDraftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsFalse(m_btDraftView.TeEditingHelper.InBookTitle);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the value of a control.
        /// Note: write operations need to occur in the context of a UndoableUnitOfWorkHelper (for Undo/Redo purposes).
        /// This requires fdoCache...so perhaps an edit control needs to be in RootSite.dll rather than SimpleRootSite.
        /// </summary>
        /// <param name="value"></param>
        /// <exception cref="T:System.InvalidOperationException">
        /// If locale-specific information is passed to a control in an incorrect format such as an incorrectly formatted date.
        /// </exception>
        /// <exception cref="T:System.ArgumentException">
        /// If a new value cannot be converted from a string to a format the control recognizes.
        /// </exception>
        /// <exception cref="T:System.Windows.Automation.ElementNotEnabledException">
        /// When an attempt is made to manipulate a control that is not enabled.
        /// </exception>
        public void SetValue(string value)
        {
            // install the range selection for this text box
            // past a string over the selection
            if (!Focused())
            {
                SetFocus();                 //installs range selection.
            }
            // get the writing system at the anchor
            int       ws  = SelectionHelper.GetFirstWsOfSelection(m_rootb.Selection);
            ITsString tss = TsStringUtils.MakeTss(value, ws);

            m_site.Invoke(() => m_site.EditingHelper.PasteCore(tss));
            // NOTE: PasteCore leaves the rootbox selection in a cursor state
            // at the end of the pasted seleciton. So
            // now we need to readjust the Selection with the new end offset.
            var shEditRange = SelectionHelper.Create(Selection, m_site);

            shEditRange.SetIch(SelectionHelper.SelLimitType.Anchor, 0);
            shEditRange.SetIch(SelectionHelper.SelLimitType.End, tss.Length);
            Selection = shEditRange.SetSelection(m_site, false, false);
            ComputeScreenBoundingRectangle();
        }
Ejemplo n.º 5
0
        public static Dictionary <string, object> GenerateRequiredProperties(FieldType fieldType, Properties.Label label)
        {
            var result = new Dictionary <string, object>
            {
                [Properties.PropertyName.SType.GetEnumStringValue()] = (int)fieldType,
                [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label],
            };

            if (fieldType == FieldType.File)
            {
                result.Add(Properties.PropertyName.DType.GetEnumStringValue(), (int)Properties.DType.Five);
                result.Add(Properties.PropertyName.Height.GetEnumStringValue(), 50);
                result.Add(Properties.PropertyName.VType.GetEnumStringValue(), CommonConstants.Files[FileType.Bmp].MimeType);
            }
            if (fieldType == FieldType.Option)
            {
                var optionInfos = SelectionHelper.GetOptionInfos(SelectionHelper.GetOptionsAlias()[new Random().Next(SelectionHelper.GetOptionsAlias().Count)]);
                result.Add(Properties.PropertyName.Id.GetEnumStringValue(), optionInfos.FirstOrDefault().Key);
                result.Add(Properties.PropertyName.DType.GetEnumStringValue(), (int)SelectionHelper.DTypeMapper[fieldType]);
                result.Add(Properties.PropertyName.Count.GetEnumStringValue(), (int)Properties.OptionCount.Zero);
            }
            return(result);
        }
Ejemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This is the actual workhorse for all the above methods that allows a selection to
        /// be created.
        /// </summary>
        /// <param name="selHelper">The selection helper that will be used tom make the
        /// selection</param>
        /// <param name="book">The 0-based index of the Scripture book in which to put the
        /// insertion point</param>
        /// <param name="section">The 0-base index of the Scripture section in which to put the
        /// insertion point</param>
        /// <param name="sectionTag">Indicates whether selection should be made in the section
        /// Heading or Contents</param>
        /// <param name="para">The 0-based index of the paragraph in which to put the insertion
        /// point</param>
        /// <param name="startCharacter">The 0-based index of the character at which the
        /// selection begins (or before which the insertion point is to be placed if
        /// startCharacter == endCharacter)</param>
        /// <param name="endCharacter">The character location to end the selection</param>
        /// <param name="fInstall"></param>
        /// <param name="fMakeVisible"></param>
        /// <param name="vwsel"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private void SelectRangeOfChars(ref SelectionHelper selHelper, int book, int section,
                                        ScrSection.ScrSectionTags sectionTag, int para, int startCharacter,
                                        int endCharacter, bool fInstall, bool fMakeVisible, out IVwSelection vwsel)
        {
            selHelper.NumberOfLevels    = 4;
            selHelper.LevelInfo[3].tag  = (int)Scripture.ScriptureTags.kflidScriptureBooks;
            selHelper.LevelInfo[3].ihvo = book;
            selHelper.LevelInfo[2].tag  = (int)ScrBook.ScrBookTags.kflidSections;
            selHelper.LevelInfo[2].ihvo = section;
            selHelper.LevelInfo[1].tag  = (int)sectionTag;
            selHelper.LevelInfo[1].ihvo = 0;                    // Atomic property, probably ignored
            // selHelper.LevelInfo[0].tag is set automatically by SelectionHelper class
            selHelper.LevelInfo[0].ihvo = para;

            // Prepare to move the IP to the specified character in the paragraph.
            selHelper.IchAnchor = startCharacter;
            selHelper.IchEnd    = endCharacter;

            // Now that all the preparation to set the IP is done, set it.
            vwsel = selHelper.SetSelection(this, fInstall, fMakeVisible);

            Application.DoEvents();
        }
Ejemplo n.º 7
0
        public void UpArrowAfterDeleteFootnoteBeginning()
        {
            CheckDisposed();

            MakeFootnoteSelection(1, 4, 1);

            // Send a backspace to the rootsite.
            m_footnoteView.OnKeyPress(new KeyPressEventArgs((char)0x08));

            // Check results
            SelectionHelper selHelper = SelectionHelper.Create(m_footnoteView);

            Assert.AreEqual(4, selHelper.LevelInfo[1].ihvo, "Selection should still be in footnote 3");
            Assert.AreEqual(0, selHelper.IchAnchor, "IchAnchor should be at start of footnote");
            Assert.AreEqual(0, selHelper.IchEnd, "IchEnd should be at start of footnote");

            m_footnoteView.OnKeyDown(new KeyEventArgs(Keys.Up));

            // Check results
            selHelper = SelectionHelper.Create(m_footnoteView);
            Assert.AreEqual(3, selHelper.LevelInfo[1].ihvo, "Selection should have moved to previous footnote");
            Assert.IsFalse(selHelper.AssocPrev);
        }
Ejemplo n.º 8
0
        public void ReCalculate()
        {
            if (!Input.TextArea.TextView.VisualLinesValid)
            {
                Input.TextArea.TextView.EnsureVisualLines();
            }

            var resultList = Calculator.Calculate(Input.Text);

            var outputText = "";

            for (int i = 0; i < resultList.Count; ++i)
            {
                // Line up to input
                int bound = (int)(Input.TextArea.TextView.VisualLines[i].Height / BaseLineHeight);
                // One less '\n' on the first line
                if (i == 0)
                {
                    bound--;
                }
                outputText += (bound > 0 ? (new string('\n', bound)) : "") + resultList[i] + "\u2001";
            }
            Output.Text = outputText;
            SelectionHelper?.InvalidateCache();

            // Show the splitter if necessary
            bool outputOverflowed = (outputColumn.ActualWidth - Output.ActualWidth - Output.Margin.Left - Output.Margin.Right) <= 10;

            if (outputOverflowed || Calculator.isInputOverflowed)
            {
                splitter.Visibility = Visibility.Visible;
            }
            else
            {
                splitter.Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 9
0
        private void OnCommitText(string text, bool checkIfFocused)
        {
            var selHelper = SetupForTypingEventHandler(checkIfFocused, true);

            if (selHelper == null)
            {
                return;
            }
            try
            {
                var selectionProps = GetSelectionProps(selHelper);

                var countBackspace = TrimBeginningBackspaces(ref text);
                var bottom         = selHelper.GetIch(SelectionHelper.SelLimitType.Bottom);
                selHelper.IchAnchor = Math.Max(0,
                                               selHelper.GetIch(SelectionHelper.SelLimitType.Top) - countBackspace);
                selHelper.IchEnd = bottom;
                selHelper.SetSelection(true);

                UpdateSelectionForReplacingPreeditText(selHelper, countBackspace);

                // Insert 'text'
                ITsString str = CreateTsStringUsingSelectionProps(text, selectionProps, false);
                selHelper.Selection.ReplaceWithTsString(str);
            }
            finally
            {
                m_InitialSelection = null;
                m_EndOfPreedit     = null;
                if (m_ActionHandler != null)
                {
                    m_ActionHandler.EndUndoTask();
                    m_ActionHandler = null;
                }
                OnPreeditClosed();
            }
        }
Ejemplo n.º 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the highlighted note to be the specified note.
        /// </summary>
        /// <param name="ann">The note to highlight.</param>
        /// ------------------------------------------------------------------------------------
        private void UpdateNoteHighlight(IScrScriptureNote ann)
        {
            if (ann == null || m_prevHightlightedNote == ann || m_suspendHighlightChange)
            {
                return;
            }

            SelectionHelper sel = EditingHelper.CurrentSelection;

            // Only selection that can get updated is a re-install of a previous selection so
            // don't bother with any selection update handling.
            m_ignoreSelChanged = true;
            try
            {
                // Need to user real object index when doing a prop change - the GetDisplayIndex method on the filter will change
                // this to the filtered index.
                m_vc.SelectedNoteHvo = ann.Hvo;
                if (m_prevHightlightedNote != null && m_prevHightlightedNote.IsValidObject)
                {
                    int ownerHvo = m_prevHightlightedNote.Owner.Hvo;
                    RootBox.PropChanged(ownerHvo, ScrBookAnnotationsTags.kflidNotes, m_prevHightlightedNote.IndexInOwner, 1, 1);
                }

                RootBox.PropChanged(ann.Owner.Hvo, ScrBookAnnotationsTags.kflidNotes, ann.IndexInOwner, 1, 1);

                m_prevHightlightedNote = ann;

                if (sel != null)
                {
                    sel.SetSelection(false);                     // restore selection taken from PropChange
                }
            }
            finally
            {
                m_ignoreSelChanged = false;
            }
        }
Ejemplo n.º 11
0
        public WordMapWindow()
        {
            InitializeComponent();

            bookSelector.IsEditable = true;
            bookSelector.IsReadOnly = true;
            bookSelector.Text       = "Book";

            chapterSelector.IsEditable = true;
            chapterSelector.IsReadOnly = true;
            chapterSelector.IsEnabled  = false;
            chapterSelector.Text       = "Chapter";

            verseSelector.IsEditable = true;
            verseSelector.IsReadOnly = true;
            verseSelector.IsEnabled  = false;
            verseSelector.Text       = "Verse";

            clearButton.IsEnabled = false;

            string server   = ConfigurationManager.AppSettings["server"];
            string port     = ConfigurationManager.AppSettings["port"];
            string user     = ConfigurationManager.AppSettings["user"];
            string password = ConfigurationManager.AppSettings["password"];
            string database = ConfigurationManager.AppSettings["database"];

            dh = new DatabaseHelper(server, port, user, password, database);
            dh.AcquireConnection();
            SelectionHelper sh = new SelectionHelper(dh.GetConnection());

            Dictionary <int, String> booksList = sh.GetBooksList();

            foreach (KeyValuePair <int, String> book in booksList)
            {
                bookSelector.Items.Insert(book.Key - 1, book.Value);
            }
        }
Ejemplo n.º 12
0
        protected override int GetInsertionIndex(ICmObject[] objs, SelectionHelper sel)
        {
            if (sel.GetNumberOfLevels(SelectionHelper.SelLimitType.Top) == 0)
            {
                int cellId = GetCell(sel, SelectionHelper.SelLimitType.Top);
                switch (cellId)
                {
                case PhMetathesisRuleTags.kidxLeftEnv:
                    return(0);

                case PhMetathesisRuleTags.kidxLeftSwitch:
                    if (Rule.MiddleIndex != -1)
                    {
                        return(Rule.MiddleIndex);
                    }
                    if (Rule.RightSwitchIndex != -1)
                    {
                        return(Rule.RightSwitchIndex);
                    }
                    if (Rule.RightEnvIndex != -1)
                    {
                        return(Rule.RightEnvIndex);
                    }
                    break;

                case PhMetathesisRuleTags.kidxRightSwitch:
                    if (Rule.RightEnvIndex != -1)
                    {
                        return(Rule.RightEnvIndex);
                    }
                    break;
                }
                return(objs.Length);
            }
            return(base.GetInsertionIndex(objs, sel));
        }
Ejemplo n.º 13
0
        public CheckFootnoteMkr m_checkFootnoteMkr = CheckFootnoteMkr.CallBaseClass;         //default

        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Refreshes the Display :)
        /// NOTE: this removes the book filter to show all books in the DB
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public override bool RefreshDisplay()
        {
            CheckDisposed();

            if (m_rootb == null || m_rootb.Site == null)
            {
                return(false);
            }

            // Save where the selection is so we can try to restore it after reconstructing.
            // we can't use EditingHelper.CurrentSelection here because the scroll position
            // of the selection may have changed.
            SelectionHelper selHelper = SelectionHelper.Create(this);

            BookFilter.ShowAllBooks();
            // Rebuild the display... the drastic way.
            m_rootb.Reconstruct();

            if (selHelper != null)
            {
                selHelper.RestoreSelectionAndScrollPos();
            }
            return(false);
        }
Ejemplo n.º 14
0
        protected override int GetItemHvo(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(0);
            }

            int cellId = GetCell(sel);

            if (cellId < 0)
            {
                return(0);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (IsCellFlid(level.tag) || level.tag == (int)PhSequenceContext.PhSequenceContextTags.kflidMembers)
                {
                    return(level.hvo);
                }
            }

            return(0);
        }
        public void FindNextMissingBtFootnoteMarker_BtSectionHeadToNowhere()
        {
            IScrSection section = m_exodus.SectionsOS[1];

            ITsStrFactory strfact     = TsStrFactoryClass.Create();
            IStTxtPara    contentPara = section.ContentOA[0];
            ITsStrBldr    strBldr     = contentPara.Contents.GetBldr();
            IStFootnote   foot        = m_exodus.InsertFootnoteAt(0, strBldr, 7);

            contentPara.Contents = strBldr.GetString();
            IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle(
                foot, ScrStyleNames.NormalFootnoteParagraph);

            footPara.Contents = strfact.MakeString("This is footnote text for footnote", Cache.DefaultVernWs);

            IMultiString trans = contentPara.SegmentsOS[1].FreeTranslation;
            ITsStrBldr   bldr  = trans.get_String(Cache.DefaultAnalWs).GetBldr();

            TsStringUtils.InsertOrcIntoPara(foot.Guid, FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultAnalWs);
            trans.set_String(Cache.DefaultAnalWs, bldr.GetString());

            m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidHeading,
                                                           0, 0, 0, 0, true, true, false, VwScrollSelOpts.kssoDefault);

            m_draftView.CallNextMissingBtFootnoteMarker();

            SelectionHelper helper = m_draftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(0, helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor)[0].ihvo, "IP should not have moved.");
            Assert.AreEqual(0, helper.IchAnchor);
            Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(0, m_draftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_draftView.ParagraphIndex);
            Assert.AreEqual(ScrSectionTags.kflidHeading, m_draftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsTrue(m_draftView.TeEditingHelper.IsBackTranslation);
        }
Ejemplo n.º 16
0
        public void MoveIPToStartOfNextFootnoteViaRightKey()
        {
            ((StTxtPara)m_Jude.FootnotesOS[1].ParagraphsOS[0]).Contents.Text = string.Empty;

            // Put IP at the beginning of the first footnote.
            MakeFootnoteSelection(1, 0, 0);

            // Use the End key to get the IP to the end of the first footnote.
            m_footnoteView.OnKeyDown(new KeyEventArgs(Keys.End));

            // Verify we're still in footnote zero.
            SelectionHelper selHelper = SelectionHelper.Create(m_footnoteView);

            Assert.AreEqual(0, selHelper.LevelInfo[1].ihvo, "Selection should still be in footnote 0");

            // Now simulate pressing the Right key.
            m_footnoteView.OnKeyDown(new KeyEventArgs(Keys.Right));

            // Check results
            selHelper = SelectionHelper.Create(m_footnoteView);
            Assert.AreEqual(1, selHelper.LevelInfo[1].ihvo, "Selection should have moved to next footnote");
            Assert.AreEqual(0, selHelper.IchAnchor, "IchAnchor should be at start of footnote");
            Assert.AreEqual(0, selHelper.IchEnd, "IchEnd should be at start of footnote");
        }
Ejemplo n.º 17
0
        public void FindPrevBackTrans_SecondBookTitleToFirstBook_LastParaFinished()
        {
            CheckDisposed();

            // add new book with a BT
            IScrBook book = m_scrInMemoryCache.AddBookToMockedScripture(3, "Leviticus");
            StText   text = m_scrInMemoryCache.AddTitleToMockedBook(book.Hvo, "Title for Leviticus");

            m_scrInMemoryCache.AddBtToMockedParagraph((StTxtPara)text.ParagraphsOS[0],
                                                      Cache.DefaultAnalWs);

            // add BT for the last section heading of the first book
            ScrTxtPara para = new ScrTxtPara(Cache, m_book.SectionsOS[2].HeadingOA.ParagraphsOS.HvoArray[0]);

            m_inMemoryCache.AddBtToMockedParagraph(para, Cache.DefaultAnalWs);
            // add BT for last para of first book
            para = new ScrTxtPara(Cache, m_book.SectionsOS[2].ContentOA.ParagraphsOS.HvoArray[0]);
            ICmTranslation trans = m_inMemoryCache.AddBtToMockedParagraph(para,
                                                                          Cache.DefaultAnalWs);

            m_btDraftView.SetTransStatus(trans, BackTranslationStatus.Finished);
            m_btDraftView.RefreshDisplay();

            m_btDraftView.SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, 1, 0);

            m_btDraftView.CallPrevUnfinishedBackTrans();
            SelectionHelper helper = m_btDraftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(0, helper.IchAnchor);
            Assert.AreEqual(0, m_btDraftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(2, m_btDraftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_btDraftView.ParagraphIndex);
            Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading,
                            m_btDraftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsFalse(m_btDraftView.TeEditingHelper.InBookTitle);
        }
Ejemplo n.º 18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the Writiing System selector combo box
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void UpdateWritingSystemSelectorForSelection(IVwRootBox rootbox)
        {
            ComboBox box = WritingSystemSelector;

            if (box == null || rootbox == null)
            {
                return;
            }
            int hvoWs = SelectionHelper.GetFirstWsOfSelection(rootbox.Selection);

            if (hvoWs == 0)
            {
                box.SelectedIndex = -1;
                return;
            }
            LgWritingSystem lgws = new LgWritingSystem(Cache, hvoWs);

            if (lgws == null)
            {
                box.SelectedIndex = -1;
                return;
            }
            box.SelectedIndex = box.FindString(lgws.ShortName);
        }
Ejemplo n.º 19
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up a TsString to be returned from the selection helper so that it will appear
        /// to the editing helper as though we're editing a string with some plain text followed
        /// by a hyperlink.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SimulateTextFollowedByHyperlink(SelectionHelper selHelper,
                                                     ITsTextProps ttpPrecedingText, IchPosition start, IchPosition end)
        {
            ITsStrBldr bldr = TsStringUtils.MakeStrBldr();

            bldr.Replace(bldr.Length, bldr.Length, "some plain text", ttpPrecedingText);
            bldr.Replace(0, 0, "Google", m_ttpHyperlink);
            selHelper.Stub(selH => selH.GetTss(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(bldr.GetString());

            int ichStart = 0;
            int ichEnd   = bldr.Length;

            switch (start)
            {
            case IchPosition.StartOfString:
                selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                            SelectionHelper.SelLimitType.Top))).Return(ttpPrecedingText);
                break;

            case IchPosition.StartOfHyperlink:
                selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                            SelectionHelper.SelLimitType.Top))).Return(m_ttpHyperlink);
                ichStart = "some plain text".Length;
                break;
            }
            switch (end)
            {
            case IchPosition.StartOfHyperlink: ichEnd = "some plain text".Length; break;
            }
            selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                        SelectionHelper.SelLimitType.Bottom))).Return(m_ttpHyperlink);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
            selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Restores the selection stored in selHelper.
        /// </summary>
        protected void RestorePreeditSelection(SelectionHelper selHelper)
        {
            if (selHelper == null || AssociatedSimpleRootSite.RootBox.Height <= 0)
            {
                return;
            }

            if (AssociatedSimpleRootSite.ReadOnlyView)
            {
                // if we are a read-only view, then we can't make a writable selection
                try
                {
                    AssociatedSimpleRootSite.RootBox.MakeSimpleSel(true, false, false, true);
                }
                catch
                {
                    // Just ignore any errors - don't get a selection but who cares.
                }
                return;
            }

            bool selectionRestored = (selHelper.SetSelection(AssociatedSimpleRootSite, true, false) != null);

            if (!selectionRestored)
            {
                try
                {
                    // Any selection is better than no selection...
                    AssociatedSimpleRootSite.RootBox.MakeSimpleSel(true, true, false, true);
                }
                catch
                {
                    // Just ignore any errors - don't get a selection but who cares.
                }
            }
        }
Ejemplo n.º 21
0
        public void GetBookHvoWithFootnotes()
        {
            IScripture scr     = Cache.LangProject.TranslatedScriptureOA;
            ScrBook    genesis = (ScrBook)scr.ScriptureBooksOS[0];
            // Add a footnote in the first book, first section, first paragraph
            IScrSection section  = (IScrSection)genesis.SectionsOS[0];
            StFootnote  footnote = m_scrInMemoryCache.AddFootnote(genesis,
                                                                  (StTxtPara)section.ContentOA.ParagraphsOS[0], 2);
            StTxtPara para = m_scrInMemoryCache.AddParaToMockedText(footnote.Hvo,
                                                                    ScrStyleNames.NormalFootnoteParagraph);

            m_scrInMemoryCache.AddRunToMockedPara(para, "A footnote", 0);

            m_ScrPubCtrl.CreatePages();
            m_ScrPubCtrl.PrepareToDrawPages(0, m_ScrPubCtrl.AutoScrollMinSize.Height * 2);

            // Simulate setting the IP at the beginning of the footnote
            bool fFoundPageWithFootnotes = false;

            foreach (DummyPage page in m_ScrPubCtrl.Pages)
            {
                if (page.DependentObjectsRootStream != null)
                {
                    fFoundPageWithFootnotes = true;
                    ((IVwRootBox)page.DependentObjectsRootStream).MakeSimpleSel(true, true, false, true);
                    m_ScrPubCtrl.FocusedStream = page.DependentObjectsRootStream;
                    break;
                }
            }
            Assert.IsTrue(fFoundPageWithFootnotes, "Can't run this test without finding any footnotes");

            SelectionHelper selHelper = SelectionHelper.Create(m_ScrPubCtrl);
            int             hvoBook   = m_ScrPubCtrl.GetBookHvo(selHelper, SelectionHelper.SelLimitType.Anchor);

            Assert.AreEqual(genesis.Hvo, hvoBook);
        }
Ejemplo n.º 22
0
        protected override ICmObject GetCmObject(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(null);
            }

            int cellId = GetCell(sel);

            if (cellId < 0)
            {
                return(null);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (IsCellFlid(level.tag) || level.tag == PhSequenceContextTags.kflidMembers)
                {
                    return(m_cache.ServiceLocator.GetObject(level.hvo));
                }
            }

            return(null);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Creates and initializes an instance of <see cref="WebControl"/> and its underlying web view.
        /// </summary>
        public WebControl()
        {
            if ( this.IsSourceControl )
                this.SetValue( WebControl.IsSourceControlPropertyKey, true );

            controlLayer = new WebControlInvalidLayer( this );
            this.IsEnabledChanged += OnIsEnabledChanged;

            if ( DesignerProperties.GetIsInDesignMode( this ) )
                return;

            toolTip = new ToolTip();
            selectionHelper = new SelectionHelper( this, OnWebSelectionChanged );

            InitializeCore();
            InitializeDelegates( this.Instance );
            InitializeCommandBindings();

            findRequestRandomizer = new Random();

            this.Loaded += OnLoaded;
            this.Unloaded += OnUnloaded;

            needsResize = false;
            flushAplha = true;
        }
Ejemplo n.º 24
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Sets up a TsString to be returned from the selection helper so that it will appear
 /// to the editing helper as though we're editing a string with some plain text followed
 /// by a hyperlink.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void SimulatePlainTextFollowedByHyperlink(SelectionHelper selHelper,
                                                   IchPosition start, IchPosition end)
 {
     SimulateTextFollowedByHyperlink(selHelper, m_ttpNormal, start, end);
 }
Ejemplo n.º 25
0
        /// <summary>
        /// If we are in ReadOnlySelect mode, intercept the click, and select the appropriate row
        /// without installing a normal selection.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            //If XmlBrouseView did not receive a mouse down event then we do not want to
            //do anything on the mouseUp because the mouseUp would have come from clicking
            //somewhere else. LT-8939
            if (!m_fMouseUpEnabled)
            {
                return;
            }

            try
            {
                if (m_selectedIndex == -1)
                {
                    return;                     // Can't do much in an empty list, so quit.
                }
                m_fHandlingMouseUp = true;
#pragma warning disable 219
                int oldSelectedIndex = m_selectedIndex;
#pragma warning restore 219

                // Note all the stuff we might want to know about what was clicked that we will
                // use later. We want to get this now before anything changes, because there can
                // be scrolling effects from converting dummy objects to real.
                IVwSelection vwsel            = MakeSelectionAt(e);
                int          newSelectedIndex = GetRowIndexFromSelection(vwsel, true);
                // If we're changing records, we need to do some tricks to keep the selection in the place
                // clicked and the focus here. Save the information we will need.
                SelectionHelper clickSel = null;
                if (newSelectedIndex != SelectedIndex && vwsel != null && SelectionHelper.IsEditable(vwsel))
                {
                    clickSel = SelectionHelper.Create(vwsel, this);
                }
                ITsString tssWord      = null;    // word clicked for click copy
                ITsString tssSource    = null;    // whole source string of clicked cell for click copy
                int       hvoNewSelRow = 0;       // hvo of new selected row (only for click copy)
                int       ichStart     = 0;       // of tssWord in tssSource
                if (ClickCopy != null && e.Button == MouseButtons.Left && newSelectedIndex >= 0)
                {
                    if (vwsel != null && vwsel.SelType == VwSelType.kstText)
                    {
                        int icol = vwsel.get_BoxIndex(false, 3);
                        if (icol != Vc.OverrideAllowEditColumn + 1)
                        {
                            IVwSelection vwSelWord = vwsel.GrowToWord();
                            // GrowToWord() can return a null -- see LT-9163 and LT-9349.
                            if (vwSelWord != null)
                            {
                                vwSelWord.GetSelectionString(out tssWord, " ");
                                tssWord      = StripTrailingNewLine(tssWord);
                                hvoNewSelRow = m_sda.get_VecItem(m_hvoRoot, m_fakeFlid,
                                                                 newSelectedIndex);
                                int  hvoObj, tag, ws;
                                bool fAssocPrev;
                                vwSelWord.TextSelInfo(false, out tssSource, out ichStart, out fAssocPrev, out hvoObj,
                                                      out tag, out ws);
                            }
                        }
                    }
                }

                // We need to manually change the index for ReadOnly views.
                // SimpleRootSite delegates RightMouseClickEvent to our RecordBrowseView parent,
                // which also makes the selection for us..
                if (ReadOnlySelect && e.Button != MouseButtons.Right)
                {
                    if (this.m_xbvvc.HasSelectColumn && e.X < m_xbvvc.SelectColumnWidth)
                    {
                        base.OnMouseUp(e);                         // allows check box to operate.
                    }
                }
                else
                {
                    // If we leave this set, the base method call's side effects like updating the WS combo
                    // don't happen.
                    m_fHandlingMouseUp = false;
                    base.OnMouseUp(e);                     // normal behavior.
                    m_fHandlingMouseUp = true;
                }
                SetSelectedIndex(newSelectedIndex);
                if (tssWord != null)
                {
                    // We're doing click copies; generate an event.
                    // Do this AFTER other actions which may change the current line.
                    ClickCopy(this, new ClickCopyEventArgs(tssWord, hvoNewSelRow, tssSource, ichStart));
                }
                if (clickSel != null)
                {
                    IVwSelection finalSel = null;
                    // There seem to be some cases where the selection helper can't restore the selection.
                    // One that came up in FWR-3666 was clicking on a check box.
                    // If we can't re-establish an editiable selection just let the default behavior continue.
                    try
                    {
                        finalSel = clickSel.MakeRangeSelection(RootBox, false);
                    }
                    catch (Exception)
                    {
                    }
                    if (finalSel != null && SelectionHelper.IsEditable(finalSel))
                    {
                        finalSel.Install();
                        FocusMe();
                    }
                }
            }
            finally
            {
                m_fHandlingMouseUp = false;
                m_fMouseUpEnabled  = false;
            }
        }
Ejemplo n.º 26
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Set both book and section. Don't make a selection; typically the caller will proceed
 /// to do that.
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <param name="iBook">The index of the book (in the book filter).</param>
 /// <param name="iSection">The index of the section (relative to
 /// <paramref name="iBook"/>), or -1 for a selection that is not in a section (e.g.
 /// title).</param>
 /// <remarks>This method should change only the book and section levels of the
 /// selection, but not any other level.</remarks>
 /// ------------------------------------------------------------------------------------
 public void SetBookAndSection(SelectionHelper selHelper,
                               SelectionHelper.SelLimitType selLimitType, int iBook, int iSection)
 {
     m_locationTracker.SetBookAndSection(selHelper, selLimitType, iBook, iSection);
 }
Ejemplo n.º 27
0
        internal WebView( IntPtr webview )
        {
            findRequestRandomizer = new Random();

            this.Instance = webview;

            beginNavigationCallback = internalBeginNavigationCallback;
            awe_webview_set_callback_begin_navigation( webview, beginNavigationCallback );

            beginLoadingCallback = internalBeginLoadingCallback;
            awe_webview_set_callback_begin_loading( webview, beginLoadingCallback );

            finishLoadingCallback = internalFinishLoadingCallback;
            awe_webview_set_callback_finish_loading( webview, finishLoadingCallback );

            jsCallback = internalJsCallback;
            awe_webview_set_callback_js_callback( webview, jsCallback );

            receiveTitleCallback = internalReceiveTitleCallback;
            awe_webview_set_callback_receive_title( webview, receiveTitleCallback );

            changeTooltipCallback = internalChangeTooltipCallback;
            awe_webview_set_callback_change_tooltip( webview, changeTooltipCallback );

            changeCursorCallback = internalChangeCursorCallback;
            awe_webview_set_callback_change_cursor( webview, changeCursorCallback );

            changeKeyboardFocusCallback = internalChangeKeyboardFocusCallback;
            awe_webview_set_callback_change_keyboard_focus( webview, changeKeyboardFocusCallback );

            changeTargetURLCallback = internalChangeTargetURLCallback;
            awe_webview_set_callback_change_target_url( webview, changeTargetURLCallback );

            openExternalLinkCallback = internalOpenExternalLinkCallback;
            awe_webview_set_callback_open_external_link( webview, openExternalLinkCallback );

            requestDownloadCallback = internalRequestDownloadCallback;
            awe_webview_set_callback_request_download( webview, requestDownloadCallback );

            webviewCrashedCallback = internalWebviewCrashedCallback;
            awe_webview_set_callback_web_view_crashed( webview, webviewCrashedCallback );

            pluginCrashedCallback = internalPluginCrashedCallback;
            awe_webview_set_callback_plugin_crashed( webview, pluginCrashedCallback );

            requestMoveCallback = internalRequestMoveCallback;
            awe_webview_set_callback_request_move( webview, requestMoveCallback );

            getPageContentsCallback = internalGetPageContentsCallback;
            awe_webview_set_callback_get_page_contents( webview, getPageContentsCallback );

            domReadyCallback = internalDomReadyCallback;
            awe_webview_set_callback_dom_ready( webview, domReadyCallback );

            requestFileChooserCallback = internalRequestFileChooser;
            awe_webview_set_callback_request_file_chooser( webview, requestFileChooserCallback );

            getScrollDataCallback = internalGetScrollData;
            awe_webview_set_callback_get_scroll_data( webview, getScrollDataCallback );

            jsConsoleMessageCallback = internalJSConsoleMessage;
            awe_webview_set_callback_js_console_message( webview, jsConsoleMessageCallback );

            getFindResultsCallback = internalGetFindResults;
            awe_webview_set_callback_get_find_results( webview, getFindResultsCallback );

            updateIMECallback = internalUpdateIME;
            awe_webview_set_callback_update_ime( webview, updateIMECallback );

            resourceRequestCallback = internalResourceRequestCallback;
            awe_webview_set_callback_resource_request( webview, resourceRequestCallback );

            resourceResponseCallback = internalResourceResponseCallback;
            awe_webview_set_callback_resource_response( webview, resourceResponseCallback );

            jsObjectCallbackMap = new Dictionary<string, JSCallback>();
            this.JSCallbackCalled += handleJSCallback;

            selectionHelper = new SelectionHelper( this, OnWebSelectionChanged );
            selectionHelper.RegisterSelectionHelper();

            RaisePropertyChanged( "IsEnabled" );
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Let Renderer decide whether the parent grid should be allowed to handle keys and prevent
        /// the key event from being handled by the visual UIElement for this renderer. If this method
        /// returns true the parent grid will handle arrow keys and set the Handled flag in the event
        /// data. Keys that the grid does not handle will be ignored and be routed to the UIElement
        /// for this renderer.
        /// </summary>
        /// <param name="e">A <see cref="KeyEventArgs" /> object.</param>
        /// <returns>
        /// True if the parent grid should be allowed to handle keys; false otherwise.
        /// </returns>
        protected override bool ShouldGridTryToHandleKeyDown(KeyEventArgs e)
        {
            if (!HasCurrentCellState)
            {
                return(false);
            }
            var columnIndex = TreeGrid.ResolveToGridVisibleColumnIndex((this.CurrentCellElement as TreeGridCell).ColumnBase.ColumnIndex);
            var column      = ((TreeGridTemplateColumn)TreeGrid.Columns[columnIndex]);
            var handleTemplatedUIElementKeyDown = FocusManagerHelper.GetWantsKeyInput(column);


            if ((column.hasCellTemplate || column.hasCellTemplateSelector) && (column.hasEditTemplate || column.hasEditTemplateSelector))
            {
                handleTemplatedUIElementKeyDown = false;
            }
            switch (e.Key)
            {
            case Key.Space:
                return(!handleTemplatedUIElementKeyDown);

            case Key.A:
            case Key.V:
            case Key.X:
            case Key.C:
            {
                if (!handleTemplatedUIElementKeyDown && SelectionHelper.CheckControlKeyPressed() && !IsInEditing)
                {
                    return(true);
                }
                break;
            }

            case Key.F2:
            case Key.Escape:
            {
                e.Handled = true;
                return(true);
            }

            case Key.Tab:
                // When press tab continuously  and its reach to last one, then the focus goes to grid.Again if you press upo key, focus any of the content control. to avoid that the condition added.
                if (!IsInEditing && !(TreeGrid.GetLastDataRowIndex() == CurrentCellIndex.RowIndex && TreeGrid.SelectionController.CurrentCellManager.GetLastCellIndex() == CurrentCellIndex.ColumnIndex))
                {
                    // If Column with CellTemplate has editor loaded, then the click on that editor will not as we click or navigate to next cell, we need to remove the focus.
                    base.SetFocus(CurrentCellRendererElement, false);
                }
                return(true);

            case Key.Enter:
            case Key.PageUp:
            case Key.PageDown:
                if (!IsInEditing)
                {
                    // If Column with CellTemplate has editor loaded, then navigation of this key will set the focus.
                    base.SetFocus(CurrentCellRendererElement, true);
                }
                return(true);

            case Key.Home:
            case Key.End:
            case Key.Down:
            case Key.Up:
            case Key.Left:
            case Key.Right:
                // if Column has WantsKeyInput Enabled the navigation should be in editor.
            {
                if (!handleTemplatedUIElementKeyDown && !IsInEditing)
                {
                    base.SetFocus(CurrentCellRendererElement, false);
                    return(true);
                }
                else if (handleTemplatedUIElementKeyDown)
                {
                    return(false);
                }
                else
                {
                    return(!IsInEditing);
                }
            }

            case Key.Delete:
            {
                if (handleTemplatedUIElementKeyDown)
                {
                    return(false);
                }
                return(!IsInEditing);
            }
            }
            return(false);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates a selection IP for the specified limit.
        /// </summary>
        /// <param name="sel">The selection.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="vwSel">The new selection.</param>
        /// <param name="curHvo">The current hvo.</param>
        /// <param name="curIch">The current ich.</param>
        /// <param name="curTag">The current tag.</param>
        /// <returns><c>true</c> if we want to create a range selection, otherwise <c>false</c></returns>
        private bool GetSelectionInfo(SelectionHelper sel, SelectionHelper.SelLimitType limit, out IVwSelection vwSel,
                                      out int curHvo, out int curIch, out int curTag)
        {
            vwSel  = null;
            curHvo = 0;
            curIch = -1;
            curTag = -1;

            object obj = m_patternControl.GetItem(sel, limit);

            if (obj == null)
            {
                return(false);
            }

            ITsString curTss;
            int       ws;
            bool      prev;

            sel.Selection.TextSelInfo(limit == SelectionHelper.SelLimitType.End, out curTss, out curIch, out prev, out curHvo, out curTag, out ws);

            object ctxt  = m_patternControl.GetContext(sel);
            int    index = m_patternControl.GetItemContextIndex(ctxt, obj);

            if (!sel.IsRange)
            {
                // if the current selection is an IP, check if it is in one of the off-limits areas, and move the IP
                if (curIch == 0 && curTag == PatternVcBase.ktagLeftNonBoundary)
                {
                    // the cursor is at a non-selectable left edge of an item, so
                    // move to the selectable left edge
                    SelectLeftBoundary(ctxt, index, true);
                    return(false);
                }
                if (curIch == curTss.Length && curTag == PatternVcBase.ktagLeftNonBoundary)
                {
                    // the cursor has been moved to the left from the left boundary, so move the
                    // cursor to the previous item in the cell or the previous cell
                    if (index > 0)
                    {
                        SelectAt(ctxt, index - 1, false, true, true);
                    }
                    else
                    {
                        object prevCtxt = m_patternControl.GetPrevContext(ctxt);
                        if (prevCtxt != null)
                        {
                            SelectCell(prevCtxt, false, true);
                        }
                        else
                        {
                            SelectLeftBoundary(ctxt, index, true);
                        }
                    }
                    return(false);
                }
                if (curIch == curTss.Length && curTag == PatternVcBase.ktagRightNonBoundary)
                {
                    // the cursor is at a non-selectable right edge of an item, so move to the
                    // selectable right edge
                    SelectRightBoundary(ctxt, index, true);
                    return(false);
                }
                if (curIch == 0 && curTag == PatternVcBase.ktagRightNonBoundary)
                {
                    // the cursor has been moved to the right from the right boundary, so move the
                    // cursor to the next item in the cell or the next cell
                    if (index < m_patternControl.GetContextCount(ctxt) - 1)
                    {
                        SelectAt(ctxt, index + 1, true, true, true);
                    }
                    else
                    {
                        object nextCtxt = m_patternControl.GetNextContext(ctxt);
                        if (nextCtxt != null)
                        {
                            SelectCell(nextCtxt, true, true);
                        }
                        else
                        {
                            SelectRightBoundary(ctxt, index, true);
                        }
                    }
                    return(false);
                }
                // when you click to the left of a ZWSP left boundary, Views might place the cursor to the right of the
                // ZWSP. Move the cursor to the proper location before the ZWSP.
                if (curTss.Text == "\u200b" && curIch == 1 && curTag == PatternVcBase.ktagLeftBoundary)
                {
                    SelectLeftBoundary(ctxt, index, true);
                    return(false);
                }

                if (!sel.Selection.IsEditable)
                {
                    return(false);
                }
            }

            // find the beginning of the currently selected item
            IVwSelection initialSel = SelectAt(ctxt, index, true, false, false);

            ITsString tss;
            int       selCellIndex = index;
            int       initialHvo, initialIch, initialTag;

            if (initialSel == null)
            {
                return(false);
            }
            initialSel.TextSelInfo(false, out tss, out initialIch, out prev, out initialHvo, out initialTag, out ws);
            // are we at the beginning of an item?
            if ((curHvo == initialHvo && curIch == initialIch && curTag == initialTag) ||
                (curIch == 0 && curTag == PatternVcBase.ktagLeftBoundary))
            {
                // if the current selection is an IP, then don't adjust anything
                if (!sel.IsRange)
                {
                    return(false);
                }

                // if we are the beginning of the current item, and the current selection is a range, and the end is before the anchor,
                // then do not include the current item in the adjusted range selection
                if (sel.Selection.EndBeforeAnchor && limit == SelectionHelper.SelLimitType.Anchor)
                {
                    selCellIndex = index - 1;
                }
            }
            else
            {
                int          finalIch, finalHvo, finalTag;
                IVwSelection finalSel = SelectAt(ctxt, index, false, false, false);
                finalSel.TextSelInfo(false, out tss, out finalIch, out prev, out finalHvo, out finalTag, out ws);
                // are we at the end of an item?
                if ((curHvo == finalHvo && curIch == finalIch && curTag == finalTag) ||
                    (curIch == curTss.Length && curTag == PatternVcBase.ktagRightBoundary))
                {
                    // if the current selection is an IP, then don't adjust anything
                    if (!sel.IsRange)
                    {
                        return(false);
                    }

                    // if we are the end of the current item, and the current selection is a range, and the anchor is before the end,
                    // then do not include the current item in the adjusted range selection
                    if (!sel.Selection.EndBeforeAnchor && limit == SelectionHelper.SelLimitType.Anchor)
                    {
                        selCellIndex = index + 1;
                    }
                }
            }

            bool initial = limit == SelectionHelper.SelLimitType.Anchor ? !sel.Selection.EndBeforeAnchor : sel.Selection.EndBeforeAnchor;

            vwSel = SelectAt(ctxt, selCellIndex, initial, false, false);

            return(vwSel != null);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Receives the broadcast message "PropertyChanged"
        /// </summary>
        public override void OnPropertyChanged(string name)
        {
            var wsBefore = 0;

            // We want to know below whether a base class changed the ws or not.
            if (name == "WritingSystemHvo")
            {
                if (RootObject != null && m_rootb != null && m_rootb.Selection.IsValid)
                {
                    wsBefore = SelectionHelper.GetWsOfEntireSelection(m_rootb.Selection);
                }
            }

            base.OnPropertyChanged(name);
            bool newVal;             // used in two cases below

            switch (name)
            {
            case "WritingSystemHvo":
                if (RootObject != null && m_rootb != null && m_rootb.Selection.IsValid)
                {
                    int hvo, tag, ws, ichMin, ichLim;
                    ws = SelectionHelper.GetWsOfEntireSelection(m_rootb.Selection);
                    if (ws != wsBefore)                             // writing system changed!
                    {
                        if (GetSelectedWordPos(m_rootb.Selection, out hvo, out tag, out ws, out ichMin, out ichLim))
                        {
                            if (tag != StTxtParaTags.kflidContents)
                            {
                                return;
                            }

                            var para = m_fdoCache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(hvo);
                            // force this paragraph to recognize it might need reparsing.
                            SetParaToReparse(para);
                        }
                    }
                }
                break;

            case "ShowInvisibleSpaces":
                newVal = ShowInvisibleSpaces;
                if (newVal != m_showSpaceDa.ShowSpaces)
                {
                    m_showSpaceDa.ShowSpaces = newVal;
                    var saveSelection = SelectionHelper.Create(this);
                    m_rootb.Reconstruct();
                    saveSelection.SetSelection(true);
                }
                if (!newVal && ClickInvisibleSpace)
                {
                    TurnOffClickInvisibleSpace();
                }
                break;

            case "ClickInvisibleSpace":
                newVal = ClickInvisibleSpace;
                if (newVal == m_fClickInsertsZws)
                {
                    return;
                }
                m_fClickInsertsZws = newVal;
                if (newVal && !ShowInvisibleSpaces)
                {
                    TurnOnShowInvisibleSpaces();
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 31
0
        private void ClearDelegates()
        {
            resourceRequestCallback = null;
            awe_webview_set_callback_resource_request( Instance, null );

            resourceResponseCallback = null;
            awe_webview_set_callback_resource_response( Instance, null );

            beginLoadingCallback = null;
            awe_webview_set_callback_begin_loading( Instance, null );

            beginNavigationCallback = null;
            awe_webview_set_callback_begin_navigation( Instance, null );

            changeCursorCallback = null;
            awe_webview_set_callback_change_cursor( Instance, null );

            changeKeyboardFocusCallback = null;
            awe_webview_set_callback_change_keyboard_focus( Instance, null );

            changeTargetURLCallback = null;
            awe_webview_set_callback_change_target_url( Instance, null );

            changeTooltipCallback = null;
            awe_webview_set_callback_change_tooltip( Instance, null );

            domReadyCallback = null;
            awe_webview_set_callback_dom_ready( Instance, null );

            finishLoadingCallback = null;
            awe_webview_set_callback_finish_loading( Instance, null );

            getFindResultsCallback = null;
            awe_webview_set_callback_get_find_results( Instance, null );

            getPageContentsCallback = null;
            awe_webview_set_callback_get_page_contents( Instance, null );

            getScrollDataCallback = null;
            awe_webview_set_callback_get_scroll_data( Instance, null );

            jsCallback = null;
            awe_webview_set_callback_js_callback( Instance, null );

            jsConsoleMessageCallback = null;
            awe_webview_set_callback_js_console_message( Instance, null );

            openExternalLinkCallback = null;
            awe_webview_set_callback_open_external_link( Instance, null );

            pluginCrashedCallback = null;
            awe_webview_set_callback_plugin_crashed( Instance, null );

            receiveTitleCallback = null;
            awe_webview_set_callback_receive_title( Instance, null );

            requestFileChooserCallback = null;
            awe_webview_set_callback_request_file_chooser( Instance, null );

            requestDownloadCallback = null;
            awe_webview_set_callback_request_download( Instance, null );

            requestMoveCallback = null;
            awe_webview_set_callback_request_move( Instance, null );

            updateIMECallback = null;
            awe_webview_set_callback_update_ime( Instance, null );

            webviewCrashedCallback = null;
            awe_webview_set_callback_web_view_crashed( Instance, null );

            selectionHelper.Dispose();
            selectionHelper = null;

            this.JSCallbackCalled -= handleJSCallback;

            if ( jsObjectCallbackMap != null )
            {
                jsObjectCallbackMap.Clear();
                jsObjectCallbackMap = null;
            }
        }
Ejemplo n.º 32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Perform tests to make sure that Anchor and End of selection are the same
		/// </summary>
		/// <param name="selHelper"></param>
		/// ------------------------------------------------------------------------------------
		protected void AssertSameAnchorAndEnd(SelectionHelper selHelper)
		{
			Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd,
				"Selection spans multiple characters");
			Assert.AreEqual(selHelper.GetIhvoRoot(SelectionHelper.SelLimitType.Anchor),
				selHelper.GetIhvoRoot(SelectionHelper.SelLimitType.End),
				"Different root objects for anchor and end");
			Assert.AreEqual(
				selHelper.GetNumberOfPreviousProps(SelectionHelper.SelLimitType.Anchor),
				selHelper.GetNumberOfPreviousProps(SelectionHelper.SelLimitType.End),
				"Different number of previous props for anchor and end");
			Assert.AreEqual(
				selHelper.GetAssocPrev(SelectionHelper.SelLimitType.Anchor),
				selHelper.GetAssocPrev(SelectionHelper.SelLimitType.End),
				"Different association with previous character");
			Assert.AreEqual(
				selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.Anchor),
				selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End),
				"Different number of levels");
			Assert.AreEqual(
				selHelper.GetWritingSystem(SelectionHelper.SelLimitType.Anchor),
				selHelper.GetWritingSystem(SelectionHelper.SelLimitType.End),
				"Different writing system");
			Assert.IsTrue(m_basicView.IsSelectionVisible(null),
				"Selection not visible");
		}
Ejemplo n.º 33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy constructor
		/// </summary>
		/// <param name="src">The source object</param>
		/// ------------------------------------------------------------------------------------
		public DummySelectionHelper(SelectionHelper src)
			: base(src)
		{
		}
Ejemplo n.º 34
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Makes a selection in the specified annotation (without scrolling the annotation in
        /// the view).
        /// </summary>
        /// <param name="vc">The notes view constructor</param>
        /// <param name="fScrollNearTop">if set to <c>true</c> scrolls the specified note to a
        /// position near the top of the view.</param>
        /// <param name="bookIndex">Index of the book.</param>
        /// <param name="iAnnotation">Index of the annotation.</param>
        /// <param name="iResponse">Index of the response (0 if setting the selection in one of
        /// the StJournalText fields rather than in a response.</param>
        /// <param name="noteTag">The tag indicating the field of the annotation where the
        /// selection is to be made.</param>
        /// <param name="rootSite">The root site.</param>
        /// <param name="fNoteIsExpanded">if <c>true</c> make a selection at the start and end so
        /// that the whole annotation can be scrolled into view. if set to <c>false</c> only
        /// make a selection at the start of the annotation.</param>
        /// ------------------------------------------------------------------------------------
        internal void MakeSelectionInNote(TeNotesVc vc, bool fScrollNearTop, int bookIndex,
                                          int iAnnotation, int iResponse, int noteTag,
                                          IVwRootSite rootSite, bool fNoteIsExpanded)
        {
            if (vc == null)
            {
                return;
            }

            SelectionHelper selHelper;

            if (fScrollNearTop)
            {
                // Make an un-installed selection at the top of the annotation in order to scroll the
                // annotation to the top of the view.
                selHelper = new SelectionHelper();
                selHelper.NumberOfLevels             = 2;
                selHelper.LevelInfo[0].cpropPrevious = 0;
                selHelper.LevelInfo[0].ich           = -1;
                selHelper.LevelInfo[0].ihvo          = iAnnotation;
                selHelper.LevelInfo[0].tag           = ScrBookAnnotationsTags.kflidNotes;
                selHelper.LevelInfo[0].ws            = 0;
                selHelper.LevelInfo[1].cpropPrevious = 0;
                selHelper.LevelInfo[1].ich           = -1;
                selHelper.LevelInfo[1].ihvo          = bookIndex;
                selHelper.LevelInfo[1].tag           = ScriptureTags.kflidBookAnnotations;
                selHelper.LevelInfo[1].ws            = 0;
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, -2);
                selHelper.IchAnchor             = 0;
                selHelper.AssocPrev             = false;
                selHelper.NumberOfPreviousProps = 2;
                if (fNoteIsExpanded)
                {
                    selHelper.SetSelection(rootSite, true, true, VwScrollSelOpts.kssoNearTop);
                }
                else
                {
                    // Annotation is collapsed. Only attempt a selection at the start of it.
                    selHelper.SetSelection(rootSite, true, true);
                    return;
                }
            }
            else
            {
                EnsureNoteIsVisible(vc, bookIndex, iAnnotation, rootSite);
            }

            // Now make the real (installed) selection in the desired field of the annotation.
            bool fIsResponse = (noteTag == ScrScriptureNoteTags.kflidResponses);

            selHelper = new SelectionHelper();
            selHelper.NumberOfLevels             = 4;
            selHelper.LevelInfo[0].tag           = StTextTags.kflidParagraphs;
            selHelper.LevelInfo[0].ihvo          = 0;
            selHelper.LevelInfo[1].tag           = (int)noteTag;
            selHelper.LevelInfo[1].ihvo          = iResponse;
            selHelper.LevelInfo[1].cpropPrevious = (fIsResponse ? 0 : 1);
            selHelper.LevelInfo[2].tag           = ScrBookAnnotationsTags.kflidNotes;
            selHelper.LevelInfo[2].ihvo          = iAnnotation;
            selHelper.LevelInfo[3].tag           = ScriptureTags.kflidBookAnnotations;
            selHelper.LevelInfo[3].ihvo          = bookIndex;
            selHelper.IchAnchor  = 0;
            selHelper.AssocPrev  = false;
            selHelper.TextPropId = StTxtParaTags.kflidContents;
            selHelper.SetSelection(rootSite, true, true);
        }
Ejemplo n.º 35
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			// Must not be run more than once.
			if (IsDisposed)
				return;

			base.Dispose(disposing);

			if (disposing)
			{
				if (components != null)
					components.Dispose();
				var disposable = m_basicViewVc as IDisposable;
				if (disposable != null)
					disposable.Dispose();
			}
			RequestedSelectionAtEndOfUow = null;
			Cache = null;
			m_basicViewVc = null;
			m_SelectionHelper = null;
		}
Ejemplo n.º 36
0
        /// <summary>
        /// The user has attempted to delete something which the system does not inherently
        /// know how to delete.  If the problem is a "complex range", then try to delete one
        /// object from the vector displayed in the entry sequence.
        /// </summary>
        public override VwDelProbResponse OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
        {
            if (dpt == VwDelProbType.kdptComplexRange)
            {
                var       helper = SelectionHelper.GetSelectionInfo(sel, this);
                var       clev   = helper.NumberOfLevels;
                var       rginfo = helper.LevelInfo;
                var       info   = rginfo[clev - 1];
                ICmObject cmo;
                if (info.tag == m_rootFlid &&
                    m_cache.ServiceLocator.ObjectRepository.TryGetObject(info.hvo, out cmo))
                {
                    var sda = m_cache.DomainDataByFlid as ISilDataAccessManaged;
                    Debug.Assert(sda != null);
                    var rghvos = sda.VecProp(m_rootObj.Hvo, m_rootFlid);
                    var ihvo   = -1;
                    for (var i = 0; i < rghvos.Length; ++i)
                    {
                        if (rghvos[i] == cmo.Hvo)
                        {
                            ihvo = i;
                            break;
                        }
                    }
                    if (ihvo >= 0)
                    {
                        var startHeight = m_rootb.Height;
                        if (Cache.MetaDataCacheAccessor.get_IsVirtual(m_rootFlid))
                        {
                            var          obj = m_cache.ServiceLocator.GetObject(rghvos[ihvo]);
                            ILexEntryRef ler = null;
                            if (obj is ILexEntry)
                            {
                                var complex = (ILexEntry)obj;
                                // the selected object in the list is a complex entry which has this as one of
                                // its components.  We want to remove this from its components.
                                foreach (var item in complex.EntryRefsOS)
                                {
                                    switch (item.RefType)
                                    {
                                    case LexEntryRefTags.krtComplexForm:
                                    case LexEntryRefTags.krtVariant:
                                        ler = item;
                                        break;

                                    default:
                                        throw new Exception("Unexpected LexEntryRef type in EntrySequenceVectorReferenceView.OnProblemDeletion");
                                    }
                                }
                            }
                            else if (obj is ILexEntryRef)
                            {
                                ler = (ILexEntryRef)obj;
                            }
                            else
                            {
                                return(VwDelProbResponse.kdprAbort);                                // we don't know how to delete it.
                            }
                            var fieldName = m_cache.MetaDataCacheAccessor.GetFieldName(m_rootFlid);
                            if (fieldName == "Subentries")
                            {
                                ler.PrimaryLexemesRS.Remove(m_rootObj);
                            }
                            else if (fieldName == "VisibleComplexFormEntries" || fieldName == "VisibleComplexFormBackRefs")
                            {
                                ler.ShowComplexFormsInRS.Remove(m_rootObj);
                            }
                            else if (fieldName == "VariantFormEntries")
                            {
                                ler.ComponentLexemesRS.Remove(m_rootObj);
                            }
                        }
                        else
                        {
                            sda.Replace(m_rootObj.Hvo, m_rootFlid, ihvo, ihvo + 1, new int[0], 0);
                        }
                        if (m_rootb != null)
                        {
                            CheckViewSizeChanged(startHeight, m_rootb.Height);
                            // Redisplay (?) the vector property.
                            m_rootb.SetRootObject(m_rootObj.Hvo, m_VectorReferenceVc, kfragTargetVector,
                                                  m_rootb.Stylesheet);
                        }
                        return(VwDelProbResponse.kdprDone);
                    }
                }
            }
            return(base.OnProblemDeletion(sel, dpt));
        }
Ejemplo n.º 37
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compare the values of <see cref="SelectionHelper"/> with the expected values
		/// </summary>
		/// <param name="type"></param>
		/// <param name="selectionHelper"></param>
		/// <param name="ihvoRoot"></param>
		/// <param name="nPrevProps"></param>
		/// <param name="ich"></param>
		/// <param name="nWs"></param>
		/// <param name="fAssocPrev"></param>
		/// <param name="nLevels"></param>
		/// <param name="tag1"></param>
		/// <param name="cpropPrev1"></param>
		/// <param name="ihvo1"></param>
		/// <param name="tag0"></param>
		/// <param name="cpropPrev0"></param>
		/// <param name="ihvo0"></param>
		/// ------------------------------------------------------------------------------------
		protected void CheckSelectionHelperValues(SelectionHelper.SelLimitType type,
			SelectionHelper selectionHelper, int ihvoRoot, int nPrevProps, int ich, int nWs,
			bool fAssocPrev, int nLevels, int tag1, int cpropPrev1, int ihvo1, int tag0,
			int cpropPrev0, int ihvo0)
		{
			Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection not visible");
			Assert.AreEqual(ihvoRoot, selectionHelper.GetIhvoRoot(type), "ihvoRoot differs");
			Assert.AreEqual(nPrevProps, selectionHelper.GetNumberOfPreviousProps(type),
				"nPrevProps differs");
			Assert.AreEqual(ich, selectionHelper.GetIch(type), "ich differs");
			Assert.AreEqual(nWs, selectionHelper.GetWritingSystem(type), "ws differs");
			Assert.AreEqual(fAssocPrev, selectionHelper.GetAssocPrev(type),
				"fAssocPrev differs");
			Assert.AreEqual(nLevels, selectionHelper.GetNumberOfLevels(type),
				"Number of levels differs");
			if (nLevels >= 2)
			{
				Assert.AreEqual(tag1, selectionHelper.GetLevelInfo(type)[1].tag,
					"tag (level 1) differs");
				Assert.AreEqual(cpropPrev1, selectionHelper.GetLevelInfo(type)[1].cpropPrevious,
					"cpropPrev (level 1) differs");
				Assert.AreEqual(ihvo1, selectionHelper.GetLevelInfo(type)[1].ihvo,
					"ihvo (level 1) differs");
			}
			Assert.AreEqual(tag0, selectionHelper.GetLevelInfo(type)[0].tag,
				"tag (level 0) differs");
			Assert.AreEqual(cpropPrev0, selectionHelper.GetLevelInfo(type)[0].cpropPrevious,
				"cpropPrev (level 0) differs");
			Assert.AreEqual(ihvo0, selectionHelper.GetLevelInfo(type)[0].ihvo,
				"ihvo (level 0) differs");
		}
Ejemplo n.º 38
0
		/// --------------------------------------------------------------------------------
		/// <summary>
		/// In this simple implementation, we just record the information about the requested
		/// selection.
		/// </summary>
		/// <param name="rootb">The rootbox</param>
		/// <param name="ihvoRoot">Index of root element</param>
		/// <param name="cvlsi">count of levels</param>
		/// <param name="rgvsli">levels</param>
		/// <param name="tagTextProp">tag or flid of property containing the text (TsString)</param>
		/// <param name="cpropPrevious">number of previous occurrences of the text property</param>
		/// <param name="ich">character offset into the text</param>
		/// <param name="wsAlt">The id of the writing system for the selection.</param>
		/// <param name="fAssocPrev">Flag indicating whether to associate the insertion point
		/// with the preceding character or the following character</param>
		/// <param name="selProps">The selection properties.</param>
		/// --------------------------------------------------------------------------------
		public override void RequestSelectionAtEndOfUow(IVwRootBox rootb, int ihvoRoot,
			int cvlsi, SelLevInfo[] rgvsli, int tagTextProp, int cpropPrevious, int ich, int wsAlt,
			bool fAssocPrev, ITsTextProps selProps)
		{
			Assert.AreEqual(RootBox, rootb);
			Assert.IsNull(RequestedSelectionAtEndOfUow);

			RequestedSelectionAtEndOfUow = new SelectionHelper();
			RequestedSelectionAtEndOfUow.RootSite = this;
			RequestedSelectionAtEndOfUow.IhvoRoot = ihvoRoot;
			RequestedSelectionAtEndOfUow.NumberOfLevels = cvlsi;
			RequestedSelectionAtEndOfUow.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, rgvsli);
			RequestedSelectionAtEndOfUow.TextPropId = tagTextProp;
			RequestedSelectionAtEndOfUow.NumberOfPreviousProps = cpropPrevious;
			RequestedSelectionAtEndOfUow.IchAnchor = ich;
			RequestedSelectionAtEndOfUow.AssocPrev = fAssocPrev;
		}
Ejemplo n.º 39
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Focus got set to the draft view
		/// </summary>
		/// <param name="e">The event data</param>
		/// -----------------------------------------------------------------------------------
		protected override void OnGotFocus(EventArgs e)
		{
			base.OnGotFocus(e);

			if (DesignMode || !m_fRootboxMade)
				return;

			if (m_SelectionHelper != null)
			{
				m_SelectionHelper.SetSelection(this);
				m_SelectionHelper = null;
			}
		}