C# (CSharp) Класс System.Drawing. Rectangle Code Examples

C# (CSharp) System.Drawing.Rectangle - 30 примеров найдено. Это лучшие примеры C# (CSharp) кода для класса System.Drawing.Rectangle, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Пример #1
0
        private Bitmap DrawDropImage(int size)
        {
            Bitmap bmp = new Bitmap(size, size);
            Rectangle rect = new Rectangle(0, 0, size, size);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.FillRectangle(Brushes.CornflowerBlue, rect);

                g.DrawRectangleProper(Pens.Black, rect);

                using (Pen pen = new Pen(Color.WhiteSmoke, 5) { Alignment = PenAlignment.Inset })
                {
                    g.DrawRectangleProper(pen, rect.Offset(-1));
                }

                string text = Resources.DropForm_DrawDropImage_Drop_here;

                using (Font font = new Font("Arial", 20, FontStyle.Bold))
                using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
                {
                    g.DrawString(text, font, Brushes.Black, rect.LocationOffset(1), sf);
                    g.DrawString(text, font, Brushes.White, rect, sf);
                }
            }

            return bmp;
        }
Пример #2
0
 public void Apply(Surface dst, Surface src, Rectangle[] rois, int startIndex, int length)
 {
     for (int i = startIndex; i < startIndex + length; ++i)
     {
         ApplyBase(dst, rois[i].Location, src, rois[i].Location, rois[i].Size);
     }
 }
	protected virtual void SetLocation()
	{
		TextArea textArea = control.ActiveTextAreaControl.TextArea;
		TextLocation caretPos  = textArea.Caret.Position;
		
		int xpos = textArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X);
		int rulerHeight = textArea.TextEditorProperties.ShowHorizontalRuler ? textArea.TextView.FontHeight : 0;
		Point pos = new Point(textArea.TextView.DrawingPosition.X + xpos,
		                      textArea.TextView.DrawingPosition.Y + (textArea.Document.GetVisibleLine(caretPos.Y)) * textArea.TextView.FontHeight
		                      - textArea.TextView.TextArea.VirtualTop.Y + textArea.TextView.FontHeight + rulerHeight);
		
		Point location = control.ActiveTextAreaControl.PointToScreen(pos);
		
		// set bounds
		Rectangle bounds = new Rectangle(location, drawingSize);
		
		if (!workingScreen.Contains(bounds)) {
			if (bounds.Right > workingScreen.Right) {
				bounds.X = workingScreen.Right - bounds.Width;
			}
			if (bounds.Left < workingScreen.Left) {
				bounds.X = workingScreen.Left;
			}
			if (bounds.Top < workingScreen.Top) {
				bounds.Y = workingScreen.Top;
			}
			if (bounds.Bottom > workingScreen.Bottom) {
				bounds.Y = bounds.Y - bounds.Height - control.ActiveTextAreaControl.TextArea.TextView.FontHeight;
				if (bounds.Bottom > workingScreen.Bottom) {
					bounds.Y = workingScreen.Bottom - bounds.Height;
				}
			}
		}
		Bounds = bounds;
	}
Пример #4
0
 public static Rectangle RtlTransform(Control control, Rectangle rectangle)
 {
     if (control.RightToLeft != RightToLeft.Yes)
         return rectangle;
     else
         return new Rectangle(control.ClientRectangle.Right - rectangle.Right, rectangle.Y, rectangle.Width, rectangle.Height);
 }
Пример #5
0
 public Bitmap DrawBitmap(int theight, int twidth)
 {
     Bitmap bitmap3;
     Bitmap bitmap = new Bitmap(this.Width, this.Height);
     Rectangle targetBounds = new Rectangle(0, 0, this.Width, this.Height);
     this.MyBrowser.DrawToBitmap(bitmap, targetBounds);
     Image image = bitmap;
     Bitmap bitmap2 = new Bitmap(twidth, theight, image.PixelFormat);
     Graphics graphics = Graphics.FromImage(bitmap2);
     graphics.CompositingQuality = CompositingQuality.HighSpeed;
     graphics.SmoothingMode = SmoothingMode.HighSpeed;
     graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
     Rectangle rect = new Rectangle(0, 0, twidth, theight);
     graphics.DrawImage(image, rect);
     try
     {
         bitmap3 = bitmap2;
     }
     catch
     {
         bitmap3 = null;
     }
     finally
     {
         image.Dispose();
         image = null;
         this.MyBrowser.Dispose();
         this.MyBrowser = null;
     }
     return bitmap3;
 }
Пример #6
0
        static long CalculateActorSelectionPriority(ActorInfo info, Rectangle bounds, int2 selectionPixel)
        {
            var centerPixel = new int2(bounds.X, bounds.Y);
            var pixelDistance = (centerPixel - selectionPixel).Length;

            return ((long)-pixelDistance << 32) + info.SelectionPriority();
        }
Пример #7
0
        void DrawGraphics(Object sender, PaintEventArgs PaintNow)
        {
            Rectangle Dot = new Rectangle(SpriteX, SpriteY, SpriteWidth, SpriteHeight); // Create rectangle (start position, and size X & Y)
            SolidBrush WhiteBrush = new SolidBrush(Color.White); // Create Brush(Color) to paint rectangle

            PaintNow.Graphics.FillRectangle(WhiteBrush, Dot);
        }
	public RECT(Rectangle rect) 
	{
		Left = rect.Left; 
		Top = rect.Top;
		Right = rect.Right;
		Bottom = rect.Bottom;
	}
        public override void Draw(System.Drawing.RectangleF dirtyRect)
        {
            var g = new Graphics();

            // NSView does not have a background color so we just use Clear to white here
            g.Clear(Color.White);

            //RectangleF ClientRectangle = this.Bounds;
            RectangleF ClientRectangle = dirtyRect;

            // Calculate the location and size of the drawing area
            // within which we want to draw the graphics:
            Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y,
                                           (int)ClientRectangle.Width, (int)ClientRectangle.Height);
            drawingRectangle = new Rectangle(rect.Location, rect.Size);
            drawingRectangle.Inflate(-offset, -offset);
            //Draw ClientRectangle and drawingRectangle using Pen:
            g.DrawRectangle(Pens.Red, rect);
            g.DrawRectangle(Pens.Black, drawingRectangle);
            // Draw a line from point (3,2) to Point (6, 7)
            // using the Pen with a width of 3 pixels:
            Pen aPen = new Pen(Color.Green, 3);
            g.DrawLine(aPen, Point2D(new PointF(3, 2)),
                       Point2D(new PointF(6, 7)));

            g.PageUnit = GraphicsUnit.Inch;
            ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f);
            aPen.Width = 1 / g.DpiX;
            g.DrawRectangle(aPen, ClientRectangle);

            aPen.Dispose();

            g.Dispose();
        }
        protected override void OnSizeChanged(EventArgs e)
        {
			base.OnSizeChanged(e);

            boxOffset = Height / 2 - 9;
            boxRectangle = new Rectangle(boxOffset, boxOffset, CHECKBOX_SIZE - 1, CHECKBOX_SIZE - 1);
        }
 /// <summary>
 /// Initialize a new instance of the ButtonDragRectangleEventArgs class.
 /// </summary>
 /// <param name="point">Left mouse down point.</param>
 public ButtonDragRectangleEventArgs(Point point)
 {
     _point = point;
     _dragRect = new Rectangle(_point, Size.Empty);
     _dragRect.Inflate(SystemInformation.DragSize);
     _preDragOffset = true;
 }
Пример #12
0
 protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
 {
     var buttonRectangle = new Rectangle(cellBounds.X + 2, cellBounds.Y + 2, cellBounds.Width - 4, cellBounds.Height - 4);
     base.Paint(graphics, clipBounds, buttonRectangle, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
     var imageRectangle = new Rectangle(cellBounds.X + 6, cellBounds.Y + 6, _detailImage.Width, _detailImage.Height);
     graphics.DrawImage(_detailImage, imageRectangle);
 }
Пример #13
0
        public static void CalcDifference(Bitmap bmp1, Bitmap bmp2)
        {
            PixelFormat pxf = PixelFormat.Format32bppArgb;
            Rectangle rect = new Rectangle(0, 0, bmp1.Width, bmp1.Height);

            BitmapData bmpData1 = bmp1.LockBits(rect, ImageLockMode.ReadWrite, pxf);
            IntPtr ptr1 = bmpData1.Scan0;

            BitmapData bmpData2 = bmp2.LockBits(rect, ImageLockMode.ReadOnly, pxf);
            IntPtr ptr2 = bmpData2.Scan0;

            int numBytes = bmp1.Width * bmp1.Height * bytesPerPixel;
            byte[] pixels1 = new byte[numBytes];
            byte[] pixels2 = new byte[numBytes];

            System.Runtime.InteropServices.Marshal.Copy(ptr1, pixels1, 0, numBytes);
            System.Runtime.InteropServices.Marshal.Copy(ptr2, pixels2, 0, numBytes);

            for (int i = 0; i < numBytes; i += bytesPerPixel)
            {
                if (pixels1[i + 0] == pixels2[i + 0] &&
                    pixels1[i + 1] == pixels2[i + 1] &&
                    pixels1[i + 2] == pixels2[i + 2])
                {
                    pixels1[i + 0] = 255;
                    pixels1[i + 1] = 255;
                    pixels1[i + 2] = 255;
                    pixels1[i + 3] = 0;
                }
            }

            System.Runtime.InteropServices.Marshal.Copy(pixels1, 0, ptr1, numBytes);
            bmp1.UnlockBits(bmpData1);
            bmp2.UnlockBits(bmpData2);
        }
Пример #14
0
    /// <summary>
    /// Returns the position closest to the given position such that this
    /// form will be completely on the screen.  E.g., if the form would be
    /// cropped off the right side of the screen, the returned point would
    /// have the same Y position and a lesser X position such that the right
    /// side of the form would be flush with the right side of the screen if
    /// it were placed at the given position.
    /// </summary>
    private Point CorrectPosition(Point position) {
      Point newPosition = new Point(position.X, position.Y);

      // Figure out the bounds of all screens (we just round if the monitors
      // happen to be different sizes).
      Rectangle screenBounds = Screen.FromControl(this).WorkingArea;
      int left = screenBounds.Left;
      int top = screenBounds.Top;
      int right = screenBounds.Right;
      int bottom = screenBounds.Bottom;
      foreach (Screen screen in Screen.AllScreens) {
        left = Math.Min(screen.WorkingArea.Left, left);
        top = Math.Min(screen.WorkingArea.Top, top);
        right = Math.Max(screen.WorkingArea.Right, right);
        bottom = Math.Max(screen.WorkingArea.Bottom, bottom);
      }
      Rectangle workingBounds = new Rectangle(left, top, right - left, bottom - top);

      Rectangle formBounds = this.Bounds;
      if (newPosition.X < workingBounds.Left) {
        newPosition.X = workingBounds.Left;
      } else if (newPosition.X + formBounds.Width > workingBounds.Right) {
        newPosition.X = workingBounds.Right - formBounds.Width;
      }
      if (newPosition.Y < workingBounds.Top) {
        newPosition.Y = workingBounds.Top;
      } else if (newPosition.Y + formBounds.Height > workingBounds.Bottom) {
        newPosition.Y = workingBounds.Bottom - formBounds.Height;
      }
      return newPosition;
    }
Пример #15
0
		private Rectangle GetThemedRect(Rectangle r)
		{
			const int offset=6;

			switch(m_Tab.Parent.TabAlignment)
			{
				case eTabStripAlignment.Top:
				{
					r.Y-=offset;
					r.Height+=offset;
					break;
				}
				case eTabStripAlignment.Left:
				{
					r.X-=offset;
					r.Width+=offset;
					break;
				}
				case eTabStripAlignment.Right:
				{
					r.Width+=offset;
					break;
				}
				case eTabStripAlignment.Bottom:
				{
					r.Height+=offset;
					break;
				}
					
			}
			return r;
		}
Пример #16
0
 public PortLinkGlyph(string id, Rectangle bounds)
     : base(id)
 {
     _From = bounds.Location;
     _To = new Point (bounds.X + bounds.Width, bounds.Y + bounds.Height);
     BuildContactPoints ();
 }
		protected override void OnMouseDown(MouseEventArgs e)
		{
			// get the index of the clicked item
			_rowIndexFromMouseDown = HitTest(e.X, e.Y).RowIndex;

			// basic mouse handling has right clicks show context menu without changing selection, so we handle it manually here
			if (e.Button == MouseButtons.Right)
				HandleRightMouseDown(e);

			// call the base class, so that the row gets selected, etc.
			base.OnMouseDown(e);

			if (_rowIndexFromMouseDown > -1)
			{
				// Remember the point where the mouse down occurred. 
				// The DragSize indicates the size that the mouse can move 
				// before a drag event should be started.                
				Size dragSize = SystemInformation.DragSize;

				// Create a rectangle using the DragSize, with the mouse position being
				// at the center of the rectangle.
				_dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width/2), e.Y - (dragSize.Height/2)), dragSize);
			}
			else
			{
				// Reset the rectangle if the mouse is not over an item in the ListBox.
				_dragBoxFromMouseDown = Rectangle.Empty;
			}
		}
Пример #18
0
        public static Rectangle AdaptProportionalRect(
            Rectangle rectMax,
            int nRealWidth,
            int nRealHeight,
            bool fillOut)
        {
            int nWidth;
            int nHeight;

            if (rectMax.Width < 1 || rectMax.Height < 1 || nRealHeight < 1 || nRealHeight < 1)
                return Rectangle.Empty;

            var sMaxRatio = (decimal)rectMax.Width / rectMax.Height;
            var sRealRatio = (decimal)nRealWidth / nRealHeight;

            if ((sMaxRatio < sRealRatio) ^ fillOut)
            {
                nWidth = Math.Min(rectMax.Width, nRealWidth);
                nHeight = (int)(nWidth / sRealRatio);
            }
            else
            {
                nHeight = Math.Min(rectMax.Height, nRealHeight);
                nWidth = (int)(nHeight * sRealRatio);
            }

            return new Rectangle(
                rectMax.X + (rectMax.Width - nWidth) / 2,
                rectMax.Y + (rectMax.Height - nHeight) / 2,
                nWidth,
                nHeight);
        }
Пример #19
0
        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
        {
            if (appointment == null)
                throw new ArgumentNullException("appointment");

            if (g == null)
                throw new ArgumentNullException("g");

            if (rect.Width != 0 && rect.Height != 0)
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    if ((appointment.Locked) && isSelected)
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }
                    else
                    {
                        // Draw back
                        using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }

                    if (isSelected)
                    {
                        using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                            g.DrawRectangle(m_Pen, rect);

                        Rectangle m_BorderRectangle = rect;

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper
                        gripRect.Width += 1;

                        using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                            g.FillRectangle(m_Brush, gripRect);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, rect);
                    }

                    rect.X += gripRect.Width;
                    g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
                }
        }
Пример #20
0
 private void CalcFinalSizes()
 {
     Size textSize = GetTextSize();
     var width = 2 * SPACING + textSize.Width;
     var height = 2 * SPACING + textSize.Height + 6;
     if (width > MAX_SIZE.Width)
     {
         width = MAX_SIZE.Width;
     }
     else if (width < MIN_SIZE.Width)
     {
         width = MIN_SIZE.Width;
     }
     if (height > MAX_SIZE.Height)
     {
         height = MAX_SIZE.Height;
     }
     else if (height < MIN_SIZE.Height)
     {
         height = MIN_SIZE.Height;
     }
     this.Size = new Size(width, height);
     var textWidth = Math.Min(this.Width - 2 * SPACING, textSize.Width);
     var textHeight = Math.Min(this.Height - 2 * SPACING, textSize.Height);
     var textLeft = (this.Width - textWidth) / 2;
     var textTop = (this.Height - textHeight - 6) / 2;
     this.textRect = new Rectangle(textLeft, textTop, textWidth, textHeight);
 }
Пример #21
0
        protected override void OnDrawItem( DrawItemEventArgs e )
        {
            base.OnDrawItem( e );

            if ( e.Index != -1 )
            {
                object item = Items[e.Index];
                e.DrawBackground();
                e.DrawFocusRectangle();

                bool separator = item is SeparatorItem;

                Rectangle bounds = e.Bounds;
                bool drawSeparator = separator && ( e.State & DrawItemState.ComboBoxEdit ) != DrawItemState.ComboBoxEdit;
                if ( drawSeparator )
                {
                    bounds.Height -= separatorHeight;
                }

                TextRenderer.DrawText( e.Graphics, GetDisplayText( e.Index ), Font, bounds, e.ForeColor, e.BackColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter );

                if ( drawSeparator )
                {
                    Rectangle sepRect = new Rectangle( e.Bounds.Left, e.Bounds.Bottom - separatorHeight, e.Bounds.Width, separatorHeight );
                    using ( Brush b = new SolidBrush( BackColor ) )
                    {
                        e.Graphics.FillRectangle( b, sepRect );
                    }
                    e.Graphics.DrawLine( SystemPens.ControlText, sepRect.Left + 2, sepRect.Top + 1, sepRect.Right - 2, sepRect.Top + 1 );
                }
            }
        }
Пример #22
0
        protected override void Edit(CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly,	string instantText, bool cellIsVisible)
        {
            if (isEditing)
                return;

            if (cellIsVisible)
            {
                mSel.Bounds = new Rectangle(bounds.X + 2, bounds.Y + 2, bounds.Width, bounds.Height);
                mSel.Visible = true;
                mSel.OnControlChanged += new EventHandler(OpenDateValueChanged);
                object value = base.GetColumnValueAtRow( source, rowNum );
                if ( value == null )
                    mSel.pSelectedItem = new PlaceCode(0, 0);
                else
                    mSel.pSelectedItem = PlaceCode.PDC2PlaceCode(value.ToString());
                value = this.GetColumnValueAtRow( source, rowNum );
                if ( value == null )
                    mSel.pText = string.Empty;
                else
                    mSel.pText = value.ToString();
            }
            else
            {
                mSel.Visible = false;
            }

            if (mSel.Visible)
            {
                isEditing = true;
                base.ColumnStartedEditing(mSel);
                DataGridTableStyle.DataGrid.Invalidate(bounds);
            }
        }
Пример #23
0
        public static GraphicsPath GetRoundedCornerTab(GraphicsPath graphicsPath, Rectangle rect, bool upCorner)
        {
            if (graphicsPath == null)
                graphicsPath = new GraphicsPath();
            else
                graphicsPath.Reset();
            
            int curveSize = 6;
            if (upCorner)
            {
                graphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top + curveSize / 2);
                graphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90);
                graphicsPath.AddLine(rect.Left + curveSize / 2, rect.Top, rect.Right - curveSize / 2, rect.Top);
                graphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Top, curveSize, curveSize), -90, 90);
                graphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, rect.Bottom);
            }
            else
            {
                graphicsPath.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom - curveSize / 2);
                graphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Bottom - curveSize, curveSize, curveSize), 0, 90);
                graphicsPath.AddLine(rect.Right - curveSize / 2, rect.Bottom, rect.Left + curveSize / 2, rect.Bottom);
                graphicsPath.AddArc(new Rectangle(rect.Left, rect.Bottom - curveSize, curveSize, curveSize), 90, 90);
                graphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, rect.Top);
            }

            return graphicsPath;
        }
 private static Point RandomPoint(Random rng, Rectangle bounds)
 {
     return new Point(
         rng.Next(bounds.Left, bounds.Right),
         rng.Next(bounds.Top, bounds.Bottom)
     );
 }
Пример #25
0
        public unsafe Point GetNextPoint(Rectangle rectTrack, byte* pIn, Size sizeIn, double[] Qu, double[] PuY0)
        {
            double[] w = new double[256];//方向权值
            for (int i = 0; i < 256; i++)
            {
                w[i] = Math.Sqrt(Qu[i] / PuY0[i]);
            }

            PointF center = new PointF(
                (float)rectTrack.Left + (float)rectTrack.Width / 2,
                (float)rectTrack.Top + (float)rectTrack.Height / 2);
            SizeF H = new SizeF((float)rectTrack.Width / 2, (float)rectTrack.Height / 2);
            double numeratorX = 0, numeratorY = 0;//分子
            double denominatorX = 0, denominatorY = 0;//分母
            for (int y = rectTrack.Top; y < rectTrack.Bottom; y++)
            {
                for (int x = rectTrack.Left; x < rectTrack.Right; x++)
                {
                    int index = DataManager.GetIndex(x, y, sizeIn.Width);
                    byte u = pIn[index];
                    //计算以高斯分布为核函数自变量X的值
                    double X = ((Math.Pow((x - center.X), 2) + Math.Pow((y - center.Y), 2))
                            / (Math.Pow(H.Width, 2) + Math.Pow(H.Height, 2)));
                    //负的高斯分布核函数的值
                    double Gi = -Math.Exp(-Math.Pow(X, 2) / 2) / Math.Sqrt(2 * Math.PI);

                    numeratorX += x * w[u] * Gi;
                    numeratorY += y * w[u] * Gi;
                    denominatorX += w[u] * Gi;
                    denominatorY += w[u] * Gi;
                }
            }
            return new Point((int)(numeratorX / denominatorX), (int)(numeratorY / denominatorY));
        }
 public ToolStripItemGlyph(ToolStripItem item, ToolStripItemDesigner itemDesigner, Rectangle bounds, System.Windows.Forms.Design.Behavior.Behavior b)
     : base(bounds, Cursors.Default, item, b)
 {
     this._item = item;
     this._bounds = bounds;
     this._itemDesigner = itemDesigner;
 }
Пример #27
0
 //This constructor is passed the bounds this form is to show in
 //It is used when in normal mode
 public MainForm(Rectangle Bounds)
 {
     InitializeComponent();
         this.Bounds = Bounds;
         //hide the cursor
         Cursor.Hide();
 }
Пример #28
0
		/// <summary></summary>
		/// <param name="box"></param>
		/// <param name="g"></param>
		protected override void PaintThisProgress(Rectangle box, Graphics g) {
			try {
				box.Width -= 1;
				box.Height -= 1;
			} catch {}
			if (box.Width <= 1) {
				return;
			}

			g.FillRectangle(brush, box);
			Rectangle innerBox = box;
			innerBox.Inflate(-1, -1);
			g.DrawRectangle(inner, innerBox);
			g.DrawLine(outer, box.X, box.Y, box.Right, box.Y);
			g.DrawLine(outer, box.X, box.Y, box.X, box.Bottom);
			g.DrawLine(edge, box.X, box.Bottom, box.Right, box.Bottom);

			if (gloss != null) {
				gloss.PaintGloss(box, g);
			}

			if (showEdge) {
				g.DrawLine(edge, box.Right, box.Y, box.Right, box.Bottom);
			}
		}
Пример #29
0
        public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
        {
            Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

            if (applyRect.Width == 0 || applyRect.Height == 0)
            {
                // nothing to do
                return;
            }
            GraphicsState state = graphics.Save();
            if (Invert)
            {
                graphics.SetClip(applyRect);
                graphics.ExcludeClip(rect);
            }
            ColorMatrix grayscaleMatrix = new ColorMatrix(new[] {
                new[] {.3f, .3f, .3f, 0, 0},
                new[] {.59f, .59f, .59f, 0, 0},
                new[] {.11f, .11f, .11f, 0, 0},
                new float[] {0, 0, 0, 1, 0},
                new float[] {0, 0, 0, 0, 1}
            });
            using (ImageAttributes ia = new ImageAttributes())
            {
                ia.SetColorMatrix(grayscaleMatrix);
                graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
            }
            graphics.Restore(state);
        }
        // 描画
        private unsafe void xnDraw()
        {
            // カメライメージの更新を待ち、画像データを取得する
              context.WaitOneUpdateAll(image);
              ImageMetaData imageMD = image.GetMetaData();

              // カメラ画像の作成
              lock (this) {
            // 書き込み用のビットマップデータを作成
            Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
            BitmapData data = bitmap.LockBits(rect, ImageLockMode.WriteOnly,
                        System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            // 生データへのポインタを取得
            byte* dst = (byte*)data.Scan0.ToPointer();
            byte* src = (byte*)image.ImageMapPtr.ToPointer();

            for (int i = 0; i < imageMD.DataSize; i += 3, src += 3, dst += 3) {
              dst[0] = src[2];
              dst[1] = src[1];
              dst[2] = src[0];
            }

            bitmap.UnlockBits(data);
              }

              // 現在の状態を表示する
              Graphics g = Graphics.FromImage(bitmap);
              string message = "Gesture:" + gestures[gestureIndex] +
                      ", Status:" + gestureStatus.ToString() + "\n";
              g.DrawString(message, font, brush, point);
        }