Exemple #1
0
 public StatesScreen(Window MainWindow, KinectSensorChooser SensorChooser, Constants.TimeZones TimeZone)
 {
     // Get the main window and sensor objects
     this.mainWindow = MainWindow;
     this.sensorChooser = SensorChooser;
     // Populate the states based on TimeZone parameter
     this.timeZone = TimeZone;
     this.states = PopulateStates(TimeZone);
     #if (DEBUG)
     Console.WriteLine(TimeZone.ToString() + " states loading...");
     foreach (Utilities.State s in this.states)
     {
         Console.WriteLine(s);
     }
     Console.WriteLine("..." + TimeZone.ToString() + " states loaded!");
     #endif
     // Initialize display containers
     CreateContentGrid();
     CreateKinectRegion();
     CreateInfoGrid();
     CreateKinectScrollViewer();
     // Set up the display
     Grid.SetColumn(this.infoGrid, 0);
     Grid.SetRow(this.infoGrid, 0);
     this.content.Children.Add(this.infoGrid);
     this.kRegion.Content = this.statesKSV;
     Grid.SetColumn(this.kRegion, 0);
     Grid.SetRow(this.kRegion, 1);
     this.content.Children.Add(this.kRegion);
     // Bind the Kinect sensor
     //var regionSensorBinding = new Binding("Kinect") { Source = SensorChooser };
     this.regionSensorBinding = new Binding("Kinect") { Source = SensorChooser };
     BindingOperations.SetBinding(this.kRegion, KinectRegion.KinectSensorProperty, this.regionSensorBinding);
 }
Exemple #2
0
 private KinectTileButton InitializeKinectTileButton(Constants.TimeZones TimeZone)
 {
     KinectTileButton ktb = new KinectTileButton();
     ktb.Name = TimeZone.ToString();
     ktb.Height = this.mainWindow.ActualHeight;
     ktb.Background = new LinearGradientBrush(Color.FromRgb(200, 200, 200), Color.FromRgb(77, 77, 77), 90);
     ktb.Opacity = 0;
     ktb.BorderThickness = new Thickness(0);
     ktb.Padding = new Thickness(0);
     ktb.Margin = new Thickness(0);
     ktb.HorizontalAlignment = HorizontalAlignment.Center;
     ktb.VerticalAlignment = VerticalAlignment.Center;
     // TODO: We also need to add event handlers for the kinect sensor cursor...
     // We only have the mouse events (for debugging) set up currently!
     // Is this called the stylus, etc.?
     ktb.MouseEnter += ButtonMouseEnter;
     ktb.MouseLeave += ButtonMouseLeave;
     ktb.Click += ZoneButtonClick;
     return ktb;
 }
 public void textAlign(Constants align, Constants yAlign)
 {
     text_align = align;
     text_y_align = yAlign;
 }
 public void textAlign(Constants align)
 {
     text_align = align;
 }
Exemple #5
0
        private void transitionToState(Constants.state aState)
        {
            mPreviousState = mCurrentState;
            mCurrentState = aState;

            switch (aState)
            {
                case Constants.state.Initial:
                    // Update Buttons
                    btnCancel.Content = "Cancel";
                    btnCancel.Background = null;
                    btnCancel.IsEnabled = false;

                    btnAccept.Content = "Accept";
                    btnAccept.Background = null;
                    btnAccept.IsEnabled = false;

                    btnHomeMotors.IsEnabled = true;
                    btnChangeProbe.IsEnabled = true;
                    btnMoveTo.IsEnabled = true;
                    btnPreferences.IsEnabled = true;

                    // Enable all GUI Controls
                    setGUIControlIsEnabled(true);

                    // Only remove the image if we are starting a new scan
                    if (mPreviousState == Constants.state.Overview)
                    {
                        // Remmove captured image and heat map
                        mLoadedImage = null;
                        imageCaptured.Source = null;
                    }

                    mHeatMap.Clear(IntensityColorKeyGrid);
                    dgZScanPoints.ItemsSource = null;

                    // Update Status
                    if (mLoadedImage == null)
                        lblStatus.Text = Constants.StatusInitial1;
                    else
                        lblStatus.Text = Constants.StatusInitial2;

                    // Show captured image
                    imageCaptured.Source = mLoadedImage;

                    // Redraw the table area on the image after calibration
                    redrawSelectionObjects();

                    // Only show the canvas if we have an image loaded
                    if (imageCaptured.Source == null)
                    {
                        canvasDrawing.Visibility = Visibility.Collapsed;
                        btnCalibrate.IsEnabled = false;
                    }
                    else
                    {
                        canvasDrawing.Visibility = Visibility.Visible;
                        btnCalibrate.IsEnabled = true;
                    }

                    // Restore the mode to whatever probe is installed
                    mProbeNum = Properties.Settings.Default.ProbeNum;
                    mScanMode = Properties.Settings.Default.ScanMode;

                    updateTitles();

                    setSAFreqRange();

                    break;

                case Constants.state.Calibration:
                    btnHomeMotors.IsEnabled = false;
                    btnChangeProbe.IsEnabled = false;
                    btnMoveTo.IsEnabled = false;
                    btnCancel.IsEnabled = true;

                    // Update Status
                    lblStatus.Text = Constants.StatusCalibration1;

                    // Reset the number of calibration points clicked
                    mCalibrationPoints = 0;

                    redrawSelectionObjects();
                    break;

                case Constants.state.Ready:
                    // Update Buttons
                    btnCancel.Content = "Cancel";
                    btnCancel.Background = null;
                    btnCancel.IsEnabled = true;

                    btnAccept.Content = "Start";
                    btnAccept.Background = Brushes.Green;
                    btnAccept.IsEnabled = true;

                    //rbEField.IsEnabled = false;
                    //rbHField.IsEnabled = false;
                    btnHomeMotors.IsEnabled = false;
                    //btnBaseLine.IsEnabled = false;
                    btnChangeProbe.IsEnabled = false;
                    btnMoveTo.IsEnabled = false;
                    btnPreferences.IsEnabled = false;
                    btnCalibrate.IsEnabled = false;

                    // Disable all GUI Controls
                    setGUIControlIsEnabled(false);

                    mScanFinished = false;
                    mScanStarted = false;

                    // Update Status
                    lblStatus.Text = Constants.StatusReady;

                    // Hide drawing canvas
                    canvasDrawing.Visibility = Visibility.Collapsed;

                    // Set the area of where to scan
                    setScanArea();

                    // Show reminder to SA
                    MessageBox.Show("Reminder: Please finalize all spectrum analyzer settings now. (Press 'Enter' on the spectrum analyzer to release remote control)",
                        "Reminder", MessageBoxButton.OK, MessageBoxImage.Information);

                    break;

                case Constants.state.Scanning:
                    // Update Buttons
                    btnCancel.Content = "Stop";
                    btnCancel.Background = Brushes.Red;
                    btnCancel.IsEnabled = true;

                    btnAccept.Content = "Start";
                    btnAccept.Background = Brushes.Green;
                    btnAccept.IsEnabled = false;

                    btnHomeMotors.IsEnabled = false;

                    // Update Status
                    lblStatus.Text = Constants.StatusScanning;

                    // Initialize the file
                    if (!mScanStarted)
                    {
                        Logger.initializeFile(mLogFileName + ".csv", mXScanPoints, mYScanPoints, mScans.Count, mDUTHeight, Properties.Settings.Default.ScanMode);
                        mScanStarted = true;
                    }

                    // Just in case the user accidently changed the frequency on the SA
                    setSAFreqRange();

                    // Start moving the motors
                    try
                    {
                        mWorkerThread.RunWorkerAsync();
                    }
                    catch (Exception)
                    {
                        string messageBoxText = "Unable to start scanning due to another process that is already running. Please try again.";
                        string caption = "Process already running";
                        MessageBoxButton button = MessageBoxButton.OK;
                        MessageBoxImage icon = MessageBoxImage.Error;
                        MessageBoxResult rsltMessageBox = MessageBox.Show(messageBoxText, caption, button, icon);

                        transitionToState(Constants.state.Stopped);
                    }

                    mCDTimer.Start();

                    break;

                case Constants.state.Stopped:
                    // Update Buttons
                    btnCancel.Content = "Reset";
                    btnCancel.Background = null;

                    btnAccept.Content = "Resume";
                    btnAccept.Background = Brushes.Green;

                    btnHomeMotors.IsEnabled = true;

                    // Update Status
                    lblStatus.Text = Constants.StatusStopped;

                    // Stop the simulator
                    if (mWorkerThread.IsBusy)
                    {
                        btnCancel.IsEnabled = false;
                        btnAccept.IsEnabled = false;
                        mWorkerThread.CancelAsync();
                    }
                    else
                    {
                        btnCancel.IsEnabled = true;
                        btnAccept.IsEnabled = true;
                    }

                    // Stop the count down timer
                    mCDTimer.Stop();

                    break;

                case Constants.state.Overview:
                    // Update Buttons
                    btnCancel.Content = "Cancel";
                    btnCancel.Background = null;
                    btnCancel.IsEnabled = false;

                    btnAccept.Content = "Accept";
                    btnAccept.Background = null;
                    btnAccept.IsEnabled = false;

                    // Update Status
                    lblStatus.Text = Constants.StatusOverview;

                    btnHomeMotors.IsEnabled = false;
                    btnChangeProbe.IsEnabled = false;
                    btnMoveTo.IsEnabled = false;
                    btnPreferences.IsEnabled = true;

                    // Disable main gui buttons
                    setGUIControlIsEnabled(false);

                    btnChangeProbe.IsEnabled = false;

                    // Disable Menu Items
                    btnCalibrate.IsEnabled = false;

                    if (mLoadedImage == null)
                        btnSaveHeatMap.IsEnabled = false;
                    else
                        btnSaveHeatMap.IsEnabled = true;

                    mVerticalScanDirection = Constants.direction.South;
                    mHorizontalScanDirection = Constants.direction.East;

                    canvasDrawing.Visibility = Visibility.Collapsed;

                    updateTitles();
                    break;

                case Constants.state.ProbeChange:

                    if (!mWorkerThread.IsBusy)
                        mWorkerThread.RunWorkerAsync();

                    break;
            }
        }
Exemple #6
0
 private List<Utilities.State> PopulateStates(Constants.TimeZones TimeZone)
 {
     List<Utilities.State> states = new List<Utilities.State>();
     foreach (Utilities.State s in Utilities.Data.States)
     {
         if (s.TimeZone == TimeZone)
         {
             states.Add(s);
         }
     }
     return states;
 }
Exemple #7
0
 private KinectTileButton CreateNavTileButton(Constants.ViewNames Name, string Content)
 {
     KinectTileButton ktb = new KinectTileButton();
     ktb.Name = Name.ToString();
     if (Name == Constants.ViewNames.TitleScreen)
     {
         ktb.Content = Content;
     }
     else if (Name == Constants.ViewNames.VehicleScreen)
     {
         ktb.Content = "  select\n" + Content;
     }
     else
     {
         ktb.Content = "select\n" + Content;
     }
     ktb.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
     ktb.MaxHeight = this.mainWindow.ActualHeight / 3.75;
     ktb.MaxWidth = this.mainWindow.ActualHeight / 3.75;
     ktb.FontSize = this.mainWindow.ActualHeight / 22;
     ktb.Click += NavButtonClick;
     ktb.HorizontalContentAlignment = HorizontalAlignment.Center;
     ktb.VerticalContentAlignment = VerticalAlignment.Center;
     ktb.HorizontalLabelAlignment = System.Windows.HorizontalAlignment.Center;
     ktb.VerticalLabelAlignment = System.Windows.VerticalAlignment.Center;
     ktb.Foreground = Brushes.White;
     return ktb;
 }
 public void ellipseMode(Constants mode)
 {
     ellipse_mode = mode;
 }
 public void strokeJoin(Constants value)
 {
     switch (value) {
     case Constants.Round:
         stroke_join = PenLineJoin.Round;
         break;
     case Constants.Miter:
         stroke_join = PenLineJoin.Miter;
         break;
     case Constants.Bevel:
         stroke_join = PenLineJoin.Bevel;
         break;
     default:
         throw new ArgumentException ("Invalid strokeJoin enumeration value: " + value);
     }
 }
 public void strokeCap(Constants value)
 {
     switch (value) {
     case Constants.Round:
         stroke_cap = PenLineCap.Round;
         break;
     case Constants.Square:
         stroke_cap = PenLineCap.Square;
         break;
     case Constants.Project:
         stroke_cap = PenLineCap.Flat;
         break;
     default:
         throw new ArgumentException ("Invalid strokeCap enumeration argument: " + value);
     }
 }
 public void rectMode(Constants mode)
 {
     this.rect_mode = mode;
 }