示例#1
0
        public void DoDisplayString(string message, SnapsTextAlignment alignment, SnapsFadeType fadeType)
        {
            AutoResetEvent displayDone = new AutoResetEvent(false);

            if (fadeType == SnapsFadeType.nofade)
            {
                // No fade - just display the new txt
                manager.InvokeOnUIThread(
                    () =>
                {
                    displayTextBlock.Text     = message;
                    displayTextBlock.FontSize = fontSize;
                    switch (alignment)
                    {
                    case SnapsTextAlignment.centre:
                        displayTextBlock.TextAlignment = TextAlignment.Center;
                        break;

                    case SnapsTextAlignment.left:
                        displayTextBlock.TextAlignment = TextAlignment.Left;
                        break;

                    case SnapsTextAlignment.right:
                        displayTextBlock.TextAlignment = TextAlignment.Right;
                        break;

                    case SnapsTextAlignment.justify:
                        displayTextBlock.TextAlignment = TextAlignment.Justify;
                        break;
                    }
                    displayDone.Set();
                }
                    );
            }
            else
            {
                TimeSpan fadeSpeed;
                if (fadeType == SnapsFadeType.fast)
                {
                    fadeSpeed = new TimeSpan(0, 0, 0, 0, 200);
                }
                else
                {
                    fadeSpeed = new TimeSpan(0, 0, 0, 0, 600);
                }

                manager.InvokeOnUIThread(
                    async() =>
                {
                    if (displayTextBlock.Opacity == 1)
                    {
                        await FadeElements.FadeElementOpacityAsync(displayTextBlock, 1, 0, new TimeSpan(0, 0, 0, 0, 200));
                    }
                    displayTextBlock.Text     = message;
                    displayTextBlock.FontSize = fontSize;
                    switch (alignment)
                    {
                    case SnapsTextAlignment.centre:
                        displayTextBlock.TextAlignment = TextAlignment.Center;
                        break;

                    case SnapsTextAlignment.left:
                        displayTextBlock.TextAlignment = TextAlignment.Left;
                        break;

                    case SnapsTextAlignment.right:
                        displayTextBlock.TextAlignment = TextAlignment.Right;
                        break;

                    case SnapsTextAlignment.justify:
                        displayTextBlock.TextAlignment = TextAlignment.Justify;
                        break;
                    }
                    await FadeElements.FadeElementOpacityAsync(displayTextBlock, 0, 1, new TimeSpan(0, 0, 0, 0, 200));
                    displayDone.Set();
                }
                    );
            }

            displayDone.WaitOne();
        }
 public void DisplayString(string message, SnapsTextAlignment alignment, SnapsFadeType fadeType, int size)
 {
     displayTextBlock.DoDisplayString(message, alignment, fadeType, size);
 }
示例#3
0
 public void DoDisplayString(string message, SnapsTextAlignment alignment, SnapsFadeType fadeType, double size)
 {
     fontSize = size;
     DoDisplayString(message, alignment, fadeType);
 }
示例#4
0
 /// <summary>
 /// Displays a string in the Snaps display region
 /// </summary>
 /// <param name="message">string to display</param>
 /// <param name="alignment">horizontal alignment of text</param>
 /// <param name="fadeType">how the text is faded onto the display</param>
 /// <param name="size">size of the text in pixels</param>
 public static void DisplayString(string message, SnapsTextAlignment alignment, SnapsFadeType fadeType, int size)
 {
     manager.DisplayString(message, alignment, fadeType, size);
 }