예제 #1
0
 public HudDebugField(string name, int lineOffset, AlignMode align)
     : base(name)
 {
     this.align = align;
     this.lineOffset = lineOffset;
     back.color = new Color4(0f, 0f, 0f, 0.3f);
     back.height = 14;
     back.width = 128;
 }
예제 #2
0
 /// <summary>You can indicate the align char.</summary>
 /// <param name="align">The position of the alignment.</param>
 /// <param name="alignChar">The character used to align.</param>
 public FieldAlignAttribute(AlignMode align, char alignChar)
 {
     Align = align;
     AlignChar = alignChar;
 }
예제 #3
0
 /// <summary>Uses the ' ' char to align.</summary>
 /// <param name="align">The position of the alignment.</param>
 public FieldAlignAttribute(AlignMode align)
     : this(align, ' ')
 {
 }
예제 #4
0
 // TODO [由UI自己缓存文本位置] 文本位置应该由UI自己负责计算和缓存,而不是每次绘制时计算
 public void WriteText(SpriteFont sf, int x, int y, int width, int height, AlignMode st, string s, Color c)
 {
     Vector2 size = sf.MeasureString(s);
     int tx = x, ty = y;//实际输出的位置
     switch (st)
     {
         case AlignMode.Middle:
             tx = (int)(x + (float)width / 2 - (float)size.X / 2);
             ty = (int)(y + (float)height / 2 - (float)size.Y / 2);
             break;
         case AlignMode.Right:
             tx = (int)(x + (float)width - (float)size.X);
             ty = (int)(y + (float)height / 2 - (float)size.Y / 2);
             break;
         case AlignMode.Left:
             ty = (int)(y + (float)height / 2 - (float)size.Y / 2);
             break;
         default:
             break;
     }
     spriteBatch.DrawString(sf, s, new Vector2(tx, ty), c);
 }
예제 #5
0
 /// <summary>
 /// Fits the specified image to the supplied max width / height.
 /// </summary>
 /// <param name="image">The image.</param>
 /// <param name="maxWidthHeight">max width / height.</param>
 /// <param name="fitMode">The fit mode.</param>
 /// <param name="scaleMode">The scale mode.</param>
 /// <param name="alignMode">The align mode.</param>
 /// <param name="format">The format.</param>
 /// <param name="quality">The quality.</param>
 /// <param name="colors">The colors.</param>
 /// <param name="bgColor">Color of the background.</param>
 /// <returns></returns>
 public static IFilteredImage Fit(this IImageFile image, int maxWidthHeight, 
     FitMode fitMode = FitMode.Pad, ScaleMode scaleMode = ScaleMode.Down,
     AlignMode alignMode = AlignMode.MiddleCenter, ImageFormat format = ImageFormat.Auto,
     int quality = 90, int colors = 256, string bgColor = "")
 {
     return image.Fit(maxWidthHeight, maxWidthHeight, fitMode, scaleMode, alignMode,
         format, quality, colors, bgColor);
 }
예제 #6
0
        /// <summary>
        /// Fits the specified image to the supplied max width and height.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="maxWidth">Width of the max.</param>
        /// <param name="maxHeight">Height of the max.</param>
        /// <param name="fitMode">The fit mode.</param>
        /// <param name="scaleMode">The scale mode.</param>
        /// <param name="alignMode">The align mode.</param>
        /// <param name="format">The format.</param>
        /// <param name="quality">The quality.</param>
        /// <param name="colors">The colors.</param>
        /// <param name="bgColor">Color of the background.</param>
        /// <returns></returns>
        public static IFilteredImage Fit(this IFilteredImage image, int maxWidth, int maxHeight, 
            FitMode fitMode = FitMode.Pad, ScaleMode scaleMode = ScaleMode.Down,
            AlignMode alignMode = AlignMode.MiddleCenter, ImageFormat format = ImageFormat.Auto,
            int quality = 90, int colors = 256, string bgColor = "")
        {
            image.Filters.Add("w", maxWidth);
            image.Filters.Add("h", maxHeight);

            if(fitMode != FitMode.Pad)
                image.Filters.Add("mode", fitMode.ToString().ToLower());

            if(scaleMode != ScaleMode.Down)
                image.Filters.Add("scale", scaleMode.ToString().ToLower());

            if(alignMode != AlignMode.MiddleCenter)
                image.Filters.Add("anchor", alignMode.ToString().ToLower());

            if(format != ImageFormat.Auto)
                image.Filters.Add("format", format.ToString().ToLower());

            if(quality != 90)
                image.Filters.Add("quality", Math.Min(100, Math.Max(0, quality)));

            if (colors != 256)
                image.Filters.Add("colors", Math.Min(256, Math.Max(2, quality)));

            if (!string.IsNullOrEmpty(bgColor))
                image.Filters.Add("bgcolor", bgColor);

            return image;
        }
예제 #7
0
파일: TextureTool.cs 프로젝트: silky/sledge
        private void TextureAligned(object sender, AlignMode align)
        {
            Action<Document, Face> action = (document, face) =>
            {
                if (align == AlignMode.Face) face.AlignTextureToFace();
                else if (align == AlignMode.World) face.AlignTextureToWorld();
                face.CalculateTextureCoordinates(false);
            };

            Document.PerformAction("Align texture", new EditFace(Document.Selection.GetSelectedFaces(), action, false));
        }
예제 #8
0
 /// <summary>
 /// Adds a new field.
 /// </summary>
 /// <param name="fieldName">Field identifier</param>
 /// <param name="lineOffset">Number of lines below the top edge of the screen</param>
 /// <param name="align">Left/Right align</param>
 /// <param name="prefix">Displayed text will be: [prefix][value][suffix]</param>
 /// <param name="suffix">Displayed text will be: [prefix][value][suffix]</param>
 private void NewField(string fieldName, int lineOffset, AlignMode align, string prefix, string suffix)
 {
     if(fields.ContainsKey(fieldName))
     {
         throw new ArgumentException("Name already exists");
     }
     fields.Add(fieldName, new HudDebugField(fieldName, lineOffset, align));
     fields[fieldName].prefix = prefix;
     fields[fieldName].suffix = suffix;
     Add(fields[fieldName]);
 }