コード例 #1
0
        public SearchResult FindPrevious(bool setSelection)
        {
            int startOffset = Caret.Offset - SearchEngine.SearchRequest.SearchPattern.Length;

            if (IsSomethingSelected && IsMatchAt(MainSelection.GetAnchorOffset(this)))
            {
                startOffset = MainSelection.GetAnchorOffset(this);
            }

            int searchOffset;

            if (startOffset < 0)
            {
                searchOffset = Document.Length - 1;
            }
            else
            {
                searchOffset = (startOffset + Document.Length - 1) % Document.Length;
            }
            SearchResult result = SearchBackward(searchOffset);

            if (result != null)
            {
                result.SearchWrapped = result.EndOffset > startOffset;
                Caret.Offset         = result.Offset + result.Length;
                if (setSelection)
                {
                    MainSelection = new Selection(Document.OffsetToLocation(result.Offset), Caret.Location);
                }
            }
            return(result);
        }
コード例 #2
0
        private void TPM_Click(object sender, RoutedEventArgs e)
        {
            MainSelection ms = new MainSelection();

            Main.Children.Clear();
            Main.Children.Add(ms);
        }
コード例 #3
0
 private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MainSelection.SelectedItems.Count > 4)
     {
         MainSelection.UnselectAll();
     }
     else
     {
         ModuleData.Selected = new int[] { -1, -1, -1, -1 };
         int i = 0;
         foreach (ListBoxItem item in MainSelection.SelectedItems)
         {
             ModuleData.Selected[i] = (int)item.Tag;
             i++;
         }
         ModuleSolver.SolveKeypads(ref ModuleData);
     }
 }
コード例 #4
0
        public bool SearchReplace(string withPattern, bool setSelection)
        {
            bool result = false;

            if (this.IsSomethingSelected)
            {
                ISegment     selection = MainSelection.GetSelectionRange(this);
                SearchResult match     = searchEngine.GetMatchAt(selection.Offset, selection.Length);
                if (match != null)
                {
                    searchEngine.Replace(match, withPattern);
                    ClearSelection();
                    Caret.Offset = selection.Offset + withPattern.Length;
                    result       = true;
                }
            }
            return(FindNext(setSelection) != null || result);
        }
コード例 #5
0
        public SearchResult FindNext(bool setSelection)
        {
            int startOffset = Caret.Offset;

            if (IsSomethingSelected && IsMatchAt(startOffset))
            {
                startOffset = MainSelection.GetLeadOffset(this);
            }

            SearchResult result = SearchForward(startOffset);

            if (result != null)
            {
                Caret.Offset = result.Offset + result.Length;
                if (setSelection)
                {
                    MainSelection = new Selection(Document.OffsetToLocation(result.Offset), Caret.Location);
                }
            }
            return(result);
        }
コード例 #6
0
 private void Reset_Click(object sender, RoutedEventArgs e)
 {
     MainSelection.UnselectAll();
     ModuleData.OtherOptions.Clear();
     ModuleData.SetSolution(null);
 }