Пример #1
0
 /// <summary>
 /// Only update the text if logRealtime is true, otherwise it will be updated only when the program crashes
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 public void updateText(object source, Events e)
 {
     if(logRealtime)
         this.textBox1.Text = EventSource.getText();
 }
Пример #2
0
        /// <summary>
        /// Used to handle the Tessellate event when a Shape collision has been simulated and the resulting data is ready to be inserted into the
        /// textboxes and used to set the scroll bars.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void updateFields(object source, Events e)
        {
            Shape tempShape = (Shape)this.tabControl1.SelectedTab;
            Tessellation tessTemp = findTessellation(tempShape.Name);
            // If that tessellation reports that the tessellation should be used for the next collision simulation
            if (tessTemp.populateByTess)
            {
                double startingPoint = ((Tessellation)source).getStartingPoint();
                double startingAngle = ((Tessellation)source).getStartingAngle();
                double distance = ((Tessellation)source).getDistance();
                double tessHeight = ((Tessellation)source).getShapeHeight();

                // Set the Shape (tab) to report the same as well as set the proper fields to run the new simulation.
                tempShape.setFromTessellation(true);
                tempShape.setStartPoint(startingPoint);
                tempShape.setStartAngle(startingAngle);
                tempShape.setDistance(distance);
                tempShape.setTessShapeHeight(tessHeight);

                // Set the text boxes to reflect those changes
                angleBox.Text = "" + startingAngle;
                bouncesBox.Text = "" + 0;
                pointBox.Text = "" + startingPoint;
                // Set the track bars to reflect those changes
                int val = 0;
                if (tempShape.getStartAngle() > 0 && tempShape.getStartAngle() < 180)
                {
                    val = 180 - (int)tempShape.getStartAngle();
                    if (val > trackBar4.Minimum && val < trackBar4.Maximum)
                    {
                        trackBar4.Value = val;
                    }
                }
                if (tempShape.getStartPoint() > 0 && tempShape.getStartPoint() < 1){
                    val = (int)(tempShape.getStartPoint() * 100);
                    if (val > trackBar2.Minimum && val < trackBar2.Maximum)
                    {
                        trackBar2.Value = val;
                    }
                }
                // Causes redraw of shape (runs the simulation)
                tempShape.Invalidate();
            }
            // If the tessellation reports back that the baseClick was on a vertex, baseIsGood will be false
            if (!tessTemp.baseIsGood)
            {
                // If so, set the shape to report that there was an undefined collision.
                tempShape.undefCollision = true;
                // Trigger the FinishedDrawShape event to check fill the boxes in with Undefined.
                EventSource.finishedDrawShape();
            }
        }
Пример #3
0
 /// <summary>
 /// This is the handler for a tabRemove event.
 /// </summary>
 /// <param name="source">The name of the tab that was selected via the right click after Remove was selected from the menu.</param>
 /// <param name="e"></param>
 private void removeThisTab(object source, Events e)
 {
     // If the source was from the default tab, ignore.
     if(!source.Equals(tabPage1)){
         string name = (string)source;
         // Find the instance of the Shape that matches the name (a unique key).
         Shape shapeTemp = (Shape)tabControl1.Controls.Find(name, true)[0];
         Tessellation tessTemp = findTessellation(shapeTemp.Name);
         // Remove the Tessellation from the splitContainer's panel2.
         splitContainer1.Panel2.Controls.RemoveByKey(name);
         // Remove the Shape from the tabControl.
         tabControl1.Controls.RemoveByKey(name);
         // If the tabControl is now empty, add the default placeholder tab back and collapse panel2 which housed the tessellation.
         if(tabControl1.TabCount == 0){
             tabControl1.Controls.Add(tabPage1);
             splitContainer1.Panel2Collapsed = true;
         }
         // Remove both from their respective Lists and decrease the tab count for the Shape that is used in some situations to get the .
         tessellations.Remove(tessTemp);
         shapes.Remove(shapeTemp);
     }
 }
Пример #4
0
 /// <summary>
 /// Used to handle the FinishedDrawTessellation event when a Shape collision has been finished using the Tessellation.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 private void updateBounces(object source, Events e)
 {
     Shape tempShape = (Shape)this.tabControl1.SelectedTab;
     if(!tempShape.undefCollision)
         bouncesBox.Text = "" + tempShape.getBounces();
 }
Пример #5
0
 /// <summary>
 /// Used to handle the FinishedDrawShape event when all of the logic + events have been performed after the collision simuilation has been performed.
 /// This is important so that the simulation can try to run before it fills in the textboxes with Undefined.
 /// </summary>
 /// <param name="source">Empty string.</param>
 /// <param name="e">Generic event.</param>
 private void OnPostShapeCollisions(object source, Events e)
 {
     // Per suggestion by Dr. Umble, if there was an issue calculating the collisions due to the tessellation's base lying directly over a vertex
     // or if a corner has been hit, just filled in the textboxes with Undefined to convey this to the user.
     Shape selectedShape = (Shape)tabControl1.SelectedTab;
     if(selectedShape.undefCollision){
         angleBox.Text = "Undefined";
         bouncesBox.Text = "Undefined";
         pointBox.Text = "Undefined";
     }
 }