Example #1
0
 public MatrixConnection(SerialManager serialManager, MainWindow main)
 {
     InitializeComponent();
     sm = serialManager;
     m  = main;
     RefreshSerialPorts();
 }
        private void Button_Imaging_ImportGif_Click(object sender, RoutedEventArgs e)
        {
            var s = new System.Diagnostics.Stopwatch();

            s.Start();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Image Files(*.GIF)|*.GIF";
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                GifPlayPause = false;
                ImageProcesser.DisposeGif();
                ImageProcesser.DisposeStill();
                if (ImageProcesser.LoadGifFromDisk(openFileDialog.FileName))
                {
                    ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap);
                    MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode);
                    IMXMax = IMX2 = ImageProcesser.LoadedGifImage.Width;
                    IMYMax = IMY2 = ImageProcesser.LoadedGifImage.Height;
                    IMX1   = 0;
                    IMY1   = 0;
                    //FrameToPreview();
                    SerialManager.PushFrame();
                    ImageProcesser.ImageLoadState = ImageProcesser.LoadState.Gif;
                    ResetSliders();
                }
                else
                {
                    System.Windows.MessageBox.Show("Cannot load image.");
                }
            }
            //  System.Windows.MessageBox.Show(s.ElapsedMilliseconds.ToString());
        }
Example #3
0
        private void SSerialConnect_Click(object sender, RoutedEventArgs e)
        {
            switch (SSColorModeList.SelectedIndex)
            {
            case 0: SerialManager.ColorMode = SerialManager.CMode.BPP24RGB; break;

            case 1: SerialManager.ColorMode = SerialManager.CMode.BPP16RGB; break;

            case 2: SerialManager.ColorMode = SerialManager.CMode.BPP8RGB; break;

            case 3: SerialManager.ColorMode = SerialManager.CMode.BPP8Gray; break;

            case 4: SerialManager.ColorMode = SerialManager.CMode.BPP1Mono; break;
            }
            int[] matrixDef = null;

            matrixDef = SerialManager.Connect(SSerialPortList.SelectedValue.ToString(), int.Parse(SBaudRate.Text));

            if (matrixDef != null)
            {
                MatrixFrame.SetDimensions(matrixDef[0], matrixDef[1]);
                // ((MainWindow)Application.Current.MainWindow).SetMatrixDimensions(matrixDef[0], matrixDef[1]);
                Close();
            }
            else
            {
                MessageBox.Show("Cannot establish connection on: " + SSerialPortList.SelectedValue.ToString());
            }
        }
        private void Button_Imaging_ImportImage_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Image Files(*.BMP;*.JPG;*.PNG;*.GIF)|*.BMP;*.JPG;*.PNG;*.GIF";
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                IMLockDim    = false;
                GifPlayPause = false;
                ImageProcesser.DisposeStill();
                ImageProcesser.DisposeGif();
                if (ImageProcesser.LoadBitmapFromDisk(openFileDialog.FileName))
                {
                    ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap);
                    MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode);
                    IMXMax = IMX2 = ImageProcesser.WorkingBitmap.Width;
                    IMYMax = IMY2 = ImageProcesser.WorkingBitmap.Height;
                    IMX1   = 0;
                    IMY1   = 0;
                    //FrameToPreview();
                    SerialManager.PushFrame();
                    ImageProcesser.ImageLoadState = ImageProcesser.LoadState.Still;
                    ResetSliders();
                }
                else
                {
                    System.Windows.MessageBox.Show("Cannot load image.");
                }
            }
        }
 void StartSerialSyncCapture()
 {
     _fpsStopWatch = Stopwatch.StartNew();
     SerialManager.SerialAcknowledged += OnSerialAcknowledged;
     MatrixFrame.InjestGDIBitmap(ScreenRecorder.ScreenToBitmap(), ScreenRecorder.InterpMode);
     //    Dispatcher.Invoke(() => { FrameToPreview(); });
     SerialManager.PushFrame();
 }
Example #6
0
 void FFTCallback(float[] fftData) //data received
 {
     Dispatcher.Invoke(() =>
     {
         MatrixFrame.FFTToFrame(fftData);
         //FrameToPreview();
         SerialManager.PushFrame();
     });
 }
Example #7
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     EndAllThreads();
     SerialManager.Disconnect();
     while (SerialManager.IsConnected())
     {
         SerialManager.Disconnect();
     }
 }
 void OnSerialAcknowledged()
 {
     if (SyncSerial == true)
     {
         MatrixFrame.InjestGDIBitmap(ScreenRecorder.ScreenToBitmap(), ScreenRecorder.InterpMode);
         //     Dispatcher.Invoke(() => { FrameToPreview(); });
         SerialManager.PushFrame();
         LocalFPS             = SerialFPS = _fpsStopWatch.ElapsedMilliseconds - _localPreviousMillis;
         _localPreviousMillis = _fpsStopWatch.ElapsedMilliseconds;
     }
 }
 private void RefreshStillImage()
 {
     if (ImageProcesser.ImageLoadState == ImageProcesser.LoadState.Still)
     {
         ImageProcesser.DisposeWorkingBitmap();
         ImageProcesser.WorkingBitmap = ImageProcesser.CropBitmap(ImageProcesser.LoadedStillBitmap, ImageProcesser.ImageRect);
         ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap);
         MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode);
         //FrameToPreview();
         SerialManager.PushFrame();
     }
 }
Example #10
0
 public PixelOrderEditor(MainWindow window, SerialManager serialM)
 {
     sm = serialM;
     w  = window;
     InitializeComponent();
     pixelOrder                     = new PixelOrder();
     pixelOrder.newLine             = sm.pixelOrder.newLine;
     pixelOrder.orientation         = sm.pixelOrder.orientation;
     pixelOrder.startCorner         = sm.pixelOrder.startCorner;
     UIOrientation.SelectedIndex    = (int)pixelOrder.orientation;
     UIStartingCorner.SelectedIndex = (int)pixelOrder.startCorner;
     UINewLine.SelectedIndex        = (int)pixelOrder.newLine;
 }
Example #11
0
 void RefreshSerialPorts()
 {
     string[] ports = SerialManager.GetPortNames();
     SSerialPortList.ItemsSource = ports;
     if (ports.Length > 0)
     {
         SSerialPortList.SelectedIndex = 0;
         SSerialConnect.IsEnabled      = true;
     }
     else
     {
         SSerialConnect.IsEnabled = false;
     }
 }
        void PixelDataCallback(Bitmap capturedBitmap)
        {
            LocalFPS             = _fpsStopWatch.ElapsedMilliseconds - _localPreviousMillis;
            _localPreviousMillis = _fpsStopWatch.ElapsedMilliseconds;

            MatrixFrame.InjestGDIBitmap(capturedBitmap, ScreenRecorder.InterpMode);

            //     Dispatcher.Invoke(() => { FrameToPreview(); });

            if (SerialManager.PushFrame())
            {
                SerialFPS             = _fpsStopWatch.ElapsedMilliseconds - _serialPreviousMillis;
                _serialPreviousMillis = _fpsStopWatch.ElapsedMilliseconds;
            }
            //GC.Collect();
        }
Example #13
0
        void DrawPixel()
        {
            if (Mouse.LeftButton == MouseButtonState.Pressed)
            {
                System.Windows.Point pos = Mouse.GetPosition(MatrixImage);

                int x = (int)(pos.X / MatrixImage.ActualWidth * MatrixFrame.Width);
                int y = (int)(pos.Y / MatrixImage.ActualHeight * MatrixFrame.Height);

                x = x > MatrixFrame.Width - 1 ? MatrixFrame.Width - 1 : x < 0 ? 0 : x;
                y = y > MatrixFrame.Height - 1 ? MatrixFrame.Height - 1 : y < 0 ? 0 : y;

                MatrixFrame.SetPixel(x, y, new Pixel(255, 32, 255));
                FrameToPreview();
                SerialManager.PushFrame();
            }
        }
Example #14
0
 private void GifTimer_Tick(object sender, EventArgs e)
 {
     ImageProcesser.DisposeWorkingBitmap();
     if (_gifFrameIndex >= ImageProcesser.LoadedGifFrameCount - 1)
     {
         _gifFrameIndex = 0;
     }
     else
     {
         _gifFrameIndex++;
     }
     ImageProcesser.LoadedGifImage.SelectActiveFrame(ImageProcesser.LoadedGifFrameDim, _gifFrameIndex);
     ImageProcesser.WorkingBitmap = ImageProcesser.CropBitmap(new Bitmap(ImageProcesser.LoadedGifImage), ImageProcesser.ImageRect);
     ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap);
     MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode);
     ImageProcesser.DisposeWorkingBitmap();
     SerialManager.PushFrame();
 }
Example #15
0
        private void RefreshGifImages()
        {
            if (ImageProcesser.ImageLoadState == ImageProcesser.LoadState.Gif)
            {
                ImageProcesser.DisposeWorkingBitmap();

                if (GifPlayPause != true) //if gif is not playing
                {
                    if (_gifFrameIndex > ImageProcesser.LoadedGifFrameCount - 1)
                    {
                        _gifFrameIndex = 0;
                    }

                    ImageProcesser.WorkingBitmap = ImageProcesser.CropBitmap(new Bitmap(ImageProcesser.LoadedGifImage), ImageProcesser.ImageRect);
                    ContentBitmap = MatrixFrame.CreateBitmapSourceFromBitmap(ImageProcesser.WorkingBitmap);
                    MatrixFrame.BitmapToFrame(ImageProcesser.WorkingBitmap, ImageProcesser.InterpMode);
                    //FrameToPreview();
                    SerialManager.PushFrame();
                }
            }
        }
Example #16
0
 private void MenuItem_Serial_Disconnect_Click(object sender, RoutedEventArgs e)
 {
     SerialManager.Disconnect();
 }