Exemplo n.º 1
0
        public UserWindow()
        {
            InitializeComponent();
            uniqueIDSpd = 0;
            uniqueIDPwr = 0;
            uniqueIDHr  = 0;

            spdData    = new List <Point>();
            cadData    = new List <Point>();
            hrData     = new List <Point>();
            pwrData    = new List <Point>();
            avgpwrData = new List <Point>();

            pTarget = new PointCollection(10);
            Point pt01 = new Point(.01, .01);
            Point pt02 = new Point(.06, .01);
            Point pt03 = new Point(.07, .06);
            Point pt04 = new Point(.04, .06);

            pTarget.Add(pt01);
            pTarget.Add(pt02);
            pTarget.Add(pt03);
            pTarget.Add(pt04);


            workoutStatus = new workoutEventArgs();

            roundRobin = 0;

            powerMax            = 400;
            labelPwrMax.Content = "400";

            dwgEngine = new cDrawingEngine();
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            //totally cheating, and making this hard coded for now
            b_hasVid     = false;
            b_vidPlaying = false;
            // video file is linked from xaml file, anyways.

            drawingEngine           = new cDrawingEngine();
            drawingEngine.chartZoom = 1.6;

            InitializeComponent();

            slider1.Value = 1.6;

            AntHandler     = new cAntHandler();
            StreamHandler  = new cStreamHandler();
            UserHandler    = new cUserHandler(StreamHandler);
            userWindows    = new List <UserWindow>();
            WorkoutHandler = new cWorkout();

            theServer = new cWebSocketServer();
            webServer = new MyHttpServer(8080);
            webListen = new ThreadStart(webServer.listen);
            webThread = new Thread(webListen);
            webThread.Start();


            clientCount = 0;

            // For IIS Express, this updates the applicationhost.config file, so that we know we run
            // from the same directory the program is running. What a PIA

/*
 *          string IISExpressFile = "C:\\Program Files\\IIS Express\\iisexpress.exe";
 *          if (!System.IO.File.Exists(IISExpressFile))
 *          {
 *              AutoClosingMessageBox.Show("To Use web features, install IISExpress from Microsoft", "Webservice Error", 3000);
 *          }
 *          else
 *          {
 *              string filename = "applicationhost.config";
 *              if (System.IO.File.Exists(filename))
 *              {
 *                  XmlDocument doc = new XmlDocument();
 *                  doc.Load(filename);
 *                  XmlAttribute path = (XmlAttribute)doc.SelectSingleNode("//configuration/system.applicationHost/sites/site/application/virtualDirectory/@physicalPath");
 *                  //path.InnerText = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location).Replace(@"\", @"\\") + "\\\\web";
 *                  path.InnerText = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\web";
 *                  doc.Save(filename);
 *              }
 *
 *              List<string> knownAddresses = new List<string>();
 *              IPHostEntry host;
 *              host = Dns.GetHostEntry(Dns.GetHostName());
 *              foreach (IPAddress ip in host.AddressList)
 *              {
 *                  if (ip.AddressFamily == AddressFamily.InterNetwork)
 *                  {
 *                      knownAddresses.Add("http://" + ip.ToString() + ":8080/");
 *                  }
 *              }
 *              knownAddresses.Add("http://localhost" + ":8080/");
 *
 *              StringBuilder Message = new StringBuilder("Now Accepting Web Connections at:\n");
 *              foreach (string url in knownAddresses) Message.AppendLine(url);
 *
 *
 *
 *              // Create Rules and Open Firewalls and Start IIS Express
 *              ProcessStartInfo p1 = new ProcessStartInfo("LaunchWeb.bat", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location).Replace(@"\", @"/"));
 *              p1.UseShellExecute = true;
 *              p1.WindowStyle = ProcessWindowStyle.Minimized;
 *              p1.Verb = "runas";
 *              try
 *              {
 *                  webProcess = Process.Start(p1);
 *                  AutoClosingMessageBox.Show(Message.ToString(), "Web Server Running", 2500);
 *              }
 *              catch
 *              { MessageBox.Show("Failed to start WebProcess"); }
 *          }
 */

            for (int i = 0; i < WorkoutHandler.workOutList.Count; i++)
            {
                TimeSpan woTime = new TimeSpan(0, 0, (int)WorkoutHandler.workOutList[i].length);
                cbSelectWorkout.Items.Add(WorkoutHandler.workOutList[i].title + " " + woTime.ToString(@"h\:mm\:ss"));
                cbSelectEditWorkout.Items.Add(WorkoutHandler.workOutList[i].title);
            }

            WorkoutHandler.workoutEventStartStop += updateWorkoutEvent;
            theServer.remoteEventStartStop       += remotePlayPauseEvent;


            dataGridPower.DataContext  = StreamHandler.pwrStreams;
            dataGridHR.DataContext     = StreamHandler.hbStreams;
            dataGridSpdCad.DataContext = StreamHandler.spdStreams;

            dataGridUsers.DataContext = UserHandler.l_Users;

            System.Timers.Timer _timer = new System.Timers.Timer(500);
            _timer.Elapsed += new ElapsedEventHandler(_timerElapsed);
            _timer.Enabled  = true;


            lbl_ANTStatus.Content = "ANT Device not Found, installing or disabling Garmin Agent, then press \"Start\"";

            if (AntHandler.startUp())
            {
                AntHandler.channelMessageHandler += StreamHandler.handleAntData;
                button_Start.Background           = System.Windows.Media.Brushes.Salmon;
                button_Start.Content              = "ANT ENABLED";
                lbl_ANTStatus.Content             = "Press \"ANT ENABLED\" button to stop";
            }
            bStartWorkout.IsEnabled  = false;
            bStartWorkout2.IsEnabled = false;
            bEndWorkout.IsEnabled    = false;
            bEndWorkout2.IsEnabled   = false;
            bStartWorkout.Content    = "Select Workout";
            bStartWorkout2.Content   = "Select Workout";
            bEndWorkout.Content      = "End Workout";
            bEndWorkout2.Content     = "End Workout";
        }