Ejemplo n.º 1
0
        public Form1()
        {
            Radars = new List <Radar>();

            XDIM      = Properties.Settings.Default.Xdim;
            YDIM      = Properties.Settings.Default.Ydim;
            scanIndex = 0;
#if DOUBLE
            GaussianKernel = new double[GAUSSIANLENGTH];
#else
            GaussianKernel = new uint[GAUSSIANLENGTH];
#endif
            InitializeComponent();
            GAUSSIANSUM = Filter.GenerateKernel(GaussianKernel, GAUSSIANLENGTH, SigmaBar.Value);

            fullBit = GuiUtil.GenerateBitmap(300, XDIM, YDIM);
            BITCOLS = fullBit.Width;
            BITROWS = fullBit.Height;

            radarGraph                = new RadarGraph();
            _async                    = new AsynchronousSocketListener();
            _async.ScanReceived      += async_ScanReceived;
            _async.SetConfigReceived += async_SetConfigReceived;
            _async.GetConfigReceived += async_GetConfigReceived;
            _async.RadarConnected    += async_RadarConnected;
            _async.RadarDisconnected += async_RadarDisconnected;
            Thread t = new Thread(new ThreadStart(_async.StartListening));
            t.Start();
            IPEndPoint ipe = _async.GetEndPoint();
            label3.Text    = ipe.Address.ToString();
            label4.Text    = ipe.Port.ToString();
            RadarXBox.Text = XDIM.ToString();
            RadarYBox.Text = YDIM.ToString();
            _scanTimer     = new System.Threading.Timer(new TimerCallback(ScanTimer_Tick), null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
        }
Ejemplo n.º 2
0
        private void RunAnimation()
        {
            GraphParams gp = new GraphParams(XDIM, YDIM, BITCOLS, BITROWS, filtering, gamma, dBBox.Checked, MultiplyBox.Checked, ColorBox.Checked);

            if (GuiUtil.DrawGraph(ref fullBit, Radars, GaussianKernel, gp))
            {
                Graphics g     = this.tabPage1.CreateGraphics();
                double   ratio = (double)BITCOLS / (double)BITROWS;
                g.DrawImage(fullBit, 5, 30, (ratio > 1.0 ? 300 : (int)(300 * ratio)), (ratio > 1.0 ? (int)(300 / ratio) : 300));
                g.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void RadarSetButton_Click(object sender, EventArgs e)
        {
            int x, y;

            if (int.TryParse(RadarXBox.Text, out x) && int.TryParse(RadarYBox.Text, out y))
            {
                if (ProximityBox.Checked)
                {
                    foreach (Radar r in Radars)
                    {
                        double proxX = (double)r.Location.X / (double)XDIM;
                        double proxY = (double)r.Location.Y / (double)YDIM;
                        if (proxX >= 0.0 && proxX <= 1.0)
                        {
                            r.Location.X = (int)(proxX * x);
                        }
                        else if (proxX > 1.0)
                        {
                            r.Location.X = (int)(r.Location.X - XDIM) + x;
                        }
                        if (proxY >= 0.0 && proxY <= 1.0)
                        {
                            r.Location.Y = (int)(proxY * y);
                        }
                        else if (proxY > 1.0)
                        {
                            r.Location.Y = (int)(r.Location.Y - YDIM) + y;
                        }
                    }
                }
                XDIM = x;
                YDIM = y;
                if (fullBit != null)
                {
                    fullBit.Dispose();
                }
                fullBit = GuiUtil.GenerateBitmap(300, XDIM, YDIM);
                BITCOLS = fullBit.Width;
                BITROWS = fullBit.Height;
            }
            else
            {
                MessageBox.Show("Invalid dimensions", "Error", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 4
0
 private void RadarTab_Paint(object sender, PaintEventArgs e)
 {
     OnPaint(e);
     GuiUtil.DrawRadarsAndEnclosure(RadarTab, Radars, XDIM, YDIM);
 }