Ignore:
Timestamp:
2015-02-18T17:29:19+13:00 (9 years ago)
Author:
cct9
Message:

Reworking of pictureBox Paint event so it is using double-buffering correctly without background-erase issue

Location:
other-projects/fft-ddr/summer-2014/trunk/FFDDR
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • other-projects/fft-ddr/summer-2014/trunk/FFDDR/Form1.Designer.cs

    r29735 r29750  
    2929        private void InitializeComponent()
    3030        {
    31             this.mainScreen = new System.Windows.Forms.PictureBox();
    32             this.beatBox = new System.Windows.Forms.PictureBox();
    33             this.beatBox1 = new System.Windows.Forms.PictureBox();
    34             this.screen = new System.Windows.Forms.PictureBox();
    35             this.screen2 = new System.Windows.Forms.PictureBox();
    36             ((System.ComponentModel.ISupportInitialize)(this.mainScreen)).BeginInit();
    37             ((System.ComponentModel.ISupportInitialize)(this.beatBox)).BeginInit();
    38             ((System.ComponentModel.ISupportInitialize)(this.beatBox1)).BeginInit();
    39             ((System.ComponentModel.ISupportInitialize)(this.screen)).BeginInit();
    40             ((System.ComponentModel.ISupportInitialize)(this.screen2)).BeginInit();
     31            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FFDDR));
     32            this.mainScreen1 = new System.Windows.Forms.PictureBox();
     33            this.redLabel = new System.Windows.Forms.Label();
     34            this.blueLabel = new System.Windows.Forms.Label();
     35            this.greenLabel = new System.Windows.Forms.Label();
     36            this.yellowLabel = new System.Windows.Forms.Label();
     37            ((System.ComponentModel.ISupportInitialize)(this.mainScreen1)).BeginInit();
    4138            this.SuspendLayout();
    4239            //
    43             // mainScreen
     40            // mainScreen1
    4441            //
    45             this.mainScreen.Location = new System.Drawing.Point(417, 12);
    46             this.mainScreen.Name = "mainScreen";
    47             this.mainScreen.Size = new System.Drawing.Size(292, 260);
    48             this.mainScreen.TabIndex = 1;
    49             this.mainScreen.TabStop = false;
     42            this.mainScreen1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("mainScreen1.BackgroundImage")));
     43            this.mainScreen1.Location = new System.Drawing.Point(0, 0);
     44            this.mainScreen1.Name = "mainScreen1";
     45            this.mainScreen1.Size = new System.Drawing.Size(1187, 561);
     46            this.mainScreen1.TabIndex = 6;
     47            this.mainScreen1.TabStop = false;
    5048            //
    51             // beatBox
     49            // redLabel
    5250            //
    53             this.beatBox.Location = new System.Drawing.Point(-2, -3);
    54             this.beatBox.Name = "beatBox";
    55             this.beatBox.Size = new System.Drawing.Size(67, 566);
    56             this.beatBox.TabIndex = 2;
    57             this.beatBox.TabStop = false;
     51            this.redLabel.AutoSize = true;
     52            this.redLabel.BackColor = System.Drawing.Color.Transparent;
     53            this.redLabel.Font = new System.Drawing.Font("Moire", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     54            this.redLabel.ForeColor = System.Drawing.Color.Red;
     55            this.redLabel.Location = new System.Drawing.Point(12, 37);
     56            this.redLabel.Name = "redLabel";
     57            this.redLabel.Size = new System.Drawing.Size(29, 29);
     58            this.redLabel.TabIndex = 7;
     59            this.redLabel.Text = "0";
    5860            //
    59             // beatBox1
     61            // blueLabel
    6062            //
    61             this.beatBox1.Location = new System.Drawing.Point(1060, -3);
    62             this.beatBox1.Name = "beatBox1";
    63             this.beatBox1.Size = new System.Drawing.Size(54, 566);
    64             this.beatBox1.TabIndex = 3;
    65             this.beatBox1.TabStop = false;
     63            this.blueLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     64            this.blueLabel.AutoSize = true;
     65            this.blueLabel.BackColor = System.Drawing.Color.Transparent;
     66            this.blueLabel.Font = new System.Drawing.Font("Moire", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     67            this.blueLabel.ForeColor = System.Drawing.Color.Aqua;
     68            this.blueLabel.Location = new System.Drawing.Point(1143, 37);
     69            this.blueLabel.Name = "blueLabel";
     70            this.blueLabel.Size = new System.Drawing.Size(29, 29);
     71            this.blueLabel.TabIndex = 8;
     72            this.blueLabel.Text = "0";
    6673            //
    67             // screen
     74            // greenLabel
    6875            //
    69             this.screen.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    70             this.screen.Location = new System.Drawing.Point(71, 12);
    71             this.screen.Name = "screen";
    72             this.screen.Size = new System.Drawing.Size(330, 330);
    73             this.screen.TabIndex = 4;
    74             this.screen.TabStop = false;
     76            this.greenLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     77            this.greenLabel.AutoSize = true;
     78            this.greenLabel.BackColor = System.Drawing.Color.Transparent;
     79            this.greenLabel.Font = new System.Drawing.Font("Moire", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     80            this.greenLabel.ForeColor = System.Drawing.Color.Lime;
     81            this.greenLabel.Location = new System.Drawing.Point(1143, 489);
     82            this.greenLabel.Name = "greenLabel";
     83            this.greenLabel.Size = new System.Drawing.Size(29, 29);
     84            this.greenLabel.TabIndex = 9;
     85            this.greenLabel.Text = "0";
    7586            //
    76             // screen2
     87            // yellowLabel
    7788            //
    78             this.screen2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    79             this.screen2.Location = new System.Drawing.Point(724, 12);
    80             this.screen2.Name = "screen2";
    81             this.screen2.Size = new System.Drawing.Size(330, 330);
    82             this.screen2.TabIndex = 5;
    83             this.screen2.TabStop = false;
     89            this.yellowLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     90            this.yellowLabel.AutoSize = true;
     91            this.yellowLabel.BackColor = System.Drawing.Color.Transparent;
     92            this.yellowLabel.Font = new System.Drawing.Font("Moire", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     93            this.yellowLabel.ForeColor = System.Drawing.Color.Yellow;
     94            this.yellowLabel.Location = new System.Drawing.Point(12, 489);
     95            this.yellowLabel.Name = "yellowLabel";
     96            this.yellowLabel.Size = new System.Drawing.Size(29, 29);
     97            this.yellowLabel.TabIndex = 10;
     98            this.yellowLabel.Text = "0";
    8499            //
    85100            // FFDDR
     
    87102            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    88103            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     104            this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
    89105            this.ClientSize = new System.Drawing.Size(1184, 561);
    90             this.Controls.Add(this.screen2);
    91             this.Controls.Add(this.screen);
    92             this.Controls.Add(this.beatBox1);
    93             this.Controls.Add(this.beatBox);
    94             this.Controls.Add(this.mainScreen);
     106            this.Controls.Add(this.yellowLabel);
     107            this.Controls.Add(this.greenLabel);
     108            this.Controls.Add(this.blueLabel);
     109            this.Controls.Add(this.redLabel);
     110            this.Controls.Add(this.mainScreen1);
     111            this.DoubleBuffered = true;
    95112            this.Name = "FFDDR";
    96113            this.Text = "FFDDR";
    97114            this.Load += new System.EventHandler(this.FFDDR_Load);
    98             ((System.ComponentModel.ISupportInitialize)(this.mainScreen)).EndInit();
    99             ((System.ComponentModel.ISupportInitialize)(this.beatBox)).EndInit();
    100             ((System.ComponentModel.ISupportInitialize)(this.beatBox1)).EndInit();
    101             ((System.ComponentModel.ISupportInitialize)(this.screen)).EndInit();
    102             ((System.ComponentModel.ISupportInitialize)(this.screen2)).EndInit();
     115            this.Resize += new System.EventHandler(this.FFDDR_Resize);
     116            ((System.ComponentModel.ISupportInitialize)(this.mainScreen1)).EndInit();
    103117            this.ResumeLayout(false);
     118            this.PerformLayout();
    104119
    105120        }
     
    107122        #endregion
    108123
    109         private System.Windows.Forms.PictureBox mainScreen;
    110         private System.Windows.Forms.PictureBox beatBox;
    111         private System.Windows.Forms.PictureBox beatBox1;
    112         private System.Windows.Forms.PictureBox screen;
    113         private System.Windows.Forms.PictureBox screen2;
     124        private System.Windows.Forms.PictureBox mainScreen1;
     125        private System.Windows.Forms.Label redLabel;
     126        private System.Windows.Forms.Label blueLabel;
     127        private System.Windows.Forms.Label greenLabel;
     128        private System.Windows.Forms.Label yellowLabel;
    114129    }
    115130}
  • other-projects/fft-ddr/summer-2014/trunk/FFDDR/Form1.cs

    r29736 r29750  
    1414using MicroLibrary;
    1515using System.IO;
    16 
     16using System.Diagnostics;
     17
     18using System.Drawing.Drawing2D;
    1719
    1820namespace FFDDR
    1921{
     22   
     23
    2024    public partial class FFDDR : Form
    2125    {
     
    4347
    4448        private PictureBox[] pboxShowCalibrated;
    45        
     49
    4650        private Vector4 centreScreen;
    4751        private bool twoPlayer = false;
    4852        private float deadspotSize = 50;
    49 
     53        private int circleRadius = 400;
     54
     55        private float footSize = 30, defaultFootSize = 20, enlargedFootSize = 70;
     56
     57        float defaultScreenHeight;
     58        float backgroundScaler = 0.4f;
     59
     60        int quadrentLeft, quadrentRight;
     61
     62
     63       
     64        int blueScore = 0, redScore = 0, yellowScore = 0, greenScore = 0;
     65
     66        private float xCoordLeft, yCoordLeft, xCoordRight, yCoordRight;
     67        List<FootStep> footstepList;
     68        BeatPicturebox mainScreen;
     69        int colourChanger = 0;
    5070
    5171        public FFDDR()
     
    5777        {
    5878            #region Beat detect
     79
     80            defaultScreenHeight = this.Height;
     81            //scoreLabel.Left = (int)(0.7f * (float)this.Width);
     82            //scoreLabel.
     83            //label1.Font.SizeInPoints = 5;
    5984
    6085            // The song to convert + read
     
    6287            output = new WaveOut();
    6388            output.Init(reader);
    64             output.Play();
    65             graphics = mainScreen.CreateGraphics();
    66 
     89            //output.Play();
     90            //graphics = mainScreen.CreateGraphics();
     91            mainScreen = new BeatPicturebox();
     92            mainScreen.Left = 0;
     93            mainScreen.Top = 0;
     94            mainScreen.Width = mainScreen1.Width;
     95            mainScreen.Height = mainScreen1.Height;
     96            this.Controls.Add(mainScreen);
     97
     98            mainScreen.BringToFront();
     99            mainScreen.BackColor = Color.Transparent;//(Color)ColorTranslator.FromHtml("#353535");
     100
     101           
    67102            this.DoubleBuffered = true;
    68103
     
    70105            wavInfo = WavProcessor.ReadWav(@"C:\Users\Chris\Downloads\", "become", 1024, 30);
    71106
    72            
     107
    73108
    74109            // Play one buffer every (songLength/temp.length(numbuffer)) milliseconds. Both values are contained in the Json string[]
     
    81116            // timer.IgnoreEventIfLateBy = (int)((temp.songLength / wavInfo.Length) )/ 4;
    82117
    83             timer.Enabled = true;
     118            //timer.Enabled = true;
    84119            timer.MicroTimerElapsed += new MicroTimer.MicroTimerElapsedEventHandler(timerTick);
     120
     121            footstepList = new List<FootStep>();
    85122
    86123            #endregion
     
    123160
    124161            skeletonManager = new SkeletonManager(6);
    125             graphics = screen.CreateGraphics();
    126             centreScreen.X = screen.Width / 2;
    127             centreScreen.Z = screen.Height / 2;
     162            graphics = mainScreen.CreateGraphics();
     163            centreScreen.X = mainScreen.Width / 2;
     164            centreScreen.Z = mainScreen.Height / 2;
     165
     166            mainScreen.Paint += screen1_Paint;
    128167
    129168            #region Display pictureboxes showing calibration information
     
    142181            }
    143182            #endregion
    144         }
    145 
    146         private void timerTick(object sender, MicroTimerEventArgs args)
    147         {
    148             timeSinceLastBeat++;
    149             wavFrameIncrement++;
    150 
    151             if (mainScreen.InvokeRequired)
    152             {
    153                 //mainScreen.Invoke(new MethodInvoker(delegate { mainScreen.Refresh(); }));
    154                 mainScreen.Invoke(new MethodInvoker(delegate { mainScreen.CreateGraphics().FillRectangle(new SolidBrush(Color.White), 0, 0, mainScreen.Width, mainScreen.Height); }));
    155             }
    156 
    157            
    158 
     183
     184            redLabel.BringToFront();
     185            blueLabel.BringToFront();
     186            greenLabel.BringToFront();
     187            yellowLabel.BringToFront();
     188            /*
     189            blueLabel = new Label();
     190            redLabel = new Label();
     191            greenLabel = new Label();
     192            yellowLabel = new Label();
     193
     194            blueLabel.Font = new Font("Microsoft Sans Serif", 20);
     195            redLabel.Font = new Font("Microsoft Sans Serif", 20);
     196            greenLabel.Font = new Font("Microsoft Sans Serif", 20);
     197            yellowLabel.Font = new Font("Microsoft Sans Serif", 20);
     198            redLabel.BackColor = Color.Red;
     199
     200            redLabel.Left = (int)(10);
     201            blueLabel.Left = (int)(0.8f * mainScreen.Width);
     202            yellowLabel.Left = (int)(0.2f * mainScreen.Width);
     203            greenLabel.Left = (int)(0.8f * mainScreen.Width);
     204
     205            redLabel.Top = (int)(10);
     206            blueLabel.Top = (int)(0.1 * mainScreen.Height);
     207            yellowLabel.Top = (int)(0.85 * mainScreen.Height);
     208            greenLabel.Top = (int)(0.85 * mainScreen.Height);
     209
     210            redLabel.BringToFront();
     211            redLabel.Visible = true;
     212            redLabel.Enabled = true;
     213            label1.BringToFront();
     214            redLabel.Text = "Test";
     215
     216           
     217            redLabel.Location = new System.Drawing.Point(10,10 );
     218            redLabel.Name = "redLabel";
     219            redLabel.Size = new System.Drawing.Size(173, 20);
     220           
    159221            // When song finished this is out of bounds. fix this.
    160222            WavFrame currentFrame = (WavFrame)JsonConvert.DeserializeObject<WavFrame>(wavInfo[wavFrameIncrement]);
    161223            for (int j = 0; j < currentFrame.bandPowers.Length; j++)
    162224            {
    163                 // Calling control change drawing beat visualizer bands) from another thread.
     225                colourChanger++;
     226                timeSinceLastBeat++;
     227                wavFrameIncrement++;
     228                /*
    164229                if (mainScreen.InvokeRequired)
    165230                {
    166                     mainScreen.Invoke(new MethodInvoker(delegate { mainScreen.CreateGraphics().DrawRectangle(new Pen(Color.DarkBlue), j * 15, 0, 10, 6 * currentFrame.bandPowers[j]); }));
    167                 }
    168             }
    169 
    170             // If a beat exists on the current frame, display it via BeatBox
    171             if (currentFrame.beatExists == true)
    172             {
    173                 if (beatBox.InvokeRequired)
    174                 {
    175                     beatBox.Invoke(new MethodInvoker(delegate { ChangeBeatBox(); }));
    176 
    177                 }
    178 
     231                    //mainScreen.Invoke(new MethodInvoker(delegate { mainScreen.Refresh(); }));
     232                    mainScreen.Invoke(new MethodInvoker(delegate { mainScreen.CreateGraphics().FillRectangle(new SolidBrush(Color.White), 0, 0, mainScreen.Width, mainScreen.Height); }));
     233                }
     234
     235
     236                */
     237
     238                if (colourChanger >= 75)
     239                {
     240
     241                    colourChanger = 0;
     242                    Random random = new Random();
     243                    if (random.Next(0, 2) == 1)
     244                    {
     245                        quadrentRight = random.Next(0, 5);
     246                    }
     247                    else
     248                    {
     249                        quadrentLeft = random.Next(0, 5);
     250                    }
     251
     252                }
     253
     254                if (footSize > defaultFootSize)
     255                {
     256                    footSize *= 0.92f;
     257                    if (footSize < defaultFootSize) footSize = defaultFootSize;
     258                }
     259
     260                for (int i = 0; i < footstepList.Count; i++)
     261                {
     262                    footstepList[i].radius *= 1.05f;
     263                    if (footstepList[i].radius > enlargedFootSize) footstepList.Remove(footstepList[i]);
     264                }
     265
     266
     267                    if (wavInfo.Length > wavFrameIncrement)
     268                    {
     269                        WavFrame currentFrame = (WavFrame)JsonConvert.DeserializeObject<WavFrame>(wavInfo[wavFrameIncrement]);
     270
     271                        /*
     272                        for (int j = 0; j < currentFrame.bandPowers.Length; j++)
     273                        {
     274                            // Calling control change drawing beat visualizer bands) from another thread.
     275                            if (mainScreen.InvokeRequired)
     276                            {
     277                                mainScreen.Invoke(new MethodInvoker(delegate { mainScreen.CreateGraphics().DrawRectangle(new Pen(Color.DarkBlue), j * 15, 0, 10, 6 * currentFrame.bandPowers[j]); }));
     278                            }
     279                        }
     280                        */
     281                        // If a beat exists on the current frame, display it via BeatBox
     282
     283                        if (currentFrame.beatExists == true)
     284                        {
     285                            ChangeBeatBox();
     286
     287                        }
     288
     289                    }
     290                    else System.Environment.Exit(1);
     291            }
     292            catch
     293            {
     294                System.Environment.Exit(1);
    179295            }
    180296        }
     
    184300
    185301            // Alternate the box which chanhges to the beat.
    186             graphics = mainScreen.CreateGraphics();
     302            //graphics = mainScreen.CreateGraphics();
     303
     304           
    187305
    188306            if (timeSinceLastBeat >= 20)
    189307            {
     308               
     309
     310                /*
    190311                beatBoxChanger++;
    191312                timeSinceLastBeat = 0;
     
    202323                }
    203324                else p.BackColor = Color.DarkBlue;
     325                */
     326
     327                //footSize = enlargedFootSize;
     328                footstepList.Add(new FootStep((float)defaultFootSize, xCoordLeft, yCoordLeft));
     329                footstepList.Add(new FootStep((float)defaultFootSize, xCoordRight, yCoordRight));
     330                timeSinceLastBeat = 0;
    204331            }
    205332        }
     
    208335        {
    209336            skeletonArray = new Skeleton[0];
    210 
     337           
    211338            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
    212339            {
     
    223350                    //screen2.Refresh();
    224351
    225                    
     352
    226353                    twoPlayer = false;
    227354                    for (int i = 0; i < skeletonArray.Length; i++)
    228355                    {
    229                         if (skeletonManager.calibrated[i] == false) skeletonManager.Calibrate(i);
     356                        if (skeletonManager.calibrated[i] == false)
     357                        {
     358                            if (skeletonManager.Calibrate(i) == 1)
     359                            {
     360                                output.Play();
     361                                timer.Enabled = true;
     362                            }
     363                        }
    230364
    231365                        if (skeletonManager.calibrated[i] == true)
     
    235369                            {
    236370                                skeletonManager.calibrated[i] = false;
    237                                 pboxShowCalibrated[i].BackColor = Color.DarkGray;
     371                                //pboxShowCalibrated[i].BackColor = Color.DarkGray;
    238372                            }
    239373                            else
    240374                            {
    241 
    242                                 pboxShowCalibrated[i].BackColor = Color.Cyan;
    243                                 if (twoPlayer == false) graphics = screen.CreateGraphics();
    244                                 else graphics = screen2.CreateGraphics();
    245 
     375                               
     376                                //pboxShowCalibrated[i].BackColor = Color.Cyan;
     377                                //if (twoPlayer == false) graphics = screen.CreateGraphics();
     378                                //else graphics = screen2.CreateGraphics();
     379                                //graphics = mainScreen.CreateGraphics();
     380                                //mainScreen.g
    246381                                twoPlayer = true;
    247 
    248                                 int quadrentLeft = skeletonManager.FindQuadrant(skeletonManager.leftFoot[i].Z, skeletonManager.leftFoot[i].X, skeletonManager.centre[i]);
    249                                 int quadrentRight = skeletonManager.FindQuadrant(skeletonManager.rightFoot[i].Z, skeletonManager.rightFoot[i].X, skeletonManager.centre[i]);
    250 
    251                                 graphics.FillRectangle(new SolidBrush(Color.White), 0, 0, screen.Width, screen.Height);
    252 
    253                                 DrawQuadrent(quadrentLeft, graphics);
    254                                 DrawQuadrent(quadrentRight, graphics);
    255 
    256                                 float xCoordLeft = centreScreen.X + (skeletonManager.leftFoot[i].X - skeletonManager.centre[i].X) * (screen.Width / 2) / 0.8f;
    257                                 float yCoordLeft = centreScreen.Z + (skeletonManager.leftFoot[i].Z - skeletonManager.centre[i].Z) * (screen.Height / 2) / 0.8f;
    258                                 float xCoordRight = centreScreen.X + (skeletonManager.rightFoot[i].X - skeletonManager.centre[i].X) * (screen.Width / 2) / 0.8f;
    259                                 float yCoordRight = centreScreen.Z + (skeletonManager.rightFoot[i].Z - skeletonManager.centre[i].Z) * (screen.Height / 2) / 0.8f;
    260 
    261 
    262 
    263                                 graphics.DrawRectangle(new Pen(Color.Black),
    264                                     (int)(xCoordLeft),
    265                                     (int)(yCoordLeft),
    266                                     20, 20);
    267 
    268                                 graphics.DrawRectangle(new Pen(Color.Black),
    269                                     (int)(xCoordRight),
    270                                     (int)(yCoordRight),
    271                                     20, 20);
    272 
    273 
     382                               
     383                                int playerQuadrentLeft = skeletonManager.FindQuadrant(skeletonManager.leftFoot[i].Z, skeletonManager.leftFoot[i].X, skeletonManager.centre[i]);
     384                                int playerQuadrentRight = skeletonManager.FindQuadrant(skeletonManager.rightFoot[i].Z, skeletonManager.rightFoot[i].X, skeletonManager.centre[i]);
     385
     386                               
     387
     388                                xCoordLeft = (centreScreen.X - footSize / 2) + (skeletonManager.leftFoot[i].X - skeletonManager.centre[i].X) * (mainScreen.Width / 2) / 1f;
     389                                yCoordLeft = (centreScreen.Z- footSize / 2) + (skeletonManager.leftFoot[i].Z - skeletonManager.centre[i].Z) * (mainScreen.Height / 2) / 1f;
     390                                xCoordRight = (centreScreen.X- footSize / 2) + (skeletonManager.rightFoot[i].X - skeletonManager.centre[i].X) * (mainScreen.Width / 2) / 1f;
     391                                yCoordRight = (centreScreen.Z- footSize / 2) + (skeletonManager.rightFoot[i].Z - skeletonManager.centre[i].Z) * (mainScreen.Height / 2) / 1f;
     392
     393                                mainScreen.Invalidate();
     394                               
     395                                //drawBackground();
    274396
    275397                            }
     
    293415        private void DrawQuadrent(int num, Graphics graphics)
    294416        {
     417           
     418
    295419            if (num == 1)
    296420            {
    297                 graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, screen.Width / 2, screen.Height / 2);
     421                drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 180, 90, "#FFFFFF", "#DE00C0");
     422                //graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, screen.Width / 2, screen.Height / 2);
    298423            }
    299424            else if (num == 2)
    300425            {
    301                 graphics.FillRectangle(new SolidBrush(Color.Blue), screen.Width / 2, 0, screen.Width / 2, screen.Height / 2);
     426                drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 270, 90, "#FFFFFF", "#00DCE8");
     427                //graphics.FillRectangle(new SolidBrush(Color.Blue), screen.Width / 2, 0, screen.Width / 2, screen.Height / 2);
    302428            }
    303429            else if (num == 3)
    304430            {
    305                 graphics.FillRectangle(new SolidBrush(Color.Green), screen.Height / 2, screen.Width / 2, screen.Width / 2, screen.Height / 2);
     431                drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 0, 90, "#FFFFFF", "#00E800");
     432               
     433                //graphics.FillRectangle(new SolidBrush(Color.Green), screen.Height / 2, screen.Width / 2, screen.Width / 2, screen.Height / 2);
    306434            }
    307435            else if (num == 4)
    308436            {
    309                 graphics.FillRectangle(new SolidBrush(Color.Yellow), 0, screen.Height / 2, screen.Width / 2, screen.Height / 2);
    310             }
    311             graphics.FillEllipse(new SolidBrush(Color.Black), screen.Width / 2 - (deadspotSize / 2), screen.Height / 2 - (deadspotSize / 2), deadspotSize, deadspotSize);
    312 
    313 
    314 
    315         }
    316 
     437                drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 90, 90, "#FFFFFF", "#E8E800");
     438                //graphics.FillRectangle(new SolidBrush(Color.Yellow), 0, screen.Height / 2, screen.Width / 2, screen.Height / 2);
     439            }
     440           
     441            //graphics.FillEllipse(new SolidBrush(Color.Black), screen.Width / 2 - (deadspotSize / 2), screen.Height / 2 - (deadspotSize / 2), deadspotSize, deadspotSize);
     442
     443
     444
     445        }
     446
     447
     448        public void screen1_Paint(object sender, PaintEventArgs e)
     449        {
     450            Graphics graphics = e.Graphics;
     451            GraphicsPath path = new GraphicsPath();
     452            //test = e.Graphics;
     453            path.AddEllipse(0, -((mainScreen.Width - mainScreen.Height) / 2), mainScreen.Width, mainScreen.Width);
     454
     455            // Create a path gradient brush based on the elliptical path.
     456            PathGradientBrush pthGrBrush = new PathGradientBrush(path);
     457
     458            // Set the color along the entire boundary to
     459            Color[] color = { (Color)ColorTranslator.FromHtml("#353535") };
     460            pthGrBrush.SurroundColors = color;
     461
     462            // Set the center color to aqua.
     463            pthGrBrush.CenterColor = (Color)ColorTranslator.FromHtml("#E8E8E8"); ;
     464
     465            // Use the path gradient brush to fill the ellipse.
     466            //graphics.FillPath(pthGrBrush, path);
     467
     468            // Set the focus scales for the path gradient brush.
     469            pthGrBrush.FocusScales = new PointF(0.4f, 0.4f);
     470
     471            // Use the path gradient brush to fill the ellipse again.
     472            // Show this filled ellipse to the right of the first filled ellipse.
     473            //graphics.TranslateTransform(220.0f, 0.0f);
     474            //e.Graphics.FillPath(pthGrBrush, path);
     475
     476           // Debug.Write("h");
     477
     478            redLabel.Text = redScore.ToString();
     479            blueLabel.Text = blueScore.ToString();
     480            yellowLabel.Text = yellowScore.ToString();
     481            greenLabel.Text = greenScore.ToString();
     482
     483            if (quadrentLeft != 1 && quadrentRight != 1) drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 180, 90, "#DE00C0", "#780068");
     484            if (quadrentLeft != 2 && quadrentRight != 2) drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 270, 90, "#000087", "#0000E8");
     485            if (quadrentLeft != 3 && quadrentRight != 3) drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 0, 90, "#008700", "#00E800");
     486            if (quadrentLeft != 4 && quadrentRight != 4) drawSegment(graphics, mainScreen.Width, mainScreen.Height, circleRadius, 90, 90, "#878700", "#E8E800");
     487           
     488
     489            DrawQuadrent(quadrentLeft, graphics);
     490            DrawQuadrent(quadrentRight, graphics);
     491
     492            for (int n = 0; n < footstepList.Count; n++)
     493            {
     494                if (n < footstepList.Count)
     495                {
     496                    graphics.DrawEllipse(new Pen(Color.Black), footstepList[n].xPos - (footstepList[n].radius / 2),
     497                        footstepList[n].yPos - (footstepList[n].radius / 2), footstepList[n].radius, footstepList[n].radius);
     498                }
     499            }
     500
     501            graphics.FillEllipse(new SolidBrush(Color.Black),
     502                (int)(xCoordLeft),
     503                (int)(yCoordLeft),
     504                 footSize, footSize);
     505
     506            graphics.FillEllipse(new SolidBrush(Color.Black),
     507                (int)(xCoordRight),
     508                (int)(yCoordRight),
     509                footSize, footSize);
     510           
     511
     512
     513        }
     514
     515        private void drawBackground()
     516        {
     517            Graphics graphics = mainScreen.CreateGraphics();
     518            GraphicsPath path = new GraphicsPath();
     519
     520            path.AddEllipse(0, -((mainScreen.Width - mainScreen.Height) / 2), mainScreen.Width, mainScreen.Width);
     521
     522            // Create a path gradient brush based on the elliptical path.
     523            PathGradientBrush pthGrBrush = new PathGradientBrush(path);
     524
     525            // Set the color along the entire boundary to
     526            Color[] color = { (Color)ColorTranslator.FromHtml("#353535") };
     527            pthGrBrush.SurroundColors = color;
     528
     529            // Set the center color to aqua.
     530            pthGrBrush.CenterColor = (Color)ColorTranslator.FromHtml("#E8E8E8"); ;
     531
     532            // Use the path gradient brush to fill the ellipse.
     533            //graphics.FillPath(pthGrBrush, path);
     534
     535            // Set the focus scales for the path gradient brush.
     536            pthGrBrush.FocusScales = new PointF(backgroundScaler, backgroundScaler);
     537
     538            // Use the path gradient brush to fill the ellipse again.
     539            // Show this filled ellipse to the right of the first filled ellipse.
     540            //graphics.TranslateTransform(220.0f, 0.0f);
     541           // graphics.FillPath(pthGrBrush, path);
     542           
     543
     544
     545        }
     546
     547        private void drawSegment(Graphics graphics, float width, float height, int radius, int startAngle, int finAngle, string innerColour, string outerColour)
     548        {
     549           
     550            //graphics.FillPie(new SolidBrush(colour), (width / 2) - (radius / 2), (height / 2) - (radius / 2), radius, radius, startAngle, finAngle);
     551
     552            // Create a path that consists of a single ellipse.
     553            GraphicsPath path = new GraphicsPath();
     554            path.AddEllipse((width / 2) - (radius / 2), (height / 2) - (radius / 2), 140, 70);
     555            path.AddPie((width / 2) - (radius / 2), (height / 2) - (radius / 2), radius, radius, startAngle, finAngle);
     556
     557            // Use the path to construct a brush.
     558            PathGradientBrush pthGrBrush = new PathGradientBrush(path);
     559
     560            // Set the center point to a location that is not
     561            // the centroid of the path.
     562            pthGrBrush.CenterPoint = new PointF((width / 2), (height / 2));
     563
     564            //orange
     565
     566            // Set the color at the center of the path to blue.
     567
     568            pthGrBrush.CenterColor = (Color)ColorTranslator.FromHtml(innerColour);
     569
     570            // Set the color along the entire boundary 
     571            // of the path to aqua.
     572            Color[] colors = { (Color)ColorTranslator.FromHtml(outerColour) };
     573            pthGrBrush.SurroundColors = colors;
     574
     575            //graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70);
     576            graphics.FillPie(pthGrBrush, (width / 2) - (radius / 2), (height / 2) - (radius / 2), radius, radius, startAngle, finAngle);
     577
     578        }
     579        /*
     580        private void FFDDR_ResizeEnd(object sender, EventArgs e)
     581        {
     582            mainScreen.Left = 0;
     583            mainScreen.Height = this.Height;
     584            mainScreen.Top = 0;
     585            mainScreen.Width = this.Width;
     586
     587            drawBackground();
     588        }
     589        */
     590        private void FFDDR_Resize(object sender, EventArgs e)
     591        {
     592            mainScreen.Left = 0;
     593            mainScreen.Height = this.Height;
     594            mainScreen.Top = 0;
     595            mainScreen.Width = this.Width;
     596
     597            drawBackground();
     598        }
     599    }
     600    public class FootStep
     601    {
     602        public float radius;
     603        public float xPos, yPos;
     604
     605        public FootStep(float Radius, float XPos, float YPos)
     606        {
     607            radius = Radius;
     608            xPos = XPos;
     609            yPos = YPos;
     610        }
    317611    }
    318612}
  • other-projects/fft-ddr/summer-2014/trunk/FFDDR/SkeletonManager.cs

    r29735 r29750  
    6161        }
    6262
    63         public void Calibrate(int skeletonNo)
     63        public int Calibrate(int skeletonNo)
    6464        {
    6565            if(calibrated[skeletonNo] == false && calibrating[skeletonNo] == false &&
     
    7474                calibrating[skeletonNo] = false;
    7575                calibrated[skeletonNo] = true;
     76                return 1;
    7677            }
     78            return 0;
    7779        }
    7880
Note: See TracChangeset for help on using the changeset viewer.