예제 #1
0
        public void setWorldRenderer(WorldRenderer renderer)
        {
            this.renderer = renderer;
            //container = (UIElement)Parent;
            matrix = new Matrix();
            matrix.Translate(100, 100);
            matrix.Scale(3, 3);

            Window mainWindow = Application.Current.Windows[0];

            new Task(() =>
            {
                while (running)
                {
                    try
                    {
                        Dispatcher.Invoke(() =>
                        {
                            InvalidateVisual();
                        });
                    }
                    catch (Exception e) { }

                    Matrix invMatrix = matrix;
                    invMatrix.Invert();
                    Point leftTopView     = invMatrix.Transform(new Point(0, 0));
                    Point rightBottomView = invMatrix.Transform(new Point(container.ActualWidth, container.ActualHeight));
                    setsToDraw            = renderer.GetSetsToDraw(leftTopView, rightBottomView, mainWindow);
                }
            }).Start();

            updateTimer          = new Timer(updateTimer.Interval);
            updateTimer.Interval = 300;            // 16;
            updateTimer.Elapsed += (a, b) =>
            {
                try
                {
                    updateTimer.Stop();
                    //start

                    Dispatcher.Invoke(() =>
                    {
                        InvalidateVisual();
                    });
                    //end
                    //mainWindow.Title = "ASD";
                    updateTimer.Start();
                }
                catch (Exception e)
                {
                }
            };
            //updateTimer.Start();
        }