コード例 #1
0
ファイル: TElement.cs プロジェクト: rzvdaniel/GuiShark
        public TElement(IElement htmlElement, TElement parent)
        {
            NormalFlowChildren   = new List <TElement>();
            FloatFlowChildren    = new List <TElement>();
            AbsoluteFlowChildren = new List <TElement>();

            DefaultBackgroundColor = new Color(255, 255, 255, 255);
            DefaultBorderColor     = new Color(0, 0, 0, 255);
            DefaultForegroundColor = new Color(0, 0, 0, 255);

            Parent   = parent;
            Children = new List <TElement>();
            Canvas   = GfxFactory.Create <IGfxCanvas>();

            InitHtml(htmlElement);
            InitCss(htmlElement);
            ComputeBoundingBox();

            var elementFactory = new TElementFactory();

            foreach (IElement htmlChild in htmlElement.Children)
            {
                var child = elementFactory.Create(htmlChild, this);

                Children.Add(child);
                ComputeBoundingBox(child);
                AddToFlowList(child);
            }
        }
コード例 #2
0
        public virtual void Create(int width, int height, TColor clearColor, string htmlDocument)
        {
            Canvas    = GfxFactory.Create <IGfxCanvas>();
            GfxServer = GfxFactory.Create <IGfxServer>();
            GfxServer.Initialize(width, height, clearColor);

            Width  = width;
            Height = height;

            var domFactory = new TDomFactory();

            Document = domFactory.Create <IDocument>();
            Document.Parse(htmlDocument);

            // Create the canvas. Need a canvas for the screen. For example,
            // the screen render the mouse cursor. Because it render something,
            // we need a Canvas.
            // As you can see, this is a hack, because, normally, every
            // control create it's own canvas in TControl::Create(). But
            // we skip the base class initialization, so need to create the
            // canvas by hand.

            //Canvas = new TCanvas(this);

            //SetBounds(Rect.left, Rect.top, Rect.right, Rect.bottom);#
        }
コード例 #3
0
        public override void Create(int width, int height, Color clearColor, string htmlDocument)
        {
            Canvas    = GfxFactory.Create <IGfxCanvas>();
            GfxServer = GfxFactory.Create <IGfxServer>();
            GfxServer.Initialize(width, height, clearColor);

            base.Create(width, height, clearColor, htmlDocument);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            string path = args.Length > 0 ? args[0] : string.Empty;

            var htmlReader = new HtmlReader();
            var html       = htmlReader.Read(path);

            var game = GfxFactory.Create <IGfxGame>();

            game.Create(1200, 800, GameWindowFlags.Default, html);
            game.Run(30.0);
        }
コード例 #5
0
        public TElement()
        {
            normalFlowChildren   = new List <IElement>();
            floatFlowChildren    = new List <IElement>();
            absoluteFlowChildren = new List <IElement>();

            DefaultBackgroundColor = new Color(255, 255, 255, 255);
            DefaultBorderColor     = new Color(0, 0, 0, 255);
            DefaultForegroundColor = new Color(0, 0, 0, 255);

            Children = new List <IElement>();
            Canvas   = GfxFactory.Create <IGfxCanvas>();
        }
コード例 #6
0
        public void Create(int width, int height, GameWindowFlags windowFlags, string htmlDocument)
        {
            Window = new GameWindow(width, height, GraphicsMode.Default, "Gui Sharp Samples", windowFlags)
            {
                VSync = VSyncMode.On
            };

            Screen = GfxFactory.Create <IScreen>();
            Screen.Create(width, height, Color.White, htmlDocument);

            Window.Load        += OnLoad;
            Window.Resize      += OnResize;
            Window.UpdateFrame += OnUpdateFrame;
            Window.RenderFrame += OnRenderFrame;
            Window.Disposed    += OnDispose;
        }