Exemplo n.º 1
0
        /// <summary>
        /// Displays a string representation of the <see cref="LogicalFont"/>.
        /// </summary>
        public static string ToFontString(this LogicalFont data)
        {
            var convert = new FontConverter();

            using (var font = ToFont(data))
                return(convert.ConvertToInvariantString(font));
        }
 // constructor for runtime instance
 public MyfirstElement(MyfirstElement other, GraphicItemVisual otherVisual)
     : base(other, otherVisual)
 {
     textBrush = other.textBrush;
     text      = other.text;
     font      = other.font;
     speed     = other.speed;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a <see cref="Font"/> with the current properties.
        /// </summary>
        public static Font ToFont(this LogicalFont data)
        {
            // Validate
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            // Create and return system font
            return(new Font(data.Family, data.Size, (FontStyle)(int)data.Style));
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void txtMarker_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            LogicalFont logfont     = new LogicalFont(txtMarker.Font);
            bool        fSymbolFont = (logfont.lfCharSet == (byte)TextMetricsCharacterSet.Symbol);

            if (UnicodeCharProps.get_IsSeparator(e.KeyChar) || (!fSymbolFont &&
                                                                (UnicodeCharProps.get_IsLetter(e.KeyChar) ||
                                                                 UnicodeCharProps.get_IsNumber(e.KeyChar))))
            {
                e.Handled = true;
                MiscUtils.ErrorBeep();
            }
        }
Exemplo n.º 5
0
        internal FontFamily(FontCallbackInfo fontInfo, FullTextMetric fontMetric, FontType fontType)
        {
            LogicalFont = fontInfo.LogicalFont;
            TextMetric  = fontMetric;

            Name     = fontInfo.LogicalFont.Name;
            FullName = fontInfo.FullName;
            Style    = fontInfo.Style;
            Script   = fontInfo.Script;
            Fixed    = fontInfo.LogicalFont.PitchAndFamily.HasFlag(PitchAndFamily.FixedPitch);
            Modern   = fontInfo.LogicalFont.PitchAndFamily.HasFlag(PitchAndFamily.ModernFamily);

            FontType = fontType;
        }
Exemplo n.º 6
0
        public void DrawingTestLogicalFontConversion()
        {
            // Create a test font
            var font1 = new LogicalFont("Verdana", 10, (int)FontStyle.Regular);

            // Convert to string
            var font1String = font1.ToFontString();

            // Convert from string
            var font2 = FontExtensions.ToLogicalFont(font1String);

            // Validate result
            Assert.AreEqual(font1, font2);
        }