예제 #1
1
 public void Draw(PictureBox pictureBox, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         g.DrawLine(pen,_startPoint, _endPoint);
     }
     pictureBox.Invalidate();
 }
예제 #2
0
        private void CustomColorDlg_Load(object sender, System.EventArgs e)
        {
            updatingUI = true;
            currentColorPanel.BackColor = CurrentColor;
            float r = CurrentColor.R;
            float g = CurrentColor.G;
            float b = CurrentColor.B;

            redEdit.Text   = (Convert.ToInt32(r)).ToString();
            greenEdit.Text = (Convert.ToInt32(g)).ToString();
            blueEdit.Text  = (Convert.ToInt32(b)).ToString();

            float h = 0;
            float s = 0;
            float l = 0;

            // Get h,s,l
            ColorUtil.RGBToHSL((int)r, (int)g, (int)b, ref h, ref s, ref l);
            hueEdit.Text = Convert.ToString((int)h);
            satEdit.Text = Convert.ToString((int)s);
            lumEdit.Text = Convert.ToString((int)l);

            // Get palette color for interpolating the luminosity picture box
            ColorUtil.HSLToRGB(h, s, 120, ref r, ref g, ref b);
            paletteColor = Color.FromArgb((int)r, (int)g, (int)b);
            lumBox.Invalidate();

            // Calculate coordinates using default values for Hue and Sat
            CalculatePaletteMarkerCoordinates((int)h, (int)s);
            updatingUI = false;
        }
 private void udLow_ValueChanged(object sender, System.EventArgs e)
 {
     if (udLow.Value + 10 > udHigh.Value && !filter_updating)
     {
         udLow.Value = udHigh.Value - 10;
     }
     preset[(int)dsp_mode].SetLow(current_filter, (int)udLow.Value);
     if (!rx2)
     {
         if (console.RX1DSPMode == dsp_mode &&
             console.RX1Filter == current_filter)
         {
             console.UpdateRX1FilterPresetLow((int)udLow.Value);
         }
     }
     else
     {
         if (console.RX2DSPMode == dsp_mode &&
             console.RX2Filter == current_filter)
         {
             console.UpdateRX2FilterPresetLow((int)udLow.Value);
         }
     }
     if (!filter_updating)
     {
         UpdateFilter((int)udLow.Value, (int)udHigh.Value);
     }
     picDisplay.Invalidate();
 }
예제 #4
0
 private void MPK_Calendar_SizeChanged(object sender, System.EventArgs e)
 {
     pWidth            = this.Size.Width;
     pPicWidth         = pWidth;
     pHeight           = this.Size.Height;
     pPicHeight        = pHeight - 35;
     picMPK_Cal.Width  = pPicWidth;
     picMPK_Cal.Height = pPicHeight;
     //keep the buttons in the same place
     btnPrev.Left  = 5;
     btnNext.Left  = this.Width - btnNext.Width - 5;
     lblMonth.Left = (this.Width - lblMonth.Width) / 2;
     rects         = CreateGrid(picMPK_Cal.Width, picMPK_Cal.Height);
     picMPK_Cal.Invalidate();
 }
예제 #5
0
        //rmr to fix this crap too
        private void _OnCloneOpen(object sender, EventArgs e)
        {
            System.Windows.Forms.PictureBox clonedBox =
                (System.Windows.Forms.PictureBox)sender;


            openFileDialog1.InitialDirectory = @"C:\Documents and Settings\my documents\my pictures";
            openFileDialog1.Title            = "Select a File";
            openFileDialog1.Filter           = "Image Files|*.bmp;*.jpg; *.jpeg;*.png; *.gif; *.tif";
            openFileDialog1.FilterIndex      = 1;
            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                clonedPic = @openFileDialog1.FileName;
                //pictureCloned = new ImageShower.Picture(clonedPic);
                this.DisplayPics();
                Text = "Cloned View";
                clonedBox.Invalidate();
                menuRemoveClone.Enabled = true;
                //menuItemClone.Enabled = false;
                cloneClosebtn.Enabled = true;
                cloneClosebtn.Visible = true;
            }
            else
            {
                clonedPic = "";
                //TabbedView._IsCloned = false;
                this.ClientSize = ClientSize;
            }
        }
예제 #6
0
파일: WebCam.cs 프로젝트: abdojobs/medipro
 public void OnImageCaptured(Touchless.Vision.Contracts.IFrameSource frameSource, Touchless.Vision.Contracts.Frame frame, double fps)
 {
     //Image img = frame.Image.Clone(new RectangleF(0, 0, this.ImgControl.Width, this.ImgControl.Height), System.Drawing.Imaging.PixelFormat.Undefined);
     //_latestFrame = img as Bitmap;
     _latestFrame = frame.Image;
     ImgControl.Invalidate();
 }
예제 #7
0
        public void ProcessGPSSatelliteData(IGPSSatelliteVehicle[] satelliteVehicles)
        {
            vehicles = satelliteVehicles;

            // Call Invalidate() rather than Redraw() so that we only redraw if the form is visible.
            pictureBox.Invalidate();
        }
예제 #8
0
파일: ctlTrendChart.cs 프로젝트: ewin66/HIS
        /// <summary>
        /// 显示参数的名称、单位和图标
        /// </summary>
        /// <param name="p_objGroupSetArr"></param>
        public void m_mthShowParamDesc(clsVitalGroupSet[] p_objGroupSetArr)
        {
            m_blnShowParam = false;

            if (p_objGroupSetArr != null)
            {
                m_objGroupSetArr = p_objGroupSetArr;
                m_blnShowParam   = true;

                m_strScaleValueArr[0] = m_objGroupSetArr[0].m_intMaxScale0.ToString().PadLeft(5, ' ');
                m_strScaleValueArr[1] = m_objGroupSetArr[0].m_intMinScale0.ToString().PadLeft(5, ' ');
                m_strScaleValueArr[2] = m_objGroupSetArr[0].m_intMaxScale1.ToString().PadLeft(5, ' ');
                m_strScaleValueArr[3] = m_objGroupSetArr[0].m_intMinScale1.ToString().PadLeft(5, ' ');
                m_strScaleValueArr[4] = m_objGroupSetArr[0].m_intMaxScale2.ToString().PadLeft(5, ' ');
                m_strScaleValueArr[5] = m_objGroupSetArr[0].m_intMinScale2.ToString().PadLeft(5, ' ');


                int intNewHeight = m_objGroupSetArr.Length * m_intParamHeight + m_intDateTimeHeight + c_intToTop + c_intToButtom;
                if (intNewHeight < c_intNormalChartHeight)
                {
                    intNewHeight = c_intNormalChartHeight;
                }

//				m_intChartHeight = (intNewHeight > m_intChartHeight) ? intNewHeight : m_intChartHeight;
                m_intChartHeight = intNewHeight;

                this.picChart.Height = m_intChartHeight;

                picChart.Invalidate();
                picChart.Update();
            }
        }
예제 #9
0
 public void UpdateGraph()
 {
     drawCPUGraph();
     drawMemoryGraph();
     cpuGraphPicBox.Invalidate();
     memoryGraphPicBox.Invalidate();
 }
예제 #10
0
        private void OnViewLineNumberUpdateTimer(object sender, EventArgs e)
        {
            var timer_ival = view_line_update_timer_ival_;

            if (view_line_update_req_)
            {
                view_line_update_req_ = false;

                PBox_LineNo.Invalidate();

                timer_ival += VIEW_LINE_NUMBER_UPDATE_IVAL_STEP;
                if (timer_ival > VIEW_LINE_NUMBER_UPDATE_IVAL_MAX)
                {
                    timer_ival = VIEW_LINE_NUMBER_UPDATE_IVAL_MAX;
                }
            }
            else
            {
                timer_ival -= VIEW_LINE_NUMBER_UPDATE_IVAL_STEP;
                if (timer_ival < VIEW_LINE_NUMBER_UPDATE_IVAL_MIN)
                {
                    timer_ival = VIEW_LINE_NUMBER_UPDATE_IVAL_MIN;
                }
            }

            if (view_line_update_timer_ival_ != timer_ival)
            {
                view_line_update_timer_ival_ = timer_ival;

                view_line_update_timer_.Stop();
                view_line_update_timer_.Interval = view_line_update_timer_ival_;
                view_line_update_timer_.Start();
            }
        }
예제 #11
0
        public void stop()
        {
            if (m_lPlayHandle < 0)
            {
                return;
            }

            //停止回放
            if (!CHCNetSDK.NET_DVR_StopPlayBack(m_lPlayHandle))
            {
                uint   iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                string str      = "NET_DVR_StopPlayBack failed, error code= " + iLastErr;
                MessageBox.Show(str);
                return;
            }

            progressBar.Value = 0;

            m_bPause        = false;
            btnPause.Text   = "||";
            labelPause.Text = "暂停";

            m_lPlayHandle = -1;
            videoPlayWnd.Invalidate();//刷新窗口
            btnStop.Enabled = false;
        }
예제 #12
0
        /* ----------------------------------------------------------------- */
        ///
        /// Render (private)
        ///
        /// <summary>
        /// MEMO: ロックは暫定処理.Microsoft によると public にアクセス
        /// 可能なオブジェクトを用いた lock は想定していないらしい.
        /// http://msdn.microsoft.com/ja-jp/library/c5kehkcz%28VS.80%29.aspx
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static bool Render(Canvas canvas, bool adjust)
        {
            if (canvas == null)
            {
                return(false);
            }
            var engine = canvas.Tag as CanvasEngine;

            if (engine == null)
            {
                return(false);
            }
            var core = engine.Core;

            if (core == null)
            {
                return(false);
            }

            lock (core) {
                var status = core.RenderPage(IntPtr.Zero, false, false);
                if (status && adjust)
                {
                    CanvasPolicy.Adjust(canvas);
                }
                canvas.Invalidate();
                return(status);
            }
        }
예제 #13
0
        private void UpdateOverlay()
        {
            FOverlay.Clear(Color.Transparent);
            double xScale = FZoomedImage.Width / (double)FOriginal.Width;
            double yScale = FZoomedImage.Height / (double)FOriginal.Height;

            int left, top, width, height;

            if ((UseAsHeaderCheckBox.Enabled && UseAsHeaderCheckBox.Checked))
            {
                left   = Math.Max(0, (int)((FMouseCurrentPoint.X - FZoomedImage.Left) / xScale) - CHeaderWidth / 2);
                left   = Math.Min(left, FOriginal.Width - CHeaderWidth);
                top    = Math.Max(0, (int)((FMouseCurrentPoint.Y - FZoomedImage.Top) / yScale) - CHeaderHeight / 2);
                top    = Math.Min(top, FOriginal.Height - CHeaderHeight);
                width  = CHeaderWidth;
                height = CHeaderHeight;
            }
            else
            {
                left   = Math.Max(0, (int)((FMouseDownPoint.X - FZoomedImage.Left) / xScale));
                top    = Math.Max(0, (int)((FMouseDownPoint.Y - FZoomedImage.Top) / yScale));
                width  = Math.Max(10, (int)((FMouseCurrentPoint.X - FMouseDownPoint.X) / xScale));
                width  = Math.Min(width, FOriginal.Width - left);
                height = Math.Max(10, (int)((FMouseCurrentPoint.Y - FMouseDownPoint.Y) / yScale));
                height = Math.Min(height, FOriginal.Height - top);
            }

            FCropRect = new Rectangle(left, top, width, height);

            if (FDrawRect)
            {
                FOverlay.DrawRectangle(FRectPen, FCropRect);
            }
            FPictureBox.Invalidate();
        }
예제 #14
0
 /// <summary>
 /// 刷新数独状态
 /// </summary>
 public void RefreshSudoKu()
 {
     if (_picBox != null)
     {
         _picBox.Invalidate();
     }
 }
예제 #15
0
        /// <summary>Display the source image with the regions on it in [picImage], and only the regions in [picMap]</summary>
        /// <param name="updateSummary">true: call UpdateSummary() when finished</param>
        private void ReDrawImages(bool updateSummary)
        {
            //create empty images
            Image bufferImageNoBackground   = new Bitmap(baseImage.Width, baseImage.Height);
            Image bufferImageWithBackground = new Bitmap(baseImage.Width, baseImage.Height);

            //get graphics
            Graphics graphicsWithBackground = Graphics.FromImage(bufferImageWithBackground);
            Graphics graphicsNoBackground   = Graphics.FromImage(bufferImageNoBackground);

            //draw backgrounds
            graphicsNoBackground.Clear(Color.White);
            graphicsWithBackground.DrawImage(baseImage, 0, 0, baseImage.Width, baseImage.Height);

            //draw regions
            foreach (RegionInfo info in drawnRegions)
            {
                PathGradientBrush brush = new PathGradientBrush(info.Points, WrapMode.Clamp);
                brush.CenterColor    = Color.Transparent;
                brush.SurroundColors = new Color[1] {
                    info == selectedRegionInfo ?  Color.Green : Color.Red
                };

                graphicsWithBackground.FillRegion(brush, info.Region);
                graphicsWithBackground.DrawPolygon(new Pen(Color.Black, 4), info.Points);

                graphicsNoBackground.FillRegion(brush, info.Region);
                graphicsNoBackground.DrawPolygon(new Pen(Color.Black, 4), info.Points);
            }

            //clean up
            graphicsWithBackground.Dispose();
            graphicsNoBackground.Dispose();

            //show images
            picImage.Image = bufferImageWithBackground;
            picMap.Image   = bufferImageNoBackground;
            picImage.Invalidate();
            picMap.Invalidate();

            //update numbers and errors
            if (updateSummary)
            {
                UpdateSummary();
            }
        }
예제 #16
0
        } // end method pieceBox_MouseDown

        // if piece is selected, move it
        private void pieceBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (selectedIndex > -1)
            {
                bMoving = true;
                Rectangle region = new Rectangle(
                    e.X - TILEWIDTH * 2, e.Y - TILEHEIGHT * 2,
                    TILEWIDTH * 4, TILEHEIGHT * 4);

                // set piece center to mouse
                GetPiece(selectedIndex).SetLocation(
                    e.X - TILEWIDTH / 2, e.Y - TILEHEIGHT / 2);

                // refresh immediate area
                pieceBox.Invalidate(region);
            }
        }
예제 #17
0
 private void updateGUI(PictureBox picBox, Bitmap img)
 {
     picBox.Image = img;
     picBox.Invalidate();
     picBox.Update();
     picBox.Refresh();
     Application.DoEvents();
 }
예제 #18
0
 private void udLow_ValueChanged(object sender, System.EventArgs e)
 {
     if (udLow.Value + 10 > udHigh.Value)
     {
         udLow.Value = udHigh.Value - 10;
     }
     console.filter_presets[(int)current_dsp_mode].SetLow(current_filter, (int)udLow.Value);
     if (console.CurrentDSPMode == current_dsp_mode &&
         console.CurrentFilter == current_filter)
     {
         console.UpdateFilterPresetLow((int)udLow.Value);
     }
     if (!filter_updating)
     {
         UpdateFilter((int)udLow.Value, (int)udHigh.Value);
     }
     picDisplay.Invalidate();
 }
예제 #19
0
 private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (lineInProgress)
     {
         endx = e.X;
         endy = e.Y;
         pictureBox1.Invalidate();
     }
 }
 private void UpdatePreviewImage()
 {
     using (new WaitCursor(this))
     {
         m_editor.SyncSessionCopy();
         _previewImg = _mappingSvc.GetLegendImage(_preview.Scale, _preview.LayerDefinition, _preview.ThemeCategory, 2, previewPicture.Width, previewPicture.Height, _preview.ImageFormat);
         previewPicture.Invalidate();
     }
 }
예제 #21
0
 public void Draw(PictureBox pictureBox, Point temporaryPoint, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         g.DrawLine(pen, _startPoint, temporaryPoint);
     }
     _startPoint = temporaryPoint;
     pictureBox.Invalidate();
 }
예제 #22
0
        void MessageArrived(string key, string xmlMessage)
        {
            printLog("MessageArrived()");
            //printLog( "\t key: "+key );

            try
            {
                MessageDrawing msg = MessageDrawing.CreateFromXml(xmlMessage);

                msg.Draw(graphics);

                pictureBox1.Invalidate();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
예제 #23
0
 private void GameField_Activated(object sender, System.EventArgs e)
 {
     // This event occurs when the window receives back the focus after had lost it to another window
     //   So, we redraw the whole game field
     // Clear the game field
     PicGameField.Invalidate();
     Application.DoEvents();
     MainGame.netterpillarGameEngine.Redraw();
 }
예제 #24
0
        private void tmrGameClock_Tick(object sender, System.EventArgs e)
        {
            int erasedLines;

            if (stillProcessing)
            {
                return;
            }
            stillProcessing = true;

            //Manage the falling block
            if (!CurrentBlock.Down())
            {
                if (CurrentBlock.Top() == 0)
                {
                    tmrGameClock.Enabled = false;
                    CmdStart.Enabled     = true;
                    MessageBox.Show("GAME OVER", ".NETTrix", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    stillProcessing = false;
                    return;
                }
                //increase score based on # of deleted lines
                erasedLines = GameField.CheckLines();
                if (erasedLines > 0)
                {
                    score += 100 * erasedLines;
                    lblScoreValue.Text = score.ToString();
                    //Clear the game field and force the window to re-paint
                    PicBackground.Invalidate();
                    Application.DoEvents();
                    GameField.Redraw();
                }

                //Replace the current block...
                CurrentBlock = new Block(new Point(GameField.SquareSize * 6, 0), NextBlock.BlockType);
                CurrentBlock.Show(PicBackground.Handle);

                //Create the Next block
                NextBlock.Hide(PicNextBlock.Handle);
                NextBlock = new Block(new Point(20, 10), Block.BlockTypes.Undefined);
                NextBlock.Show(PicNextBlock.Handle);
            }
            stillProcessing = false;
        }
예제 #25
0
 private void tmrGameClock_Tick(object sender, System.EventArgs e)
 {
     if (stillProcessing)
     {
         return;
     }
     stillProcessing = true;
     //Manage the falling block
     if (!CurrentBlock.Down())
     {
         //Update to Pocket PC: Update the score value
         score += 5;
         lblScoreValue.Text = score.ToString();
         if (CurrentBlock.Top() == 0)
         {
             tmrGameClock.Enabled = false;
             CmdStart.Enabled     = true;
             //Update to Pocket PC: Changed box icon
             MessageBox.Show("GAME OVER", "NETTrix", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
             stillProcessing = false;
             return;
         }
         //increase score based on # of deleted lines
         int erasedLines = GameField.CheckLines();
         if (erasedLines > 0)
         {
             score += 100 * erasedLines;
             lblScoreValue.Text = score.ToString();
             //Update to Pocket PC: Use Clear/Redraw
             GameField.Clear();
             GameField.Redraw();
         }
         //Replace the current block...
         CurrentBlock = new Block(new Point(GameField.SquareSize * 6, 0), NextBlock.BlockType);
         CurrentBlock.Show(GameField.GraphBackground);
         //Create the Next block
         NextBlock.Hide(GameField.GraphNextBlock);
         NextBlock = new Block(new Point(20, 10), Block.BlockTypes.Undefined);
         NextBlock.Show(GameField.GraphNextBlock);
         PicNextBlock.Invalidate();
     }
     PicBackground.Invalidate();
     stillProcessing = false;
 }
예제 #26
0
 void Tick_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     --ci;
     if (ci == -1)
     {
         ci = 11;
     }
     pbAnimation.Invalidate();
     lblTotalTimeElapsed.Text = "Time Elapsed: " + totalTime.Elapsed.ToString();
 }
예제 #27
0
        private void SelFont_Click(object sender, System.EventArgs e)
        {
            FontDialog fd = new FontDialog();

            fd.Font = CurFont;
            if (fd.ShowDialog() != DialogResult.Cancel)
            {
                CurFont = (Font)fd.Font.Clone();
                ExportBitmap.Enabled = true;
                if (CurChar == -1)
                {
                    CurChar = 'A';
                }
                CharIdx.Text = CurChar.ToString();
                CharBox.Invalidate();
                FontName.Text = CurFont.Name;
                FontSize.Text = CurFont.Size.ToString();
            }
            GenerateFontBitmap();
        }
예제 #28
0
파일: Rubber.cs 프로젝트: red2015/Paint
 public void Draw(PictureBox pictureBox, Point temporaryPoint, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         Pen newPen = new Pen(Color.White, 10);
         g.DrawLine(newPen, _startPoint, temporaryPoint);
         Rectangle rectangle = new Rectangle(temporaryPoint.X,temporaryPoint.Y, 10, 10);
         g.DrawRectangle(newPen, rectangle);
     }
     _startPoint = temporaryPoint;
     pictureBox.Invalidate();
 }
예제 #29
0
        public ImageEditor(PictureBox picturebox, fmMain _fm)
        {
            fm = _fm;
            PB = picturebox;
            //g = PB.CreateGraphics();
            g = Graphics.FromImage(PB.Image);
            PB.Invalidate(); // вызов полной перерисовки контрола

            Polygs = new List<Polygon>();
            CurPoints = new List<int>();
            PolygonMaxNumber = 2;
        }
예제 #30
0
 private void MandelViewerForm_Resize(object sender, System.EventArgs e)
 {
     if (bConnected)
     {
         outputBox.Invalidate();
     }
 }
예제 #31
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     m_ValidationPoints.Clear();
     m_TrainingPoints.Clear();
     m_TemplatePoints.Clear();
     lblTrainingCounter.Text = "0";
     lblResult.Visible       = false;
     btnStartStop.Text       = "Start training";
     m_PredictionModule      = null;
     shapePB.Invalidate();
     lblResult.Invalidate();
     lblTrainingCounter.Invalidate();
 }
예제 #32
0
        /// <summary>Draw the image and the carrier regions</summary>
        /// <param name="imageInfo">Image and regions</param>
        private void DrawRegions(ImageInfo imageInfo)
        {
            picImage.Image = (Image)imageInfo.Image;
            picImage.Size  = picImage.Image.Size;
            Graphics graphics = Graphics.FromImage(picImage.Image);

            foreach (RegionInfo info in imageInfo.RegionInfo)
            {
                graphics.FillRegion(new SolidBrush(Color.Red), info.Region);
            }

            graphics.Dispose();
            picImage.Invalidate();
        }
예제 #33
0
 private void updateByDataObj()
 {
     this.Height = _DataObj.Height + MOVE_PAN_HEIGHT;
     this.Width  = _DataObj.Width;
     if (this.CaptionCtl != null)
     {
         this.CaptionCtl.Width = _DataObj.Width;
     }
     this.SectionType = _DataObj.SectionType;
     this.IsDisplay   = _DataObj.Visibled;
     if (_SectionList != null)
     {
         _SectionList.RefreshDesignLayout();
     }
     picMain.Invalidate();
 }
예제 #34
0
        void mouse_move(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (!can_draw)
            {
                return;
            }
            pictureBox1.Image = bmp;
            Graphics g   = Graphics.FromImage(bmp);
            Point    p   = new Point(e.X, e.Y);
            Pen      pen = new Pen(Color.Black);

            g.DrawLine(pen, prev, p);
            prev = p;
            g.Dispose();
            pictureBox1.Invalidate();
        }
예제 #35
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            // Получить изображение (jpg или gif)
            Image img = pictureBox1.Image;

            // Создать объект атрибутов изображения
            System.Drawing.Imaging.ImageAttributes imageAttrs =
                new System.Drawing.Imaging.ImageAttributes();
            // Создать атрибуты по матрице преобразования
            imageAttrs.SetColorMatrix(CreateSepiaMatrix());
            // Нарисовать новое изображение с помощью преобразования
            using (Graphics g = Graphics.FromImage(img))
            {
                g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height),
                            0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imageAttrs);
            }
            // Обновить рисунок
            pictureBox1.Invalidate();
        }
예제 #36
0
        private void InitializeComponent()
        {
            gameBox = new PictureBox ();
            gameBox.Parent = this;
            gameBox.Location = new Point (5, 5);
            gameBox.Size = new Size (ClientSize.Width - 10, ClientSize.Height - 40);
            gameBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            gameBox.Paint += game_Paint;
            gameBox.MouseUp += game_MouseUp;
            Controls.Add (gameBox);

            advance = new Button ();
            advance.Parent = this;
            advance.Location = new Point (5, ClientSize.Height - 35);
            advance.Size = new Size (120, 30);
            advance.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            advance.Text = "Next generation";
            advance.Click += advance_Click;
            Controls.Add (advance);

            startstop = new Button ();
            startstop.Parent = this;
            startstop.Location = new Point (advance.Location.X + advance.Width + 5, advance.Location.Y);
            startstop.Size = new Size (100, 30);
            startstop.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            startstop.Text = "Start Timer";
            startstop.Click += startstop_Click;
            Controls.Add (startstop);

            clear = new Button ();
            clear.Parent = this;
            clear.Location = new Point (startstop.Location.X + startstop.Width + 5, startstop.Location.Y);
            clear.Size = new Size (80, 30);
            clear.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            clear.Text = "Clear";
            clear.Click += (sender, e) => ReinitBoard (0);
            Controls.Add (clear);

            width = new NumericUpDown ();
            width.Width = 50;
            width.Location = new Point (clear.Location.X + clear.Width + 5, clear.Location.Y + (clear.Height - width.Height) / 2);
            width.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            width.Minimum = 10;
            width.Maximum = 128;
            width.Value = 48;
            Controls.Add (width);

            height = new NumericUpDown ();
            height.Width = 50;
            height.Location = new Point (width.Location.X + width.Width + 5, width.Location.Y);
            height.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            height.Minimum = 10;
            height.Maximum = 128;
            height.Value = 48;
            Controls.Add (height);

            rule = new TextBox ();
            rule.Width = 80;
            rule.Location = new Point (height.Location.X + height.Width + 5, height.Location.Y);
            rule.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            rule.Text = "23/3";
            Controls.Add (rule);

            reinit = new Button ();
            reinit.Parent = this;
            reinit.Location = new Point (rule.Location.X + rule.Width + 5, clear.Location.Y);
            reinit.Size = new Size (80, 30);
            reinit.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            reinit.Text = "New";
            reinit.Click += (sender, e) => ReinitBoard (30);
            Controls.Add (reinit);

            timer = new Timer ();
            timer.Enabled = false;
            timer.Interval = 500;
            timer.Tick += (sender, e) => advance_Click (sender, e);

            Resize += (sender, e) => gameBox.Invalidate ();
        }
예제 #37
0
        private void CreateThumbnails()
        {
            try
            {
                PictureBox previous = annotateBox;
                //previous.Top =0;
                int nCount = 1;
                int GAP = 15;

                //Rectangle rectpicture=new Rectangle(0,0,0,0);
                int top=0;//annotateBox.Top;
                int left=annotateBox.Left;
                int width=annotateBox.Width;
                int height=annotateBox.Height;

                annotation = previous;
                bool bFirst =true;
                string strImagePath;
            //				if(this.IsLaunchFromMangeContent)//check if its ManageContent
            //					nCount=1;
            //				else
            //					nCount=1;
                this.panelAnnotations.Width=80;
                //this.panel1.left=100;
                //this.axWebBrowser1.Left=100;

                while(nCount <=  pictureCount)
                {
                    if(!bFirst)
                    {
                        Invoke(CreatePictureBox, new object[] {System.IntPtr.Zero } );
                        //annotation.Height=previous.Height;
                        annotation.Left=left-10;
                        annotation.Width=width;
                        annotation.Height=height;
                        annotation.Top=top;
                        //annotation.Left =rectpicture.Left;
                        //						annotation.Height=previous.Height;
                        //						annotation.Left=previous.Left;
                        //						annotation.Width= previous.Width;
                        //						//annotation.Height = previous.Height;
                        //						annotation.Top =previous.Top+previous.Height+GAP;
                    }
                    else
                    {
                        annotation.Left=left-10;
                        annotation.Width=width;
                        annotation.Height=height;
                        annotation.Top=top;
                    }

                    annotation.SizeMode = PictureBoxSizeMode.StretchImage;
                    if(this.IsLaunchFromMangeContent==true || this.IsLaunchFromMangeContent==false)//check if its ManageContent
                    {//Start ManageContent
                        HttpWebRequest req;
                        HttpWebResponse	resp;
                        try
                        {
                            if(this.strLocalPath!="")
                            {
                                if(File.Exists((this.strLocalPath+"\\"+nCount+".jpg")))
                                {
                                    annotation.Image = Image.FromFile(this.strLocalPath+"\\"+nCount+".jpg");
                                }
                                else
                                {
                                    if(IsLaunchFromMangeContent==true)
                                        req = (HttpWebRequest) HttpWebRequest.Create(this.strRemoteUrl + nCount + ".jpg");
                                    else
                                        req = (HttpWebRequest) HttpWebRequest.Create(this.m_DocumentMessage.DownloadURL + nCount + ".jpg");

                                    req.ProtocolVersion = HttpVersion.Version11;
                                    req.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)";
                                    //req.CookieContainer=CookieCont;
                                    //	req.AllowAutoRedirect = CbxAutoRedirect.Checked;
                                    req.Accept="image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-powerpoint, application/vnd.ms-excel";
                                    //HttpWebResponse resp;
                                    try
                                    {
                                        resp = (HttpWebResponse) req.GetResponse();
                                        if(resp.ContentType=="image/jpeg")
                                        {
                                            //Stream rcvStream = resp.GetResponseStream();
                                            //									if(NewImage!=null)
                                            //									{
                                            //										NewImage.Dispose();
                                            //										NewImage=null;
                                            //									}
                                            Image NewImage=Image.FromStream(resp.GetResponseStream());
                                            if(! Directory.Exists(Application.StartupPath + "\\"+this.sessionID.ToString() ))
                                            {
                                                Directory.CreateDirectory(Application.StartupPath + "\\"+this.sessionID.ToString());
                                            }
                                            strImagePath=Application.StartupPath+"\\"+this.sessionID.ToString()+ "\\"+nCount+".jpg";
                                            NewImage.Save(strImagePath,System.Drawing.Imaging.ImageFormat.Jpeg);
                                            annotation.Image = NewImage;
            //											if(! Directory.Exists(Application.StartupPath + "\\"+this.sessionID.ToString() ))
            //											{
            //												Directory.CreateDirectory(Application.StartupPath + "\\"+this.sessionID.ToString());
            //											}

            //											lock(annotation)
            //											{
            //												strImagePath=Application.StartupPath+"\\"+this.sessionID.ToString()+ "\\"+nCount+".jpg";
            //												annotation.Image.Save(strImagePath,System.Drawing.Imaging.ImageFormat.Jpeg);
            //											}
                                            //annotation.Image.Save(Application.StartupPath+"\\"+this.sessionID.ToString()+ "\\"+nCount+".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

            //											Trace.WriteLine("File Name ::: " + strImagePath);
            //											Image.FromStream(resp.GetResponseStream()).Save(strImagePath, System.Drawing.Imaging.ImageFormat.Jpeg);

                                            // save to image //

                                            resp.Close();
                                            req=null;
                                            resp=null;
                                            GC.Collect();
                                            GC.WaitForPendingFinalizers();
                                            //								this.pictureBox1.Image=NewImage;
                                            //								this.pictureBox1.Width=NewImage.Width;
                                            //								this.pictureBox1.Height=NewImage.Height;
                                        }
                                    }
                                    catch (WebException err)
                                    {
                                        //MessageBox.Show(err.Status + " - " + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        resp = (HttpWebResponse) err.Response;
                                        if (resp == null)
                                        {
                                        }
                                    }
                                }

                            }
                            else
                            {
                                if(IsLaunchFromMangeContent==true)
                                    req = (HttpWebRequest) HttpWebRequest.Create(this.strRemoteUrl + nCount + ".jpg");
                                else
                                    req = (HttpWebRequest) HttpWebRequest.Create(this.m_DocumentMessage.DownloadURL + nCount + ".jpg");

                                req.ProtocolVersion = HttpVersion.Version11;
                                req.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)";
                                //req.CookieContainer=CookieCont;
                                //	req.AllowAutoRedirect = CbxAutoRedirect.Checked;
                                req.Accept="image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-powerpoint, application/vnd.ms-excel";
                                //HttpWebResponse resp;
                                try
                                {
                                    resp = (HttpWebResponse) req.GetResponse();
                                    if(resp.ContentType=="image/jpeg")
                                    {
                                        //Stream rcvStream = resp.GetResponseStream();
                                        //									if(NewImage!=null)
                                        //									{
                                        //										NewImage.Dispose();
                                        //										NewImage=null;
                                        //									}
                                        //NewImage=
                                        Image NewImage=Image.FromStream(resp.GetResponseStream());
                                        if(! Directory.Exists(Application.StartupPath + "\\"+this.sessionID.ToString() ))
                                        {
                                            Directory.CreateDirectory(Application.StartupPath + "\\"+this.sessionID.ToString());
                                        }
                                        NewImage.Save(Application.StartupPath+"\\"+this.sessionID.ToString()+ "\\"+nCount+".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                                        annotation.Image = NewImage;

                                        //annotation.Image.Save(Application.StartupPath+"\\"+this.sessionID.ToString()+ "\\"+nCount+".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

                                        // save to image //

                                        resp.Close();
                                        req=null;
                                        resp=null;
                                        GC.Collect();
                                        GC.WaitForPendingFinalizers();
                                        //								this.pictureBox1.Image=NewImage;
                                        //								this.pictureBox1.Width=NewImage.Width;
                                        //								this.pictureBox1.Height=NewImage.Height;
                                    }
                                }
                                catch (WebException err)
                                {

                                    WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("documentSharingControl.cs ==> CreateThumbnails() line==> 1468",err,null,false);
                                    //MessageBox.Show(err.Status + " - " + err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    resp = (HttpWebResponse) err.Response;
                                    if (resp == null)
                                    {
                                    }
                                }
                            }

                        }
                        catch(Exception exp)
                        {
                            WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("documentSharingControl.cs ==> CreateThumbnails() line==> 1478",exp,null,false);

                        }
                    }//End ManageContent

                    //					//if(this.IsLaunchFromMangeContent)
                        annotation.Tag = nCount;
                    //annotation.Image = Image.FromFile(@"C:\Documents and Settings\Danish\My Documents\Visual Studio Projects\Uraan Projects\WebMeetingClient\bin\Debug\Presentation\Copy of presentation2\Slide3.JPG");
                    annotation.Visible = true;
                    annotation.Invalidate();
                    annotation.Click += new EventHandler(annotateBox_Click);
                    nCount+=1;
                    //previous = annotation;
                    bFirst = false;
                    top=top+height+GAP;

                }

                annotationBrowser.annotationType = AnnotationMessageType.PPT;
            }
            catch(Exception ee)
            {
                ee = ee;
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
예제 #38
0
        /// <summary>
        /// Draws curve in to the panel
        /// </summary>
        /// <param name="panel">Panel</param>
        /// <param name="curve">Curve</param>
        /// <param name="delay">Delay if animation is requested</param>
        public static void DrawCurve(PictureBox pictureBox, List<PointF> curve, int delay)
        {
            Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
            //pictureBox.Image = bmp;            
            Pen pen = new Pen(Brushes.Blue, 6);
            pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
            Graphics gp = Graphics.FromImage(bmp);
            gp.FillRectangle(Brushes.White, 0, 0, pictureBox.Width, pictureBox.Height);
            gp.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            pictureBox.Image = bmp;
            if (curve == null || curve.Count == 0)
            {
                gp.Dispose();
                return;
            }

            List<PointF> new_curve = ScaleToCenter(curve, pictureBox.ClientRectangle);
            if (delay != 0)
            {
                List<PointF> exactCurve = CreateExactPath(new_curve, 2, 4);
                new_curve = exactCurve;
            }
            
            //Brush brushStart = new System.Drawing.Drawing2D.LinearGradientBrush(
            //        new_curve[0], new_curve[15], Color.Green, Color.Blue);
            

            for (int i = 0; i < new_curve.Count - 1; i++)
            {
                //int lastIndex = i > 15 ? i - 15 : 0;
                //List<PointF> last10Points = new List<PointF>();
                //last10Points.AddRange(new_curve.GetRange(lastIndex, i - lastIndex + 2));
                ////gp.FillEllipse(Brushes.Blue, new_curve[i].X - 3, new_curve[i].Y - 3, 6, 6);
                //Brush brushEnd = new System.Drawing.Drawing2D.LinearGradientBrush(
                //    last10Points[0], last10Points[last10Points.Count - 1], Color.Blue, Color.Red);

                
                //List<PointF> allPoints =  new_curve.GetRange(0, i + 2);
                //pen.Brush = Brushes.Blue;
                //gp.DrawLines(pen, last10Points.ToArray());
                //pen.Brush = brushEnd;
                //if (last10Points.Count > 2)
                //    last10Points.RemoveAt(0);
                //gp.DrawLines(pen, last10Points.ToArray());

                gp.DrawLine(pen, new_curve[i], new_curve[i + 1]);    
                if (delay != 0)
                {
                    pictureBox.Invalidate();
                    System.Threading.Thread.Sleep(delay);
                }
            }
            gp.FillEllipse(Brushes.Green, new_curve[0].X - 3, new_curve[0].Y - 3, 6, 6);
            gp.FillEllipse(Brushes.Red, new_curve[new_curve.Count - 1].X - 3, new_curve[new_curve.Count - 1].Y - 3, 6, 6);
            gp.Dispose();
            pictureBox.Invalidate();
        }
예제 #39
0
        private void createSelPBs(bool force, List<Province> newSelection, List<Province> oldSelection, IList<Province> provinces, PictureBox pb)
        {
            if (force || !newSelection.SequenceEqual(oldSelection))
            {
                Rectangle invalidRect = Rectangle.Empty;
                if (force)
                {
                    invalidRect = new Rectangle(0, 0, pb.Image.Width, pb.Image.Height);
                }
                else
                {
                    if (newSelection.Count > 0)
                        invalidRect = Program.ScaleRect(newSelection[0].Rect, scaleFactor);
                    else if (oldSelection.Count > 0)
                        invalidRect = Program.ScaleRect(oldSelection[0].Rect, scaleFactor);
                    foreach (Province p in newSelection)
                    {
                        invalidRect = Rectangle.Union(invalidRect, Program.ScaleRect(p.Rect, scaleFactor));
                    }
                    foreach (Province p in oldSelection)
                    {
                        invalidRect = Rectangle.Union(invalidRect, Program.ScaleRect(p.Rect, scaleFactor));
                    }
                }

                Graphics g = Graphics.FromImage(pb.Image);
                g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                g.FillRectangle(Brushes.Transparent, invalidRect);
                g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;

                // disable interpolation and smoothing to preserve chroma
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;

                if (MaskMapped)
                {
                    foreach (Province p in provinces)
                    {
                        Rectangle scaledRect = Program.ScaleRect(p.Rect, scaleFactor);
                        if (p.mapping != null && Rectangle.Intersect(scaledRect, invalidRect) != Rectangle.Empty)
                            g.DrawImage(p.BlackMask, scaledRect);
                    }
                }

                foreach (Province p in newSelection)
                {
                    Rectangle scaledRect = Program.ScaleRect(p.Rect, scaleFactor);
                    if (Rectangle.Intersect(scaledRect, invalidRect) != Rectangle.Empty)
                        g.DrawImage(p.SelectionMask, scaledRect);
                }
                pb.Invalidate(invalidRect);

                oldSelection.Clear();
                oldSelection.AddRange(newSelection);
            }
        }
예제 #40
0
 public override void HandleMouseUp(int pxX, int pxY, PictureBox pb)
 {
     if (!m_fOptionbox_Selecting)
         return;
     m_fOptionbox_Selecting = false;
     pb.Invalidate();
 }
예제 #41
0
        internal void PlotBackground(PictureBox pbox, int order)
        {
            pbox.Image = new Bitmap(pbox.Width, pbox.Height, PixelFormat.Format24bppRgb);

            Bitmap bmp = new Bitmap(pbox.Width, pbox.Height, PixelFormat.Format24bppRgb);
            int[,] bgModel = GenerateBackground(order, 1, 0, 0, m_X0, m_Y0, Math.Max(pbox.Width, pbox.Height));

            for (int x = 0; x < pbox.Width; x++)
            {
                for (int y = 0; y < pbox.Height; y++)
                {
                    int clr = Math.Max(0, Math.Min(255, bgModel[x, y]));
                    bmp.SetPixel(x, y, Color.FromArgb(clr, clr, clr));
                }
            }

            using (Graphics g = Graphics.FromImage(pbox.Image))
            {
                g.DrawImage(bmp, 0, 0);
                g.Save();
            }

            pbox.Invalidate();
            pbox.Update();
        }
예제 #42
0
        private void SetCurrentToolHilight(PictureBox pb, bool fValue)
        {
            // Update toolbox button hilight value.
            m_toolOptionCurrent.Hilight = fValue;

            // Update the option based on the state of the toolbox button.
            Options.Set(m_toolOptionCurrent.OptionName, fValue);

            // Update toolbox display
            pb.Invalidate();
        }
        private void DrawSolidFaces(Solid solid, PictureBox pc, int ipc, Pen myPen = null)
        {
            var x = 0;
            var y = 0;
            switch (ipc) {
                case 0:        //Top View
                    x = 0;
                    y = 2;
                    solid.ComputeVisibility(new Vector(solid.Points[0, 8], 1, solid.Points[2, 8]));
                    break;
                case 1:       //Front View
                    x = 0;
                    y = 1;
                    solid.ComputeVisibility(new Vector(solid.Points[0, 8], solid.Points[1, 8], 1));
                    break;
                case 2:       //Left View
                    x = 2;
                    y = 1;
                    solid.ComputeVisibility(new Vector(1, solid.Points[1, 8], solid.Points[2, 8]));
                    break;
                case 3:     //Perspective
                    x = 0;
                    y = 1;
                    if (isometricCheckBox.Checked) {
                        solid.ComputeVisibility(new Vector(0, 0, 1), new Vector(0, 0, 0));
                    } else {
                        solid.ComputeVisibility(VRP, P);
                    }

                    break;

            }
            var g = Graphics.FromImage(pc.Image);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            if (myPen == null) {
                myPen = new Pen(Color.Black, 1);
            }

            var matrix = solid.Points;
            for (var i = 0; i < 6; i++) {
                if (!solid.VisibleFaces[i] && hideFacesBox.Checked) continue;
                for (int j = 0; j < 3; j++) {
                    g.DrawLine(myPen, (float)matrix[x, solid.Faces[i, j]],
                        (float)matrix[y, solid.Faces[i, j]],
                        (float)matrix[x, solid.Faces[i, j + 1]],
                        (float)matrix[y, solid.Faces[i, j + 1]]);
                }
                g.DrawLine(myPen, (float)matrix[x, solid.Faces[i, 3]],
                    (float)matrix[y, solid.Faces[i, 3]],
                    (float)matrix[x, solid.Faces[i, 0]],
                    (float)matrix[y, solid.Faces[i, 0]]);
            }
            pc.Invalidate();
        }
예제 #44
0
 internal void ClearImage(Bitmap bitmap, Color secondaryColor, PictureBox imageBox)
 {
     Graphics.FromImage(bitmap).Clear(secondaryColor);
       imageBox.Invalidate();
 }
예제 #45
0
 void updateDrawing(PictureBox picture)
 {
     if (colourTheme.Count > 0)
     {
         for (int k = 0; k < colourTheme.Count; k++)
         {
             int r, g, b;
             hexToRGB(colours[colourTheme[k]].hex, out r, out g, out b);
             SolidBrush myBrush = new SolidBrush(Color.FromArgb(255, r, g, b));
             Graphics formGraphics;
             formGraphics = picture.CreateGraphics();
             formGraphics.FillRectangle(myBrush, new Rectangle(0, k * picture.Height / colourTheme.Count, picture.Width, picture.Height / colourTheme.Count));
             myBrush.Dispose();
             formGraphics.Dispose();
         }
     }
     else
     {
         picture.Invalidate();
     }
 }
예제 #46
0
 /// <summary>
 /// Sets the image in a picturebox and invalidates the picture box
 /// This is just a helper function that takes care of
 /// cross-thread invokations that would result in .NET
 /// exceptions.
 /// </summary>
 /// <param name="box"></param>
 /// <param name="image"></param>
 public static void SetImage(PictureBox box, Image image)
 {
     if (box.InvokeRequired)
     {
         box.Invoke(new setImage(SetImage), box, image);
     }
     else
     {
         box.Image = image;
         box.Invalidate();
     }
 }
예제 #47
0
파일: Form1.cs 프로젝트: lightfaith/NAVY
        private void DrawFractal(PictureBox pic, Fractal f)
        {
            if (pic.Image == null)
                pic.Image = new Bitmap(pic.Width, pic.Height);

            Random r = new Random();

            pic.Image = fractal.Picture;
            pic.Invalidate();
        }
예제 #48
0
        public override void AnimateToPictureBox(PictureBox pictureBox)
        {
            if (m_trigger == MouseButtons.None) return;

            bool swapedButtons = Win32.GetSystemMetrics(Win32.SM_SWAPBUTTON) == 0 ? false : true;

            Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
            Graphics gp = Graphics.FromImage(bmp);
            gp.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
            int width = (int)Math.Min(bmp.Width * 0.8, bmp.Height * 0.8);
            if (width > Resources.base_mouse.Width)
                width = Resources.base_mouse.Width;
            int height = width;
            Point pos = new Point((bmp.Width - width) / 2, (bmp.Height - height) / 4);
            Rectangle r = new Rectangle(pos, new Size(width, height));
            Point strPos = new Point(0, pos.Y + (int)Math.Floor(r.Height * 0.95));
            Rectangle rString = new Rectangle(strPos, new Size(bmp.Width, (int)Math.Floor((bmp.Height - height) * 0.75)));
            float fontHeight = (float)r.Height / 18;
            Font strFont = new Font(FontFamily.GenericSansSerif, fontHeight, FontStyle.Bold); //SystemFonts.DefaultFont; 
            string txtPushHoldBtn = string.Format(Translation.GetText("Animate_WheelG_pushHoldBtn"), Translation.GetMouseBtnText(m_trigger));
            string txtScrollWheelUp = Translation.GetText("Animate_WheelG_scrollWheelUp");
            string txtScrollWheelDown = Translation.GetText("Animate_WheelG_scrollWheelDown");
            string txtReleaseHoldBtn = string.Format(Translation.GetText("Animate_WheelG_releaseHoldBtn"), Translation.GetMouseBtnText(m_trigger));
            StringFormat strFormat = new StringFormat();
            strFormat.LineAlignment = StringAlignment.Center;
            strFormat.Alignment = StringAlignment.Center;            
            SolidBrush strTriggerBrush = new SolidBrush(Color.FromArgb(250, 10, 10)); //red 
            SolidBrush strModifierBrush = new SolidBrush(Color.FromArgb(220, 215, 16)); //yellow
                        
            gp.DrawImage(Resources.base_mouse, r.X, r.Y, r.Width, r.Height);
            pictureBox.Image = bmp;
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            System.Threading.Thread.Sleep(DELAY / 4);

            // Push Hold-down button
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            DrawTrigger(m_trigger, gp, r);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.DrawString(txtPushHoldBtn, strFont, strTriggerBrush, rString, strFormat);
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);

            // Scroll with wheel up
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.DrawImage(Resources.btn_wheel_up, r.X, r.Y, r.Width, r.Height);
            gp.DrawImage(Resources.btn_middle_modifier, r.X, r.Y, r.Width, r.Height);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.DrawString(txtScrollWheelUp, strFont, strModifierBrush, rString, strFormat);
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);

            // Scroll with wheel down
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), 0, 0, pictureBox.Width, pictureBox.Height);
            gp.DrawImage(Resources.base_mouse, r.X, r.Y, r.Width, r.Height);
            DrawTrigger(m_trigger, gp, r);            
            gp.DrawImage(Resources.btn_wheel_down, r.X, r.Y, r.Width, r.Height);
            gp.DrawImage(Resources.btn_middle_modifier, r.X, r.Y, r.Width, r.Height);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.DrawString(txtScrollWheelDown, strFont, strModifierBrush, rString, strFormat);
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);

            // Release Hold-down button
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), 0, 0, pictureBox.Width, pictureBox.Height);
            gp.DrawImage(Resources.base_mouse, r.X, r.Y, r.Width, r.Height);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY); 
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.DrawString(txtReleaseHoldBtn, strFont, strTriggerBrush, rString, strFormat);
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);


            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.Dispose();
            pictureBox.Image = DrawWheelBtnMouse(pictureBox.Size, false);            
            pictureBox.Invalidate();
            
        }
예제 #49
0
 /// <summary>
 /// 在指定PictureBox演示生成过程
 /// </summary>
 /// <param name="p">要展示的PictureBox</param>
 public void DrawCreate(PictureBox p)
 {
     Bitmap newBitmap = new Bitmap(Bmp.Width, Bmp.Height);
     Graphics g = Graphics.FromImage(newBitmap);
     for (int i = 0; i <= PreviewMaze.GetUpperBound(0); i++)
         for (int j = 0; j <= PreviewMaze.GetUpperBound(1); j++)
             if (PreviewMaze[i, j] == Block)
                 g.DrawImage(Resources.block, i * BlockWidth, j * BlockHeight, BlockWidth, BlockHeight);
     p.Image = newBitmap;
     p.Invalidate();
     Application.DoEvents();
     foreach (var value in CreateScript)
     {
         if (value.A)
             g.DrawImage(Resources.block, value.P.X * BlockWidth, value.P.Y * BlockHeight, BlockWidth, BlockHeight);
         else
             g.DrawImage(Resources.empty, value.P.X * BlockWidth, value.P.Y * BlockHeight, BlockWidth, BlockHeight);
         p.Image = newBitmap;
         p.Invalidate();
         Application.DoEvents();
     }
 }
        private void goGenerateProcessesFriendship()
        {
            int artOfficial = 0;
            foreach (var theProcess in Process.GetProcesses())
            {
                if (theProcess.MainWindowTitle != "" && theProcess.MainWindowTitle != "Space")
                {
                    artOfficial++;
                }
            }

            if (artOfficial != currentCountProc)
            {
                spaceForProcesses.Controls.Clear();
                int procCount = 0;
                foreach (var theProcess in Process.GetProcesses())
                {

                    if (procCount != 0 && procCount != 4)
                    {

                        if ((theProcess.MainWindowTitle != "" && theProcess.Modules[0].FileName != "ProjectSnowshoes.exe") && theProcess.MainWindowHandle != null)
                        {
                            foreach (var h in getHandles(theProcess))
                            {
                                if (IsWindowVisible(h))
                                {
                                    PictureBox hmGreatJobFantasticAmazing = new PictureBox();
                                    StringBuilder sb = new StringBuilder(GetWindowTextLength(h) + 1);
                                    GetWindowText(h, sb, sb.Capacity);




                                    hmGreatJobFantasticAmazing.Margin = new Padding(6, 0, 6, 0);
                                    hmGreatJobFantasticAmazing.Visible = true;
                                    hmGreatJobFantasticAmazing.SizeMode = PictureBoxSizeMode.CenterImage;
                                    hmGreatJobFantasticAmazing.BackgroundImageLayout = ImageLayout.Zoom;

                                    Icon.ExtractAssociatedIcon(theProcess.Modules[0].FileName).ToBitmap().Save(@"C:\ProjectSnowshoes\temptaskico.png");

                                    ImageFactory grayify = new ImageFactory();
                                    grayify.Load(@"C:\ProjectSnowshoes\temptaskico.png");
                                    Size sizeeeee = new System.Drawing.Size();
                                    sizeeeee.Height = 20;
                                    sizeeeee.Width = 20;
                                    ImageProcessor.Imaging.ResizeLayer reLay = new ImageProcessor.Imaging.ResizeLayer(sizeeeee);
                                    grayify.Resize(reLay);

                                    hmGreatJobFantasticAmazing.Image = grayify.Image;
                                    hmGreatJobFantasticAmazing.Click += (sender, args) =>
                                    {

                                        ShowWindow(theProcess.MainWindowHandle, 5);
                                        ShowWindow(theProcess.MainWindowHandle, 9);
                                    };
                                    hmGreatJobFantasticAmazing.MouseHover += (sender, args) =>
                                    {
                                        Properties.Settings.Default.stayHere = true;
                                        Properties.Settings.Default.Save();
                                        int recordNao = hmGreatJobFantasticAmazing.Left;

                                        hmGreatJobFantasticAmazing.Image.Save(@"C:\ProjectSnowshoes\TheyNeedToKeepOriginalAlbums.png");
                                        Size sizeeeeeA = new System.Drawing.Size();
                                        sizeeeeeA.Height = 100;
                                        sizeeeeeA.Width = 100;
                                        ImageProcessor.Imaging.ResizeLayer reLayA = new ImageProcessor.Imaging.ResizeLayer(sizeeeeeA);
                                        ImageProcessor.Imaging.GaussianLayer gauLay = new ImageProcessor.Imaging.GaussianLayer();
                                        gauLay.Sigma = 2;
                                        gauLay.Threshold = 10;
                                        gauLay.Size = 20;
                                        ImageFactory backify = new ImageFactory();
                                        backify.Load(@"C:\ProjectSnowshoes\TheyNeedToKeepOriginalAlbums.png");
                                        backify.Brightness(-30);
                                        backify.Resize(reLayA);
                                        backify.GaussianBlur(gauLay);
                                        ImageProcessor.Imaging.CropLayer notAsLongAsOriginalName = new ImageProcessor.Imaging.CropLayer(90, 0, 0, 0, ImageProcessor.Imaging.CropMode.Percentage);
                                        backify.Crop(new Rectangle(25, (100 - this.Height) / 2, 50, this.Height));
                                        hmGreatJobFantasticAmazing.BackgroundImage = backify.Image;
                                        grayify.Save(@"C:\ProjectSnowshoes\TheyStillNeedToKeepOriginalAlbums.png");
                                        ImageFactory grayifyA = new ImageFactory();
                                        grayifyA.Load(@"C:\ProjectSnowshoes\TheyStillNeedToKeepOriginalAlbums.png");
                                        grayifyA.Saturation(44);
                                        grayifyA.Brightness(42);
                                        hmGreatJobFantasticAmazing.Image = grayifyA.Image;
                                        // Yeahhhhhhhhh I'm going to have to do this another way
                                        // panel1.Controls.Add(areYouSeriouslyStillDoingThisLetItGo);
                                        // Oh
                                        // I can just make another form to draw over and go have turnips with parameters
                                        // Also credits to Microsoft Word's "Sentence Case" option as this came out in all caps originally
                                        // Measuring string turnt-up-edness was guided by an answer on Stack Overflow by Tom Anderson.
                                        String keepThisShortWeNeedToOptimize = sb.ToString().Replace("&", "&&");
                                        Graphics heyGuessWhatGraphicsYeahThatsRight = Graphics.FromImage(new Bitmap(1, 1));
                                        SizeF sure = heyGuessWhatGraphicsYeahThatsRight.MeasureString(keepThisShortWeNeedToOptimize, new System.Drawing.Font(Properties.Settings.Default.fontsOfScience[Properties.Settings.Default.whoIsThisCrazyDoge], 14, FontStyle.Regular, GraphicsUnit.Point));
                                        Size sureAgain = sure.ToSize();
                                        int recordThatJim;
                                        if (sureAgain.Width >= 300)
                                        {
                                            recordThatJim = sureAgain.Width + 10;
                                        }
                                        else
                                        {
                                            recordThatJim = 300;
                                        }
                                        CanWeMakeAHoverFormLikeThisIsThisLegal notAsLongInstanceName = new CanWeMakeAHoverFormLikeThisIsThisLegal(recordNao + 150, this.Height, recordThatJim, keepThisShortWeNeedToOptimize);
                                        notAsLongInstanceName.Show();
                                        notAsLongInstanceName.BringToFront();
                                        //hmGreatJobFantasticAmazing.BringToFront();
                                        //panel1.Controls.Add(hmGreatJobFantasticAmazing);
                                        //hmGreatJobFantasticAmazing.Top = this.Top - 40;
                                        //hmGreatJobFantasticAmazing.Left = recordNao + 150;
                                        //hmGreatJobFantasticAmazing.BringToFront();
                                        //hmGreatJobFantasticAmazing.Invalidate();
                                        /*hmGreatJobFantasticAmazing.Height = 100;
                                        hmGreatJobFantasticAmazing.Width = 100;*/
                                    };
                                    hmGreatJobFantasticAmazing.MouseLeave += (sender, args) =>
                                    {
                                        /*hmGreatJobFantasticAmazing.ImageAlign = ContentAlignment.MiddleCenter;
                                        hmGreatJobFantasticAmazing.AutoEllipsis = false;
                                        hmGreatJobFantasticAmazing.Width = 40;
                                        hmGreatJobFantasticAmazing.BackColor = Color.Transparent;
                                        //hmGreatJobFantasticAmazing.Font = new System.Drawing.Font(Properties.Settings.Default.fontsOfScience[Properties.Settings.Default.whoIsThisCrazyDoge], 14, FontStyle.Regular);
                                        //hmGreatJobFantasticAmazing.ForeColor = Color.White;
                                        hmGreatJobFantasticAmazing.TextAlign = ContentAlignment.MiddleLeft;
                                        hmGreatJobFantasticAmazing.Text = "";*/
                                        try
                                        {
                                            Application.OpenForms["CanWeMakeAHoverFormLikeThisIsThisLegal"].Close();
                                        }
                                        catch (Exception exTurnip) { }
                                        hmGreatJobFantasticAmazing.BackgroundImage = null;
                                        hmGreatJobFantasticAmazing.Invalidate();
                                        Properties.Settings.Default.stayHere = false;
                                        Properties.Settings.Default.Save();
                                        hmGreatJobFantasticAmazing.Image = grayify.Image;
                                    };
                                    //openFileToolTip.SetToolTip(hmGreatJobFantasticAmazing, theProcess.MainWindowTitle);
                                    //hmGreatJobFantasticAmazing.BackgroundImage = Icon.ExtractAssociatedIcon(theProcess.Modules[0].FileName).ToBitmap();
                                    hmGreatJobFantasticAmazing.Height = this.Height;
                                    hmGreatJobFantasticAmazing.Width = 50;
                                    spaceForProcesses.Controls.Add(hmGreatJobFantasticAmazing);
                                }
                            }
                        }

                    }
                    procCount++;
                }

            }

            currentCountProc = artOfficial;


        }
예제 #51
0
        /* ----------------------------------------------------------------- */
        ///
        /// Render (private)
        ///
        /// <summary>
        /// MEMO: ロックは暫定処理.Microsoft によると public にアクセス
        /// 可能なオブジェクトを用いた lock は想定していないらしい.
        /// http://msdn.microsoft.com/ja-jp/library/c5kehkcz%28VS.80%29.aspx
        /// </summary>
        /// 
        /* ----------------------------------------------------------------- */
        private static bool Render(Canvas canvas, bool adjust)
        {
            if (canvas == null) return false;
            var engine = canvas.Tag as CanvasEngine;
            if (engine == null) return false;
            var core = engine.Core;
            if (core == null) return false;

            lock (core) {
                var status = core.RenderPage(IntPtr.Zero, false, false);
                if (status && adjust) CanvasPolicy.Adjust(canvas);
                canvas.Invalidate();
                return status;
            }
        }
예제 #52
0
 /// <summary>
 /// 在指定的PictureBox演示寻路过程
 /// </summary>
 /// <param name="p">要演示寻路过程的PictureBox</param>
 public void DrawGoPath(PictureBox p)
 {
     //拷贝迷宫地图到新对象
     Bitmap newBmp = new Bitmap(Bmp);
     //创建绘制对象
     Graphics g = Graphics.FromImage(newBmp);
     foreach (var value in FindScript)
     {
         if (value.A)
             g.DrawImage(Resources.unblock, value.P.X * BlockWidth, value.P.Y * BlockHeight, BlockWidth, BlockHeight);
         else
             g.DrawImage(Resources.step, value.P.X * BlockWidth, value.P.Y * BlockHeight, BlockWidth, BlockHeight);
         p.Image = newBmp;
         p.Invalidate();
         Application.DoEvents();
     }
 }
예제 #53
0
		/* S E T  V I E W  D A T E  T I M E  S C R O L L */
		/*----------------------------------------------------------------------------
			%%Function: SetViewDateTimeScroll
			%%Qualified: bg.BgGraph.SetViewDateTimeScroll
			%%Contact: rlittle

		----------------------------------------------------------------------------*/
		void SetViewDateTimeScroll(PictureBox pb, HScrollBar sbh, VScrollBar sbv, DateTime dttm, int iFirstQuarter)
		{
			if (BvFromPb(pb) == BoxView.Log)
				{
				Reporter rpt = (Reporter)pb.Tag;

				rpt.SetFirstDateTime(dttm);
				sbv.Value = rpt.GetFirstLine();
				}
			else if (BvFromPb(pb) == BoxView.Graph)
				{
				Grapher grph = (Grapher)pb.Tag;

				if (iFirstQuarter >= 0)
					{
					grph.SetFirstFromScroll(iFirstQuarter);
					sbh.Value = iFirstQuarter;
					}
				else
					{
					grph.SetFirstDateTime(dttm.AddDays(-1.0));
					if (grph.GetFirstForScroll() > sbh.Maximum)	 // if we have exceeded the scrolling regions, then we want to act as if we've scrolled to the end
						grph.SetFirstFromScroll(sbh.Value);
					if (grph.GetFirstForScroll() < 0)
						grph.SetFirstFromScroll(0);
					sbh.Value = grph.GetFirstForScroll();
					}
				}
			pb.Invalidate();
		}
예제 #54
0
        private static void drawChart(PictureBox pictureBox1, String command)
        {
            StringBuilder plotCommmand = new StringBuilder();

            plotCommmand.Append(@"CairoPNG('c:\\temp\\r.png',bg='transparent');");
            plotCommmand.Append(command + ";\n");
            plotCommmand.Append("graphics.off();");
            engine.Evaluate(plotCommmand.ToString());

            using (System.IO.StreamReader str = new System.IO.StreamReader("c:\\temp\\r.png"))
            {
                pictureBox1.Image = new Bitmap(str.BaseStream);
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                str.Close();
            }
            pictureBox1.Invalidate();
        }
예제 #55
0
        public override void AnimateToPictureBox(PictureBox pictureBox)
        {
            if (m_trigger == MouseButtons.None || m_modifier == MouseButtons.None) return;

            bool swapedButtons = Win32.GetSystemMetrics(Win32.SM_SWAPBUTTON) == 0 ? false : true;
            
            Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);            
            Graphics gp = Graphics.FromImage(bmp);
            gp.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;            
            int width = (int)Math.Min(bmp.Width * 0.8, bmp.Height * 0.8);
            if (width > Resources.base_mouse.Width)
                width = Resources.base_mouse.Width;
            int height = width;
            Point pos = new Point((bmp.Width - width) / 2, (bmp.Height - height) / 4);
            Rectangle r = new Rectangle(pos, new Size(width, height));
            Point strPos = new Point(0, pos.Y + (int)Math.Floor(r.Height * 0.95));
            Rectangle rString = new Rectangle(strPos, new Size(bmp.Width, (int)Math.Floor((bmp.Height - height) * 0.75)));
            float fontHeight = (float)r.Height / 18;
            Font strFont = new Font(FontFamily.GenericSansSerif, fontHeight, FontStyle.Bold); //SystemFonts.DefaultFont;
            
            string txtPushHoldBtn = string.Format(Translation.GetText("Animate_RockerG_pushHoldBtn"), Translation.GetMouseBtnText(m_trigger));
            string txtClickExecuteBtn = string.Format(Translation.GetText("Animate_RockerG_clickExecuteBtn"), Translation.GetMouseBtnText(m_modifier));

            //float strWidth = Math.Max(gp.MeasureString(txtPushHoldBtn, strFont).Width, gp.MeasureString(txtClickExecuteBtn, strFont).Width);
            //if (strWidth > r.Width * 2)
            //{
            //    fontHeight = (float)r.Height / 22;
            //    strFont = new Font(strFont.FontFamily, fontHeight, strFont.Style);
            //}

            StringFormat strFormat = new StringFormat();
            strFormat.LineAlignment = StringAlignment.Center;
            strFormat.Alignment = StringAlignment.Center;            
            SolidBrush strTriggerBrush = new SolidBrush(Color.FromArgb(250, 10, 10)); //red 
            SolidBrush strModifierBrush = new SolidBrush(Color.FromArgb(220, 215, 16)); //yellow

            gp.DrawImage(Resources.base_mouse, r.X, r.Y, r.Width, r.Height);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            pictureBox.Image = bmp;            
            System.Threading.Thread.Sleep(DELAY / 4);
            
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            DrawTrigger(m_trigger, gp, r);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            //text = string.Format("Push and hold the {0} button.", button.ToUpper());
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            gp.DrawString(txtPushHoldBtn, strFont, strTriggerBrush, rString, strFormat);            
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);

            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            DrawModifier(m_modifier, gp, r);
            if (swapedButtons) bmp.RotateFlip(RotateFlipType.Rotate180FlipY);
            //text = string.Format("Click on the {0} button to invoke the action.", button.ToUpper());
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);            
            gp.DrawString(txtClickExecuteBtn, strFont, strModifierBrush, rString, strFormat);            
            pictureBox.Invalidate();
            System.Threading.Thread.Sleep(DELAY);
            
            gp.FillRectangle(new SolidBrush(pictureBox.BackColor), rString);
            pictureBox.Invalidate();
            gp.Dispose();
        }
예제 #56
0
 private void DrawMatrix(BinImage bi, PictureBox p)
 {
     //      pictureBox1.Dispose();
     btp = new Bitmap(bi.Width, bi.Height);
     for (int i = 0; i < bi.Width; ++i)
         for (int j = 0; j < bi.Height; ++j)
             if (bi.matr[i, j] == 1)
                 btp.SetPixel(i, j, Color.White);
             else
                 btp.SetPixel(i, j, Color.Black);
     p.Image = btp;
     p.Invalidate();
     p.Update();
 }
예제 #57
0
        public static void TakePic(PictureBox c, PictureBox s)
        {
            
            pictureBox1 = c;
            snapShot = s;

            Point p = rect.Location;
            Point unscaled_p = new Point();
            int unscaled_height = new int();
            int unscaled_width = new int();

            int w_i = new int();
            int h_i = new int();
            int w_c = new int();
            int h_c = new int();

            // image and container dimensions
            w_i = pictureBox1.Image.Width;
            h_i = pictureBox1.Image.Height;
            w_c = pictureBox1.Width;
            h_c = pictureBox1.Height;

            float imageRatio = w_i / (float)h_i; // image W:H ratio
            float containerRatio = w_c / (float)h_c; // container W:H ratio

            if (imageRatio >= containerRatio)
            {
                // horizontal image
                float scaleFactor = w_c / (float)w_i;
                float scaledHeight = h_i * scaleFactor;
                // calculate gap between top of container and top of image
                float filler = Math.Abs(h_c - scaledHeight) / 2;
                unscaled_p.X = (int)(p.X / scaleFactor);
                unscaled_p.Y = (int)((p.Y - filler) / scaleFactor);
                unscaled_width = (int)(rect.Width / scaleFactor);
                unscaled_height = (int)(rect.Height / scaleFactor);
            }
            else
            {
                // vertical image
                float scaleFactor = h_c / (float)h_i;
                float scaledWidth = w_i * scaleFactor;
                float filler = Math.Abs(w_c - scaledWidth) / 2;
                unscaled_p.X = (int)((p.X - filler) / scaleFactor);
                unscaled_p.Y = (int)(p.Y / scaleFactor);
                unscaled_width = (int)(rect.Width / scaleFactor);
                unscaled_height = (int)(rect.Height / scaleFactor);
            }


            Rectangle cropBoxUnscaled = new Rectangle(unscaled_p.X, unscaled_p.Y, unscaled_width, unscaled_height);
            Bitmap bmp = new Bitmap(pictureBox1.Image);
            croppedbmp = bmp.Clone(cropBoxUnscaled, bmp.PixelFormat);
            snapShot.Image = croppedbmp;
            snapShot.Invalidate();
        }
예제 #58
0
		/* P I C T U R E  B O X  S I Z E  C H A N G E */
		/*----------------------------------------------------------------------------
			%%Function: PictureBoxSizeChange
			%%Qualified: bg.BgGraph.PictureBoxSizeChange
			%%Contact: rlittle

		----------------------------------------------------------------------------*/
		void PictureBoxSizeChange(PictureBox pb, HScrollBar sbh, VScrollBar sbv)
		{
			Graphics gr = this.CreateGraphics();
			RectangleF rcf = new RectangleF(Reporter.DxpFromDxa(gr, 100), 
											Reporter.DypFromDya(gr, 100), 
											pb.Width - Reporter.DxpFromDxa(gr, 200), 
											pb.Height - Reporter.DypFromDya(gr, 200));

			if (pb.Tag != null)
				{
				int iFirst = ((GraphicBox)pb.Tag).GetFirstForScroll();
				GraphicBox gb = null;
	
				if (BvFromPb(pb) == BoxView.Graph)
					pb.Tag = gb = (GraphicBox) new Grapher(rcf, gr);
				else if (BvFromPb(pb) == BoxView.Log)
					pb.Tag = gb = (GraphicBox) new Reporter(rcf, gr);
	
				if (gb != null)
					{
					gb.SetProps(m_gp);
					gb.SetDataPoints(m_oData, sbv, sbh);
					gb.Calc();
					gb.SetFirstFromScroll(iFirst);
					}
	
				pb.Invalidate();
				}
		}
예제 #59
0
 /// <summary>
 /// 显示路径到指定的PictureBox
 /// </summary>
 /// <param name="p">要显示路径的PictureBox</param>
 public void DrawPath(PictureBox p)
 {
     //拷贝迷宫地图到新对象
     Bitmap newBmp = new Bitmap(Bmp);
     //创建绘制对象
     Graphics g = Graphics.FromImage(newBmp);
     //将栈内记录的路线点绘制在迷宫图上
     Stack<Point> points = new Stack<Point>(PathStack);
     while (points.Count > 0)
     {
         Point point = points.Pop();
         g.DrawImage(Resources.unblock, point.X * BlockWidth, point.Y * BlockWidth, BlockWidth, BlockHeight);
     }
     p.Image = newBmp;
     p.Invalidate();
 }
예제 #60
-1
 public void Draw(PictureBox pictureBox, Pen pen)
 {
     using (Graphics g = Graphics.FromImage(pictureBox.Image))
     {
         g.DrawEllipse(pen, _rectangle);
     }
     pictureBox.Invalidate();
 }