コード例 #1
0
 public ShaderFile(VisualContext visualContext, ISynchronizeInvoke syncObject)
 {
     this.visualContext = visualContext;
     //establish watcher
     shaderWatcher.Changed            += (object sender, FileSystemEventArgs e) => LoadShader(e.FullPath);
     shaderWatcher.SynchronizingObject = syncObject;
 }
コード例 #2
0
        public static DemoModel Create(ISynchronizeInvoke syncObject)
        {
            var visualContext = new VisualContext();
            var shaders       = new Shaders(() => new ShaderFile(visualContext, syncObject));
            var textures      = new Textures(visualContext);

            return(new DemoModel(visualContext, shaders, textures, true));
        }
コード例 #3
0
        private MyApplication()
        {
            gameWindow.KeyDown     += GameWindow_KeyDown;
            gameWindow.RenderFrame += game_RenderFrame;
            visualContext           = new VisualContext();
            var textures = new Textures(visualContext);
            var shaders  = new Shaders(NewShaderFile);

            demo = new DemoModel(visualContext, shaders, textures, false);
            demo.TimeSource.TimeFinished += () => gameWindow.Close();

            var arguments = Environment.GetCommandLineArgs();

            if (3 > arguments.Length)
            {
                MessageBox.Show("DemoRecorder <configfile> <saveDirectory> [<resX> <resY> <frameRate>]"
                                + Environment.NewLine
                                + " Please give the demo config file name as application parameter followed by the render buffer resolution.");
                gameWindow.Close();
            }
            bufferWidth  = gameWindow.Width;
            bufferHeight = gameWindow.Height;
            try
            {
                bufferWidth  = int.Parse(arguments.ElementAt(3));
                bufferHeight = int.Parse(arguments.ElementAt(4));
            }
            catch
            {
                bufferWidth  = gameWindow.Width;
                bufferHeight = gameWindow.Height;
            }
            try
            {
                frameRate = int.Parse(arguments.ElementAt(5));
            }
            catch
            {
                frameRate = 25;
            }
            try
            {
                DemoLoader.LoadFromFile(demo, arguments.ElementAt(1));
                saveDirectory  = Directory.CreateDirectory(arguments.ElementAt(2)).FullName;
                saveDirectory += Path.DirectorySeparatorChar;
                saveDirectory += DateTime.Now.ToString("yyyyMMdd HHmmss");
                saveDirectory += Path.DirectorySeparatorChar;
                Directory.CreateDirectory(saveDirectory);
                fileNumber = 0;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error loading demo '" + arguments.ElementAt(1) + '"'
                                + Environment.NewLine + e.Message);
                gameWindow.Close();
            }
        }
コード例 #4
0
ファイル: DemoModel.cs プロジェクト: Jonnyf16/Framework
        public DemoModel(VisualContext visualContext, IShaders shaders, ITextures textures, bool isLooping)
        {
            uniforms        = new Uniforms();
            ShaderKeyframes = new ShaderKeyframes();
            TimeSource      = new DemoTimeSource(isLooping);

            this.visualContext = visualContext;
            Shaders            = shaders;
            Textures           = textures;
        }
コード例 #5
0
        private MyApplication()
        {
            gameWindow.Load        += GameWindow_Load;
            gameWindow.KeyDown     += GameWindow_KeyDown;
            gameWindow.RenderFrame += game_RenderFrame;
            visualContext           = new VisualContext();
            var textures = new Textures(visualContext);
            var shaders  = new Shaders(NewShaderFile);

            demo = new DemoModel(visualContext, shaders, textures, false);
            demo.TimeSource.TimeFinished += () => gameWindow.Close();

            var arguments = Environment.GetCommandLineArgs();

            if (1 == arguments.Length)
            {
                MessageBox.Show("DemoPlayer <configfile> [<resX> <resY>]"
                                + Environment.NewLine
                                + " Please give the demo config file name you wish to play as application parameter followed by the render buffer resolution.");
                gameWindow.Close();
            }
            bufferWidth  = gameWindow.Width;
            bufferHeight = gameWindow.Height;
            try
            {
                bufferWidth  = int.Parse(arguments.ElementAt(2));
                bufferHeight = int.Parse(arguments.ElementAt(3));
            }
            catch
            {
                bufferWidth  = gameWindow.Width;
                bufferHeight = gameWindow.Height;
            }
            try
            {
                DemoLoader.LoadFromFile(demo, arguments.ElementAt(1));
            }
            catch (Exception e)
            {
                MessageBox.Show("Error loading demo '" + arguments.ElementAt(1) + '"'
                                + Environment.NewLine + e.Message);
                gameWindow.Close();
            }
        }
コード例 #6
0
        public Visual GetVisualContent(VisualContext context)
        {
            Visual visualContent = null;

            // gets visual content by context
            switch (context)
            {
            case VisualContext.Page:

                // check if need to load window content ref
                if (_windowContentRef == null)
                {
                    // window background content is always static
                    var rootGrid = (Grid)_navigator.Container.Parent;

                    foreach (var child in rootGrid.Children)
                    {
                        var control = (FrameworkElement)child;

                        // find window background content
                        // ReSharper disable once InvertIf
                        if (control.Name == WINDOW_BACKGROUND_CONTENT)
                        {
                            _windowContentRef = control;
                            break;
                        }
                    }
                }

                visualContent = _windowContentRef;
                break;

            case VisualContext.Control:

                // save current content
                visualContent = _navigator.CurrentPage;
                break;

            default: break;
            }

            return(visualContent);
        }
コード例 #7
0
        public void BorderAndLayout()
        {
            const string file = "..\\..\\..\\AssertionImages\\border.png";
            var          bord = new Border
            {
                Foreground = new SKPaint {
                    Color = SKColors.White, IsAntialias = true
                },
                BorderBrush = new SKPaint {
                    Color = SKColors.Gray.WithAlpha(255), IsStroke = true, IsAntialias = true
                },
                Background = new SKPaint
                {
                    Color       = SKColors.White,
                    IsStroke    = false,
                    IsAntialias = true,
                    Shader      = SKShader.CreateLinearGradient(new SKPoint(0, 250), new SKPoint(0, 280),
                                                                new[] { new SKColor(70, 70, 70), SKColors.Black },
                                                                new[] { 0f, 1f }, SKShaderTileMode.Clamp)
                },
                CornerRadius = new CornerRadius(10),
                Thickness    = new Thickness(1, 5),
                HorizAlign   = HorizAlign.Left,
                VertAlign    = VertAlign.Top,
                Width        = 100,
                Height       = 50,
                Margin       = new Thickness(20),
                Content      = "Hello World"
            };
            var visualContext = new VisualContext(_app.MainWindow);

            visualContext.AddVisual(bord);
            visualContext.Render();
            visualContext.SaveToImage(file);
            Process.Start("mspaint.exe", Path.Combine(Environment.CurrentDirectory, file));
        }
コード例 #8
0
ファイル: ShaderFile.cs プロジェクト: Jonnyf16/Framework
 public ShaderFile(VisualContext visualContext)
 {
     this.visualContext = visualContext;
 }
コード例 #9
0
ファイル: Textures.cs プロジェクト: Jonnyf16/Framework
 public Textures(VisualContext visual)
 {
     this.visual = visual;
 }