Click here to Skip to main content
14,356,442 members
   

C#

 
QuestionDoes the Visual studio C#.net have a progressBar and a control line ? Pin
Member 24584677-Oct-19 0:34
memberMember 24584677-Oct-19 0:34 
AnswerRe: Does the Visual studio C#.net have a progressBar and a control line ? Pin
Afzaal Ahmad Zeeshan7-Oct-19 0:44
mveAfzaal Ahmad Zeeshan7-Oct-19 0:44 
GeneralRe: Does the Visual studio C#.net have a progressBar and a control line ? Pin
Member 24584677-Oct-19 17:41
memberMember 24584677-Oct-19 17:41 
QuestionDrawing from a Class library to a pictureBox Pin
Ali Zigon6-Oct-19 6:27
memberAli Zigon6-Oct-19 6:27 
AnswerRe: Drawing from a Class library to a pictureBox Pin
Richard MacCutchan6-Oct-19 6:48
protectorRichard MacCutchan6-Oct-19 6:48 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Ali Zigon6-Oct-19 7:19
memberAli Zigon6-Oct-19 7:19 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Richard MacCutchan6-Oct-19 8:08
protectorRichard MacCutchan6-Oct-19 8:08 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Ali Zigon6-Oct-19 9:37
memberAli Zigon6-Oct-19 9:37 
Thank you 1M times!
I've got it working (well... sort of...). It works BUT it works SLOWLY and it draws only 2/3 of the width of the pictureBox!Confused | :confused: Confused | :confused: Any idea?

Here's the code so far...

CLASS:
namespace Osciloscope
{

    public class Osciloscope
    {
        int SCOPE_WIDTH, SCOPE_HEIGHT; // the width and the height of the osciloscope screen
        int SCOPE_HORIZONTAL_CENTER, SCOPE_VERTICAL_CENTER; //center point of the screen
        int SCAN_POINT_X; //number of points in the line (the width of the scope)
        int SCAN_POINT_Y; //as above but vertical (input...)
        int SCAN_POINT_X_NEW;
        int SCAN_POINT_Y_NEW;
        int TIMER_INTERVAL;

        Bitmap _Image;
        Graphics g;
        Pen p;

        public Osciloscope(PictureBox picture, bool Run, int Interval)
        {
            SCOPE_HEIGHT = picture.Height;
            SCOPE_WIDTH = picture.Width;
            TIMER_INTERVAL = Interval;

            //calculate mid point if the scope
            SCOPE_HORIZONTAL_CENTER = SCOPE_WIDTH / 2;
            SCOPE_VERTICAL_CENTER = SCOPE_HEIGHT / 2;
            SCAN_POINT_X = 1;// leftmost point on the screen (start scan)
            SCAN_POINT_Y = SCOPE_VERTICAL_CENTER; //the line runs in the middle of the screen

            _Image = new Bitmap(SCOPE_HEIGHT, SCOPE_WIDTH);
            Timer t = new Timer();

            t.Tick += new EventHandler(t_Tick);

            if (Run)
            {
                t.Enabled = true;
                t.Interval = TIMER_INTERVAL;
                t.Start();
            }
            else
            {
                t.Stop();
            }

        }

        void t_Tick(object sender, EventArgs e)
        {
            DrawGraph();
        }

        public Bitmap DrawGraph()
        {
            g = Graphics.FromImage(_Image);

            p = new Pen(Color.Green, 1f);

            SCAN_POINT_Y_NEW =(int) Math.Sin(SCAN_POINT_X);

            // draw the line
            g.DrawLine(p, SCAN_POINT_X, SCAN_POINT_Y, SCAN_POINT_X_NEW, SCAN_POINT_Y_NEW);

            p.Dispose();
            g.Dispose();

            SCAN_POINT_X_NEW = SCAN_POINT_X;
            SCAN_POINT_X=SCAN_POINT_X+10;

            if (SCAN_POINT_X == SCOPE_WIDTH)
                {
                    SCAN_POINT_X = 1;
                }

            return _Image;

        }
    }
}


And Form...
public partial class FrmMain : Form
{
    public FrmMain()
    {
        InitializeComponent();
    }

    Osciloscope Osciloscope;
    private void FrmMain_Load(object sender, EventArgs e)
    {
        Osciloscope = new Osciloscope(Scope, true, 1);
        this.Text = Scope.Width.ToString();

        // invoke Paint event
        Scope.Invalidate();
    }

    private void Scope_Paint(object sender, PaintEventArgs e)
    {
        Scope.Image = Osciloscope.DrawGraph();
    }
}

GeneralRe: Drawing from a Class library to a pictureBox Pin
Richard MacCutchan6-Oct-19 23:17
protectorRichard MacCutchan6-Oct-19 23:17 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Ali Zigon7-Oct-19 4:31
memberAli Zigon7-Oct-19 4:31 
QuestionReading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 6:27
professionalKevin Marois4-Oct-19 6:27 
AnswerRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 6:42
protectorRichard MacCutchan4-Oct-19 6:42 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 7:46
professionalKevin Marois4-Oct-19 7:46 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 7:54
protectorRichard MacCutchan4-Oct-19 7:54 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 8:20
professionalKevin Marois4-Oct-19 8:20 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 8:30
protectorRichard MacCutchan4-Oct-19 8:30 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 8:40
professionalKevin Marois4-Oct-19 8:40 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 23:37
protectorRichard MacCutchan4-Oct-19 23:37 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Eddy Vluggen5-Oct-19 10:17
mveEddy Vluggen5-Oct-19 10:17 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois6-Oct-19 7:25
professionalKevin Marois6-Oct-19 7:25 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Eddy Vluggen6-Oct-19 7:52
mveEddy Vluggen6-Oct-19 7:52 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Dave Kreskowiak6-Oct-19 9:47
mveDave Kreskowiak6-Oct-19 9:47 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois6-Oct-19 9:51
professionalKevin Marois6-Oct-19 9:51 
AnswerRe: Reading Access Into SQL - OLE Provider Errors Pin
Gerry Schmitz4-Oct-19 11:22
mveGerry Schmitz4-Oct-19 11:22 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois6-Oct-19 7:16
professionalKevin Marois6-Oct-19 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.