예제 #1
0
        public App()
        {
            InitializeComponent();
            NewForm = new NewForm(this);

            SetAvailableComPorts();

            this.ReadBuffer = new List <int>();
            this.Playing    = false;
            this.Loop       = false;

            this.graph1.SetBase(this);

            ConnectionTimer          = new Timer();
            ConnectionTimer.Tick    += ConnectionTimer_Tick;
            ConnectionTimer.Interval = 1000 * 1;
            ConnectionTimer.Start();

            DataPort.BaudRate = 57600;

            ReadTimer                     = new SuperTimer();
            ReadTimer.Mode                = TimerMode.Periodic;
            ReadTimer.Tick               += ReadTimer_Tick;
            ReadTimer.Period              = 20;
            ReadTimer.Resolution          = 1;
            ReadTimer.SynchronizingObject = this.graph1;
        }
예제 #2
0
        /// <summary>
        /// Initialize graph component.
        /// </summary>
        public Graph()
        {
            InitializeComponent();
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);

            // set arrays
            DataBuffer = new byte[5];
            WaveData   = new List <double>();
            ReadData   = new List <double>();

            // visual styling
            BorderPen    = new Pen(Color.Gray);
            ThinPen      = new Pen(Color.LightGray);
            ThinnestPen  = new Pen(Color.FromArgb(100, 210, 210, 210));
            DataPen      = new Pen(Color.LightGreen, 3f);
            MiniFont     = new Font("Tahoma", 8);
            Brush        = new SolidBrush(Color.Black);
            SecondsBrush = new SolidBrush(Color.Gray);
            BgBrush      = new SolidBrush(Color.White);
            DataBrush    = new SolidBrush(Color.LightGreen);
            ReadPen1     = new Pen(Color.Magenta, 2);
            ReadPen2     = new Pen(Color.Lime, 1);

            TimePen   = new Pen(Color.Red);
            CursorPen = new SolidBrush(Color.Orange);

            // timer for sending data over time (every 20ms)

            Timer                     = new SuperTimer();
            Timer.Mode                = TimerMode.Periodic;
            Timer.Period              = 20; //         50 times a second , 1000/50
            Timer.Resolution          = 1;
            Timer.SynchronizingObject = this;
            Timer.Tick               += new System.EventHandler(this.Timer_Tick);
            startTime                 = DateTime.Now;
            timerPoint                = new PointF(this.Width - 50, this.Height - 8);
            Changed                   = false;
        }