Пример #1
0
        /// <summary>
        /// Sauvegarde les positions des clicks de souris, met à jour la PictureBox
        /// et détecte si les traits sont sur les points
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MouseClick_Affiche9Points(object sender, EventArgs e)
        {
            int iFirstCaseEmpty = 0;

            /*Trouve la première case vide*/
            for (int i = 0; i < tSaveMouseClickPosition.Length; i++)
            {
                if (tSaveMouseClickPosition[i].IsEmpty)
                {
                    iFirstCaseEmpty = i;
                    break;
                }
            }

            /*Ajoute les dernières positions connues*/
            tSaveMouseClickPosition[iFirstCaseEmpty] = PointToClient(Cursor.Position);

            /*Éxecute la suite du code si le numéro de la première case vide est impaire*/
            if (iFirstCaseEmpty != 0)
            {
                pcbCase9Points.Invalidate();
            }

            /*Détecte si tous les points sont tracés*/
            if (iFirstCaseEmpty == 4)
            {
                /*Vérifie que chaque point à été tracé*/
                for (int iPoint = 0; iPoint < tCentrePoint.Length; iPoint++)
                {
                    for (int iTrait = 1; iTrait < tSaveMouseClickPosition.Length; iTrait++)
                    {
                        if (RAYON_POINT > Distance(tSaveMouseClickPosition[iTrait - 1], tSaveMouseClickPosition[iTrait], tCentrePoint[iPoint]))
                        {
                            tPointTrace[iPoint] = true;
                        }
                    }
                }
                /*Vérifie si l'un des points n'a pas été tracé*/
                bool bOk = true;
                for (int i = 0; i < tPointTrace.Length; i++)
                {
                    if (tPointTrace[i] != true)
                    {
                        bOk = false;
                    }
                }

                /*Message de fin - victoire/ défaite?*/
                if (bOk)
                {
                    MessageBox.Show("La réponse est \" 9.\"");
                    pcbCase9Points.Enabled = false;
                }
                else
                {
                    MessageBox.Show("Perdu! Vous n'avez pas réussi à passer par tous les points!");
                    RedemarrerEnigme();
                }
            }
        }
Пример #2
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case PCDimNaturalizer.WM_USER1:
                txtStatus.Text = Marshal.PtrToStringAnsi(m.LParam);
                if (txtStatus.Width < TextRenderer.MeasureText(txtStatus.Text, txtStatus.Font).Width || txtStatus.Lines.Length > 1)
                {
                    udStatus.Visible = true;
                }
                else
                {
                    udStatus.Visible = false;
                }
                btnClose.Select();
                break;

            case PCDimNaturalizer.WM_USER2:
                pictureBox1.Paint -= pictureBox1_Paint;
                ImageAnimator.StopAnimate(waitImage, OnFrameChanged);
                pictureBox1.Image = Bitmap.FromHbitmap(m.LParam);
                pictureBox1.Refresh();
                pictureBox1.Invalidate();
                btnClose.Select();
                break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
        // Invert one pixel
        private void pbGrid_MouseClick(object sender, MouseEventArgs e)
        {
            Rectangle rect;

            if (pbGrid.Image != null)
            {
                // x and y are relative to the image
                int x = Math.Max(0, Math.Min(e.Location.X / cellSize * cellSize, pbGrid.Image.Width - 1));
                int y = Math.Max(0, Math.Min(e.Location.Y / cellSize * cellSize, pbGrid.Image.Height - 1));
                // row and column are relative to the bitmap
                int row = y / cellSize;
                int col = x / cellSize;

                rect = new Rectangle(x, y, cellSize, cellSize);
                using (Graphics g = Graphics.FromImage(pbGrid.Image)) {
                    // Flip the color
                    if (bmGrid.GetPixel(col, row).ToArgb() == blackPixel)
                    {
                        // if black, write white
                        g.FillRectangle(Brushes.White, rect);
                        bmGrid.SetPixel(col, row, Color.White);
                    }
                    else
                    {
                        // not black, write black
                        g.FillRectangle(Brushes.Black, rect);
                        bmGrid.SetPixel(col, row, Color.Black);
                    }
                }
                pbGrid.Invalidate(rect);
            }
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (animationStarted)
            {
                needsRestarting = true;
            }
            button1.Text = "Start";
            label3.Text  = "FPS";
            if (BWworks)
            {
                backgroundWorker1.CancelAsync();
                BWworks = false;
            }

            Graphics g4      = Graphics.FromImage(pb2.BackgroundImage);
            Color    toClean = System.Drawing.Color.White;

            g4.Clear(toClean);

            for (int k = 0; k < shapes.Count; k++)
            {
                if (shapes[k].Shape == shape.Kształt.Linia)
                {
                    Line l2 = shapes[k] as Line;
                    g4.DrawLine(l2.Pen, l2.Ends.Item1, l2.Ends.Item2);
                }
                else
                {
                    Circle c2 = shapes[k] as Circle;
                    g4.DrawEllipse(c2.Pen, c2.Rect);
                }
            }
            pb2.Invalidate();
        }
Пример #5
0
 public void Resize(int width, int height)
 {
     this.width  = width;
     this.height = height;
     InitGrid();
     pictureBox.Invalidate();
 }
Пример #6
0
 private void pic_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     tiles[e.X, e.Y].Region = TileRegion.Spawn;
     bmp.SetPixel(e.X, e.Y, Color.FromArgb((int)GetColor(tiles[e.X, e.Y])));
     pic.Invalidate();
     pic2.Invalidate();
 }
Пример #7
0
        void Display_MouseUp(object sender, MouseEventArgs e)
        {
            this.isDragging = false;
            if (!cChanged)
            {
                place(cX, cY, cZ, true);
            }
            switch (e.Button)
            {
            case System.Windows.Forms.MouseButtons.Left:
                if (isDragging)
                {
                    isDragging = false;
                }
                if (!cChanged)
                {
                    place(cX, cY, cZ, true);
                }
                break;

            case System.Windows.Forms.MouseButtons.Right:
                Blocks b = currentSim[cX, cY, cZ];
                if (b.isControl)
                {
                    currentSim.SetPower(cX, cY, cZ, 16);
                    Display.Invalidate();
                }
                break;
            }
        }
Пример #8
0
            private void CalculateClipMatrix()
            {
                mWorldScale = Matrix4.CreateScale(
                    new Vector3(mSize.Width / (mScale * mClip.Width), mSize.Height / (mScale * mClip.Height), 1f));

                //TODO - mSize.[W,H] may have to be reversed
                Matrix4 toClipScale = Matrix4.CreateScale(
                    new Vector3((mScale * mClip.Width) / mSize.Width, (mScale * mClip.Height) / mSize.Height, 1f));

                Vector3 topLeft         = new Vector3(mCrop.X, mCrop.Y, 0f);
                Matrix4 toClipTranslate = Matrix4.CreateTranslation(topLeft);

                mClipMatrix = Matrix4.Identity;
                //mClipMatrix *= mWorldMatrix;
                mClipMatrix *= toClipTranslate;
                mClipMatrix *= toClipScale;

                if (mDrawPanel.InvokeRequired)
                {
                    mDrawPanel.BeginInvoke(new Action(() => mDrawPanel.Invalidate()));
                }
                else
                {
                    mDrawPanel.Invalidate();
                }
            }
Пример #9
0
        private void ImgRes__MouseUp(object sender, MouseEventArgs e)
        {
            X_END = e.X;
            Y_END = e.Y;

            pctDraw.Invalidate();
            isClicked = false;
        }
Пример #10
0
 private void mPictureBox_MouseUp(object sender, MouseEventArgs e)
 {
     //Main snap = new Main();
     mIsClick = false;
     mMove    = false;
     mPictureBox.Invalidate();
     //TakePic(pictureBox1, snapShot);
 }
 void pictureBox_MouseUp(object sender, MouseEventArgs e)
 {
     if (this.Selected != null)
     {
         this.Selected.OnMouseUp(this, e);
         pictureBox.Invalidate();
     }
 }
Пример #12
0
 private void ContainerColorBoxClick(object sender, EventArgs e)
 {
     colorDialog.Color = Color.FromArgb(255, Settings.ContainerColor);
     if (colorDialog.ShowDialog(this) == DialogResult.OK)
     {
         Settings.ContainerColor = Color.FromArgb(Settings.ContainerColor.A, colorDialog.Color);
         containerColorBox.Invalidate();
     }
 }
Пример #13
0
 private void timer_Tick(object sender, EventArgs e)
 {
     totalTicks++;
     if (totalTicks >= Draw.CC.Ticks)
     {
         totalTicks = 0;
     }
     panel.Invalidate();
 }
Пример #14
0
        private void button10_Click(object sender, EventArgs e)
        {
            UltimatePolygon u = new UltimatePolygon();

            u.SetPictureBox(pictureBox);
            figures.Add(u);

            pictureBox.Invalidate();
        }
Пример #15
0
        private void AreaDraw_MouseMove(object sender, MouseEventArgs e)
        {
            switch (toolselec)
            {
            case ToolSelec.puntero:
                #region Selección Figura

                if (Aselec != null)
                {
                    Aselec.Mover(e.Location.X - pos.X, e.Location.Y - pos.Y);
                    AreaDraw.Invalidate();
                    pos = e.Location;
                }
                else
                {
                    if (Cselec != null)
                    {
                        Cselec.Mover(e.Location.X - pos.X, e.Location.Y - pos.Y);
                        AreaDraw.Invalidate();
                        pos = e.Location;
                    }
                }
                #endregion
                break;

            case ToolSelec.asociacion:
                #region Dibuja asociacion

                if (clic)
                {
                    //if el segundo punto esta dentro de, entonces que mande mensaje
                    //y deje de dibujar

                    g         = AreaDraw.CreateGraphics();
                    objaso.PF = e.Location;
                    g.Clear(Color.White);
                    objaso.DrawAsociacion(g, objaso.PI, objaso.PF);
                }
                #endregion
                exit : break;

            case ToolSelec.clase:
                #region Dibuja Clase


                if (clic)
                {
                    g = AreaDraw.CreateGraphics();
                    objcla.puntoFinal = e.Location;
                    g.Clear(Color.White);
                    objcla.DrawClase(g, objcla.puntoInicial, objcla.puntoFinal);
                }
                #endregion
                break;
            }
        }
Пример #16
0
 public void _Refresh()
 {
     try
     {
         m_pictureBox.Invalidate();
         // Invalidate() just puts a message into GUI loop, while Refresh() calls repainting in the current thread
         // Therefore calling Refresh here causes freezing of the GUI
     }
     catch {}
 }
Пример #17
0
 /// <summary>
 /// This Method is called when Mouse Pointer is moved.
 /// It provides the Mouse Coordinates.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void shapePB_MouseMove(object sender, MouseEventArgs e)
 {
     if (mouseDownPoint.IsEmpty)
     {
         return;
     }
     shapePB.Invalidate();
     addShape(e);
     shapePB.Invalidate();
 }
Пример #18
0
 /**
  * Vycisteni vykreslovaci oblasti
  */
 internal void Clear()
 {
     if (timer != null)
     {
         isRunning = false;     // Animace nebezi
         timer.Stop();          // Zastav casovac
     }
     g.Clear(Color.Black);      // Premaz platno cernou barvou
     activeCanvas.Invalidate(); // Promitni zmeny na vykreslovaci platno
 }
Пример #19
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            Point p2 = pictureBox1.PointToClient(MousePosition);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.DrawLine(Pens.Black, p1.Value, pictureBox1.PointToClient(MousePosition));
            }
            p1 = null;
            pictureBox1.Invalidate();
        }
Пример #20
0
        void CallBack(int index, bool draw)
        {
            int r, c, v;

            Decode(index, out r, out c, out v);

            PrintCell(r, c, v + 1, draw);
            pictureBox.Invalidate();

            Thread.Sleep(200);
        }
 public void DrawRectangle(Rectangle destination)
 {
     using (var g = Graphics.FromImage(_image))
     {
         System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(destination.X, destination.Y, destination.Width, destination.Lenght);
         g.FillRectangle(new SolidBrush(_color), rectangle);
         g.DrawRectangle(new Pen(_color), rectangle);
         canvas.Invalidate();
     }
     //throw new NotImplementedException();
 }
Пример #22
0
        // Мы двигаем маркер точку.
        private void pictureBox_MouseMove_MovingMarker(object sender, MouseEventArgs e)
        {
            markerPoint =
                new Point(SoundLineEditor.Clamp(e.X + OffsetX, lineStartPos.X, playerLeghtPerPixel), markerPoint.Y);

            // Перерисовать.
            pictureBox.Invalidate();
        }
 private void HandleMove(object sender, MouseEventArgs e)
 {
     if (!_isDrawing)
     {
         return;
     }
     _pictureBoxContainer.Refresh();
     _regionSelectionDTO.XEnd = e.X;
     _regionSelectionDTO.YEnd = e.Y;
     _form.UpdateRectangle(_regionSelectionDTO.ToRectangle());
     _pictureBoxContainer.Invalidate();
 }
Пример #24
0
        private void m_colorBut_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();

            if (cd.ShowDialog() == DialogResult.OK)
            {
                Color newColor = Color.FromArgb(100, cd.Color.R, cd.Color.G, cd.Color.B);
                m_cropperForm.m_slotsPanel.SetSlotColor(newColor);
                m_colorBut.BackColor = Color.FromArgb(255, newColor.R, newColor.G, newColor.B);
                m_cropPb.Invalidate();
            }
        }
Пример #25
0
        private void grdIntermittenc_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            foreach (DataRow row in ControlDT.Rows)// (int i = 0; i < txtTeamNames.Length; i++)
            {
                TextBox tbx = this.Controls.Find(row["NameLabItem"].ToString(), true).FirstOrDefault() as TextBox;
                tbx.Text = "";
            }
            pictureBox1.Enabled = true;

            if (pictureBox1.Image != null)
            {
                pictureBox1.Image.Dispose();
                pictureBox1.Image = null;
            }
            pictureBox1.Invalidate();
            Byte[] imageData = new Byte[0];
            FillDocumentsGrid();
            if (DocumentDT.Rows.Count > 0)
            {
                imageData = (Byte[])(DocumentDT.Rows[DocumentDT.Rows.Count - 1]["image"]);
                short documentType = Convert.ToInt16(DocumentDT.Rows[DocumentDT.Rows.Count - 1]["DocumentType"]);
                //switch (documentType)
                //{
                //    case 1:
                //        tabControl1.SelectedIndex = documentType - 1;
                //        break;
                //    case 2:
                //        tabControl1.SelectedIndex = documentType - 1;
                //        break;
                //    case 3:
                //        tabControl1.SelectedIndex = documentType - 1;
                //        break;
                //}
                if (imageData != null)
                {
                    MemoryStream stream = new MemoryStream(imageData);
                    pictureBox1.Image = Image.FromStream(stream);
                }

                return;
            }
            else
            {
                if (pictureBox1.Image != null)
                {
                    pictureBox1.Image.Dispose();
                    pictureBox1.Image = null;
                }

                pictureBox1.Invalidate();
                tabControl1.SelectedIndex = 0;
            }
        }
Пример #26
0
        public void SetText(string msg)
        {
            if (invalid)
            {
                return;
            }

            lbl.Text = msg;
            barValue = float.NaN;
            gifBox.Invalidate();
            ForceUpdate();
        }
Пример #27
0
        //取得滑鼠座標並計算
        private void Form1_Con(object sender, MouseEventArgs e)
        {
            PictureBox pb = (PictureBox)sender;

            if (dataGridViewMeasureData.RowCount < 2)
            {
                if (labelImageName.Text == "MT" || labelImageName.Text == "MB")
                {
                    if (dataGridViewMeasureData.RowCount >= 1)
                    {
                        dataGridViewMeasureData.Rows.Add();
                        //判斷是否為垂直
                        if (fsf.CheckVerticalOrParallel(dataGridViewMeasureData.Rows[0].Cells[1].Value.ToString(), dataGridViewMeasureData.Rows[0].Cells[2].Value.ToString(), e.Location.X.ToString(), e.Location.Y.ToString()))
                        {
                            //是垂直
                            dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[0].Value = dataGridViewMeasureData.RowCount.ToString();
                            dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[1].Value = dataGridViewMeasureData.Rows[0].Cells[1].Value.ToString();    //垂直量測X2強制改為X1鎖定X軸
                            dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[2].Value = Convert.ToString(y);
                            Point p = new Point(Convert.ToInt16(dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[1].Value), Convert.ToInt16(dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[2].Value));
                            points.Add(p);
                        }
                        else
                        {
                            //是水平
                            dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[0].Value = dataGridViewMeasureData.RowCount.ToString();
                            dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[1].Value = Convert.ToString(x);
                            dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[2].Value = dataGridViewMeasureData.Rows[0].Cells[2].Value.ToString();        //水平量測Y2強制改為Y1鎖定Y軸
                            Point p = new Point(Convert.ToInt16(dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[1].Value), Convert.ToInt16(dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[2].Value));
                            points.Add(p);
                        }
                    }
                    else
                    {
                        dataGridViewMeasureData.Rows.Add();
                        dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[0].Value = dataGridViewMeasureData.RowCount.ToString();
                        dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[1].Value = Convert.ToString(x);
                        dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[2].Value = Convert.ToString(y);
                        points.Add(e.Location);
                        pb.Invalidate();
                    }
                }
                else
                {
                    dataGridViewMeasureData.Rows.Add();
                    dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[0].Value = dataGridViewMeasureData.RowCount.ToString();
                    dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[1].Value = Convert.ToString(x);
                    dataGridViewMeasureData.Rows[dataGridViewMeasureData.RowCount - 1].Cells[2].Value = Convert.ToString(y);
                    points.Add(e.Location);
                    pb.Invalidate();
                }
            }
        }
Пример #28
0
        private void pictureBoxDrawingLeft_MouseUp(object sender, MouseEventArgs e)
        {
            isMouseDown = false;
            if (e.Button == MouseButtons.Right)
            {
                isDrawAble = false;
                //listPolygonPoint.Clear();
            }
            //PointF checkPoint = new PointF(e.X, e.Y);

            isDrawingLockedLeft = false;
            pictureBoxDrawingLeft.Invalidate();
        }
Пример #29
0
    private void btnAddControl_Click(object sender, EventArgs e)
    {
        Size size = new Size(125, 125);

        if (this.chkRandom.Checked)
        {
            size = sizes[rnd.Next(sizes.Length)];
        }

        PictureBox pBox = new PictureBox()
        {
            Anchor      = AnchorStyles.None,
            BackColor   = colors[rnd.Next(colors.Length)],
            MinimumSize = size,
            Size        = size
        };
        bool drawborder = false;

        pBox.MouseEnter += (s, evt) => { drawborder = true;  pBox.Invalidate(); };
        pBox.MouseLeave += (s, evt) => { drawborder = false; pBox.Invalidate(); };
        pBox.MouseDown  += (s, evt) => { selectedObject = pBox;  pBox.Invalidate(); };
        pBox.Paint      += (s, evt) => { if (drawborder)
                                         {
                                             ControlPaint.DrawBorder(evt.Graphics, pBox.ClientRectangle,
                                                                     Color.White, ButtonBorderStyle.Solid);
                                         }
        };
        var ctl         = this.tlp1.GetControlFromPosition(0, this.tlp1.RowCount - 1);
        int overallWith = ctl.Controls.OfType <Control>().Sum(c => c.Width + c.Margin.Left + c.Margin.Right);

        overallWith += (ctl.Margin.Right + ctl.Margin.Left);
        if ((overallWith + pBox.Size.Width + pBox.Margin.Left + pBox.Margin.Right) >= this.tlp1.Width)
        {
            var flp = new FlowLayoutPanel()
            {
                Anchor       = AnchorStyles.Top | AnchorStyles.Bottom,
                AutoSize     = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
            };
            flp.Controls.Add(pBox);
            this.tlp1.SuspendLayout();
            this.tlp1.RowCount += 1;
            this.tlp1.Controls.Add(flp, 0, this.tlp1.RowCount - 1);
            this.tlp1.ResumeLayout(true);
        }
        else
        {
            ctl.Controls.Add(pBox);
        }
    }
Пример #30
0
        //Als er op de Picturebox geklikt wordt, wordt Veldenklikker aangeroepen. Deze methode kijkt of het legaal is om op de desbetreffende
        //plek een steen te plaatsen. Zo ja, dan wordt er een steen getekend en veranderen de vijandige stenen die worden ingesloten van kleur.
        private void Veldenklikker(object o, MouseEventArgs mea)
        {
            int locatieMuisX = mea.X;
            int locatieMuisY = mea.Y;
            int a = 0, b = 0;

            Point locatieSteen = new Point(a, b);

            //Stap 1: Transleer de muispositie naar de positie in de array stenen.
            for (int positieX = xkolommen; locatieMuisX < xkolommen * grootte && locatieMuisX > 0; positieX -= 1)
            {
                locatieMuisX += grootte;
                a             = positieX - 1;
            }
            for (int positieY = yrijen; locatieMuisY < xkolommen * grootte && locatieMuisY > 0; positieY -= 1)
            {
                locatieMuisY += grootte;
                b             = positieY - 1;
            }

            //Stap 2: Is de desbetreffende positie legaal? Oftewel er mag nog geen steen liggen en er moet minstens een vijandige steen worden ingesloten.
            if (stenen[a, b] == null && Insluit(a, b) == true)
            {
                legaal = true;
            }

            //Stap 3: Creeer een nieuwe Steen op de positie indien deze legaal is, en verander omliggende stenen van kleur.
            if (legaal == true)
            {
                if (beurt % 2 == 0)
                {
                    stenen[a, b] = new Steen(a, b, true);
                    beurt        = beurt + 1;
                }

                else
                {
                    stenen[a, b] = new Steen(a, b, false);
                    beurt        = beurt + 1;
                }

                Omzet(a, b);
                legaal = false;
                velden.Invalidate();
                zet.Text         = AanDeBeurt();
                winnaar.Text     = Winnaar();
                aantalgroen.Text = Aantalgroen() + " stenen";
                aantalblauw.Text = Aantalblauw() + " stenen";
            }
        }
Пример #31
0
 public void constructGrid(PictureBox thePictureBox, Map theMap)
 {
     this.thePictureBox = thePictureBox;
     this.theMap = theMap;
     thePictureBox.Invalidate();
     thePictureBox.Paint += new PaintEventHandler(paintGrid);
 }