Beispiel #1
0
        public static void RenderScopeLine(Device dev, int count, bool monitor)
        {
            try
            {
                Mode new_mode = MainForm.OpModeVFOA;

                if (Audio.channel == 6)
                    new_mode = MainForm.OpModeVFOB;

                switch (new_mode)
                {
                    case Mode.RTTY:
                        {
                            ////////////// mark ////////////////////

                            for (int i = 0; i < count * 2; i++)
                            {
                                ScopeLine_verts[i] = new Vertex();
                                ScopeLine_verts[i].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data_mark[i], 0.0f, 0.0f);
                                ScopeLine_verts[i + 1] = new Vertex();
                                ScopeLine_verts[i + 1].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data_mark[i + 1], 0.0f, 0.0f);
                                i++;
                            }

                            if (monitor)
                            {
                                ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb_monitor.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                            else
                            {
                                ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }

                            ////////////// space ///////////////////

                            for (int i = 0; i < count * 2; i++)
                            {
                                ScopeLine_verts[i] = new Vertex();
                                ScopeLine_verts[i].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data_space[i], 0.0f, 0.0f);
                                ScopeLine_verts[i + 1] = new Vertex();
                                ScopeLine_verts[i + 1].Color = data_line_color.ToArgb();
                                ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data_space[i + 1], 0.0f, 0.0f);
                                i++;
                            }

                            if (monitor)
                            {
                                ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb_monitor.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                            else
                            {
                                ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                        }
                        break;

                    default:
                        {
                            for (int i = 0; i < count * 2; i++)
                            {
                                ScopeLine_verts[i] = new Vertex();
                                ScopeLine_verts[i].Color = data_line_color.ToArgb();// Color.Wheat.ToArgb();
                                ScopeLine_verts[i].Position = new Vector4(i / 2, panadapterX_scope_data[i], 0.0f, 0.0f);
                                ScopeLine_verts[i + 1] = new Vertex();
                                ScopeLine_verts[i + 1].Color = data_line_color.ToArgb(); // Color.Wheat.ToArgb();
                                ScopeLine_verts[i + 1].Position = new Vector4(i / 2, panadapterX_scope_data[i + 1], 0.0f, 0.0f);
                                i++;
                            }

                            if (monitor)
                            {
                                ScopeLine_vb_monitor.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb_monitor.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb_monitor, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                            else
                            {
                                ScopeLine_vb.Lock(0, 0, LockFlags.None).WriteRange(ScopeLine_verts, 0, count * 2);
                                ScopeLine_vb.Unlock();
                                dev.SetStreamSource(0, ScopeLine_vb, 0, 20);
                                dev.DrawPrimitives(PrimitiveType.LineList, 0, count * 2);
                            }
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
            }
        }
Beispiel #2
0
        private static void RenderRectangle(Device dev, DXRectangle rect, Color color)
        {
            Vertex[] verts = new Vertex[4];

            var vb = new VertexBuffer(dev, 4 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Default);

            verts[0] = new Vertex();
            verts[0].Color = color.ToArgb();
            verts[0].Position = new Vector4(rect.x1, rect.y1, 0.0f, 0.0f);
            verts[1] = new Vertex();
            verts[1].Color = color.ToArgb();
            verts[1].Position = new Vector4(rect.x2, rect.y2, 0.0f, 0.0f);
            verts[2] = new Vertex();
            verts[2].Color = color.ToArgb();
            verts[2].Position = new Vector4(rect.x3, rect.y3, 0.0f, 0.0f);
            verts[3] = new Vertex();
            verts[3].Color = color.ToArgb();
            verts[3].Position = new Vector4(rect.x4, rect.y4, 0.0f, 0.0f);

            vb.Lock(0, 0, LockFlags.None).WriteRange(verts, 0, 4);
            vb.Unlock();
            device.SetStreamSource(0, vb, 0, 20);
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);

            vb.Dispose();
        }
Beispiel #3
0
        private static void RenderPanadapterLine(Device dev)        
        {
            if (pan_fill)
            {
                int j = 0;
                int i = 0;

                for (i = 0; i < panadapter_W * 2; i++)
                {
                    PanLine_verts_fill[i] = new Vertex();
                    PanLine_verts_fill[i].Color = pan_fill_color.ToArgb();
                    PanLine_verts_fill[i].Position = new Vector4(i / 2, panadapterX_data[j], 0.0f, 0.0f);
                    PanLine_verts_fill[i + 1] = new Vertex();
                    PanLine_verts_fill[i + 1].Color = pan_fill_color.ToArgb();
                    PanLine_verts_fill[i + 1].Position = new Vector4(i / 2, panadapter_H, 0.0f, 0.0f);
                    i++;
                    j++;
                }

                PanLine_vb_fill.Lock(0, 0, LockFlags.None).WriteRange(PanLine_verts_fill, 0, panadapter_W * 2);
                PanLine_vb_fill.Unlock();

                dev.SetStreamSource(0, PanLine_vb_fill, 0, 20);
                dev.DrawPrimitives(PrimitiveType.LineList, 0, panadapter_W);
            }

            for (int i = 0; i < panadapter_W; i++)
            {
                PanLine_verts[i] = new Vertex();
                PanLine_verts[i].Color = data_line_color.ToArgb();
                PanLine_verts[i].Position = new Vector4(i, panadapterX_data[i], 0.0f, 0.0f);
            }

            PanLine_vb.Lock(0, 0, LockFlags.None).WriteRange(PanLine_verts, 0, panadapter_W);
            PanLine_vb.Unlock();

            dev.SetStreamSource(0, PanLine_vb, 0, 20);
            dev.DrawPrimitives(PrimitiveType.LineStrip, 0, panadapter_W-1);
        }
Beispiel #4
0
        private void picMonitorRender()
        {
            try
            {
                try
                {
            #if DirectX
                    float slope = 0.0f;
                    int num_samples = 0;
                    int start_sample_index = 0;
                    float max_y = float.MinValue;
                    int R = 0, G = 0, B = 0;
                    int i = 0;
                    float[] waterfall_data = new float[picMonitor.Width];
                    int end_sample_index = 0;
                    int yRange = 0;
                    int Low = Display_GDI.RXDisplayLow;
                    int High = Display_GDI.RXDisplayHigh;

                    if (video_driver == DisplayDriver.DIRECTX)
                        yRange = DX.SpectrumGridMax - DX.SpectrumGridMin;
                    else
                        yRange = Display_GDI.SpectrumGridMax - Display_GDI.SpectrumGridMin;

                    if (DX.AverageOn)
                    {
                        if (!UpdateDisplayPanadapterAverage())
                        {
                            average_buffer = null;
                            average_buffer = new float[4096];	// initialize averaging buffer array
                            average_buffer[0] = -999.999F;		// set the clear flag
                            Debug.Write("Reset display average buffer!");
                        }
                    }

                    num_samples = picMonitor.Width;
                    double low = losc * 1e6 - Audio.SampleRate;
                    double high = losc * 1e6 + Audio.SampleRate;
                    start_sample_index = (int)((4096 >> 1) + (Low * 4096.0) / Audio.SampleRate + 1.0);
                    num_samples = (int)((High - Low) * 4096 / Audio.SampleRate);

                    if (start_sample_index < 0)
                        start_sample_index += 4096;

                    if ((num_samples - start_sample_index) > (4096 + 1))
                        num_samples = 4096 - start_sample_index;

                    slope = (float)num_samples / (float)picMonitor.Width;

                    if (start_sample_index < 0)
                    {
                        start_sample_index = 0;
                        end_sample_index = picMonitor.Width;
                    }

                    for (i = 0; i < picMonitor.Width; i++)
                    {
                        float max = float.MinValue;
                        float dval = i * slope + start_sample_index;
                        int lindex = (int)Math.Floor(dval);
                        int rindex = (int)Math.Floor(dval + slope);

                        if (slope <= 1.0 || lindex == rindex)
                        {
                            max = picMonitor_buffer[lindex % 4096] * ((float)lindex - dval + 1)
                                + picMonitor_buffer[(lindex + 1) % 4096] * (dval - (float)lindex);
                        }
                        else
                        {
                            for (int j = lindex; j < rindex; j++)
                                if (picMonitor_buffer[j % 4096] > max) max = picMonitor_buffer[j % 4096];
                        }

                        if (video_driver == DisplayDriver.DIRECTX)
                            max += DX.DisplayCalOffset;
                        else
                            max += Display_GDI.DisplayCalOffset;

                        if (max > max_y)
                            max_y = max;

                        waterfall_data[i] = max;
                        panadapterX_data[i] = (int)(Math.Floor((DX.SpectrumGridMax - max) * picMonitor.Height / yRange));
                    }

                    if (!mox && (monitor_mode == DisplayMode.WATERFALL || monitor_mode == DisplayMode.PANADAPTER))
                    {
                        if (monitor_mode == DisplayMode.WATERFALL)
                        {
                            int pixel_size = 4;
                            int ptr = 0;

                            if (DX.ReverseWaterfall)
                            {
                                Array.Copy(waterfall_memory, waterfall_bmp_stride, waterfall_memory, 0, waterfall_bmp_size - waterfall_bmp_stride);
                                ptr = waterfall_bmp_size - waterfall_bmp_stride;
                            }
                            else
                            {
                                Array.Copy(waterfall_memory, 0, waterfall_memory, waterfall_bmp_stride, waterfall_bmp_size - waterfall_bmp_stride);
                            }

                            i = 0;
                            // draw new data
                            for (i = 0; i < picMonitor.Width; i++)	// for each pixel in the new line
                            {
                                if (waterfall_data[i] <= Display_GDI.WaterfallLowThreshold)
                                {
                                    R = Display_GDI.WaterfallLowColor.R;
                                    G = Display_GDI.WaterfallLowColor.G;
                                    B = Display_GDI.WaterfallLowColor.B;
                                }
                                else if (waterfall_data[i] >= Display_GDI.WaterfallHighThreshold)
                                {
                                    R = 192;
                                    G = 124;
                                    B = 255;
                                }
                                else // value is between low and high
                                {
                                    float range = Display_GDI.WaterfallHighThreshold - Display_GDI.WaterfallLowThreshold;
                                    float offset = waterfall_data[i] - Display_GDI.WaterfallLowThreshold;
                                    float overall_percent = offset / range; // value from 0.0 to 1.0 where 1.0 is high and 0.0 is low.

                                    if (overall_percent < (float)2 / 9) // background to blue
                                    {
                                        float local_percent = overall_percent / ((float)2 / 9);
                                        R = (int)((1.0 - local_percent) * Display_GDI.WaterfallLowColor.R);
                                        G = (int)((1.0 - local_percent) * Display_GDI.WaterfallLowColor.G);
                                        B = (int)(Display_GDI.WaterfallLowColor.B + local_percent * (255 - Display_GDI.WaterfallLowColor.B));
                                    }
                                    else if (overall_percent < (float)3 / 9) // blue to blue-green
                                    {
                                        float local_percent = (overall_percent - (float)2 / 9) / ((float)1 / 9);
                                        R = 0;
                                        G = (int)(local_percent * 255);
                                        B = 255;
                                    }
                                    else if (overall_percent < (float)4 / 9) // blue-green to green
                                    {
                                        float local_percent = (overall_percent - (float)3 / 9) / ((float)1 / 9);
                                        R = 0;
                                        G = 255;
                                        B = (int)((1.0 - local_percent) * 255);
                                    }
                                    else if (overall_percent < (float)5 / 9) // green to red-green
                                    {
                                        float local_percent = (overall_percent - (float)4 / 9) / ((float)1 / 9);
                                        R = (int)(local_percent * 255);
                                        G = 255;
                                        B = 0;
                                    }
                                    else if (overall_percent < (float)7 / 9) // red-green to red
                                    {
                                        float local_percent = (overall_percent - (float)5 / 9) / ((float)2 / 9);
                                        R = 255;
                                        G = (int)((1.0 - local_percent) * 255);
                                        B = 0;
                                    }
                                    else if (overall_percent < (float)8 / 9) // red to red-blue
                                    {
                                        float local_percent = (overall_percent - (float)7 / 9) / ((float)1 / 9);
                                        R = 255;
                                        G = 0;
                                        B = (int)(local_percent * 255);
                                    }
                                    else // red-blue to purple end
                                    {
                                        float local_percent = (overall_percent - (float)8 / 9) / ((float)1 / 9);
                                        R = (int)((0.75 + 0.25 * (1.0 - local_percent)) * 255);
                                        G = (int)(local_percent * 255 * 0.5);
                                        B = 255;
                                    }
                                }

                                // set pixel color
                                waterfall_memory[i * pixel_size + 3 + ptr] = 255;
                                waterfall_memory[i * pixel_size + 2 + ptr] = (byte)R;	// set color in memory
                                waterfall_memory[i * pixel_size + 1 + ptr] = (byte)G;
                                waterfall_memory[i * pixel_size + 0 + ptr] = (byte)B;
                            }

                            try
                            {
                                if (!MOX)
                                {
                                    DataRectangle data;
                                    data = WaterfallTexture.LockRectangle(0, waterfall_rect, LockFlags.None);
                                    waterfall_data_stream = data.Data;
                                    waterfall_data_stream.Position = 0;
                                    waterfall_data_stream.Write(waterfall_memory, 0, (int)waterfall_data_stream.Length);
                                    WaterfallTexture.UnlockRectangle(0);
                                    waterfall_dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 0.0f, 0);
                                    Waterfall_Sprite.Begin(SpriteFlags.None);
                                    Waterfall_Sprite.Draw(WaterfallTexture, Waterfall_texture_size, (Color4)Color.White);
                                    Waterfall_Sprite.End();
                                }
                            }
                            catch (Exception ex)
                            {
                                Debug.Write(ex.ToString());
                            }

                            waterfall_dx_device.BeginScene();
                            //waterfall_dx_device.SetRenderState(RenderState.AlphaBlendEnable, true);
                            //waterfall_dx_device.SetRenderState(RenderState.SourceBlendAlpha, Blend.SourceAlpha);
                            //waterfall_dx_device.SetRenderState(RenderState.DestinationBlend, Blend.DestinationAlpha);
                        }
                        else if (monitor_mode == DisplayMode.PANADAPTER)
                        {
                            waterfall_dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 0.0f, 0);
                            Panadapter_Sprite.Begin(SpriteFlags.AlphaBlend);
                            Panadapter_Sprite.Draw(PanadapterTexture, Panadapter_texture_size, (Color4)Color.White);
                            Panadapter_Sprite.End();

                            waterfall_dx_device.BeginScene();
                            //waterfall_dx_device.SetRenderState(RenderState.AlphaBlendEnable, true);
                            //waterfall_dx_device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
                            //waterfall_dx_device.SetRenderState(RenderState.DestinationBlend, Blend.DestinationAlpha);

                            int j = 0;

                            for (i = 0; i < picMonitor.Width * 2; i++)
                            {
                                PanLine_verts_fill[i] = new Vertex();
                                PanLine_verts_fill[i].Color = DX.PanFillColor.ToArgb();
                                PanLine_verts_fill[i].Position = new Vector4(i / 2, panadapterX_data[j], 0.0f, 0.0f);
                                PanLine_verts_fill[i + 1] = new Vertex();
                                PanLine_verts_fill[i + 1].Color = DX.PanFillColor.ToArgb();
                                PanLine_verts_fill[i + 1].Position = new Vector4(i / 2, picMonitor.Height, 0.0f, 0.0f);
                                i++;
                                j++;
                            }

                            PanLine_vb_fill.Lock(0, 0, LockFlags.None).WriteRange(PanLine_verts_fill, 0, picMonitor.Width * 2);
                            PanLine_vb_fill.Unlock();

                            waterfall_dx_device.SetStreamSource(0, PanLine_vb_fill, 0, 20);
                            waterfall_dx_device.DrawPrimitives(PrimitiveType.LineList, 0, picMonitor.Width);

                            for (i = 0; i < picMonitor.Width; i++)
                            {
                                PanLine_verts[i] = new Vertex();
                                PanLine_verts[i].Color = DX.DataLineColor.ToArgb();
                                PanLine_verts[i].Position = new Vector4(i, panadapterX_data[i], 0.0f, 0.0f);
                            }

                            PanLine_vb.Lock(0, 0, LockFlags.None).WriteRange(PanLine_verts, 0, picMonitor.Width);
                            PanLine_vb.Unlock();

                            waterfall_dx_device.SetStreamSource(0, PanLine_vb, 0, 20);
                            waterfall_dx_device.DrawPrimitives(PrimitiveType.LineStrip, 0, picMonitor.Width - 1);

                        }

                        double vfoa_hz = vfoa * 1e6;
                        double vfob_hz = vfob * 1e6;
                        double losc_hz = losc * 1e6;
                        int vfoa_filter_low = 0;
                        int vfoa_filter_high = 0;
                        int vfoa_filter_left = 0;
                        int vfoa_filter_right = 0;
                        int vfob_filter_low = 0;
                        int vfob_filter_high = 0;
                        int vfob_filter_left = 0;
                        int vfob_filter_right = 0;

                        switch (op_mode_vfoA)
                        {
                            case Mode.RTTY:
                                {
                                    vfoa_filter_low = -FilterWidthVFOA / 2;
                                    vfoa_filter_high = FilterWidthVFOA / 2;
                                    vfoa_filter_left = (int)(((-Low + (vfoa_hz - (int)(rtty.trx.modem[0].shift / 2)) - losc_hz) /
                                        (High - Low) * picMonitor.Width));
                                    vfoa_filter_right = (int)(((-Low + (vfoa_hz + (int)(rtty.trx.modem[0].shift / 2)) - losc_hz) /
                                        (High - Low) * picMonitor.Width));

                                    if (vfoa_filter_left == vfoa_filter_right)
                                        vfoa_filter_right = vfoa_filter_left + 1;

                                    if (vfob_filter_left == vfob_filter_right)
                                        vfob_filter_right = vfob_filter_left + 1;

                                    double w = (vfoa_filter_right - vfoa_filter_left);
                                    int ww = (int)((w * rtty.trx.modem[0].shift / 2) / (int)(rtty.trx.modem[0].shift)) / 2;

                                    RenderVerticalLine(waterfall_dx_device, vfoa_filter_left - ww, 0,
                                        vfoa_filter_left - ww, 20, Color.White);
                                    RenderVerticalLine(waterfall_dx_device, vfoa_filter_left + ww, 0,
                                        vfoa_filter_left + ww, 20, Color.White);
                                    RenderVerticalLine(waterfall_dx_device, vfoa_filter_right + ww, 0,
                                        vfoa_filter_right + ww, 20, Color.White);
                                    RenderVerticalLine(waterfall_dx_device, vfoa_filter_right - ww, 0,
                                        vfoa_filter_right - ww, 20, Color.White);

                                    RenderHorizontalLine(waterfall_dx_device, vfoa_filter_left - ww, 0,
                                        vfoa_filter_right + ww, 0, Color.White);
                                    RenderHorizontalLine(waterfall_dx_device, vfoa_filter_left - ww, 1,
                                        vfoa_filter_right + ww, 1, Color.White);
                                }
                                break;

                            case Mode.BPSK31:
                            case Mode.BPSK63:
                            case Mode.BPSK125:
                            case Mode.BPSK250:
                            case Mode.QPSK31:
                            case Mode.QPSK63:
                            case Mode.QPSK125:
                            case Mode.QPSK250:
                                vfoa_filter_low = -(int)psk.trx.modem[0].bandwidth / 2;
                                vfoa_filter_high = (int)psk.trx.modem[0].bandwidth / 2;
                                vfoa_filter_left = (int)(((-Low + vfoa_hz - filter_width_vfoA / 2 - losc_hz) /
                                    (High - Low) * picMonitor.Width));
                                vfoa_filter_right = (int)(((-Low + vfoa_hz + filter_width_vfoA / 2 - losc_hz) /
                                    (High - Low) * picMonitor.Width));

                                if (vfoa_filter_left == vfoa_filter_right)
                                    vfoa_filter_right = vfoa_filter_left + 1;

                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_left, 0,
                                    vfoa_filter_left, picMonitor.Height, Color.White);
                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_left - 1, 0,
                                    vfoa_filter_left - 1, picMonitor.Height, Color.White);
                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_right, 0,
                                    vfoa_filter_right, picMonitor.Height, Color.White);
                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_right + 1, 0,
                                    vfoa_filter_right + 1, picMonitor.Height, Color.White);
                                break;
                            case Mode.CW:
                                vfoa_filter_low = -FilterWidthVFOA / 2;
                                vfoa_filter_high = FilterWidthVFOA / 2;
                                vfoa_filter_left = (int)(((-Low + vfoa_hz - filter_width_vfoA / 2 - losc_hz) /
                                    (High - Low) * picMonitor.Width));
                                vfoa_filter_right = (int)(((-Low + vfoa_hz + filter_width_vfoA / 2 - losc_hz) /
                                    (High - Low) * picMonitor.Width));

                                if (vfoa_filter_left == vfoa_filter_right)
                                    vfoa_filter_right = vfoa_filter_left + 1;

                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_left, 0,
                                    vfoa_filter_left, picMonitor.Height, Color.White);
                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_left - 1, 0,
                                    vfoa_filter_left - 1, picMonitor.Height, Color.White);
                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_right, 0,
                                    vfoa_filter_right, picMonitor.Height, Color.White);
                                RenderVerticalLine(waterfall_dx_device, vfoa_filter_right + 1, 0,
                                    vfoa_filter_right + 1, picMonitor.Height, Color.White);
                                break;
                        }

                        switch (op_mode_vfoB)
                        {
                            case Mode.RTTY:
                                {
                                    vfob_filter_low = -FilterWidthVFOB / 2;
                                    vfob_filter_high = FilterWidthVFOB / 2;
                                    vfob_filter_left = (int)(((-Low + vfob_hz - (int)(rtty.trx.modem[0].shift / 2) - losc_hz) /
                                        (High - Low) * picMonitor.Width));
                                    vfob_filter_right = (int)(((-Low + vfob_hz + (int)(rtty.trx.modem[0].shift / 2) - losc_hz) /
                                        (High - Low) * picMonitor.Width));

                                    if (vfob_filter_left == vfob_filter_right)
                                        vfob_filter_right = vfob_filter_left + 1;

                                    double w = (vfob_filter_right - vfob_filter_left);
                                    int ww = (int)((w * rtty.trx.modem[0].shift / 2) / (int)(rtty.trx.modem[0].shift)) / 2;

                                    if (btnRX2On.BackColor == Color.LimeGreen)
                                    {
                                        RenderHorizontalLine(waterfall_dx_device, vfob_filter_left - ww, 0,
                                            vfob_filter_right + ww, 0, Color.Red);
                                        RenderHorizontalLine(waterfall_dx_device, vfob_filter_left - ww, 1,
                                            vfob_filter_right + ww, 1, Color.Red);
                                        RenderVerticalLine(waterfall_dx_device, vfob_filter_left - ww, 0,
                                            vfob_filter_left - ww, 20, Color.Red);
                                        RenderVerticalLine(waterfall_dx_device, vfob_filter_left + ww, 0,
                                            vfob_filter_left + ww, 20, Color.Red);
                                        RenderVerticalLine(waterfall_dx_device, vfob_filter_right + ww, 0,
                                            vfob_filter_right + ww, 20, Color.Red);
                                        RenderVerticalLine(waterfall_dx_device, vfob_filter_right - ww, 0,
                                            vfob_filter_right - ww, 20, Color.Red);
                                    }
                                }
                                break;

                            case Mode.BPSK31:
                            case Mode.BPSK63:
                            case Mode.BPSK125:
                            case Mode.BPSK250:
                            case Mode.QPSK31:
                            case Mode.QPSK63:
                            case Mode.QPSK125:
                            case Mode.QPSK250:
                                if (btnRX2On.BackColor == Color.LimeGreen)
                                {
                                    vfob_filter_low = -(int)psk.trx.modem[1].bandwidth / 2;
                                    vfob_filter_high = (int)psk.trx.modem[1].bandwidth / 2;
                                    vfob_filter_left = (int)(((-Low + vfob_hz - filter_width_vfoB / 2 - losc_hz) /
                                        (High - Low) * picMonitor.Width));
                                    vfob_filter_right = (int)(((-Low + vfob_hz + filter_width_vfoB / 2 - losc_hz) /
                                        (High - Low) * picMonitor.Width));

                                    if (vfob_filter_left == vfob_filter_right)
                                        vfob_filter_right = vfob_filter_left + 1;

                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_left, 0,
                                        vfob_filter_left, picMonitor.Height, Color.Red);
                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_left - 1, 0,
                                        vfob_filter_left - 1, picMonitor.Height, Color.Red);
                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_right, 0,
                                        vfob_filter_right, picMonitor.Height, Color.Red);
                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_right + 1, 0,
                                        vfob_filter_right + 1, picMonitor.Height, Color.Red);
                                }
                                break;
                            case Mode.CW:
                                if (btnRX2On.BackColor == Color.LimeGreen)
                                {
                                    vfob_filter_low = -FilterWidthVFOB / 2;
                                    vfob_filter_high = FilterWidthVFOB / 2;
                                    vfob_filter_left = (int)(((-Low + vfob_hz - filter_width_vfoB / 2 - losc_hz) /
                                        (High - Low) * picMonitor.Width));
                                    vfob_filter_right = (int)(((-Low + vfob_hz + filter_width_vfoB / 2 - losc_hz) /
                                        (High - Low) * picMonitor.Width));

                                    if (vfob_filter_left == vfob_filter_right)
                                        vfob_filter_right = vfob_filter_left + 1;

                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_left, 0,
                                        vfob_filter_left, picMonitor.Height, Color.Red);
                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_left - 1, 0,
                                        vfob_filter_left - 1, picMonitor.Height, Color.Red);
                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_right, 0,
                                        vfob_filter_right, picMonitor.Height, Color.Red);
                                    RenderVerticalLine(waterfall_dx_device, vfob_filter_right + 1, 0,
                                        vfob_filter_right + 1, picMonitor.Height, Color.Red);
                                }
                                break;
                        }

                        waterfall_dx_device.EndScene();
                        waterfall_dx_device.Present();
                    }
                    else if (monitor_mode == DisplayMode.SCOPE)
                    {
                        Mode new_mode = op_mode_vfoA;

                        if (tx_split)
                            new_mode = op_mode_vfoB;

                        if ((new_mode == Mode.CW && mox) || !mox)
                        {
                            DX.ConvertDataForScope(picMonitor.Width, picMonitor.Height);
                            waterfall_dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 0.0f, 0);
                            Panadapter_Sprite.Begin(SpriteFlags.AlphaBlend);
                            Panadapter_Sprite.Draw(PanadapterTexture, Panadapter_texture_size, (Color4)Color.White);
                            Panadapter_Sprite.End();
                            waterfall_dx_device.BeginScene();
                            DX.RenderScopeLine(waterfall_dx_device, picMonitor.Width, true);
                            waterfall_dx_device.EndScene();
                            waterfall_dx_device.Present();
                        }
                    }
            #endif
                }
                catch (Exception ex)
                {
                    Debug.Write(ex.ToString());
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.ToString());
            }
        }