예제 #1
0
        public ParticleSimulator()
        {
            InitializeComponent();

            Application.Current.MainWindow.Closing += OnClosing;

            // Initialize simulation
            particleSim = new ParticleSim(SimCanvas);

            // Setup toolbar + commandbar
            UserToolBar.Setup(SimCanvas, particleSim, ToolOptionBar);
            CommandBar.Setup(particleSim, this);
            TopBarDockPanel.PreviewMouseWheel += (s, e) =>
            {
                if (e.Delta < 0)
                {
                    OptionBarScrollViewer.LineRight();
                }
                else
                {
                    OptionBarScrollViewer.LineLeft();
                }
                e.Handled = true;
            };

            // Setup settings window
            settingsWindow            = new SettingsWindow(this, particleSim);
            settingsWindow.Activated += SettingsWindowActivated;
            SettingsButton.Click     += (s, e) =>
            {
                if (settingsWindow.IsVisible)
                {
                    settingsWindow.Hide();
                }
                else
                {
                    settingsWindow.Show();
                }
            };

            // Capture render loop to use as main simulation loop
            CompositionTarget.Rendering += (s, e) => MainLoop();
        }