Пример #1
0
        private void DrawWithHighlighting(String description, String textToHighlight, Graphics graphics,
                                          Rectangle descriptionBounds, Color textColor, Color backColor)
        {
            var findMatch         = new FindMatch(description);
            int ichHighlightBegin = description.ToLower().IndexOf(textToHighlight.ToLower(), StringComparison.Ordinal);

            // A very short search only matches at the front of a word
            if ((textToHighlight.Length < ProteinMatchQuery.MIN_FREE_SEARCH_LENGTH) && (ichHighlightBegin > 0))
            {
                // Insist on a leading space for match
                ichHighlightBegin = description.ToLower().IndexOf(" " + textToHighlight.ToLower(), StringComparison.Ordinal); // Not L10N
                if (ichHighlightBegin > 0)
                {
                    ichHighlightBegin++; // Don't really want to highlight the space
                }
            }
            if (ichHighlightBegin >= 0)
            {
                findMatch = findMatch.ChangeRange(ichHighlightBegin, ichHighlightBegin + textToHighlight.Length);
            }
            else
            {
                findMatch = findMatch.ChangeRange(0, 0); // No highlighting
            }
            var textRendererHelper = new TextRendererHelper
            {
                Font          = ListView.Font,
                HighlightFont = new Font(ListView.Font, FontStyle.Bold),
                ForeColor     = textColor,
                BackColor     = backColor,
            };

            textRendererHelper.DrawHighlightedText(graphics, descriptionBounds, findMatch);
        }
Пример #2
0
        /// <summary>
        /// Process in thread
        /// </summary>
        public void ThreadProc()
        {
            Validation = string.Empty;

            _asn        = new AssigneeModel();
            AsnResponse = _asn.Read(AssigneePath);

            _enh        = new EnhancementModel();
            EnhResponse = _enh.Read(EnhancementPath);

            if (EnhResponse == true && AsnResponse == true)
            {
                _find = new FindMatch(_asn, _enh);
                _find.Get();
                LoaderVisiblity = "Hidden";
                ButtonEnable    = "True";
            }
            else if (AsnResponse == false)
            {
                Validation      = "Invalid Assignee Document Format";
                LoaderVisiblity = "Hidden";
                ButtonEnable    = "True";
            }
            else if (EnhResponse == false)
            {
                Validation      = "Invalid Enhancement Document Format";
                LoaderVisiblity = "Hidden";
                ButtonEnable    = "True";
            }
        }
Пример #3
0
 public FindResult(FindPredicate findPredicate, BookmarkEnumerator bookmarkEnumerator, FindMatch match)
 {
     FindPredicate = findPredicate;
     Bookmark = bookmarkEnumerator.Current;
     Document = bookmarkEnumerator.Document;
     LocationName = bookmarkEnumerator.GetLocationName(findPredicate.DisplaySettings);
     LocationType = bookmarkEnumerator.GetLocationType();
     FindMatch = match;
     IsValid = true;
 }
Пример #4
0
 public FindResult(FindPredicate findPredicate, BookmarkEnumerator bookmarkEnumerator, FindMatch match)
 {
     FindPredicate = findPredicate;
     Bookmark      = bookmarkEnumerator.Current;
     Document      = bookmarkEnumerator.Document;
     LocationName  = bookmarkEnumerator.GetLocationName(findPredicate.DisplaySettings);
     LocationType  = bookmarkEnumerator.GetLocationType();
     FindMatch     = match;
     IsValid       = true;
 }
Пример #5
0
 void Start()
 {
     _matchScript = _matchObj.GetComponent <FindMatch>();
     _gridScript  = gridObject.GetComponent <CreateGrid>();
     _width       = _gridScript.width;
     _height      = _gridScript.height;
     _tiles       = new GameObject[_width, _height];
     _tiles       = CreateGrid.gridMainScript._tiles;
     _tmpTiles    = _tiles;
     StartCoroutine(FindTilesToFallDown());
 }
Пример #6
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = FindPredicate.GetHashCode();
         result = (result * 397) ^ Document.GetHashCode();
         result = (result * 397) ^ Bookmark.GetHashCode();
         result = (result * 397) ^ FindMatch.GetHashCode();
         result = (result * 397) ^ IsValid.GetHashCode();
         result = (result * 397) ^ LocationName.GetHashCode();
         result = (result * 397) ^ LocationType.GetHashCode();
         return(result);
     }
 }
Пример #7
0
        //Open
        public Client(Player a, GetPlayerMove b, FindMatch c, RichTextBox d, ResetGame e, MainForm f)
        {
            player = a;
            wc     = new WebClient();

            mainform      = f;
            getplayermove = b;
            findmatch     = c;
            output        = d;
            resetgame     = e;

            MatchFinder = new Thread(FindQueue);
            MoveFinder  = new Thread(GetOpponentMove);
        }
        public void FindMatch_Returns_False_Test2()
        {
            string enhancement = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\Documents\testEmpty.docx";
            string assignee    = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\Documents\testEmpty.docx";

            bool expected = false;

            _enhancement.Read(enhancement);
            _assignee.Read(assignee);
            FindMatch _fm    = new FindMatch(_assignee, _enhancement);
            bool      result = _fm.Get();

            Assert.AreEqual(expected, result);
        }
Пример #9
0
        //LOAD
        private void NewForm_Load(object sender, EventArgs e)
        {
            graphics      = Screen.CreateGraphics();
            unitdestroly  = OnUnitDestroly;
            sakkfor       = OnSakkFor;
            findmatch     = MatchFound;
            getplayermove = OppMove;
            resetgame     = Reset;
            endform       = new GEndForm(this);
            label5.Text  += version;

            this.Opacity = 0;
            nameinput    = new Chess.NameInput(this);
            nameinput.Show();
        }
Пример #10
0
        public FindResult ChangeDocument(SrmDocument document)
        {
            var result = new FindResult(this)
            {
                Document = document
            };
            var       bookMarkEnumerator = BookmarkEnumerator.TryGet(document, Bookmark);
            FindMatch findMatch          = null;

            if (bookMarkEnumerator != null)
            {
                findMatch = FindPredicate.Match(bookMarkEnumerator);
            }
            if (findMatch == null)
            {
                result.IsValid = false;
            }
            else
            {
                result.IsValid   = true;
                result.FindMatch = findMatch;
            }
            return(result);
        }
Пример #11
0
 private void Start()
 {
     findMatch = FindObjectOfType <FindMatch>();
     board     = FindObjectOfType <Board>();
     PopupMenu = FindObjectOfType <Menu>();
 }
Пример #12
0
 private void XCorr_Click(object sender, EventArgs e)
 {
     FindMatch cross = new FindMatch(@"sync_pattern/sweep_tone.wav", @"mixed.wav");
 }
Пример #13
0
        public void DrawHighlightedText(Graphics graphics, Rectangle descriptionBounds, FindMatch findMatch)
        {
            if (descriptionBounds.Width < 0)
            {
                return;
            }
            var graphicsState = graphics.Save();

            try
            {
                graphics.SetClip(descriptionBounds);
                int ichHighlightBegin = findMatch.RangeStart;
                int ichHighlightEnd   = findMatch.RangeEnd;
                var displayText       = findMatch.DisplayText;
                var beginText         = displayText.Substring(0, ichHighlightBegin);
                var highlightedText   = displayText.Substring(ichHighlightBegin, ichHighlightEnd - ichHighlightBegin);
                var endText           = displayText.Substring(ichHighlightEnd);
                // Measure the width of the three parts of text
                const int             xPad   = 0;
                const TextFormatFlags format = TextFormatFlags.SingleLine |
                                               TextFormatFlags.PreserveGraphicsClipping |
                                               TextFormatFlags.NoPadding;
                Size sizeMax = new Size(int.MaxValue, int.MaxValue);
                int  dxBegin =
                    TextRenderer.MeasureText(graphics, beginText, Font, sizeMax, format).Width - xPad;
                int dxHighlight =
                    TextRenderer.MeasureText(graphics, highlightedText, HighlightFont, sizeMax, format).Width - xPad;
                int dxEnd =
                    TextRenderer.MeasureText(graphics, endText, Font, sizeMax, format).Width - xPad;
                int dxTotal = dxBegin + dxHighlight + dxEnd;

                int dxBeginUnclipped = dxBegin;
                // If the text won't all fit in the space provided, figure out what should be clipped,
                // trying to keep the bold text centered in the middle of the line.
                if (dxTotal > descriptionBounds.Width)
                {
                    int dxHalf = (descriptionBounds.Width - dxHighlight) / 2;
                    if (dxBegin > dxHalf && dxEnd > dxHalf)
                    {
                        dxBegin = dxHalf;
                    }
                    else if (dxBegin > dxHalf)
                    {
                        dxBegin = descriptionBounds.Width - dxHighlight - dxEnd;
                    }
                    else
                    {
                        dxEnd = descriptionBounds.Width - dxHighlight - dxBegin;
                    }
                }
                // Draw the text before the highlight
                var rect = new Rectangle(
                    descriptionBounds.Left + dxBegin - dxBeginUnclipped,
                    descriptionBounds.Top,
                    dxBeginUnclipped, descriptionBounds.Height);
                TextRenderer.DrawText(graphics, beginText, Font, rect, ForeColor, BackColor, format);
                // Draw the highlighted text
                rect.X    += dxBeginUnclipped;
                rect.Width = dxHighlight;
                TextRenderer.DrawText(graphics, highlightedText, HighlightFont, rect, ForeColor, BackColor, format);
                // Draw the text after the highlight
                rect.X    += dxHighlight;
                rect.Width = dxEnd;
                TextRenderer.DrawText(graphics, endText, Font, rect, ForeColor, BackColor, format);
            }
            finally
            {
                graphics.Restore(graphicsState);
            }
        }
Пример #14
0
 private void BuildFindMatch(int start, int length)
 {
     // build text_selections list for F3 and Shift+F3
     FindMatch text_selection = new FindMatch();
     if (m_find_matches != null)
     {
         text_selection.Start = start;
         text_selection.Length = length;
         m_find_matches.Add(text_selection);
     }
 }