Click here to Skip to main content
14,845,581 members
Home / Discussions / C#
   

C#

 
QuestionDoes the Visual studio C#.net have a progressBar and a control line ? Pin
Member 24584676-Oct-19 23:34
MemberMember 24584676-Oct-19 23:34 
AnswerRe: Does the Visual studio C#.net have a progressBar and a control line ? Pin
Afzaal Ahmad Zeeshan6-Oct-19 23:44
mveAfzaal Ahmad Zeeshan6-Oct-19 23:44 
GeneralRe: Does the Visual studio C#.net have a progressBar and a control line ? Pin
Member 24584677-Oct-19 16:41
MemberMember 24584677-Oct-19 16:41 
QuestionDrawing from a Class library to a pictureBox Pin
Ali Zigon6-Oct-19 5:27
MemberAli Zigon6-Oct-19 5:27 
AnswerRe: Drawing from a Class library to a pictureBox Pin
Richard MacCutchan6-Oct-19 5:48
mveRichard MacCutchan6-Oct-19 5:48 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Ali Zigon6-Oct-19 6:19
MemberAli Zigon6-Oct-19 6:19 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Richard MacCutchan6-Oct-19 7:08
mveRichard MacCutchan6-Oct-19 7:08 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Ali Zigon6-Oct-19 8:37
MemberAli Zigon6-Oct-19 8: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 22:17
mveRichard MacCutchan6-Oct-19 22:17 
GeneralRe: Drawing from a Class library to a pictureBox Pin
Ali Zigon7-Oct-19 3:31
MemberAli Zigon7-Oct-19 3:31 
QuestionReading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 5:27
professionalKevin Marois4-Oct-19 5:27 
AnswerRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 5:42
mveRichard MacCutchan4-Oct-19 5:42 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 6:46
professionalKevin Marois4-Oct-19 6:46 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 6:54
mveRichard MacCutchan4-Oct-19 6:54 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 7:20
professionalKevin Marois4-Oct-19 7:20 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 7:30
mveRichard MacCutchan4-Oct-19 7:30 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois4-Oct-19 7:40
professionalKevin Marois4-Oct-19 7:40 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Richard MacCutchan4-Oct-19 22:37
mveRichard MacCutchan4-Oct-19 22:37 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Eddy Vluggen5-Oct-19 9:17
professionalEddy Vluggen5-Oct-19 9:17 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois6-Oct-19 6:25
professionalKevin Marois6-Oct-19 6:25 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Eddy Vluggen6-Oct-19 6:52
professionalEddy Vluggen6-Oct-19 6:52 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Dave Kreskowiak6-Oct-19 8:47
mveDave Kreskowiak6-Oct-19 8:47 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois6-Oct-19 8:51
professionalKevin Marois6-Oct-19 8:51 
AnswerRe: Reading Access Into SQL - OLE Provider Errors Pin
Gerry Schmitz4-Oct-19 10:22
mveGerry Schmitz4-Oct-19 10:22 
GeneralRe: Reading Access Into SQL - OLE Provider Errors Pin
Kevin Marois6-Oct-19 6:16
professionalKevin Marois6-Oct-19 6: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.