예제 #1
0
 protected override void HandleCopy()
 {
     if (selectionLength != 0)
     {
         var whatToCopy = DisplayedText.Substring(
             selectionStart, selectionLength);
         Clipboard.ClipboardImplementation.PushStringToClipboard(
             whatToCopy);
     }
 }
예제 #2
0
        internal void RecalculateBoundingAndDisplayedText()
        {
            BoundingIgnoredSizeAndFlags = TextHandle.MeasureText(SpriteHandle, TextValue, FontDrawFlags.NoClip);
            DisplayedText = TextValue;
            Bounding      = BoundingIgnoredSizeAndFlags;
            if (Bounding.Width - 4 > Width)
            {
                while (Bounding.Width - 4 > Width && DisplayedText.Length > 3)
                {
                    DisplayedText = string.Concat(DisplayedText.Substring(0, DisplayedText.Length - 4), "...");
                    Bounding      = TextHandle.MeasureText(SpriteHandle, DisplayedText, DrawFlags);
                }
            }

            // Recalculate the position rectangle
            RecalculatePositionRectangle();

            // Preload the text
            TextHandle.PreloadText(DisplayedText);
        }
예제 #3
0
        protected void UpdateToSelection()
        {
            if (selectionInstance != null && selectionLength > 0 && DisplayedText?.Length > 0)
            {
                selectionInstance.Visible = true;

                selectionInstance.XUnits =
                    global::Gum.Converters.GeneralUnitType.PixelsFromSmall;

                var substring    = DisplayedText.Substring(0, selectionStart);
                var firstMeasure = this.coreTextObject.BitmapFont.MeasureString(substring);
                selectionInstance.X = this.textComponent.X + firstMeasure;

                substring = DisplayedText.Substring(0, selectionStart + selectionLength);
                selectionInstance.Width = 1 +
                                          this.coreTextObject.BitmapFont.MeasureString(substring) - firstMeasure;
            }
            else if (selectionInstance != null)
            {
                selectionInstance.Visible = false;
            }
        }