예제 #1
0
        /// <summary>
        /// Starts Sandpile movement after stock vertices are selected
        /// </summary>
        private void StockLabel_Click(object sender, EventArgs e)
        {
            if (SandpilePanel.Size.Height > 60)
            {
                return;
            }
            SandpilePanel.Visible = false;
            TimeTextBox.Visible   = true;
            SandpileLabel.Enabled = false;
            TimeTextBox.BringToFront();
            SandpileLabel.Text = @"Select vertex to add a grain of sand to       ";
            SandpileLabel.Font = new Font("Segoe UI", 9);
            SandpilePanel.Size = new Size(SandpilePanel.Size.Width, 91);

            movement.MovementEnded += MovementEndedSandpileEventHandler;

            movement.StartMovementModeling();
        }
예제 #2
0
        /// <summary>
        /// Prepares MovementModeling instance for modeling the movement
        /// </summary>
        /// <param name="type">Modeling type</param>
        /// <param name="actions">Additional actions</param>
        /// <param name="sandpileChartTypes">Sandpile chart types</param>
        private bool PrepareMovementModeling(MovementModelingType type,
                                             MovementModelingActions[] actions,
                                             SandpileChartType[] sandpileChartTypes)
        {
            movement = new MovementModeling(digraph, (double)SpeedNumeric.Value / 1000, type, actions)
            {
                GraphDrawing       = graphDrawing,
                DrawingSurface     = DrawingSurface,
                SandpileChartTypes = sandpileChartTypes
            };

            isOnMovement            = true;
            movement.Tick          += UpdateElapsedTime;
            movement.MovementEnded += StopToolStripMenuItem_Click;

            MovementToolStripMenuItem.Text    = @"Continue";
            MovementToolStripMenuItem.Enabled = false;
            StopToolStripMenuItem.Enabled     = true;

            if (type == MovementModelingType.Sandpile)
            {
                graphDrawing.DrawTheWholeGraphSandpile(digraph, true);
                DrawingSurface.Image  = graphDrawing.Image;
                SandpilePanel.Visible = true;
                SandpilePanel.BringToFront();
                return(true);
            }

            if (SaveGifCheckBox.Checked)
            {
                movement.MovementEnded += SaveGif;
            }
            movement.MovementEnded += (s, ea) =>
            {
                movement.Tick -= UpdateElapsedTime;
                movement       = null;
            };

            TimeTextBox.Visible = true;
            TimeTextBox.BringToFront();
            return(false);
        }