public AbsoluteScreen(Window Parent)
        {
            InitializeComponent();

            _parent = Parent;

            _scrollback = new ScrollbackArea(this);

            _cursorCanvas = new System.Windows.Controls.Canvas();
            _cursorCanvas.Background = ZColorCheck.ZColorToBrush(1, ColorType.Foreground);
            _cursorCanvas.Visibility = System.Windows.Visibility.Visible;
            cnvsTop.Children.Add(_cursorCanvas);

            _sound = new FrotzSound();
            LayoutRoot.Children.Add(_sound);


            _substituion = new NumberSubstitution();

            setFontInfo();

            _currentInfo = new CharDisplayInfo(1, 0, 1, 1);
            bColor = 1;
            this.Background = ZColorCheck.ZColorToBrush(bColor, ColorType.Background);

            this.MouseDown += new MouseButtonEventHandler(AbsoluteScreen_MouseDown);
            this.MouseDoubleClick += new MouseButtonEventHandler(AbsoluteScreen_MouseDoubleClick);
        }
        public TextControlScreen(Window Parent)
        {
            InitializeComponent();

            _parent = Parent;
            this.Margin = new Thickness(0);

            _parent = Parent;

            _cursorCanvas = new System.Windows.Controls.Canvas();
            _cursorCanvas.Background = ZColorCheck.ZColorToBrush(1, ColorType.Foreground);
            _cursorCanvas.Visibility = System.Windows.Visibility.Hidden;
            cnvsTop.Children.Add(_cursorCanvas);

            _sound = new FrotzSound();
            LayoutRoot.Children.Add(_sound);

            fColor = 1;
            bColor = 1;

            this.Background = ZColorCheck.ZColorToBrush(1, ColorType.Background);

            _substituion = new NumberSubstitution();

            setFontInfo();
        }
示例#3
0
        internal double DetermineWidth(String Text)
        {
            NumberSubstitution ns = new NumberSubstitution();
            FormattedText ft = new FormattedText(Text,
            CultureInfo.CurrentCulture,
            FlowDirection.LeftToRight,
            new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, this.FontStretch),
            this.FontSize,
            this.Foreground, ns, TextFormattingMode.Display);

            return ft.Width;
        }
示例#4
0
        /// <summary>
        /// Checks whether this object is equal to another NumberSubstitution object.
        /// </summary>
        /// <param name="obj">Object to compare with.</param>
        /// <returns>Returns true if the specified object is a NumberSubstitution object with the
        /// same properties as this object, and false otherwise.</returns>
        public override bool Equals(object obj)
        {
            NumberSubstitution sub = obj as NumberSubstitution;

            // Suppress PRESharp warning that sub can be null; apparently PRESharp
            // doesn't understand short circuit evaluation of operator &&.
            #pragma warning disable 6506
            return(sub != null &&
                   _source == sub._source &&
                   _substitution == sub._substitution &&
                   (_cultureOverride == null ? (sub._cultureOverride == null) : (_cultureOverride.Equals(sub._cultureOverride))));

            #pragma warning restore 6506
        }
 /// <summary>
 /// Constructing TextRunProperties
 /// </summary>
 /// <param name="typeface">typeface</param> 
 /// <param name="size">text size</param>
 /// <param name="hintingSize">text size for Truetype hinting program</param> 
 /// <param name="culture">text culture info</param> 
 /// <param name="textDecorations">TextDecorations </param>
 /// <param name="foregroundBrush">text foreground brush</param> 
 /// <param name="backgroundBrush">highlight background brush</param>
 /// <param name="baselineAlignment">text vertical alignment to its container</param>
 /// <param name="substitution">number substitution behavior to apply to the text; can be null,
 /// in which case the default number substitution method for the text culture is used</param> 
 public GenericTextRunProperties(
     Typeface                 typeface, 
     double                   size, 
     double                   hintingSize,
     TextDecorationCollection textDecorations, 
     Brush                    foregroundBrush,
     Brush                    backgroundBrush,
     BaselineAlignment        baselineAlignment,
     CultureInfo              culture, 
     NumberSubstitution       substitution
 ) 
 { 
      _typeface = typeface;
     _emSize = size; 
     _emHintingSize = hintingSize;
     _textDecorations = textDecorations;
     _foregroundBrush = foregroundBrush;
     _backgroundBrush = backgroundBrush; 
     _baselineAlignment = baselineAlignment;
     _culture = culture; 
     _numberSubstitution = substitution; 
 }
		/// <summary>
		/// Creates a new VisualLineElementTextRunProperties instance that copies its values
		/// from the specified <paramref name="textRunProperties"/>.
		/// For the <see cref="TextDecorations"/> and <see cref="TextEffects"/> collections, deep copies
		/// are created if those collections are not frozen.
		/// </summary>
		public VisualLineElementTextRunProperties(TextRunProperties textRunProperties)
		{
			if (textRunProperties == null)
				throw new ArgumentNullException("textRunProperties");
			backgroundBrush = textRunProperties.BackgroundBrush;
			baselineAlignment = textRunProperties.BaselineAlignment;
			cultureInfo = textRunProperties.CultureInfo;
			fontHintingEmSize = textRunProperties.FontHintingEmSize;
			fontRenderingEmSize = textRunProperties.FontRenderingEmSize;
			foregroundBrush = textRunProperties.ForegroundBrush;
			typeface = textRunProperties.Typeface;
			textDecorations = textRunProperties.TextDecorations;
			if (textDecorations != null && !textDecorations.IsFrozen) {
				textDecorations = textDecorations.Clone();
			}
			textEffects = textRunProperties.TextEffects;
			if (textEffects != null && !textEffects.IsFrozen) {
				textEffects = textEffects.Clone();
			}
			typographyProperties = textRunProperties.TypographyProperties;
			numberSubstitution = textRunProperties.NumberSubstitution;
		}
        // ----------------------------------------------------------------- 
        // Retrieve Number substitution properties from given element
        // ------------------------------------------------------------------ 
        internal static NumberSubstitution GetNumberSubstitution(DependencyObject element)
        {
            NumberSubstitution numberSubstitution = new NumberSubstitution();
 
            numberSubstitution.CultureSource = (NumberCultureSource)element.GetValue(NumberSubstitution.CultureSourceProperty);
            numberSubstitution.CultureOverride = (CultureInfo)element.GetValue(NumberSubstitution.CultureOverrideProperty); 
            numberSubstitution.Substitution = (NumberSubstitutionMethod)element.GetValue(NumberSubstitution.SubstitutionProperty); 

            return numberSubstitution; 
        }
示例#8
0
        /// <summary>
        /// Sets or changes the number substitution behavior for a range of text.
        /// </summary>
        /// <param name="numberSubstitution">Number substitution behavior to apply to the text; can be null,
        /// in which case the default number substitution method for the text culture is used.</param>
        /// <param name="startIndex">The start index of initial character to apply the change to.</param>
        /// <param name="count">The number of characters the change should be applied to.</param>
        public void SetNumberSubstitution(
            NumberSubstitution numberSubstitution,
            int startIndex,
            int count
            )
        {
            int limit = ValidateRange(startIndex, count);
            for (int i = startIndex; i < limit; )
            {
                SpanRider formatRider = new SpanRider(_formatRuns, _latestPosition, i);
                i = Math.Min(limit, i + formatRider.Length);

#pragma warning disable 6506
                // Presharp warns that runProps is not validated, but it can never be null 
                // because the rider is already checked to be in range
                GenericTextRunProperties runProps = formatRider.CurrentElement as GenericTextRunProperties;

                Invariant.Assert(runProps != null);

                if (numberSubstitution != null)
                {
                    if (numberSubstitution.Equals(runProps.NumberSubstitution))
                        continue;
                }
                else
                {
                    if (runProps.NumberSubstitution == null)
                        continue;
                }

                GenericTextRunProperties newProps = new GenericTextRunProperties(
                    runProps.Typeface,
                    runProps.FontRenderingEmSize,
                    runProps.FontHintingEmSize,
                    runProps.TextDecorations,
                    runProps.ForegroundBrush,
                    runProps.BackgroundBrush,
                    runProps.BaselineAlignment,
                    runProps.CultureInfo,
                    numberSubstitution
                    );
#pragma warning restore 6506
                _latestPosition = _formatRuns.SetValue(formatRider.CurrentPosition, i - formatRider.CurrentPosition, newProps, formatRider.SpanPosition);
                InvalidateMetrics();
            }
        }
示例#9
0
 /// <summary>
 /// Construct a FormattedText object.
 /// </summary>
 /// <param name="textToFormat">String of text to be displayed.</param>
 /// <param name="culture">Culture of text.</param>
 /// <param name="flowDirection">Flow direction of text.</param>
 /// <param name="typeface">Type face used to display text.</param>
 /// <param name="emSize">Font em size in visual units (1/96 of an inch).</param>
 /// <param name="foreground">Foreground brush used to render text.</param>
 /// <param name="numberSubstitution">Number substitution behavior to apply to the text; can be null,
 /// in which case the default number number method for the text culture is used.</param>
 public FormattedText(
     string textToFormat,
     CultureInfo culture,
     FlowDirection flowDirection,
     Typeface typeface,
     double emSize,
     Brush foreground,
     NumberSubstitution numberSubstitution) : this(
         textToFormat,
         culture,
         flowDirection,
         typeface,
         emSize,
         foreground,
         numberSubstitution,
         TextFormattingMode.Ideal
     )
 {
 }
示例#10
0
        /// <summary>
        /// Construct a FormattedText object.
        /// </summary>
        /// <param name="textToFormat">String of text to be displayed.</param>
        /// <param name="culture">Culture of text.</param>
        /// <param name="flowDirection">Flow direction of text.</param>
        /// <param name="typeface">Type face used to display text.</param>
        /// <param name="emSize">Font em size in visual units (1/96 of an inch).</param>
        /// <param name="foreground">Foreground brush used to render text.</param>
        /// <param name="numberSubstitution">Number substitution behavior to apply to the text; can be null,
        /// in which case the default number number method for the text culture is used.</param>
        public FormattedText(
            string textToFormat,
            CultureInfo culture,
            FlowDirection flowDirection,
            Typeface typeface,
            double emSize,
            Brush foreground,
            NumberSubstitution numberSubstitution,
            TextFormattingMode textFormattingMode)
        {
            if (textToFormat == null)
                throw new ArgumentNullException("textToFormat");

            if (typeface == null)
                throw new ArgumentNullException("typeface");

            ValidateCulture(culture);
            ValidateFlowDirection(flowDirection, "flowDirection");
            ValidateFontSize(emSize);

            _textFormattingMode = textFormattingMode;
            _text = textToFormat;
            GenericTextRunProperties runProps = new GenericTextRunProperties(
                                     typeface,
                                     emSize,
                                     12.0f, // default hinting size
                                     null,  // decorations
                                     foreground,
                                     null,  // highlight background
                                     BaselineAlignment.Baseline,
                                     culture,
                                     numberSubstitution
                                     );
            _latestPosition = _formatRuns.SetValue(0, _text.Length, runProps, _latestPosition);

            _defaultParaProps = new GenericTextParagraphProperties(
                flowDirection,
                TextAlignment.Left,
                false,
                false,
                runProps,
                TextWrapping.WrapWithOverflow,
                0,  // line height not specified
                0   // indentation not specified
                );

            InvalidateMetrics();
        }
示例#11
0
 /// <summary>
 /// Sets or changes the number substitution behavior for the text.
 /// </summary>
 /// <param name="numberSubstitution">Number substitution behavior to apply to the text; can be null,
 /// in which case the default number substitution method for the text culture is used.</param>
 public void SetNumberSubstitution(
     NumberSubstitution numberSubstitution
     )
 {
     SetNumberSubstitution(numberSubstitution, 0, _text.Length);
 }
 public void SetNumberSubstitution(NumberSubstitution numberSubstitution)
 {
 }
 public FormattedText(string textToFormat, System.Globalization.CultureInfo culture, System.Windows.FlowDirection flowDirection, Typeface typeface, double emSize, Brush foreground, NumberSubstitution numberSubstitution, TextFormattingMode textFormattingMode)
 {
 }
 public void SetNumberSubstitution(NumberSubstitution numberSubstitution, int startIndex, int count)
 {
 }
		/// <summary>
		/// Sets the <see cref="NumberSubstitution"/>.
		/// </summary>
		public void SetNumberSubstitution(NumberSubstitution value)
		{
			numberSubstitution = value;
		}
示例#16
0
		static bool Equals(NumberSubstitution a, NumberSubstitution b) {
			if (a == b)
				return true;
			if (a == null || b == null)
				return false;
			return a.Equals(b);
		}
 public void SetNumberSubstitution(NumberSubstitution numberSubstitution, int startIndex, int count)
 {
 }
 public FormattedText(string textToFormat, System.Globalization.CultureInfo culture, System.Windows.FlowDirection flowDirection, Typeface typeface, double emSize, Brush foreground, NumberSubstitution numberSubstitution, TextFormattingMode textFormattingMode)
 {
 }
示例#19
0
        /// <summary>
        /// Determines whether or not the text in <paramref name="textBlock"/> is currently being trimmed due to width or height constraints.
        /// </summary>
        /// <param name="textBlock">The <see cref="TextBlock"/> to evaluate.</param>
        /// <returns><c>true</c> if the text is currently being trimmed; otherwise <c>false</c></returns>
        private static bool EvaluateIsTextTrimmed([NotNull] TextBlock textBlock)
        {
            Contract.Requires(textBlock != null);

            var fontFamily = textBlock.FontFamily;
            var text = textBlock.Text;

            if ((fontFamily == null) || (text == null))
                return false;

            var typeface = new Typeface(fontFamily, textBlock.FontStyle, textBlock.FontWeight, textBlock.FontStretch);

            var numberSubstitution = new NumberSubstitution(NumberSubstitution.GetCultureSource(textBlock), NumberSubstitution.GetCultureOverride(textBlock), NumberSubstitution.GetSubstitution(textBlock));
            var formattedText = new FormattedText(text, CultureInfo.CurrentCulture, textBlock.FlowDirection, typeface, textBlock.FontSize, textBlock.Foreground, numberSubstitution, TextOptions.GetTextFormattingMode(textBlock));

            var padding = textBlock.Padding;
            var actualWidth = textBlock.ActualWidth - padding.Left - padding.Right;
            var actualHeight = textBlock.ActualHeight - padding.Top - padding.Bottom;

            if (textBlock.TextWrapping != TextWrapping.NoWrap)
                formattedText.MaxTextWidth = actualWidth;

            var isTextTrimmed = ((Math.Floor(formattedText.Height) - actualHeight) > 0.0001) || (Math.Floor(formattedText.Width) - actualWidth > 0.0001);

            return isTextTrimmed;
        }
 public void SetNumberSubstitution(NumberSubstitution numberSubstitution)
 {
 }