Exemple #1
0
        public void Initialize(MapEditorViewModel vm)
        {
            DataContext = new MainWindowViewModel(vm);
            ViewModel.ObjectPropertiesViewModel.OnInvalidateEntry += (s, e) =>
            {
                ViewModel.IsRedrawingNeeded = true;
            };
            var timer = new System.Timers.Timer
            {
                Interval = 1000.0 / FPS
            };

            timer.Elapsed += (s, e) =>
            {
                // Returns to the main thread
                Application.Current?.Dispatcher.Invoke(new Action(() =>
                {
                    if (ViewModel.IsRedrawingNeeded == true)
                    {
                        ViewModel.IsRedrawingNeeded = false;
                        var stopWatch = new Stopwatch();
                        stopWatch.Start();
                        ctrlTileMap.DoRender();
                        stopWatch.Stop();
                        ViewModel.LastRenderingTime = stopWatch.Elapsed.TotalMilliseconds;
                    }
                }));
            };
            timer.Enabled = true;
        }
Exemple #2
0
        public MainWindow()
        {
            MapEditorViewModel model = new MapEditorViewModel();

            this.DataContext = model;

            InitializeComponent();
        }
Exemple #3
0
 public MainWindow(MapEditorViewModel vm)
 {
     InitializeComponent();
     Initialize(vm);
 }