IdwTest/MainForm.cs
changeset 4 328515997e35
child 5 d16669f69f0d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/IdwTest/MainForm.cs	Mon Apr 21 12:02:38 2014 +0200
     1.3 @@ -0,0 +1,106 @@
     1.4 +using System;
     1.5 +using System.Collections.Generic;
     1.6 +using System.ComponentModel;
     1.7 +using System.Data;
     1.8 +using System.Drawing;
     1.9 +using System.Linq;
    1.10 +using System.Text;
    1.11 +using System.Threading.Tasks;
    1.12 +using System.Windows.Forms;
    1.13 +using System.Timers;
    1.14 +using System.Runtime.InteropServices;
    1.15 +
    1.16 +namespace IdwTest
    1.17 +{
    1.18 +    public partial class MainForm : Form
    1.19 +    {
    1.20 +        iMON.Display iDisplay;
    1.21 +        System.Timers.Timer iTimer;
    1.22 +        int iFrameCount = 0;
    1.23 +
    1.24 +        iMON.Display.DSPEQDATA iEqLeft;
    1.25 +        iMON.Display.DSPEQDATA iEqRight;
    1.26 +        iMON.Display.DSPEQDATA iEqMono;
    1.27 +
    1.28 +        Random iRandom;
    1.29 +
    1.30 +        public MainForm()
    1.31 +        {
    1.32 +            iDisplay = new iMON.Display();
    1.33 +            InitializeComponent();
    1.34 +            iTimer = new System.Timers.Timer(500); // Set up the timer for N ms
    1.35 +            iTimer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
    1.36 +            iTimer.Enabled = false; // Enable it
    1.37 +            //
    1.38 +            iEqLeft =new iMON.Display.DSPEQDATA();
    1.39 +            iEqRight = new iMON.Display.DSPEQDATA();
    1.40 +            iEqMono = new iMON.Display.DSPEQDATA();
    1.41 +            //
    1.42 +            iRandom = new Random();
    1.43 +        }
    1.44 +
    1.45 +        private void buttonInit_Click(object sender, EventArgs e)
    1.46 +        {
    1.47 +            if (!iDisplay.DoInit())
    1.48 +            {
    1.49 +                labelStatus.Text = iDisplay.StatusMessage;
    1.50 +            }
    1.51 +            else
    1.52 +            {
    1.53 +                labelStatus.Text = iDisplay.Name();
    1.54 +            }
    1.55 +        }
    1.56 +
    1.57 +        private void buttonUninit_Click(object sender, EventArgs e)
    1.58 +        {
    1.59 +            iDisplay.DoUninit();
    1.60 +        }
    1.61 +
    1.62 +        private void buttonSetLcdText_Click(object sender, EventArgs e)
    1.63 +        {
    1.64 +            iMON.Display.IDW_SetLcdText(textBoxLcd.Text);
    1.65 +        }
    1.66 +
    1.67 +        private void timer_Elapsed(object sender, ElapsedEventArgs e)
    1.68 +        {
    1.69 +            if (iDisplay.IsLcd())
    1.70 +            {
    1.71 +                if (!checkBoxRandomEq.Checked)
    1.72 +                {
    1.73 +                    iMON.Display.IDW_SetLcdText(iFrameCount.ToString());
    1.74 +                    iFrameCount++;
    1.75 +                }
    1.76 +                else
    1.77 +                {
    1.78 +                    for (int i = 0; i < 16; i++)
    1.79 +                    {
    1.80 +                        iEqLeft.BandData[i] = iRandom.Next(0,101);
    1.81 +                        iEqRight.BandData[i] = iRandom.Next(0, 101);
    1.82 +                    }
    1.83 +
    1.84 +                    iMON.Display.IDW_SetLcdEqData(iEqLeft, iEqRight);
    1.85 +                    iFrameCount++;
    1.86 +                }
    1.87 +            }
    1.88 +        }
    1.89 +
    1.90 +        private void buttonToggleTimer_Click(object sender, EventArgs e)
    1.91 +        {
    1.92 +            if (iTimer.Enabled)
    1.93 +            {
    1.94 +                //Stop our timer
    1.95 +                iTimer.Enabled = false;
    1.96 +                buttonToggleTimer.Text = "Start";
    1.97 +            }
    1.98 +            else
    1.99 +            {
   1.100 +                iFrameCount = 0;
   1.101 +                //Start our timer
   1.102 +                iTimer.Interval = (double)numericTimerInterval.Value;
   1.103 +                iTimer.Enabled = true;
   1.104 +                buttonToggleTimer.Text = "Stop";
   1.105 +            }
   1.106 +        }
   1.107 +
   1.108 +    }
   1.109 +}