Пример #1
0
        public void DrawPreview()
        {
            pltStructure structureOld =new pltStructure(PloterPen.up,0,0);
            pltStructure structureNew =new pltStructure();

            forma.ClearLog();
            forma.log("Nr of Commands:"+IloscKomend.ToString());
            //forma.log("Xmin:"+ MinX.ToString( )+" Ymin:"+MinY.ToString( ));
            forma.log("Xmax:" + pictureMaxX.ToString() + " Ymax:" + pictureMaxY.ToString());
            g.Clear(Color.Black);
            rysujPoleRysowania();
            forma.checkedListBox1.Items.Clear();
            NrNastepnaKomenda = 0;

            while (structureNew.Pen!=PloterPen.end)
            {
                structureNew = GetNextCommand1(false);
                forma.progressBar1.Value = NrNastepnaKomenda;
                forma.progressBar1.Refresh();
                Application.DoEvents();

                if (structureNew.Pen== PloterPen.up )
                {
                    //g.DrawLine(Pens.WhiteSmoke, map(structureOld.X, 0, 10000, 0, 1000), map(structureOld.Y, 0, 10000, 1000, 0), map(structureNew.X, 0, 10000, 0, 1000), map(structureNew.Y, 0, 10000, 1000, 0));
                }

                if (structureNew.Pen == PloterPen.down)
                {
                    g.DrawLine(Pens.Yellow , map(structureOld.X, 0, 10000, 0, 1000), map(structureOld.Y, 0, 10000, 1000, 0), map(structureNew.X, 0, 10000, 0, 1000), map(structureNew.Y, 0, 10000, 1000, 0));
                }
                structureOld = structureNew;
                // forma.pictureBox1.Image = bmp;
            }

            NrNastepnaKomenda = 0;
            forma.pictureBox1.Image   = bmp;
        }
Пример #2
0
        private bool draw(bool first)
        {
            pltStructure dane = new pltStructure();
            dane = plt.GetNextCommand1(false);

            if (dane.Pen == PloterPen.end)
            {
                arduino.SetPosition(PenUp, Speed, 0, 0, first);
               return  false;
            }

            switch (dane.Pen)
            {
                case PloterPen.up:
                    arduino.SetPosition(PenUp, Speed, dane.X, dane.Y, first);
                   break;
                case PloterPen.down:
                   arduino.SetPosition(PenDown, Speed, dane.X, dane.Y, first);
                   break;

            }
            return true;
        }
Пример #3
0
        private void FindMinXandMinY()
        {
            pictureMinX = 0;
            pictureMinY = 0;
            pictureMaxX = 0;
            pictureMaxY = 0;

            pltStructure structureNew = new pltStructure();
            while (structureNew.Pen != PloterPen.end)
            {
                structureNew = GetNextCommand1(false);
                if (structureNew.X < pictureMinX)
                {
                    pictureMinX = structureNew.X;
                }
                if (structureNew.Y < pictureMinY)
                {
                    pictureMinY = structureNew.Y;
                }

                if (structureNew.X > pictureMaxX)
                {
                    pictureMaxX = structureNew.X;
                }
                if (structureNew.Y > pictureMaxY)
                {
                    pictureMaxY = structureNew.Y;
                }
            }
        }