Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        protected bool OnGroupBySortedField(object args)
        {
            if (!m_activeView)
            {
                return(false);
            }

            if (WordListGrid.IsGroupedByField)
            {
                WordListGrid.GroupByField = null;
            }
            else if (WordListGrid.SortOptions.SortFields != null &&
                     WordListGrid.SortOptions.SortFields.Count > 0)
            {
                WordListGrid.GroupByField = WordListGrid.SortOptions.SortFields[0].Field;
                if (Properties.Settings.Default.CollapseWordListsOnGrouping)
                {
                    WordListGrid.ToggleGroupExpansion(false);
                }
            }

            if (!WordListGrid.CurrentCell.Displayed && WordListGrid.CurrentCell != null)
            {
                WordListGrid.ScrollRowToMiddleOfGrid(WordListGrid.CurrentCell.RowIndex);
            }

            FindInfo.ResetStartSearchCell(true);
            FindInfo.CanFindAgain = true;
            return(true);
        }
Ejemplo n.º 2
0
        public void GroupOnSortedFieldTest()
        {
            // Test data before grouping
            SetSearchString("cvc");
            m_findDlg.MatchEntireWord = true;
            Assert.AreEqual(true, FindInfo.FindFirst(false));
            Assert.AreEqual(true, IsCurrCellLocation(0, 1));             // cvc
            Assert.AreEqual(true, FindInfo.Find(false));
            Assert.AreEqual(true, IsCurrCellLocation(1, 1));             // cvc

            m_grid.Sort("Gloss", false);

            // Adds 5 new SilHierarchicalGridRow's & 1 new column
            m_grid.GroupByField = _prj.Fields.Single(f => f.Name == "Gloss");

            ResetStartCell();
            // WordListGroupingBuilder>GroupByField() inserted a hierarchical column for
            // the + and - glpyhs, so we also have to update the column indexes by
            // passing 'true' to ResetStartSearchCell().
            FindInfo.ResetStartSearchCell(true);

            SetSearchString("cvc");
            m_findDlg.MatchEntireWord = true;
            Assert.AreEqual(true, FindInfo.FindFirst(false));
            Assert.AreEqual(true, IsCurrCellLocation(1, 2));             // cvc
            Assert.AreEqual(true, FindInfo.Find(false));
            Assert.AreEqual(true, IsCurrCellLocation(6, 2));             // cvc
            Assert.AreEqual(true, FindInfo.Find(false));

            // ------------------------------------------------------------------------------------
            // Testing finds in collapsed & expanded groups.
            // ------------------------------------------------------------------------------------

            m_grid.ToggleGroupExpansion(false);             // collapse all groups
            FindInfo.SearchCollapsedGroups = false;

            ResetStartCell();
            Assert.AreEqual(false, FindInfo.FindFirst(false));
            Assert.AreEqual(false, FindInfo.Find(false));
            Assert.AreEqual(false, FindInfo.Find(false));

            m_grid.ToggleGroupExpansion(true);               // expand all groups
            Assert.AreEqual(true, FindInfo.FindFirst(false));
            Assert.AreEqual(true, IsCurrCellLocation(1, 2)); // cvc
            Assert.AreEqual(true, FindInfo.Find(false));
            Assert.AreEqual(true, IsCurrCellLocation(6, 2)); // cvc
            Assert.AreEqual(true, FindInfo.Find(false));

            // ------------------------------------------------------------------------------------
            // Searching for "cvc" in 2 groups after collapsing one of them.
            // ------------------------------------------------------------------------------------

            // Collapse 'glbitter' Group
            ((SilHierarchicalGridRow)m_grid.Rows[4]).SetExpandedState(false, false);

            ResetStartCell();
            Assert.AreEqual(true, FindInfo.FindFirst(false));
            Assert.AreEqual(true, IsCurrCellLocation(1, 2));
            Assert.AreEqual(true, FindInfo.Find(false));
            Assert.AreEqual(true, IsCurrCellLocation(1, 2));

            // ------------------------------------------------------------------------------------
            // Searching for "cvc" in 2 groups after collapsing one of them, but
            // searching collapsed groups this time.
            // ------------------------------------------------------------------------------------
            FindInfo.SearchCollapsedGroups = true;

            ResetStartCell();
            Assert.AreEqual(true, FindInfo.FindFirst(false));
            Assert.AreEqual(true, IsCurrCellLocation(1, 2));
            Assert.AreEqual(true, FindInfo.Find(false));
            Assert.AreEqual(true, IsCurrCellLocation(6, 2));
        }