private void BtnDone_Click(object sender, RoutedEventArgs e)
 {
     this.WindowState = WindowState.Minimized;
     VTchart.ClearCurveDataPointsFromGraph();
     FVchart.ClearCurveDataPointsFromGraph();
 }
        void ReceivedMessage(string msg)
        {
            string[] cmd = msg.ToLower().Split('>');

            switch (cmd[0])
            {
            case "<startspirovc":
                string[] ht1 = cmd[2].Split(':');
                this.Dispatcher.Invoke(DispatcherPriority.Send,
                                       new Action(delegate
                {
                    this.Top = 200;   // Convert.ToDouble(ht[1] ) ;

                    this.Left    = 0; // Convert.ToDouble(ht[0]);
                    this.Width   = Convert.ToDouble(ht1[3]) + 215;
                    this.Height  = Convert.ToDouble(ht1[2]) - 105;
                    appheight    = Convert.ToDouble(ht1[2]) - 105;;
                    apptop       = 200;
                    count        = 0;
                    this.Topmost = Topmost;
                    if (Height < 750)
                    {
                        BtnFullView.IsEnabled = true;
                    }
                    else
                    {
                        BtnFullView.IsEnabled = false;
                    }
                    VTchart.ClearCurveDataPointsFromGraph();
                    FVchart.ClearCurveDataPointsFromGraph();
                    this.WindowState = WindowState.Normal;
                }));


                break;

            case "<startspirofvc":
                string[] ht = cmd[2].Split(':');
                this.Dispatcher.Invoke(DispatcherPriority.Send,
                                       new Action(delegate
                {
                    this.Top = 200;  // Convert.ToDouble(ht[1] ) ;

                    this.Left   = 0; // Convert.ToDouble(ht[0]);
                    this.Width  = Convert.ToDouble(ht[3]) + 215;
                    this.Height = Convert.ToDouble(ht[2]) - 105;
                    appheight   = Convert.ToDouble(ht[2]) - 105;;
                    apptop      = 200;
                    if (Height < 750)
                    {
                        BtnFullView.IsEnabled = true;
                    }
                    else
                    {
                        BtnFullView.IsEnabled = false;
                    }


                    this.WindowState = WindowState.Normal;
                    count            = 0;
                    VTchart.ClearCurveDataPointsFromGraph();
                    FVchart.ClearCurveDataPointsFromGraph();
                }));


                break;

            case "spirofvcvt":
                //  Application.Current.Dispatcher.BeginInvoke(
                //  DispatcherPriority.Background,
                //  new Action(() =>
                //  {
                //      string[] vdata = cmd[1].Split(',');
                //      double vol = Convert.ToDouble(vdata[0]);
                //      double time = Convert.ToDouble(vdata[1]);
                //      VTchart.AddPointToLine(vol, time);
                //  }
                //  ));
                DisplayVolumeTimeData(cmd[1]);
                break;

            case "spirofvc":
                //  DisplayFlowVolumeData(cmd[1]);

                Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() => {
                    string[] vdata = cmd[1].Split(',');
                    double flow    = Convert.ToDouble(vdata[0]);
                    double vol     = Convert.ToDouble(vdata[1]);
                    count++;
                    ///  this.WindowState = WindowState.Minimized;
                    //  TxtLbl.Text = "";
                    //   TxtLbl.Text = count.ToString();
                    FVchart.AddPointToLine(flow, vol);
                }));


                break;

            case "spirovc":

                DisplayVolumeTimeData(cmd[1]);
                break;

            case "<stopspiro":
                this.Dispatcher.Invoke(DispatcherPriority.Send,
                                       new Action(delegate
                {
                    this.WindowState = WindowState.Minimized;
                }));

                break;
            }
            //  commtoDAQ.readDataasync();
        }
 private void BtnClear_Click(object sender, RoutedEventArgs e)
 {
     FVchart.ClearCurveDataPointsFromGraph();
 }