protected TextSprite(string name)
     : base()
 {
     _name = name;
     _hAlign = TextHorizontalAlignment.Left;
     _vAlign = TextVerticalAlignment.Center;
 }
        public TextSprite(TextSprite clone)
        {
            _name = clone._name + "_clone";
            _transform = clone._transform;
            _tint = clone._tint;

            _hAlign = clone.HorizontalAlignment;
            _vAlign = clone.VerticalAlignment;

            _font = clone._font;
            _text = clone._text;
            _size = clone._size;

            _flipMode = clone._flipMode;
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Paragraph" /> class.
 /// </summary>
 /// <param name="LineSpacing">Line spacing mode.</param>
 /// <param name="WrapMode">Word wrap mode.</param>
 /// <param name="HorizontalAlignment">Horizontal alignment for the text inside paragraph&#39;s rectangle.</param>
 /// <param name="LeftMargin">Left margin.</param>
 /// <param name="RightMargin">Right margin.</param>
 /// <param name="TopMargin">Top margin.</param>
 /// <param name="BottomMargin">Bottom margin.</param>
 /// <param name="Rectangle">Rectangle of the paragraph.</param>
 /// <param name="Rotation">Rotation angle in degrees.</param>
 /// <param name="SubsequentLinesIndent">Subsequent lines indent value.</param>
 /// <param name="VerticalAlignment">Vertical alignment for the text inside paragraph&#39;s rectangle</param>
 /// <param name="Lines">An array of text lines. (required)</param>
 public Paragraph(LineSpacing LineSpacing = default(LineSpacing), WrapMode WrapMode = default(WrapMode), TextHorizontalAlignment HorizontalAlignment = default(TextHorizontalAlignment), double?LeftMargin = default(double?), double?RightMargin = default(double?), double?TopMargin = default(double?), double?BottomMargin = default(double?), Rectangle Rectangle = default(Rectangle), double?Rotation = default(double?), double?SubsequentLinesIndent = default(double?), VerticalAlignment VerticalAlignment = default(VerticalAlignment), List <TextLine> Lines = default(List <TextLine>))
 {
     // to ensure "Lines" is required (not null)
     if (Lines == null)
     {
         throw new InvalidDataException("Lines is a required property for Paragraph and cannot be null");
     }
     else
     {
         this.Lines = Lines;
     }
     this.LineSpacing           = LineSpacing;
     this.WrapMode              = WrapMode;
     this.HorizontalAlignment   = HorizontalAlignment;
     this.LeftMargin            = LeftMargin;
     this.RightMargin           = RightMargin;
     this.TopMargin             = TopMargin;
     this.BottomMargin          = BottomMargin;
     this.Rectangle             = Rectangle;
     this.Rotation              = Rotation;
     this.SubsequentLinesIndent = SubsequentLinesIndent;
     this.VerticalAlignment     = VerticalAlignment;
 }
Esempio n. 4
0
File: UFC.cs Progetto: appsou/Helios
        //private void AddTextDisplay(string name, double x, double y, Size size, string testDisp)
        //{
        //    AddTextDisplay(name, x, y, size, 32, testDisp, TextHorizontalAlignment.Left);
        //}

        private void AddTextDisplay(string name, double x, double y, Size size,
                                    string interfaceElementName, double baseFontsize, string testDisp, TextHorizontalAlignment hTextAlign, string ufcDictionary)
        {
            TextDisplay display = AddTextDisplay(
                name: name,
                posn: new Point(x, y),
                size: size,
                font: "Helios Virtual Cockpit F/A-18C_Hornet-Up_Front_Controller",
                baseFontsize: baseFontsize,
                horizontalAlignment: hTextAlign,
                verticalAligment: TextVerticalAlignment.Center,
                testTextDisplay: testDisp,
                textColor: Color.FromArgb(0xff, 0x7e, 0xde, 0x72),
                backgroundColor: Color.FromArgb(0xff, 0x26, 0x3f, 0x36),
                useBackground: false,
                interfaceDeviceName: _interfaceDeviceName,
                interfaceElementName: interfaceElementName,
                textDisplayDictionary: ufcDictionary
                );
        }
Esempio n. 5
0
        public void ReadXml(XmlReader reader)
        {
            TypeConverter ffc = TypeDescriptor.GetConverter(typeof(FontFamily));
            TypeConverter fsc = TypeDescriptor.GetConverter(typeof(FontStyle));
            TypeConverter fwc = TypeDescriptor.GetConverter(typeof(FontWeight));
            TypeConverter rc = TypeDescriptor.GetConverter(typeof(Rect));

            _family = (FontFamily)ffc.ConvertFromString(null, System.Globalization.CultureInfo.InvariantCulture, reader.ReadElementString("FontFamily"));
            _style = (FontStyle)fsc.ConvertFromString(null, System.Globalization.CultureInfo.InvariantCulture, reader.ReadElementString("FontStyle"));
            _weight = (FontWeight)fwc.ConvertFromString(null, System.Globalization.CultureInfo.InvariantCulture, reader.ReadElementString("FontWeight"));
            _size = double.Parse(reader.ReadElementString("FontSize"), CultureInfo.InvariantCulture);

            if (reader.Name.Equals("HorizontalAlignment"))
            {
                _horizontalAlignment = (TextHorizontalAlignment)Enum.Parse(typeof(TextHorizontalAlignment), reader.ReadElementString("HorizontalAlignment"));
                _verticalAlignment = (TextVerticalAlignment)Enum.Parse(typeof(TextVerticalAlignment), reader.ReadElementString("VerticalAlignment"));
            }

            if (reader.Name.Equals("Padding"))
            {
                reader.ReadStartElement("Padding");
                PaddingLeft = double.Parse(reader.ReadElementString("Left"), CultureInfo.InvariantCulture);
                PaddingTop = double.Parse(reader.ReadElementString("Top"), CultureInfo.InvariantCulture);
                PaddingRight = double.Parse(reader.ReadElementString("Right"), CultureInfo.InvariantCulture);
                PaddingBottom = double.Parse(reader.ReadElementString("Bottom"), CultureInfo.InvariantCulture);
                reader.ReadEndElement();
            }
            else
            {
                PaddingLeft = 0d;
                PaddingRight = 0d;
                PaddingTop = 0d;
                PaddingBottom = 0d;
            }
            
            if (reader.Name.Equals("Underline"))
            {
                _decorations |= Helios.TextDecorations.Underline;
                reader.Skip();
            }
            if (reader.Name.Equals("Strikethrough"))
            {
                _decorations |= Helios.TextDecorations.Strikethrough;
                reader.Skip();
            }
            if (reader.Name.Equals("Baseline"))
            {
                _decorations |= Helios.TextDecorations.Baseline;
                reader.Skip();
            }
            if (reader.Name.Equals("OverLine"))
            {
                _decorations |= Helios.TextDecorations.OverLine;
                reader.Skip();
            }
        }
Esempio n. 6
0
        protected TextDisplay AddTextDisplay(
            string name,
            Point posn,
            Size size,
            string font,
            TextHorizontalAlignment horizontalAlignment,
            TextVerticalAlignment verticalAligment,
            double baseFontsize,
            string testTextDisplay,
            Color textColor,
            Color backgroundColor,
            bool useBackground,
            string interfaceDeviceName,
            string interfaceElementName,
            string textDisplayDictionary
            )
        {
            string      componentName = GetComponentName(name);
            TextDisplay display       = new TextDisplay
            {
                Top    = posn.Y,
                Left   = posn.X,
                Width  = size.Width,
                Height = size.Height,
                Name   = componentName
            };
            TextFormat textFormat = new TextFormat
            {
                FontFamily          = new FontFamily(font),
                HorizontalAlignment = horizontalAlignment,
                VerticalAlignment   = verticalAligment,
                FontSize            = baseFontsize,
                PaddingRight        = 0,
                PaddingLeft         = 0,
                PaddingTop          = 0,
                PaddingBottom       = 0
            };

            display.TextFormat      = textFormat;
            display.OnTextColor     = textColor;       // Color.FromArgb(0xff, 0x40, 0xb3, 0x29);
            display.BackgroundColor = backgroundColor; // Color.FromArgb(0xff, 0x00, 0x00, 0x00);
            display.UseBackground   = useBackground;
            if (textDisplayDictionary.Equals(""))
            {
                display.ParserDictionary = "";
            }
            else
            {
                display.ParserDictionary   = textDisplayDictionary;
                display.UseParseDictionary = true;
            }
            display.TextTestValue = testTextDisplay;
            Children.Add(display);
            AddAction(display.Actions["set.TextDisplay"], componentName);

            AddDefaultInputBinding(
                childName: componentName,
                interfaceTriggerName: interfaceDeviceName + "." + interfaceElementName + ".changed",
                deviceActionName: "set.TextDisplay");

            return(display);
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Text" /> class.
        /// </summary>
        /// <param name="text">Text that will be drawn.</param>
        /// <param name="font">Font that will be used to draw the text.</param>
        /// <param name="foreground">Brush that will be used to paint the text.</param>
        /// <param name="background">Brush that will be used to paint the text's background.</param>
        /// <param name="left">Left position of the text.</param>
        /// <param name="top">Top position of the text.</param>
        /// <param name="width">Virtual text box width. If value is less than 0, it will be automatically computed.</param>
        /// <param name="height">Virtual text box height. If value is less than 0, it will be automatically computed.</param>
        /// <param name="horizontalAlignment">Text horizontal alignment.</param>
        /// <param name="verticalAlignment">Text vertical alignment.</param>
        /// <param name="wrapping">Text wrapping.</param>
        /// <param name="rotation">Text clockwise rotation in radians.</param>
        public Text(string text, IFont font, IBrush foreground, IBrush background, double left, double top, double width, double height, TextHorizontalAlignment horizontalAlignment, TextVerticalAlignment verticalAlignment, TextWrapping wrapping, double rotation)
        {
            Label               = text;
            Font                = font;
            Background          = background;
            Foreground          = foreground;
            Width               = width;
            Height              = height;
            HorizontalAlignment = horizontalAlignment;
            VerticalAlignment   = verticalAlignment;
            Wrapping            = wrapping;
            Rotation            = rotation;

            System.Windows.FontStyle fontStyle;

            switch (font.Style)
            {
            default:
            case FontStyle.Normal:
                fontStyle = System.Windows.FontStyles.Normal;
                break;

            case FontStyle.Italic:
                fontStyle = System.Windows.FontStyles.Italic;
                break;

            case FontStyle.Oblique:
                fontStyle = System.Windows.FontStyles.Oblique;
                break;
            }
            UIText = new System.Windows.Controls.TextBlock()
            {
                Text = text,
                HorizontalAlignment = (System.Windows.HorizontalAlignment)horizontalAlignment,
                VerticalAlignment   = (System.Windows.VerticalAlignment)((int)verticalAlignment - 1),
                Foreground          = (foreground as Brush)?.UIBrush,
                Background          = (background as Brush)?.UIBrush,
                FontFamily          = new System.Windows.Media.FontFamily(font.Family),
                FontSize            = font.Size,
                FontStyle           = fontStyle,
                FontWeight          = System.Windows.FontWeight.FromOpenTypeWeight((int)font.Weight),
                TextWrapping        = (System.Windows.TextWrapping)((int)wrapping + 1),
            };
            if (width >= 0)
            {
                UIText.Width = width;
            }
            if (height >= 0)
            {
                UIText.Height = height;
            }
            if (rotation != 0)
            {
                UIText.RenderTransform       = new System.Windows.Media.RotateTransform(rotation * 180 / Math.PI);
                UIText.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5);
            }
            System.Windows.Controls.Canvas.SetLeft(UIText, left);
            System.Windows.Controls.Canvas.SetTop(UIText, top);
        }
Esempio n. 8
0
File: ODU.cs Progetto: Phar71/Helios
        private void AddTextDisplay(string name, double x, double y, Size size, double baseFontsize, string testDisp, TextHorizontalAlignment hTextAlign)
        {
            Helios.Controls.TextDisplay display = new Helios.Controls.TextDisplay
            {
                Top    = y,
                Left   = x,
                Width  = size.Width,
                Height = size.Height,
                Name   = name
            };
            // display.FontSize = 20;
            TextFormat textFormat = new TextFormat
            {
                FontFamily          = new FontFamily("Hornet UFC"),
                HorizontalAlignment = hTextAlign,
                VerticalAlignment   = TextVerticalAlignment.Center,
                FontSize            = baseFontsize
            };

            //textFormat.FontFamily.Baseline = 0;
            textFormat.PaddingRight  = 0;
            textFormat.PaddingLeft   = 0;
            textFormat.PaddingTop    = 0;
            textFormat.PaddingBottom = 0;
            display.TextFormat       = textFormat;
            display.OnTextColor      = Color.FromArgb(0xff, 0x7e, 0xde, 0x72);
            display.BackgroundColor  = Color.FromArgb(0xff, 0x26, 0x3f, 0x36);
            display.UseBackground    = true;
            display.TextTestValue    = testDisp;
            Children.Add(display);
            AddAction(display.Actions["set.TextDisplay"], "ODU Display " + name);
        }
Esempio n. 9
0
File: ODU.cs Progetto: Phar71/Helios
 private void AddTextDisplay(string name, double x, double y, Size size, TextHorizontalAlignment hTextAlign)
 {
     AddTextDisplay(name, x, y, size, 32, "~", hTextAlign);
 }
Esempio n. 10
0
 private void AddTextDisplay(string name, double x, double y, Size size,
                             string interfaceElementName, double baseFontsize, string testDisp, TextHorizontalAlignment hTextAlign, string ufcDictionary)
 {
     TextDisplay display = AddTextDisplay(
         name: name,
         posn: new Point(x, y),
         size: size,
         font: _font,
         baseFontsize: baseFontsize,
         horizontalAlignment: hTextAlign,
         verticalAligment: TextVerticalAlignment.Center,
         testTextDisplay: testDisp,
         textColor: Color.FromArgb(0xff, 0x30, 0x30, 0x30),
         backgroundColor: Color.FromArgb(0x00, 0xbb, 0xbb, 0xbb),
         useBackground: true,
         interfaceDeviceName: _interfaceDeviceName,
         interfaceElementName: interfaceElementName,
         textDisplayDictionary: ufcDictionary
         );
 }
Esempio n. 11
0
 private void AddTextDisplay(string name, double x, double y, Size size,
                             string interfaceElementName, double baseFontsize, string testDisp, TextHorizontalAlignment hTextAlign)
 {
     AddTextDisplay(name, x, y, size,
                    interfaceElementName, baseFontsize, testDisp, hTextAlign, "");
 }