Example #1
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     CalibrationSettings.Instance().Save();
     CaptureSettings.Instance().Save();
     GraphicsSettings.Instance().Save();
     PhysicSettings.Instance().Save();
 }
Example #2
0
 /// <summary>
 /// Reset of al settings
 /// </summary>
 private void resetBut_Click(object sender, RoutedEventArgs e)
 {
     CalibrationSettings.Instance().Restart();
     CaptureSettings.Instance().Restart();
     GraphicsSettings.Instance().Restart();
     PhysicSettings.Instance().Restart();
 }
Example #3
0
 /// <summary>
 /// Renders the system
 /// </summary>
 /// <param name="objects"></param>
 public void Repaint(TableDepositor objects)
 {
     if (CommonAttribService.OUTPUT_DRAW_ALLOWED)
     {
         BitmapSource bmp = null;
         if (GraphicsSettings.Instance().OUTPUT_TABLE_SIZE_DEPENDENT)
         {
             bmp = tableDrawingManager.CreateBitmap(objects, true);
         }
         else
         {
             if (((int)tableDrawingManager.actual_size.X) != CommonAttribService.ACTUAL_OUTPUT_WIDTH)
             {
                 tableDrawingManager.Resize(CommonAttribService.ACTUAL_OUTPUT_WIDTH,
                                            (int)(CommonAttribService.ACTUAL_TABLE_HEIGHT * (((double)CommonAttribService.ACTUAL_OUTPUT_WIDTH) / CommonAttribService.ACTUAL_TABLE_WIDTH)));
             }
             bmp = tableDrawingManager.CreateBitmap(objects, false);
         }
         if (bmp != null)
         {
             tableImage.Source = bmp;
             tableImage.Width  = ActualWidth;
             tableImage.Height = ActualHeight;
         }
     }
 }
Example #4
0
        /// <summary>
        /// Po nacteni hlavniho okna se inicializuje hlavni manazer, ktery se postara
        /// o zbytek inicializace; take se inicializuje manazer kamery
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // pokud loading timer uz nebezi, zrus loading okno
            if (!loadingTimer.Enabled)
            {
                loadingWindow.Close();
            }

            // nacteni veskereho nastaveni z XML souboru
            CalibrationSettings.Instance().Load();
            CaptureSettings.Instance().Load();
            GraphicsSettings.Instance().Load();
            PhysicSettings.Instance().Load();


            CommonAttribService.mainWindow = this;

            // vytvoreni manazeru, ktery propoji funkcionalitu VSEM hlavnim modelum
            myManager          = new WindowManager();
            myManager.MyWindow = this;
            myManager.LoadDefaultValues();
            myManager.ManageMainWindow();

            CameraManager.Reinitialize();
        }
Example #5
0
        /// <summary>
        /// Renders a particle
        /// </summary>
        /// <param name="part"></param>
        private void DrawParticle(Particle part)
        {
            FPoint position = new FPoint(part.Position.X, part.Position.Y);

            position.X += CommonAttribService.ACTUAL_TABLE_WIDTH / 2;
            position.Y += CommonAttribService.ACTUAL_TABLE_HEIGHT / 2;
            position.X *= ratioX;
            position.Y *= ratioY;


            if (CommonAttribService.DEFAULT_FADE_COLORS == null || CommonAttribService.DEFAULT_FADE_COLORS.Count == 0 || !GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_ALLOWED)
            {
                DrawCircle((int)position.X, (int)position.Y, (int)part.Settings.size, color_particle);
            }
            else
            {
                // distinguish among various settings
                if (GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE == ParticleColorMode.GRAVITY)
                {
                    DrawCircle((int)position.X, (int)position.Y, (int)part.Settings.size, ColorVelocity(part.Vector_Acceleration.Size() / 5.0));
                }
                else if (GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE == ParticleColorMode.SIZE)
                {
                    DrawCircle((int)position.X, (int)position.Y, (int)part.Settings.size, ColorVelocity(part.Settings.size / 30.0));
                }
                else if (GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE == ParticleColorMode.VELOCITY)
                {
                    DrawCircle((int)position.X, (int)position.Y, (int)part.Settings.size, ColorVelocity(part.Vector_Velocity.Size() / 25.0));
                }
                else if (GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE == ParticleColorMode.WEIGH)
                {
                    DrawCircle((int)position.X, (int)position.Y, (int)part.Settings.size, ColorVelocity(part.Settings.weigh / 50.0));
                }
            }
        }
Example #6
0
        /// <summary>
        /// Load all values from storage
        /// </summary>
        public void LoadValues()
        {
            contourPathTbx.Text            = CaptureSettings.Instance().DEFAULT_TEMPLATE_PATH;
            camIndexCombo.SelectedIndex    = CaptureSettings.Instance().DEFAULT_CAMERA_INDEX;
            dependOutputSizeChck.IsChecked = GraphicsSettings.Instance().OUTPUT_TABLE_SIZE_DEPENDENT;
            contourPathTbx.IsEnabled       = GraphicsSettings.Instance().OUTPUT_TABLE_SIZE_DEPENDENT;
            dependOutputSizeTbx.Text       = CommonAttribService.ACTUAL_OUTPUT_WIDTH.ToString();

            partColorRedTbx.Text          = GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_R.ToString();
            partColorGreenTbx.Text        = GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_G.ToString();
            partColorBlueTbx.Text         = GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_B.ToString();
            motionDetectionChck.IsChecked = CaptureSettings.Instance().MOTION_DETECTION;
            detectionThreshold.Text       = CaptureSettings.Instance().MOTION_TOLERANCE.ToString();
        }
Example #7
0
        /// <summary>
        /// Click on OK will save all changes
        /// </summary>
        private void okBut_Click(object sender, RoutedEventArgs e)
        {
            CaptureSettings.Instance().DEFAULT_TEMPLATE_PATH        = contourPathTbx.Text;
            CaptureSettings.Instance().DEFAULT_CAMERA_INDEX         = camIndexCombo.SelectedIndex;
            GraphicsSettings.Instance().OUTPUT_TABLE_SIZE_DEPENDENT = (bool)dependOutputSizeChck.IsChecked;
            CaptureSettings.Instance().MOTION_DETECTION             = (bool)motionDetectionChck.IsChecked;

            try
            {
                GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_R = Byte.Parse(partColorRedTbx.Text);
                GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_G = Byte.Parse(partColorGreenTbx.Text);
                GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_B = Byte.Parse(partColorBlueTbx.Text);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Wrong values of particle colors (need to be 0-255)");
                return;
            }
            try
            {
                int otp_width = Int32.Parse(dependOutputSizeTbx.Text);
                if (otp_width > 100 && otp_width < 2000)
                {
                    CommonAttribService.ACTUAL_OUTPUT_WIDTH = otp_width;
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Allowed sizes are 100-2000");
                    return;
                }
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("The size cannot be determined!");
                return;
            }

            try
            {
                int tolerance = Int32.Parse(detectionThreshold.Text);
                if (tolerance < 500 || tolerance > 10000)
                {
                    throw new Exception();
                }
                CaptureSettings.Instance().MOTION_TOLERANCE = tolerance;
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Allowed value for tolerance must be in 500-10000");
                return;
            }

            CaptureSettings.Instance().Save();
            GraphicsSettings.Instance().Save();

            // if the left shift is pressed, we will not close the window (WTF??)
            if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
            {
                this.Close();
            }
        }
Example #8
0
        /// <summary>
        /// Change of all checkboxes
        /// </summary>
        private void CheckBoxCheckChanged(object sender, System.Windows.RoutedEventArgs e)
        {
            if (sender == tableSetPanel.generatorRegularGenChck) // regular generating of particles
            {
                tableManager.TableDepositor.table.Settings.generatorSettings.Regular_generating =
                    (bool)tableSetPanel.generatorRegularGenChck.IsChecked;
            }

            if (sender == tableSetPanel.gravityMovementChck) // variable gravity field
            {
                tableManager.TableDepositor.table.Settings.gravitonSettings.enabled =
                    (bool)tableSetPanel.gravityMovementChck.IsChecked;
            }

            if (sender == tableSetPanel.magnetonMovementChck) // magnetism
            {
                tableManager.TableDepositor.table.Settings.magnetonSettings.enabled =
                    (bool)tableSetPanel.magnetonMovementChck.IsChecked;
            }

            if (sender == tableSetPanel.particleColorChangeChck) // particle color change
            {
                GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_ALLOWED =
                    (bool)tableSetPanel.particleColorChangeChck.IsChecked;
            }

            if (sender == tableSetPanel.particleEnergyLoseChck) // particle energy change
            {
                tableManager.TableDepositor.table.Settings.energy_loosing =
                    (bool)tableSetPanel.particleEnergyLoseChck.IsChecked;
            }

            if (sender == tableSetPanel.gravitonLocalPulseChck) // change of local pulse of gravity stones
            {
                tableManager.TableDepositor.table.Settings.gravitonSettings.Energy_pulsing =
                    (bool)tableSetPanel.gravitonLocalPulseChck.IsChecked;
            }

            if (sender == tableSetPanel.magnetonLocalPulseChck) // change of local pulse of magnet stones
            {
                tableManager.TableDepositor.table.Settings.magnetonSettings.Energy_pulsing =
                    (bool)tableSetPanel.magnetonLocalPulseChck.IsChecked;
            }

            if (sender == tableSetPanel.surfaceInterChck) // collision change with the borders of the table
            {
                tableManager.TableDepositor.table.Settings.interaction =
                    (bool)tableSetPanel.surfaceInterChck.IsChecked;
            }

            if (sender == tableSetPanel.tableGravityChck) // gravity generated by the table
            {
                tableManager.TableDepositor.table.Settings.gravity_allowed =
                    (bool)tableSetPanel.tableGravityChck.IsChecked;
            }

            if (sender == tableSetPanel.generationChck) // enabling particle generator
            {
                tableManager.TableDepositor.table.Settings.generatorSettings.enabled =
                    (bool)tableSetPanel.generationChck.IsChecked;
            }

            if (sender == tableSetPanel.absorbChck) // enabling particle absorber
            {
                tableManager.TableDepositor.table.Settings.blackHoleSettings.enabled =
                    (bool)tableSetPanel.absorbChck.IsChecked;
            }

            if (sender == tableSetPanel.particleSizeChck) // enable variable size of particles
            {
                PhysicsSettings.particle_sizeChanging_allowed = (bool)tableSetPanel.particleSizeChck.IsChecked;
            }

            if (sender == tableSetPanel.gridDispChck) // display grid
            {
                GraphicsSettings.Instance().DEFAULT_GRID_ENABLED = (bool)tableSetPanel.gridDispChck.IsChecked;
            }

            if (sender == tableSetPanel.blackHoleLocalPulseChck)
            {
                tableManager.TableDepositor.table.Settings.blackHoleSettings.Energy_pulsing =
                    (bool)tableSetPanel.blackHoleLocalPulseChck.IsChecked;
            }

            if (sender == tableSetPanel.rockDispChck) // draw stones in the opengl window
            {
                GraphicsSettings.Instance().DEFAULT_OUTPUT_ROCK_DISPLAY = (bool)tableSetPanel.rockDispChck.IsChecked;
            }
        }
Example #9
0
        public void SetHandlers()
        {
            // default settings of all checkboxes and sliders
            tableSetPanel.surfaceInterChck.IsChecked        = PhysicSettings.Instance().DEFAULT_INTERACTION_ALLOWED;
            tableSetPanel.gravityMovementChck.IsChecked     = PhysicSettings.Instance().DEFAULT_GRAVITON_ENABLED;
            tableSetPanel.magnetonMovementChck.IsChecked    = PhysicSettings.Instance().DEFAULT_MAGNETON_ENABLED;
            tableSetPanel.generationChck.IsChecked          = PhysicSettings.Instance().DEFAULT_GENERATOR_ENABLED;
            tableSetPanel.absorbChck.IsChecked              = PhysicSettings.Instance().DEFAULT_BLACKHOLE_ENABLED;
            tableSetPanel.tableGravityChck.IsChecked        = PhysicSettings.Instance().DEFAULT_TABLE_GRAVITY;
            tableSetPanel.gravitonLocalPulseChck.IsChecked  = PhysicSettings.Instance().DEFAULT_ENERGY_GRAVITON_PULSING;
            tableSetPanel.magnetonLocalPulseChck.IsChecked  = PhysicSettings.Instance().DEFAULT_ENERGY_MAGNETON_PULSING;
            tableSetPanel.particleEnergyLoseChck.IsChecked  = PhysicSettings.Instance().DEFAULT_ENERGY_TABLE_LOOSING;
            tableSetPanel.particleColorChangeChck.IsChecked = GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_ALLOWED;
            tableSetPanel.generatorRegularGenChck.IsChecked = PhysicSettings.Instance().DEFAULT_GENERATING_REGULAR;
            tableSetPanel.particleSizeChck.IsChecked        = PhysicSettings.Instance().DEFAULT_PARTICLE_SIZING_ENABLED;
            tableSetPanel.gridDispChck.IsChecked            = GraphicsSettings.Instance().DEFAULT_GRID_ENABLED;
            tableSetPanel.particleColorChangeChck.IsChecked = GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_ALLOWED;
            tableSetPanel.rockDispChck.IsChecked            = GraphicsSettings.Instance().DEFAULT_OUTPUT_ROCK_DISPLAY;

            tableSetPanel.particleEnergyLoseSizeSlider.Value   = PhysicSettings.Instance().DEFAULT_ENERGY_TABLE_LOOSING_SPEED;
            tableSetPanel.particleEnergyLoseSizeSlider.Maximum = PhysicSettings.Instance().DEFAULT_ENERGY_TABLE_LOOSING_SPEED_MAX;
            tableSetPanel.particleEnergyLoseSizeTb.Text        = tableSetPanel.particleEnergyLoseSizeSlider.Value.ToString();
            tableSetPanel.generatorGenFirstAngleSlider.Value   = PhysicSettings.Instance().DEFAULT_GENERATOR_ANGLE_OFFSET;
            tableSetPanel.generatorGenFirstAngleTb.Text        = tableSetPanel.generatorGenFirstAngleSlider.Value.ToString();
            tableSetPanel.generatorGenAngleSlider.Value        = PhysicSettings.Instance().DEFAULT_GENERATOR_ANGLE_MAX;
            tableSetPanel.generatorGenAngleTb.Text             = tableSetPanel.generatorGenAngleSlider.Value.ToString();
            tableSetPanel.generatorMinVelocSlider.Value        = PhysicSettings.Instance().DEFAULT_MIN_GENERATING_VELOCITY;
            tableSetPanel.generatorMinVelocTb.Text             = tableSetPanel.generatorMinVelocSlider.Value.ToString();
            tableSetPanel.generatorMaxVelocSlider.Value        = PhysicSettings.Instance().DEFAULT_MAX_GENERATING_VELOCITY;
            tableSetPanel.generatorMaxVelocTb.Text             = tableSetPanel.generatorMaxVelocSlider.Value.ToString();
            tableSetPanel.generatorSpeedSlider.Value           = PhysicSettings.Instance().DEFAULT_GENERATING_SPEED;
            tableSetPanel.generatorSpeedTb.Text        = tableSetPanel.generatorSpeedSlider.Value.ToString();
            tableSetPanel.generatorMinSizeSlider.Value = PhysicSettings.Instance().DEFAULT_PARTICLE_SIZE;
            tableSetPanel.generatorMinSizeTb.Text      = tableSetPanel.generatorMinSizeSlider.Value.ToString();
            tableSetPanel.generatorMaxSizeSlider.Value = PhysicSettings.Instance().DEFAULT_PARTICLE_SIZE;
            tableSetPanel.generatorMaxSizeTb.Text      = tableSetPanel.generatorMaxSizeSlider.Value.ToString();
            tableSetPanel.tableSizeSlider.Value        = CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER;
            tableSetPanel.tableSizeTb.Text             = CommonAttribService.ACTUAL_TABLE_SIZE_MULTIPLIER.ToString("#");
            tableSetPanel.tableGravityXTbx.Text        = PhysicSettings.Instance().DEFAULT_TABLE_GRAVITY_VECTOR.X.ToString();
            tableSetPanel.tableGravityYTbx.Text        = PhysicSettings.Instance().DEFAULT_TABLE_GRAVITY_VECTOR.Y.ToString();

            tableSetPanel.pauseImage.MouseUp      += new System.Windows.Input.MouseButtonEventHandler(pauseImage_MouseUp);
            tableSetPanel.playImage.MouseUp       += new System.Windows.Input.MouseButtonEventHandler(playImage_MouseUp);
            tableSetPanel.stopImage.MouseUp       += new System.Windows.Input.MouseButtonEventHandler(stopImage_MouseUp);
            tableSetPanel.cameraImage.MouseUp     += new System.Windows.Input.MouseButtonEventHandler(cameraImage_MouseUp);
            tableSetPanel.recordImage.MouseUp     += new System.Windows.Input.MouseButtonEventHandler(recordImage_MouseUp);
            tableSetPanel.simulationImage.MouseUp += new System.Windows.Input.MouseButtonEventHandler(simulationImage_MouseUp);
            tableSetPanel.outputImage.MouseUp     += new System.Windows.Input.MouseButtonEventHandler(outputImage_MouseUp);
            tableSetPanel.generatorGenAngleSlider.ValueChanged      += new System.Windows.RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorGenFirstAngleSlider.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorMaxVelocSlider.ValueChanged      += new System.Windows.RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorMinVelocSlider.ValueChanged      += new System.Windows.RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.particleEnergyLoseSizeSlider.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorSpeedSlider.ValueChanged         += new RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorMinSizeSlider.ValueChanged       += new RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorMaxSizeSlider.ValueChanged       += new RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.tableSizeSlider.ValueChanged  += new RoutedPropertyChangedEventHandler <double>(sliderValueChanged);
            tableSetPanel.generatorRegularGenChck.Click += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.gravityMovementChck.Click     += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.magnetonMovementChck.Click    += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.particleColorChangeChck.Click += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.particleEnergyLoseChck.Click  += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.particleSizeChck.Click        += new RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.gravitonLocalPulseChck.Click  += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.magnetonLocalPulseChck.Click  += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.surfaceInterChck.Click        += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.tableGravityChck.Click        += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.generationChck.Click          += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.absorbChck.Click              += new System.Windows.RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.gridDispChck.Click            += new RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.blackHoleLocalPulseChck.Click += new RoutedEventHandler(CheckBoxCheckChanged);
            tableSetPanel.rockDispChck.Click            += new RoutedEventHandler(CheckBoxCheckChanged);

            tableSetPanel.gravityComboBox.SelectionChanged             += new System.Windows.Controls.SelectionChangedEventHandler(ComboBoxItem_changed);
            tableSetPanel.magnetonComboBox.SelectionChanged            += new System.Windows.Controls.SelectionChangedEventHandler(ComboBoxItem_changed);
            tableSetPanel.particleColorChangeComboBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(ComboBoxItem_changed);
            tableSetPanel.generationComboBox.SelectionChanged          += new System.Windows.Controls.SelectionChangedEventHandler(ComboBoxItem_changed);
            tableSetPanel.absorbComboBox.SelectionChanged             += new System.Windows.Controls.SelectionChangedEventHandler(ComboBoxItem_changed);
            tableSetPanel.particleSizeChangeComboBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(ComboBoxItem_changed);
            tableSetPanel.tableGravityXTbx.LostFocus   += new System.Windows.RoutedEventHandler(TextBox_FocusLost);
            tableSetPanel.tableGravityYTbx.LostFocus   += new System.Windows.RoutedEventHandler(TextBox_FocusLost);
            tableSetPanel.settingVisibilityBut.MouseUp += new System.Windows.Input.MouseButtonEventHandler(settingVisibilityBut_Click);
            tableSetPanel.particleColorChangeBut.Click += new RoutedEventHandler(particleColorChangeBut_Click);
        }
Example #10
0
        /// <summary>
        /// Change of all dropdowns
        /// </summary>
        private void ComboBoxItem_changed(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (sender == tableSetPanel.gravityComboBox) // gravity mode change
            {
                if (tableSetPanel.aditiveGravityCmbIt.IsSelected)
                {
                    PhysicsSettings.gravitationMode = GravitationMode.ADITIVE;
                }
                if (tableSetPanel.averageGravityCmbIt.IsSelected)
                {
                    PhysicsSettings.gravitationMode = GravitationMode.AVERAGE;
                }
                if (tableSetPanel.multiplyGravityCmbIt.IsSelected)
                {
                    PhysicsSettings.gravitationMode = GravitationMode.MULTIPLY;
                }
            }

            if (sender == tableSetPanel.magnetonComboBox) // magnetism mode change
            {
                if (tableSetPanel.aditiveMagnetonCmbIt.IsSelected)
                {
                    PhysicsSettings.magnetismMode = MagnetismMode.ADITIVE;
                }
                if (tableSetPanel.averageMagnetonCmbIt.IsSelected)
                {
                    PhysicsSettings.magnetismMode = MagnetismMode.AVERAGE;
                }
                if (tableSetPanel.multiplyMagnetonCmbIt.IsSelected)
                {
                    PhysicsSettings.magnetismMode = MagnetismMode.MULTIPLY;
                }
            }


            if (sender == tableSetPanel.particleColorChangeComboBox) // colouring mode change
            {
                if (tableSetPanel.colorChange_gravityCmbIt.IsSelected)
                {
                    GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE = ParticleColorMode.GRAVITY;
                }
                if (tableSetPanel.colorChange_sizeCmbIt.IsSelected)
                {
                    GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE = ParticleColorMode.SIZE;
                }
                if (tableSetPanel.colorChange_velocityCmbIt.IsSelected)
                {
                    GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE = ParticleColorMode.VELOCITY;
                }
                if (tableSetPanel.colorChange_weighCmbIt.IsSelected)
                {
                    GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_MODE = ParticleColorMode.WEIGH;
                }
            }

            if (sender == tableSetPanel.generationComboBox) // particle generating mode change
            {
                if (tableSetPanel.standardGenerationCmbIt.IsSelected)
                {
                    tableManager.TableDepositor.table.Settings.generatorSettings.generationMode = GenerationMode.STANDARD;
                }
                if (tableSetPanel.strangeGenerationCmbIt.IsSelected)
                {
                    tableManager.TableDepositor.table.Settings.generatorSettings.generationMode = GenerationMode.STRANGE;
                }
            }

            if (sender == tableSetPanel.absorbComboBox) // absorption mode change
            {
                if (tableSetPanel.blackHoleAbsorbCmbIt.IsSelected)
                {
                    PhysicsSettings.absorptionMode = AbsorptionMode.BLACKHOLE;
                }
                if (tableSetPanel.regenerationAbsorbCmbIt.IsSelected)
                {
                    PhysicsSettings.absorptionMode = AbsorptionMode.RECYCLE;
                }
                if (tableSetPanel.selectingAbsorbCmbIt.IsSelected)
                {
                    PhysicsSettings.absorptionMode = AbsorptionMode.SELECT;
                }
            }

            if (sender == tableSetPanel.particleSizeChangeComboBox) // dynamic particle size mode change
            {
                if (tableSetPanel.sizeChange_gravityCmbIt.IsSelected)
                {
                    PhysicsSettings.particle_sizeMode = ParticleSizeMode.GRAVITY;
                }
                if (tableSetPanel.sizeChange_velocityCmbIt.IsSelected)
                {
                    PhysicsSettings.particle_sizeMode = ParticleSizeMode.VELOCITY;
                }
                if (tableSetPanel.sizeChange_weighCmbIt.IsSelected)
                {
                    PhysicsSettings.particle_sizeMode = ParticleSizeMode.WEIGH;
                }
                if (tableSetPanel.sizeChange_noneCmbIt.IsSelected)
                {
                    PhysicsSettings.particle_sizeMode = ParticleSizeMode.NONE;
                }
            }
        }
Example #11
0
        /// <summary>
        /// Creates an image of a table system
        /// </summary>
        /// <returns></returns>
        public BitmapSource CreateBitmap(TableDepositor objects, Boolean isTableSized)
        {
            try
            {
                renderCounter++; // used for garbage collector

                // invoke GC
                if (renderCounter > 30)
                {
                    renderCounter = 0;
                    GC.Collect();
                }

                ratioX = actual_size.X / CommonAttribService.ACTUAL_TABLE_WIDTH;
                ratioY = actual_size.Y / CommonAttribService.ACTUAL_TABLE_HEIGHT;

                color_particle = 0x00000000 + (uint)(255 << 24 | GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_R << 16
                                                     | GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_G << 8 | GraphicsSettings.Instance().DEFAULT_PARTICLE_COLOR_B);

                // check resizing
                if (isTableSized)
                {
                    if (pixelData.Length != (int)(CommonAttribService.ACTUAL_TABLE_HEIGHT * CommonAttribService.ACTUAL_TABLE_WIDTH))
                    {
                        pixelData     = new UInt32[(int)(CommonAttribService.ACTUAL_TABLE_HEIGHT * CommonAttribService.ACTUAL_TABLE_WIDTH)];
                        actual_size.X = CommonAttribService.ACTUAL_TABLE_WIDTH;
                        actual_size.Y = CommonAttribService.ACTUAL_TABLE_HEIGHT;
                    }
                }

                // remove pixel buffer
                for (int i = 0; i < pixelData.Length; i++)
                {
                    pixelData[i] = 0xFF000000;
                }

                if (GraphicsSettings.Instance().DEFAULT_GRID_ENABLED)
                {
                    DrawLines(objects);                                                  // draw grid
                }
                // draw particles
                foreach (Particle part in objects.particles)
                {
                    DrawParticle(part);
                }

                // draw stones
                if (GraphicsSettings.Instance().DEFAULT_OUTPUT_ROCK_DISPLAY)
                {
                    DrawRocks(objects);
                }

                // create a bitmap for pixel array
                BitmapSource bmp = BitmapSource.Create((int)actual_size.X, (int)actual_size.Y, 96, 96, PixelFormats.Bgra32, null, pixelData, ((((int)actual_size.X * 32 + 31) & ~31) / 8));
                CommonAttribService.LAST_BITMAP = bmp;
                return(bmp);
            }
            catch {
                // no-op here
            }

            return(null);
        }