Esempio n. 1
0
        private void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.D:
                foreach (var fig in MarkedFigures)
                {
                    DrawnFigureList.Remove(fig);
                }
                MarkedFigures = new List <Figure>();
                RefreshAndDrawFigures();
                break;

            case Key.M:
                Polygon newRandom = Quickhull.CreateConvexPolygon(0, bottomBitmap.Width, 0, bottomBitmap.Height);
                newRandom.FillColor   = System.Drawing.Color.FromArgb(100, 255, 0, 0);
                newRandom.FillTexture = RandomFiguresFillTexture;
                newRandom.BumpMap     = RandomFiguresBumpMap;
                newRandom             = new RandomPolygon(newRandom);
                (newRandom as RandomPolygon).Speed = ReturnRandomSpeed();
                RandomFigureList.Add(newRandom);
                DrawRandomFigures();
                break;

            case Key.K:
                Polygon[] temp = WeilerAtherton.PerformAlgorithm(DrawnFigureList[0] as Polygon, DrawnFigureList[1] as Polygon);
                DrawnFigureList = new List <Figure>();
                DrawnFigureList.AddRange(temp);
                RefreshAndDrawFigures();
                break;

            case Key.Y:
                foreach (var fig in DrawnFigureList)
                {
                    fig.Fill(CurrentBitmap, LightColor, new Vector3D(XLightCoord, YLightCoord, LightHeight));
                    fig.Draw(CurrentBitmap);
                    BottomImage.Source = loadBitmap(CurrentBitmap);
                }
                break;
            }
        }
Esempio n. 2
0
        private void TimerEventProcessor(object myObject, EventArgs myEventArgs)
        {
            if (RandomFigureList.Count == 0)
            {
                return;
            }
            List <Figure> ListToRemove = new List <Figure>();

            foreach (var figure in RandomFigureList)
            {
                bool    toRemove = true;
                Polygon polygon  = figure as Polygon;
                double  speed    = (polygon as RandomPolygon).Speed;
                (polygon as RandomPolygon).WayGone += speed;
                figure.MoveFigure(new Point(-speed, 0));
                foreach (var segment in polygon.segmentList)
                {
                    if (segment.pointA.X >= 0)
                    {
                        toRemove = false;
                        break;
                    }
                }
                if (toRemove)
                {
                    ListToRemove.Add(figure);
                }
            }
            IntersectionFigureList.AddRange(FindAllIntersectionPolygons());
            foreach (var fig in ListToRemove)
            {
                RandomFigureList.Remove(fig);
            }
            DrawRandomFigures();
            FillIntersectionFigures();
            IntersectionFigureList = new List <Figure>();
        }