Пример #1
0
 private void typeLegendPanel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if ((e.Button & MouseButtons.Left) != MouseButtons.None)
     {
         for (int i = 0; i < buckets.Length; i++)
         {
             if (buckets[i].selected)
             {
                 graphPanel.Invalidate();
                 typeLegendPanel.Invalidate();
                 buckets[i].selected = false;
             }
         }
         if (sortedTypeTable != null)
         {
             foreach (TypeDesc t in sortedTypeTable)
             {
                 if (t.rect.Contains(e.X, e.Y) != t.selected)
                 {
                     t.selected = !t.selected;
                     graphPanel.Invalidate();
                     typeLegendPanel.Invalidate();
                 }
             }
         }
     }
     else if ((e.Button & MouseButtons.Right) != MouseButtons.None)
     {
         Point p = new Point(e.X, e.Y);
         contextMenu.Show(typeLegendPanel, p);
     }
 }
Пример #2
0
 private void InvertButton_Click(object sender, System.EventArgs e)
 {
     if (Filters.Invert(m_Bitmap, out gray))
     {
         LcolorPanel.Invalidate();
         graydo();
     }
 }
Пример #3
0
        private void PanelMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            Marquis.Size = new Size(e.X - Marquis.X, e.Y - Marquis.Y);
            P1.Invalidate();
        }
 private void M_Down(object sender, MouseEventArgs m)
 {
     if (m.Button == MouseButtons.Left)
     {
         mStartPoint = new Point(m.X, m.Y);
         mLastPoint  = mStartPoint;
         mPath       = new GraphicsPath();
         P1.Invalidate();
     }
 }
Пример #5
0
        private void runButton_Click(object sender, System.EventArgs e)
        {
            int N = int.Parse(pointCount.Text);

            pts = new Point[N];
            for (int i = 0; i < N; i++)
            {
                pts[i] = Point.Random(500, 500);
            }
            chpts = Convexhull.ConvexHull(pts);

            drawarea.Invalidate();
        }
Пример #6
0
        private bool ClosePage()
        {
            CategoryPanel cp = _pages[(int)_currentPageID];

            if (!cp.Commit(_options))
            {
                return(false);
            }
            this.Controls.Remove(cp);
            PanelItemAt(_currentPageID).Selected = false;
            _categoryItems.Invalidate(true);
            return(true);
        }
Пример #7
0
        private bool ClosePage()
        {
            Debug.Assert(_currentEntry != null);

            if (!_currentEntry.Extension.Commit(GetWorkPreferencesFor(_currentEntry)))
            {
                return(false);
            }
            this.Controls.Remove(_currentEntry.Extension.ContentPanel);
            PanelItemAt(_currentEntry.Index).Selected = false;
            _categoryItems.Invalidate(true);
            return(true);
        }
Пример #8
0
        //Writer : Junsuk Park
        //Function : panel1_MouseDown
        //Print the angle to display (Actually, the angle in reading from the gimbal has weird value. (Not solved..)
        private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // Update the mouse path with the mouse information
            Point mouseDownLocation = new Point(e.X, e.Y);

            angle = SerialProtocol.getAngle();

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (angle[1] > 360)
                {
                    //angle[1] = angle[1] - 360;
                }
                this.label8.Text = "Pitch: " + angle[1].ToString();
                if (angle[2] > 360)
                {
                    // angle[2] = angle[2] - 360;
                }
                this.label7.Text = "Yaw: " + angle[2].ToString();
                break;

            default:
                break;
            }


            panel1.Focus();
            panel1.Invalidate();
        }
Пример #9
0
        private void GraphArea_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            selectImage = (Image)Form1.myImage.Clone();
            using (Graphics selectGraph = Graphics.FromImage(selectImage))
            {
                int   pointIndex = 0;
                float minError   = 640 * 640 + 480 * 480;         //Max number that it is possible to have

                for (ushort i = 0; i <= 359; i++)
                {
                    errorVector[i] = Convert.ToSingle((e.X - circleXvalue[i]) * (e.X - circleXvalue[i])
                                                      + (e.Y - circleYvalue[i]) * (e.Y - circleYvalue[i]));
                    if (errorVector[i] < minError)
                    {
                        pointIndex = i;                         //at the end pintIndex has the angle as well
                        minError   = errorVector[i];
                    }
                }

                selectGraph.DrawEllipse(Pens.Red, circleXvalue[pointIndex] - 1, circleYvalue[pointIndex] - 1, 2, 2);         //Draw circles to indicate the selected point
                selectGraph.DrawEllipse(Pens.Red, circleXvalue[pointIndex] - 2, circleYvalue[pointIndex] - 2, 4, 4);


                GraphArea.Invalidate();
                GraphArea.Update();

                Form1.ml  = Math.Sqrt(Math.Pow(circleXvalue[pointIndex] - 320, 2) + Math.Pow(circleYvalue[pointIndex] - 240, 2)) / 220; //220=Gama(1), Center point is 320,240
                Form1.al1 = (pointIndex < 180)?(-pointIndex):(360 - pointIndex);                                                        //Make it in +/- format

                this.lbltxtAng.Text = Convert.ToString(Form1.al1);
                this.lbltxtMag.Text = Convert.ToString(Math.Round(Form1.ml, 3));

                this.btnContinue.Enabled = true;               //enables the Continue botton that user can decide between continuing the design or re-selecting the point
            }
        }
Пример #10
0
 private void button1_Click(object sender, System.EventArgs e)
 //repaint the panel as a way of clearing it
 {
     panel2.Invalidate();
     HowManyDrags      = 0;
     lblDragCount.Text = "";
 }
Пример #11
0
 public static void randomizeArray(int[] array, Panel panel)
 {
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = random.Next(10, 100);
     }
     panel.Invalidate();
 }
Пример #12
0
        private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // Update the mouse path with the mouse information
            Point mouseDownLocation = new Point(e.X, e.Y);

            string eventString = null;

            switch (e.Button)
            {
            case MouseButtons.Left:
                eventString = "L";
                break;

            case MouseButtons.Right:
                eventString = "R";
                break;

            case MouseButtons.Middle:
                eventString = "M";
                break;

            case MouseButtons.XButton1:
                eventString = "X1";
                break;

            case MouseButtons.XButton2:
                eventString = "X2";
                break;

            case MouseButtons.None:
            default:
                break;
            }

            if (eventString != null)
            {
                mousePath.AddString(eventString, FontFamily.GenericSerif, (int)FontStyle.Bold, fontSize, mouseDownLocation, StringFormat.GenericDefault);
            }
            else
            {
                mousePath.AddLine(mouseDownLocation, mouseDownLocation);
            }
            panel1.Focus();
            panel1.Invalidate();
            count++;
        }
Пример #13
0
        // 窗体淡入淡出,和进度条控制
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            try
            {
                lblStatus.Text = ms_sStatus;
                //窗体淡入淡出
                if (m_dblOpacityIncrement > 0)
                {
                    m_iActualTicks++;
                    if (this.Opacity < 1)
                    {
                        this.Opacity += m_dblOpacityIncrement;
                    }
                }
                else
                {
                    if (this.Opacity > 0)
                    {
                        this.Opacity += m_dblOpacityIncrement;
                    }
                    else
                    {
                        StoreIncrements();//存储时间
                        this.Close();
                        Debug.WriteLine("Called this.Close()");
                    }
                }

                //进度条控制
                if (m_bFirstLaunch == false && m_dblLastCompletionFraction < m_dblCompletionFraction)
                {
                    m_dblLastCompletionFraction += m_dblPBIncrementPerTimerInterval;
                    int width  = (int)Math.Floor(pnlStatus.ClientRectangle.Width * m_dblLastCompletionFraction);
                    int height = pnlStatus.ClientRectangle.Height;
                    int x      = pnlStatus.ClientRectangle.X;
                    int y      = pnlStatus.ClientRectangle.Y;
                    if (width > 0 && height > 0)
                    {
                        m_rProgress = new Rectangle(x, y, width, height);
                        pnlStatus.Invalidate(m_rProgress);
                        int iSecondsLeft = 1 + (int)(TIMER_INTERVAL * ((1.0 - m_dblLastCompletionFraction) / m_dblPBIncrementPerTimerInterval)) / 1000;
                        if (iSecondsLeft == 1)
                        {
                            //lblTimeRemaining.Text = string.Format( "时间剩余 1 秒");
                            SetTimeRemaining(string.Format("时间剩余 1 秒"));
                        }
                        else
                        {
                            //lblTimeRemaining.Text = string.Format( "时间剩余 {0} 秒 ", iSecondsLeft);
                            SetTimeRemaining(string.Format("时间剩余 {0} 秒 ", iSecondsLeft));
                        }
                    }
                }
            }
            catch
            {
            }
        }
Пример #14
0
 public void MouseMove(ref EditorData data, Panel panel, Point gridPosition)
 {
     if (mouseDown&&!mPrevious.Equals(gridPosition))
     {
         data.SelectedEntities = data.Level.SelectEntities(mInitial, gridPosition, true);
         mPrevious = gridPosition;
         panel.Invalidate(panel.DisplayRectangle);
     }
 }
Пример #15
0
        // Method to store the intervals (in percent complete) from the current invocation of
        // the splash screen to the registry.

        /*
         *      private void StoreIncrements()
         *      {
         *              string sPercent = "";
         *              double dblElapsedMilliseconds = ElapsedMilliSeconds();
         *              for( int i = 0; i < m_alActualTimes.Count; i++ )
         *                      sPercent += ((double)m_alActualTimes[i]/dblElapsedMilliseconds).ToString("0.####", System.Globalization.NumberFormatInfo.InvariantInfo) + " ";
         *
         *  SetPercents(sPercent);
         *
         *              m_dblPBIncrementPerTimerInterval = 1.0/(double)m_iActualTicks;
         *  string sIncrement = m_dblPBIncrementPerTimerInterval.ToString("#.000000", System.Globalization.NumberFormatInfo.InvariantInfo);
         *  SetIncrement(sIncrement);
         *      }
         */

        //********* Event Handlers ************

        // Tick Event handler for the Timer control.  Handle fade in and fade out.  Also
        // handle the smoothed progress bar.
        private void timer1_Tick(object sender, System.EventArgs e)
        {
            lblStatus.Text = ms_sStatus;

            if (m_dblOpacityIncrement > 0)
            {
                m_iActualTicks++;
                if (this.Opacity < 1)
                {
                    this.Opacity += m_dblOpacityIncrement;
                }
            }
            else
            {
                if (this.Opacity > 0)
                {
                    this.Opacity += m_dblOpacityIncrement;
                }
                else
                {
                    //StoreIncrements();
                    this.Close();

                    // SS: Avoid cross-thread call
                    //Debug.WriteLine("Called this.Close()");
                }
            }
            if (m_bFirstLaunch == false && m_dblLastCompletionFraction < m_dblCompletionFraction)
            {
                m_dblLastCompletionFraction += m_dblPBIncrementPerTimerInterval;
                int width  = (int)Math.Floor(pnlStatus.ClientRectangle.Width * m_dblLastCompletionFraction);
                int height = pnlStatus.ClientRectangle.Height;
                int x      = pnlStatus.ClientRectangle.X;
                int y      = pnlStatus.ClientRectangle.Y;
                if (width > 0 && height > 0)
                {
                    m_rProgress = new Rectangle(x, y, width, height);
                    pnlStatus.Invalidate(m_rProgress);
                    int iSecondsLeft = 1 + (int)(TIMER_INTERVAL * ((1.0 - m_dblLastCompletionFraction) / m_dblPBIncrementPerTimerInterval)) / 1000;

                    if (iSecondsLeft > 1 && !lblTimeRemaining.Visible)
                    {
                        lblTimeRemaining.Visible = true;
                    }

                    if (iSecondsLeft == 1)
                    {
                        lblTimeRemaining.Text = string.Format("1 second remaining");
                    }
                    else
                    {
                        lblTimeRemaining.Text = string.Format("{0} seconds remaining", iSecondsLeft);
                    }
                }
            }
        }
Пример #16
0
 protected override void OnInvalidated(InvalidateEventArgs e)
 {
     base.OnInvalidated(e);
     //Check if there is a watermark
     if (waterMarkContainer != null)
     {
         //if there is a watermark it should also be invalidated();
         waterMarkContainer.Invalidate();
     }
 }
Пример #17
0
 protected override void OnInvalidated(InvalidateEventArgs e)
 {
     base.OnInvalidated(e);
     //Check if there is a placeholder
     if (placeholderContainer != null)
     {
         //if there is a placeholder it should also be invalidated();
         placeholderContainer.Invalidate();
     }
 }
Пример #18
0
 /// <summary>
 /// Draws the placeholder if the text length is 0
 /// </summary>
 private void DrawPlaceholder()
 {
     if (placeholderContainer == null && TextLength <= 0)
     {
         placeholderContainer        = new Panel(); // Creates the new panel instance
         placeholderContainer.Paint += new PaintEventHandler(placeholderContainer_Paint);
         placeholderContainer.Invalidate();
         placeholderContainer.Click += new EventHandler(placeholderContainer_Click);
         Controls.Add(placeholderContainer); // adds the control
     }
 }
Пример #19
0
 /// <summary>
 /// Draws the watermark if the text length is 0
 /// </summary>
 private void DrawWaterMark()
 {
     if (this.waterMarkContainer == null && this.TextLength <= 0)
     {
         waterMarkContainer = new Panel(); // Creates the new panel instance
         waterMarkContainer.Paint += new PaintEventHandler(waterMarkContainer_Paint);
         waterMarkContainer.Invalidate();
         waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click);
         this.Controls.Add(waterMarkContainer); // adds the control
     }
 }
Пример #20
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// -----------------------------------------------------------------------------------
        protected void UpdateStepLabel()
        {
            lblSteps.Text = String.Format(m_StepIndicatorFormat,
                                          (m_CurrentStepNumber + 1).ToString(),
                                          (m_LastStepNumber + 1).ToString());

            lblSteps.Left = this.ClientSize.Width - (lblSteps.Width +
                                                     (int)kdxpStepsLabelRightPadding);

            panSteps.Invalidate();
        }
Пример #21
0
 public void MouseMove(ref EditorData data, Panel panel, Point gridPosition)
 {
     if (!_mPrevious.Equals(gridPosition) && data.SelectedEntities.Count > 0 && _mouseDown)
     {
         //Keep an eye on this. The SelectedEntities can return an empty list
         data.Level.MoveEntity(data.SelectedEntities,
             new Size(Point.Subtract(gridPosition, new Size(_mPrevious))), false);
         _mPrevious = gridPosition;
         panel.Invalidate(panel.DisplayRectangle);
     }
 }
Пример #22
0
 /// <summary>
 /// Draws the watermark if the text length is 0
 /// </summary>
 private void DrawWaterMark()
 {
     if (this.waterMarkContainer == null && this.TextLength <= 0)
     {
         waterMarkContainer        = new Panel(); // Creates the new panel instance
         waterMarkContainer.Paint += new PaintEventHandler(waterMarkContainer_Paint);
         waterMarkContainer.Invalidate();
         waterMarkContainer.Click += new EventHandler(waterMarkContainer_Click);
         this.Controls.Add(waterMarkContainer); // adds the control
     }
 }
Пример #23
0
 // draw panel mouse down event handler
 private void drawPanel_MouseDown(object sender,
                                  System.Windows.Forms.MouseEventArgs e)
 {
     // add mouse position to vertex list
     points.Add(new Point(e.X, e.Y));
     drawPanel.Invalidate(); // refresh panel
 } // end method drawPanel_MouseDown
Пример #24
0
        private void panel1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Point mouseUpLocation = new System.Drawing.Point(e.X, e.Y);

            // Show the number of clicks in the path graphic.
            int numberOfClicks = e.Clicks;

            mousePath.AddString("    " + numberOfClicks.ToString(),
                                FontFamily.GenericSerif, (int)FontStyle.Bold,
                                fontSize, mouseUpLocation, StringFormat.GenericDefault);

            panel1.Invalidate();
        }
Пример #25
0
 private void graydo()
 {
     this.flag = 1;
     count     = m_Bitmap.Width * m_Bitmap.Height;
     gl        = new float[256];
     for (int i = 0; i < 256; i++)
     {
         gl[i] = gray[i] / count * 1500;
     }
     pen1 = Pens.Red;
     panel1.Invalidate();
     GraphyPanel.Invalidate();
 }
Пример #26
0
        private void Open_Click(object sender, System.EventArgs e)
        {
            BrightButton.Enabled    = false;
            NoiselessButton.Enabled = false;
            MarginalButton.Enabled  = false;
            TwoValueButton.Enabled  = false;
            SaveButton.Enabled      = false;
            panel4.Enabled          = false;


            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Jpeg文件(*.jpg)|*.jpg|Bitmap文件(*.bmp)|*.bmp| 所有合适文件(*.bmp/*.jpg)|*.bmp/*.jpg";

            openFileDialog.FilterIndex = 2;

            openFileDialog.RestoreDirectory = true;

            if (DialogResult.OK == openFileDialog.ShowDialog())

            {
                name     = openFileDialog.FileName;
                m_Bitmap = (Bitmap)Bitmap.FromFile(name, false);

                this.panel1.AutoScroll = true;

                this.panel1.AutoScrollMinSize = new Size((int)(m_Bitmap.Width), (int)

                                                         m_Bitmap.Height);

                this.InvertButton.Enabled = true;
                this.GrayButton.Enabled   = true;


                panel1.Invalidate();
                panel2.Invalidate();
                panel4.Invalidate();
            }
        }
Пример #27
0
 private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
 {
     if (radioButton1.Checked == true)
     {
         FractalType = 1;
         panel1.Invalidate();
     }
 }
Пример #28
0
        // Update map from network weights
        private void UpdateMap( )
        {
            // lock
            Monitor.Enter(this);

            // lock bitmap
            BitmapData mapData = mapBitmap.LockBits(new Rectangle(0, 0, 200, 200),
                                                    ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int   stride = mapData.Stride;
            int   offset = stride - 200 * 3;
            Layer layer  = network.Layers[0];

            unsafe
            {
                byte *ptr = (byte *)mapData.Scan0;

                // for all rows
                for (int y = 0, i = 0; y < 100; y++)
                {
                    // for all pixels
                    for (int x = 0; x < 100; x++, i++, ptr += 6)
                    {
                        Neuron neuron = layer.Neurons[i];

                        // red
                        ptr[2] = ptr[2 + 3] = ptr[2 + stride] = ptr[2 + 3 + stride] =
                            (byte)Math.Max(0, Math.Min(255, neuron.Weights[0]));
                        // green
                        ptr[1] = ptr[1 + 3] = ptr[1 + stride] = ptr[1 + 3 + stride] =
                            (byte)Math.Max(0, Math.Min(255, neuron.Weights[1]));
                        // blue
                        ptr[0] = ptr[0 + 3] = ptr[0 + stride] = ptr[0 + 3 + stride] =
                            (byte)Math.Max(0, Math.Min(255, neuron.Weights[2]));
                    }

                    ptr += offset;
                    ptr += stride;
                }
            }

            // unlock image
            mapBitmap.UnlockBits(mapData);

            // unlock
            Monitor.Exit(this);

            // invalidate maps panel
            mapPanel.Invalidate( );
        }
Пример #29
0
 public void MouseMove(ref EditorData data, Panel panel, Point gridPosition)
 {
     if (data.OnDeck == null || !data.OnDeck.Paintable) return;
     if (data.Level.SelectEntity(gridPosition) == null && _mPainting && !_mPrevious.Equals(gridPosition))
     {
         var entity = data.OnDeck.Copy();
         entity.Location = gridPosition;
         data.Level.AddEntity(entity, gridPosition, true);
         data.SelectedEntities.Clear();
         data.SelectedEntities.Add(entity);
         _mPrevious = gridPosition;
         panel.Invalidate(panel.DisplayRectangle);
     }
 }
Пример #30
0
        // Generate point
        private void GeneratePoints( )
        {
            int width    = pointsPanel.ClientRectangle.Width;
            int height   = pointsPanel.ClientRectangle.Height;
            int diameter = groupRadius * 2;

            // generate groups of ten points
            for (int i = 0; i < pointsCount;)
            {
                int cx = rand.Next(width);
                int cy = rand.Next(height);

                // generate group
                for (int j = 0; (i < pointsCount) && (j < 10);)
                {
                    int x = cx + rand.Next(diameter) - groupRadius;
                    int y = cy + rand.Next(diameter) - groupRadius;

                    // check if wee are not out
                    if ((x < 0) || (y < 0) || (x >= width) || (y >= height))
                    {
                        continue;
                    }

                    // add point
                    points[i, 0] = x;
                    points[i, 1] = y;

                    j++;
                    i++;
                }
            }

            map = null;
            pointsPanel.Invalidate( );
            mapPanel.Invalidate( );
        }
        public void PreviewSong()
        {
            if (songlines != null)
            {
                Previewing = true;
                SetPreviewText("Stop Preview");
                Console.WriteLine("Scheduling notes");

                for (int i = 0; i < songlines.Length - 1; i++)
                {
                    string[] songinfo  = songlines[i].Split(' '); //[0] = Pitch, [1] = TimeStartStamp [2] = LengthOfNote
                    string[] songinfo2 = songlines[i + 1].Split(' ');
                    KeyToPlay = Convert.ToInt32(songinfo[0]) - 48;
                    Pitch pitch = (Pitch)Convert.ToInt32(songinfo[0]) + 5; //THE BROTHER JAKOB FILE IS IN THE WRONG KEY!!!!

                    //Start note and visualize
                    keyBoard[KeyToPlay].SetKeyFill(mainKeyColor);
                    canvas.Invalidate(new Rectangle(keyBoard[KeyToPlay].X, keyBoard[KeyToPlay].Y, 12 * multiplier, 42 * multiplier));
                    noteScheduler.NoteOn(pitch);
                    Thread.Sleep(Convert.ToInt32(songinfo[2]) * 3); //*3 for breathing room

                    //Stop note and visualize
                    noteScheduler.NoteOff(pitch);
                    keyBoard[KeyToPlay].Clear();
                    canvas.Invalidate(new Rectangle(keyBoard[KeyToPlay].X, keyBoard[KeyToPlay].Y, 12 * multiplier, 42 * multiplier));
                    //Let some time between notes
                    Thread.Sleep(((Convert.ToInt32(songinfo2[1]) - Convert.ToInt32(songinfo[1])) - Convert.ToInt32(songinfo[2])) * 3);
                    if (i == songlines.Length - 2)
                    {
                        KeyToPlay = Convert.ToInt32(songinfo2[0]) - 48;
                        pitch     = (Pitch)Convert.ToInt32(songinfo2[0]) + 5;

                        keyBoard[KeyToPlay].SetKeyFill(mainKeyColor);
                        canvas.Invalidate(new Rectangle(keyBoard[KeyToPlay].X, keyBoard[KeyToPlay].Y, 12 * multiplier, 42 * multiplier));
                        noteScheduler.NoteOn(pitch);
                        Thread.Sleep(Convert.ToInt32(songinfo2[2]) * 3);
                        noteScheduler.NoteOff(pitch);
                        keyBoard[KeyToPlay].Clear();
                        canvas.Invalidate(new Rectangle(keyBoard[KeyToPlay].X, keyBoard[KeyToPlay].Y, 12 * multiplier, 42 * multiplier));
                    }
                }
                SetPreviewText("Preview Song");
                Previewing = false;
            }
            else
            {
                Console.WriteLine("No songlines found");
            }

            Console.WriteLine("previewthread ended");
        }
Пример #32
0
        void OnNewPopulation(object o, NewPopulationEventArgs e)
        {
            //System.Threading.Monitor.Enter(this);
            currentPopulationSummary = e.OldPopulation.Summary;
            //System.Threading.Monitor.Exit(this);

            axMSChart1.RowCount++;
            axMSChart1.DataGrid.SetData(
                ++generation,
                1,
                currentPopulationSummary.BestChromosome.RawObjective,
                0
                );

            graphPanel.Invalidate();
        }
Пример #33
0
        public void MouseMove(ref EditorData data, Panel panel, Point gridPosition)
        {
            var topEntity = new ArrayList();
            var entity = data.Level.SelectEntity(gridPosition);

            if (entity != null && _mPainting && !_mPrevious.Equals(gridPosition))
                try
                {
                    data.SelectedEntities.Clear();
                    topEntity.Add(entity);
                    data.Level.RemoveEntity(topEntity, true);
                    _mPrevious = gridPosition;
                    panel.Invalidate(panel.DisplayRectangle);
                }
                catch (Exception)
                {
                    //If the tile is empty, fail silently
                }
        }
Пример #34
0
        /// <summary>
        /// When the mouse moves, update the X and Y coordinates of the mouse cursor
        /// </summary>
        private void PointEditorUI_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Point movePt = new Point(e.X, e.Y);
            // scale the location back to the coordinates of
            // the actual control.
            //
            Point p = PointToTarget(movePt);

            label1.Text = "x: " + p.X + ", y:" + p.Y;

            // if the left button is down, update the polygon.
            //
            if (e.Button == MouseButtons.Left && this.targetIndex != -1)
            {
                targetPoints[targetIndex] = movePt;
                panel1.Invalidate();
                panel1.Update();
            }
        }
Пример #35
0
        private void txtMaxFrames_UpdateData()
        {
            try
            {
                timeLength = Convert.ToInt32(txtMaxFrames.Text);
                if (currentTime > timeLength)
                {
                    currentTime = timeLength;
                }
                pnlSlider.Left = GetDrawLocationFromTime(currentTime, true);                    // move the slider

                // redraw everything
                this.SetCaption();
                pnlTimeline.Invalidate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Input error - invalid value:\n\n" + ex.Message, "Input Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                txtMaxFrames.Text = timeLength.ToString();
            }
        }
Пример #36
0
 public static void PaintScroll(ref MouseEventArgs margs,ref Panel listpanel,ref Panel scrollpanel, ref List<Control> controllist)
 {
     panel2 = listpanel;
     listpanel.MouseWheel -= Listpanel_MouseWheel;
     newscrolled += margs.Delta;
     listpanel.MouseWheel += Listpanel_MouseWheel;
     if (newscrolled > oldscrolled)
     {
         selecteditem += 1;
         beginline += 50;
         endline += 50;
     }
     else if (newscrolled < oldscrolled)
     {
         selecteditem -= 1;
         beginline -= 50;
         endline -= 50;
     }
     oldscrolled = newscrolled;
     scrollpanel.Invalidate();
     graphic = scrollpanel.CreateGraphics();
     scrollpanel.Paint += PaintScrollBar;
 }
Пример #37
0
 public static void SelectionSort(int[] array, Panel panel)
 {
     // cheating..... should implement algorithm...
     Array.Sort(array);
     panel.Invalidate();
 }
Пример #38
0
 //We draw the ships
 public void DrawShip(int y, int x, int w, int h, int size, Panel panelBattle)
 {
     RemoveShip();
     CreateShip(x, y, 1, size - 1, _Player);
     for (int i = 0; i < _Player.Count(); ++i)
     {
         for (int j = 0; j < _Player[i].Count(); ++j)
         {
             if (Rendering(x, y, i, j, size - 1))
             {
                 panelBattle.Invalidate(new Rectangle(i * w, j * h, w, h));
             }
         }
     }
 }
Пример #39
0
 private void panel2_MouseDown(object sender, MouseEventArgs e)
 {
     Panel painel = (Panel)sender;
     if(e.Button == MouseButtons.Left)
     {
         obj = (Panel) sender;
         Dragging = true;
         mousex = -e.X;
         mousey = -e.Y;
         int clipleft  = panel1.PointToClient(MousePosition).X - obj.Location.X;
         int cliptop = panel1.PointToClient(MousePosition).Y - obj.Location.Y;
         int clipwidth = panel1.ClientSize.Width - (obj.Width - clipleft);
         int clipheight = panel1.ClientSize.Height - (obj.Height - cliptop);
         Cursor.Clip = panel1.RectangleToScreen(new Rectangle(clipleft, cliptop, clipwidth, clipheight));
         obj.Invalidate();
     }
 }
Пример #40
0
        public override object CreateView(Panel hostPanel)
        {
            NLView nlView = new NLView();
            if (_image != null)
                nlView.Image = _image.ToBitmap();
            else
                nlView.Image = null;

            nlView.DetectionDetails = _detectionDetails;
            nlView.Dock = DockStyle.Fill;
            hostPanel.Controls.Add(nlView);
            hostPanel.PerformLayout();
            nlView.AutoScroll = true;
            hostPanel.Invalidate();
            return nlView;
        }
 private void InvalidateAndUpdate(Panel panel)
 {
     panel.Invalidate(true);
     panel.Update();
 }
Пример #42
0
 void mouseEvent(Panel panel, MouseEventArgs e, FileCharset charset)
 {
     int c = e.X / (FileCharset.CharWidth + 2);
     int f = e.Y / (FileCharset.CharHeight + 2);
     byte id = (byte)((f * 16) + c);
     if (e.Button == MouseButtons.Left)
     {
         character = charset.getChar(id);
         panel3.Invalidate();
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (charset!=null && character != null)
             charset.setChar(id, character);
         panel.Invalidate();
     }
 }
Пример #43
0
        public WocketsScalablePlotter(System.Windows.Forms.Panel aPanel)
        {
            this.numSensors = CurrentWockets._Controller._Sensors.Count;

            if (numSensors > 3)
            {
                skippedPoints = 3;
            }
            else if (numSensors > 1)
            {
                skippedPoints = 2;
            }

            this.aPanel       = aPanel;
            this.plotAreaSize = new Size(this.aPanel.Width, ((int)(this.aPanel.Height)));
            graphSize         = (int)Math.Floor((plotAreaSize.Height / ((double)numSensors)));


            scaleFactors       = new double[numSensors];
            currentColumns     = new int[numSensors];
            firstColumn        = new int[numSensors];
            lastColumn         = new int[numSensors];
            decoderTails       = new int[numSensors];
            lastUnixTimestamps = new double[numSensors];
            this.pointsToPlot  = new int[numSensors];
            this.mode          = PlottingMode.Normal;

            for (int i = 0; (i < numSensors); i++)
            {
                this.currentColumns[i]     = this.plotAreaSize.Width - 1;
                this.firstColumn[i]        = 999999;
                this.lastColumn[i]         = this.plotAreaSize.Width - 1;
                this.decoderTails[i]       = CurrentWockets._Controller._Sensors[i]._Decoder._Head;
                this.lastUnixTimestamps[i] = 0;
                this.pointsToPlot[i]       = 0;
                double range = 1024;//((Accelerometer)this.wocketsController._Sensors[i])._Max - ((Accelerometer)this.wocketsController._Sensors[i])._Min;
                scaleFactors[i] = graphSize / range;
            }


            int dy     = (int)Math.Floor(plotAreaSize.Height / ((double)numSensors));
            int offset = dy;

            axisOffset = new int[numSensors];
            for (int i = 0; i < axisOffset.Length; i++)
            {
                axisOffset[i] = offset;
                offset       += dy;
            }


            previousTimes = new double[numSensors];
            previousVals  = new int[numSensors][];
            for (int i = 0; (i < numSensors); i++)
            {
                previousVals[i] = new int[3];
                for (int j = 0; (j < 3); j++)
                {
                    previousVals[i][j] = 0;
                }
            }


            p = new System.Drawing.Pen[SIGNALS_PER_AXIS];

            p[0] = new Pen(System.Drawing.Color.Orange);
            p[1] = new Pen(System.Drawing.Color.Red);
            p[2] = new Pen(System.Drawing.Color.Blue);
            requiresFullRedraw = true;
            aPanel.Invalidate();
        }
Пример #44
0
        public WocketsScalablePlotter(System.Windows.Forms.Panel aPanel)
        {
            this.numSensors = CurrentWockets._Controller._Sensors.Count;

            if (numSensors > 3)
                skippedPoints = 3;
            else if (numSensors > 1)
                skippedPoints = 2;

            this.aPanel = aPanel;
            this.plotAreaSize = new Size(this.aPanel.Width, ((int)(this.aPanel.Height)));
            graphSize = (int)Math.Floor((plotAreaSize.Height / ((double)numSensors)));


            scaleFactors = new double[numSensors];
            currentColumns = new int[numSensors];
            firstColumn = new int[numSensors];
            lastColumn = new int[numSensors];
            decoderTails = new int[numSensors];
            lastUnixTimestamps = new double[numSensors];
            this.pointsToPlot = new int[numSensors];
            this.mode = PlottingMode.Normal;

            for (int i = 0; (i < numSensors); i++)
            {
                this.currentColumns[i] = this.plotAreaSize.Width - 1;
                this.firstColumn[i] = 999999;
                this.lastColumn[i] = this.plotAreaSize.Width - 1;
                this.decoderTails[i] = CurrentWockets._Controller._Sensors[i]._Decoder._Head;
                this.lastUnixTimestamps[i] = 0;
                this.pointsToPlot[i] = 0;
                double range = 1024;//((Accelerometer)this.wocketsController._Sensors[i])._Max - ((Accelerometer)this.wocketsController._Sensors[i])._Min;
                scaleFactors[i] = graphSize / range;
            }


            int dy = (int)Math.Floor(plotAreaSize.Height / ((double)numSensors));
            int offset = dy;
            axisOffset = new int[numSensors];
            for (int i = 0; i < axisOffset.Length; i++)
            {
                axisOffset[i] = offset;
                offset += dy;
            }


            previousTimes = new double[numSensors];
            previousVals = new int[numSensors][];
            for (int i = 0; (i < numSensors); i++)
            {
                previousVals[i] = new int[3];
                for (int j = 0; (j < 3); j++)
                    previousVals[i][j] = 0;
            }


            p = new System.Drawing.Pen[SIGNALS_PER_AXIS];

            p[0] = new Pen(System.Drawing.Color.Orange);
            p[1] = new Pen(System.Drawing.Color.Red);
            p[2] = new Pen(System.Drawing.Color.Blue);
            requiresFullRedraw = true;
            aPanel.Invalidate();

        }