Canvas control. It should be the root parent for all other controls.
Inheritance: Control
示例#1
0
        public GwenInput(InputManager inputManager)
        {
            this.inputManager = inputManager;

            canvas = null;
            mouseX = 0;
            mouseY = 0;
            m_AltGr = false;

            mouse = inputManager.Mouse;
            if (mouse != null)
            {
                mouse.MouseMove += ProcessMouseMove;
                mouse.MouseDrag += ProcessMouseDrag;
                mouse.MouseButtonPress += ProcessMouseButtonPressed;
                mouse.MouseButtonRelease += ProcessMouseButtonReleased;
                mouse.MouseWheelMove += ProcessMouseWheel;
            }

            keyboard = inputManager.Keyboard;
            if (keyboard != null)
            {
                keyboard.KeyPress += ProcessKeyDown;
                keyboard.KeyRelease += ProcessKeyUp;
                keyboard.KeyText += ProcessText;
            }
        }
示例#2
0
文件: GuiWindow.cs 项目: tritao/flood
        public void Init(Renderer renderer, string textureName)
        {
            Renderer = renderer;
            Skin = new TexturedSkin(renderer, textureName);
            Canvas = new Canvas(Skin);

            Init();
        }
示例#3
0
文件: GUITests.cs 项目: chartly/flood
        public void TestButton()
        {
            using (var canvas = new Canvas(GUI.Skin))
            {
                var control = new Button(canvas);
                control.Text = "Button";

                GUI.AssertUnchanged(canvas, "button1");
            }
        }
示例#4
0
        void InitializeGui()
        {
            GuiRenderer = new GwenRenderer();

            var textureName = "DefaultSkin.png";
            var defaultFont = new Font("Vera.ttf", 16);

            var resMan = Engine.GetEngine().ResourceManager;
            var options = new ResourceLoadOptions {Name = textureName, AsynchronousLoad = false};
            var imageHandle = resMan.LoadResource<Image>(options);
            if (imageHandle.Id == 0)
                throw new Exception("Could not load GUI texture: " + textureName);

            Skin = new TexturedSkin(GuiRenderer, imageHandle, defaultFont);
            Canvas = new Canvas(Skin);

            Input = new GwenInput(Engine.GetEngine().InputManager);
            Input.Initialize(Canvas);
        }
示例#5
0
 public void Initialize(Canvas c)
 {
     canvas = c;
 }
示例#6
0
        public static void RenderOverlay(Canvas canvas, Skins.Skin skin)
        {
            if (CurrentPackage == null)
                return;
            if (CurrentPackage.DrawControl == null)
                return;

            var old = skin.Renderer.RenderOffset;

            skin.Renderer.AddRenderOffset(new Rectangle(
                m_MouseX - SourceControl.X - CurrentPackage.HoldOffset.X,
                m_MouseY - SourceControl.Y - CurrentPackage.HoldOffset.Y, 0, 0));
            CurrentPackage.DrawControl.DoRender(skin);

            skin.Renderer.RenderOffset = old;
        }
示例#7
0
 public void TestSetup()
 {
     canvas = GUI.guiRenderable.Canvas;
     canvas.Children.Clear();
 }
示例#8
0
文件: GUI.cs 项目: chartly/flood
        private void Render(Canvas canvas, string outputPath)
        {
            canvas.RenderCanvas();

            var width = 0;
            var height = 0;
            foreach (var control in canvas.Children)
                RenderBounds(control, ref width, ref height);

            var imageSettings = new Settings { Height = (ushort)height, Width = (ushort)width };
            var renderBuffer = RenderDevice.Backend.CreateRenderBuffer(imageSettings);
            renderBuffer.CreateRenderBuffer(RenderBufferType.Color);
            renderBuffer.CreateRenderBuffer(RenderBufferType.Depth);

            renderBuffer.Context = MainWindow.Context;
            MainView.RenderTarget = renderBuffer;
            MainView.Size = new Vector2i(width, height);
            canvas.SetSize(width, height);

            RenderDevice.ActiveView = MainView;

            if (!renderBuffer.Check())
                throw new Exception("Error creating render buffer");

            renderBuffer.Bind();

            var rb = new RenderBlock();

            Renderer.Render(rb);

            RenderDevice.ClearView();

            RenderDevice.Render(rb);
            Engine.StepFrame();

            var image = renderBuffer.ReadImage(1);

            var imageWriter = new ImageWriter();
            imageWriter.Save(image, outputPath);

            renderBuffer.Unbind();
        }
示例#9
0
文件: GUI.cs 项目: chartly/flood
        private bool HasRenderChanged(Canvas canvas, string assertId)
        {
            var baseDirectory = Path.GetFullPath(StoredValuesDirectory);
            var resultImagePath = Path.Combine(baseDirectory, assertId + "_result.png");
            var expectedImagePath = Path.Combine(baseDirectory, assertId + "_expected.png");
            var diffImagePath = Path.Combine(baseDirectory, assertId + "_diff.png");

            Render(canvas, resultImagePath);

            if (!File.Exists(expectedImagePath))
            {
                File.Copy(resultImagePath, expectedImagePath);
                File.Delete(resultImagePath);
                return false;
            }

            if (AreImagesEqual(expectedImagePath, resultImagePath, diffImagePath))
            {
                File.Delete(resultImagePath);
                File.Delete(diffImagePath);
                return false;
            }

            return true;
        }
示例#10
0
文件: GUI.cs 项目: chartly/flood
        public void AssertUnchanged(Canvas canvas, string assertId, string assertMessage = "")
        {
            var renderChanged = HasRenderChanged(canvas, assertId);
            var serializationChanged = HasSerializationChanged(canvas, assertId);

            Assert.IsFalse(renderChanged, assertId+" render changed. "+assertMessage);
            Assert.IsFalse(serializationChanged, assertId+" serialization changed. "+assertMessage);
        }
示例#11
0
        public PaneManager(Canvas canvas)
        {
            container = new Container(canvas) { Dock = Pos.Fill };

            FocusedGroup = new LinkedList<PaneGroup>();
        }