예제 #1
0
 private void flockRadiusSelector_ValueChanged(object sender, EventArgs e)
 {
     lock (this)
     {
         ITaskForce tf = taskForces[taskForceSelector.SelectedIndex];
         tf.FlockRadius = Convert.ToSingle(flockRadiusSelector.Value);
     }
 }
예제 #2
0
 /// <summary>
 /// Make this task force a copy of another.
 /// </summary>
 /// <param name="copy">The other task force.</param>
 /// <remarks>Does not deep copy the list of ships.</remarks>
 public void CopyFrom(ITaskForce copy)
 {
     Boids              = copy.Boids;
     AlignmentStrength  = copy.AlignmentStrength;
     CohesionStrength   = copy.CohesionStrength;
     SeparationStrength = copy.SeparationStrength;
     Color              = copy.Color;
 }
예제 #3
0
 private void separationWeightSelector_ValueChanged(object sender, EventArgs e)
 {
     lock (this)
     {
         ITaskForce tf = taskForces[taskForceSelector.SelectedIndex];
         tf.SeparationStrength = Convert.ToSingle(separationWeightSelector.Value)
                                 / sliderPrecision;
         separationWeightInfo.Text = tf.SeparationStrength.ToString("F");
     }
 }
예제 #4
0
        private void numShipsSelector_ValueChanged(object sender, EventArgs e)
        {
            ITaskForce tf = taskForces[taskForceSelector.SelectedIndex];

            lock (this)
            {
                tf.SetShipAmount(Convert.ToInt32(numShipsSelector.Value));
                taskForceSelector.Items[taskForceSelector.SelectedIndex] = tf.ToString();
            }
        }
예제 #5
0
        private void colorButton_Click(object sender, EventArgs e)
        {
            ITaskForce  tf = taskForces[taskForceSelector.SelectedIndex];
            ColorDialog cd = new ColorDialog();

            lock (this)
            {
                renderControl.Enabled = false;
                cd.ShowDialog(this);
                tf.Color = cd.Color;
                renderControl.Enabled = true;
            }
            taskForceSelector.Items[taskForceSelector.SelectedIndex] = tf.ToString();
            colorButton.BackColor = cd.Color;
            colorButton.ForeColor = GetReadableForeColor(colorButton.BackColor);
        }
예제 #6
0
 private void taskForceSelector_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (-1 == taskForceSelector.SelectedIndex)
     {
         // nothing selected, disable controls
         numShipsSelector.Enabled         = false;
         colorButton.Enabled              = false;
         alignmentWeightSelector.Enabled  = false;
         cohesionWeightSelector.Enabled   = false;
         separationWeightSelector.Enabled = false;
         flockRadiusSelector.Enabled      = false;
     }
     else
     {
         lock (this)
         {
             // reset controls to selected taskforce's information
             ITaskForce tf = taskForces[taskForceSelector.SelectedIndex];
             numShipsSelector.Enabled         = true;
             numShipsSelector.Value           = tf.Boids.Count;
             colorButton.Enabled              = true;
             colorButton.BackColor            = Color.FromArgb(tf.Color.ToArgb());
             colorButton.ForeColor            = GetReadableForeColor(colorButton.BackColor);
             alignmentWeightSelector.Enabled  = true;
             alignmentWeightSelector.Value    = Clamp(Convert.ToInt32(tf.AlignmentStrength * sliderPrecision), alignmentWeightSelector.Minimum, alignmentWeightSelector.Maximum);
             alignmentWeightInfo.Text         = tf.AlignmentStrength.ToString("F");
             cohesionWeightSelector.Enabled   = true;
             cohesionWeightSelector.Value     = Clamp(Convert.ToInt32(tf.CohesionStrength * sliderPrecision), cohesionWeightSelector.Minimum, cohesionWeightSelector.Maximum);
             cohesionWeightInfo.Text          = tf.CohesionStrength.ToString("F");
             separationWeightSelector.Enabled = true;
             separationWeightSelector.Value   = Clamp(Convert.ToInt32(tf.SeparationStrength * sliderPrecision), separationWeightSelector.Minimum, separationWeightSelector.Maximum);
             separationWeightInfo.Text        = tf.SeparationStrength.ToString("F");
             flockRadiusSelector.Enabled      = true;
             flockRadiusSelector.Value        = Clamp(Convert.ToDecimal(tf.FlockRadius), flockRadiusSelector.Minimum, flockRadiusSelector.Maximum);
         }
     }
 }