Exemple #1
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            var G = e.Graphics;

            G.Clear(Color.Black);
            G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            G.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;


            for (int i = 0; i < 5; i++)
            {
                TestFrameLoader.RunPendulum();
                TestFrameLoader.RunPendulumInt();

                //TestFrameLoader.Compare();
            }

            float F1 = TestFrameLoader.RunPendulum();
            float F2 = TestFrameLoader.RunPendulum2();

            float iF1 = (float)TestFrameLoader.RunPendulumInt();
            float iF2 = (float)TestFrameLoader.RunPendulum2Int();

            // F1 *= 6.283f  / ((float)(1 <<24)) ;
            // F2 *= 6.283f / ((float)(1 << 24));

            F1  /= (float)0xffff;
            F2  /= (float)0xffff;
            iF1 *= 1.0f / (float)(1 << 25);
            iF2 *= 1.0f / (float)(1 << 25);



            FloatDisp.Update(F1, F2);
            IntDisp.Update(iF1, iF2);

            FloatDisp.Render(G, 10, 0);
            IntDisp.Render(G, 620, 0);

            float S = (float)Math.Min(pictureBox1.Width / ((10 + 5.08 * 12)), pictureBox1.Height / (10 + 128.5));
            //S = 1.0f / S;
            float S2 = 1.0f / S;

            G.ScaleTransform(S, S);
            G.TranslateTransform(5, 5);
            float H  = 128.5f;
            float Hi = 106.5f;
            float W  = (5.08f * 12);
            float R  = 1.5f;

            G.DrawRectangle(new Pen(Color.Gray, S2), 0, (H - Hi) / 2, W, Hi);
            G.DrawRectangle(new Pen(Color.White, S2), 0, 0, W, H);

            float x1 = -6;
            float x2 = (W - x1);
            float W1 = W / 2 - R * 2;
            float y1 = H - 2.54f - 11;

            //    string RR = "";
            //  List<string> dnames = new List<string>{ "d10", "d11", "d33", "d4", "d5", "d6", "d7", "d8", "d9" };
            for (int i = 0; i < 9; i++)
            {
                float p  = (i * 3.1415f) / 19.0f - 0.1f;
                float cx = -(float)Math.Sin(p) * W1;
                float sx = (float)Math.Cos(p) * W1;

                int lA = TestFrameLoader.GetWobbleLed(i, 0);
                int lB = TestFrameLoader.GetWobbleLed(i, 1);
                G.FillEllipse(new SolidBrush(Color.FromArgb(lA, 0, 0)), x1 + sx - R, y1 + cx - R, R * 2, R * 2);
                G.FillEllipse(new SolidBrush(Color.FromArgb(lB, 0, 0)), W - (x1 + sx) - R, y1 + cx - R, R * 2, R * 2);


                G.DrawEllipse(new Pen(Color.Yellow, S2), x1 + sx - R, y1 + cx - R, R * 2, R * 2);
                G.DrawEllipse(new Pen(Color.Yellow, S2), W - (x1 + sx) - R, y1 + cx - R, R * 2, R * 2);
//                RR += String.Format("MOVE D{0} ({1} {2}); ", i + 24, (x1 + sx).ToString().Replace(',','.'), (H*2 - ( y1 + cx)).ToString().Replace(',', '.'));
//              RR += String.Format("MOVE {0} ({1} {2}); ", dnames[i], (W - (x1 + sx)).ToString().Replace(',', '.'), (H * 2 - (y1 + cx)).ToString().Replace(',', '.'));
            }
            //     Console.WriteLine(RR);
            //MessageBox.Show(RR);
        }