Exemple #1
0
        /// <summary>
        /// Draw each circle in the problem and save it to the lookup dictionary.
        /// Circles in LiveGeometry need two points. We have the center, but may need a point on the circle itself.
        /// If a point exists on the circle we will use that, if not a point will be created on the circle to the direct
        /// right of the center.
        /// </summary>
        /// <param name="problem">The problem being drawn.</param>
        private void drawCircles(UIProblemDrawer.ProblemDescription problem)
        {
            //Add circles to the drawing
            foreach (var circ in problem.Circles)
            {
                //Lookup center point
                var    center = points[circ.center];
                IPoint pointOnCircle;

                if (circ.pointsOnCircle.Count > 0) //Point on circle exists
                {
                    pointOnCircle = points[circ.pointsOnCircle[0]];
                }
                else //Does not exist, we need to make one
                {
                    pointOnCircle = Factory.CreateFreePoint(
                        drawingHost.CurrentDrawing,
                        new System.Windows.Point(circ.center.X + circ.radius, circ.center.Y));
                }

                //Create circle and add to drawing
                IPoint[] dependencies = { center, pointOnCircle };
                Circle   circle       = Factory.CreateCircle(drawingHost.CurrentDrawing, new List <IFigure>(dependencies));
                Actions.Add(drawingHost.CurrentDrawing, circle);

                //Save to lookup dictionary
                circles.Add(circ, circle);
            }
        }
Exemple #2
0
        /// <summary>
        /// This method is executed with the Add button is clicked.
        /// Will draw the problem and run it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            UIProblemDrawer drawer  = UIProblemDrawer.getInstance();
            ActualProblem   problem = problems[problemsBox.SelectedValue as string];

            //Create the problem description from the actual problem
            UIProblemDrawer.ProblemDescription desc = new UIProblemDrawer.ProblemDescription();
            desc.Points   = problem.parser.implied.allFigurePoints;
            desc.Segments = problem.segments;
            desc.Circles  = problem.circles;
            //Decide if there is a region to shade
            ActualShadedAreaProblem saProb = problem as ActualShadedAreaProblem;

            if (saProb != null)
            {
                desc.Regions = saProb.goalRegions;
            }
            else
            {
                desc.Regions = null;
            }

            //Draw the problem
            drawer.reset();
            drawer.clear();
            drawer.draw(desc);

            //Run the problem
            problem.Run();

            Close();
        }
        public UIProblemDrawer.ProblemDescription MakeUIProblemDescription()
        {
            UIProblemDrawer.ProblemDescription desc = new UIProblemDrawer.ProblemDescription();

            desc.Points = this.points;
            desc.Segments = this.segments;
            desc.Circles = this.circles;
            desc.Regions = this.goalRegions;

            return desc;
        }
        public UIProblemDrawer.ProblemDescription MakeUIProblemDescription()
        {
            UIProblemDrawer.ProblemDescription desc = new UIProblemDrawer.ProblemDescription();

            desc.Points   = this.points;
            desc.Segments = this.segments;
            desc.Circles  = this.circles;
            desc.Regions  = this.goalRegions;

            return(desc);
        }
Exemple #5
0
 /// <summary>
 /// If the problem is a shaded area problem, shade the goal regions.
 /// </summary>
 /// <param name="problem">The problem being drawn.</param>
 private void shadeProblem(UIProblemDrawer.ProblemDescription problem)
 {
     if (problem.Regions != null)
     {
         //Shade each region
         foreach (var region in problem.Regions)
         {
             ShadedRegion sr = new ShadedRegion(region);
             sr.Draw(drawingHost.CurrentDrawing, ShadedRegion.BRUSHES[1]);
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// Draw each point in the problem and save it to the lookup dictionary.
        /// </summary>
        /// <param name="problem">The problem being drawn.</param>
        private void drawPoints(UIProblemDrawer.ProblemDescription problem)
        {
            //Add each point to the drawing
            foreach (var pt in problem.Points)
            {
                //Create and add the point
                var point = Factory.CreateFreePoint(drawingHost.CurrentDrawing, new System.Windows.Point(pt.X, pt.Y));
                point.Name = pt.name;
                Actions.Add(drawingHost.CurrentDrawing, point);

                //Save to lookup dictionary
                points.Add(pt, point);
            }
        }
Exemple #7
0
        /// <summary>
        /// Draw the given problem to the drawing.
        /// </summary>
        /// <param name="problem">The problem to draw.</param>
        public void draw(UIProblemDrawer.ProblemDescription problem)
        {
            // Reset to create the dictionaries.
            reset();

            //Draw the hard-coded problem.
            try
            {
                drawPoints(problem);
                drawSegments(problem);
                drawCircles(problem);

                shadeProblem(problem);
            } catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message + " " + e.StackTrace);
            }
        }
Exemple #8
0
        /// <summary>
        /// Draw each segment in the problem and save it to the lookup dictionary.
        /// </summary>
        /// <param name="problem">The problem being drawn.</param>
        private void drawSegments(UIProblemDrawer.ProblemDescription problem)
        {
            //Add each segment to the drawing
            foreach (var seg in problem.Segments)
            {
                if (seg != null)
                {
                    //Look already drawn points
                    var pt1 = points[seg.Point1];
                    var pt2 = points[seg.Point2];

                    //Create and add the segment
                    var segment = Factory.CreateSegment(drawingHost.CurrentDrawing, pt1, pt2);
                    Actions.Add(drawingHost.CurrentDrawing, segment);

                    //Save to lookup dictionary
                    segments.Add(seg, segment);
                }
            }
        }
Exemple #9
0
 /// <summary>
 /// Async invocation of draw on the UI thread.
 /// </summary>
 /// <param name="desc">The problem to draw.</param>
 public void invokeDraw(UIProblemDrawer.ProblemDescription desc)
 {
     SmartDispatcher.BeginInvoke(() => draw(desc));
 }