Inheritance: ITextSurfaceRendered
コード例 #1
0
        /// <summary>
        /// Loads a <see cref="TextSurfaceView"/> from a file and existing <see cref="ITextSurfaceRendered"/>.
        /// </summary>
        /// <param name="file">The source file.</param>
        /// <param name="surfaceHydrate">The surface this view was originally from.</param>
        /// <returns>A surface view.</returns>
        public static TextSurfaceView Load(string file, ITextSurfaceRendered surfaceHydrate)
        {
            TextSurfaceView surface = Serializer.Load <TextSurfaceView>(file);

            surface.Hydrate(surfaceHydrate);
            return(surface);
        }
コード例 #2
0
 /// <summary>
 /// Creates a serialized object from an existing <see cref="TextSurfaceView"/>.
 /// </summary>
 /// <param name="surface">The surface to serialize.</param>
 public Serialized(TextSurfaceView surfaceView)
 {
     Area              = surfaceView.originalArea;
     FontName          = surfaceView.font.Name;
     FontMultiple      = surfaceView.font.SizeMultiple;
     DefaultBackground = surfaceView.DefaultBackground;
     DefaultForeground = surfaceView.DefaultForeground;
     Tint              = surfaceView.Tint;
 }
コード例 #3
0
            /// <summary>
            /// Loads a <see cref="TextSurfaceView"/> from a file and existing <see cref="ITextSurfaceRendered"/>.
            /// </summary>
            /// <param name="file">The source file.</param>
            /// <param name="surfaceHydrate">The surface this view was originally from.</param>
            /// <returns>A surface view.</returns>
            public static TextSurfaceView Load(string file, ITextSurfaceRendered surfaceHydrate)
            {
                Serialized data = Serializer.Load <Serialized>(file);
                Font       font;

                // Try to find font
                if (Engine.Fonts.ContainsKey(data.FontName))
                {
                    font = Engine.Fonts[data.FontName].GetFont(data.FontMultiple);
                }
                else
                {
                    font = Engine.DefaultFont;
                }

                TextSurfaceView newSurface = new TextSurfaceView(surfaceHydrate, data.Area);

                newSurface.Font = font;
                newSurface.DefaultBackground = data.DefaultBackground;
                newSurface.DefaultForeground = data.DefaultForeground;
                newSurface.Tint = data.Tint;

                return(newSurface);
            }