Beispiel #1
0
        public Main()
        {
            Control.CheckForIllegalCrossThreadCalls = true;
            InitializeComponent();
            DoubleBuffered = true;
            SuspendLayout();
            bufferedChart = new BufferedChart();
            bufferedChart.mainForm = this;
            bufferedChart.Dock = DockStyle.Fill;
            kontainerPreGraf.Controls.Add(bufferedChart);

            ResumeLayout();
            //fillRandomDataPoints();
            timer1_Tick(this, EventArgs.Empty);
            timer1.Interval = (60 - DateTime.Now.Second) * 1000;
            timer1.Enabled = true;
            setTimer = true;

            MeasurementControl = new MeasurementControl();
            MeasurementControl.Graf = bufferedChart;

            MeasurementControl.setMainForm(this);
        }
        public BufferedChart()
            : base()
        {
            AutoScroll = true;
            AutoScrollMinSize = new Size(100, 100);
            zoomYScales = new long[28];
            for (long f = 1, i = 0; i < 28; i++)
            {
                long c = 0;
                if (i % 3 == 0) c = 10 * f;
                if (i % 3 == 1) c = 20 * f;
                if (i % 3 == 2)
                {
                    c = 50 * f;
                    f *= 10;
                }
                zoomYScales[i] = c;
            }
            LeftMargin = 60;
            RightMargin = 30;
            BottomMargin = 30;
            TopMargin = 40;
            scrollBarHeight = 10;
            dragging = false;
            setParameters(0, 1, 1); //default na zaciatku... prepise sa pri volani metody zvonka
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            // Configure the Form for this example.
            this.Text = "User double buffering";
            this.MouseDown += new MouseEventHandler(this.MouseDownHandler);
            this.MouseDown += klikMysi;
            this.MouseMove += pohybMysi;
            this.MouseUp += uvolnenieMysi;
            //this.PreviewKeyDown += klikKlavesy;
            this.Resize += new EventHandler(this.OnResize);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.PreviewKeyDown += new PreviewKeyDownEventHandler(previewKlik);
            // Configure a timer to draw graphics updates.
            timer1 = new System.Windows.Forms.Timer();
            timer1.Interval = 50;
            timer1.Tick += new EventHandler(this.OnTimer);

            bufferingMode = 2;
            count = 0;
            bufferedChartClassReference = this;
            // Retrieves the BufferedGraphicsContext for the
            // current application domain.
            context = BufferedGraphicsManager.Current;

            // Sets the maximum size for the primary graphics buffer
            // of the buffered graphics context for the application
            // domain.  Any allocation requests for a buffer larger
            // than this will create a temporary buffered graphics
            // context to host the graphics buffer.
            context.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);

            // Allocates a graphics buffer the size of this form
            // using the pixel format of the Graphics created by
            // the Form.CreateGraphics() method, which returns a
            // Graphics object that matches the pixel format of the form.
            grafx = context.Allocate(this.CreateGraphics(),
                 new Rectangle(0, 0, this.Width, this.Height));

            // Draw the first frame to the buffer.
            // DrawToBuffer(grafx.Graphics);
            timer1.Enabled = true;
        }