Offset() public method

Adjusts the location of this rectangle by the specified amount.

public Offset ( Point pos ) : void
pos Point
return void
Example #1
0
		private void PenAlignment_Paint(object sender, PaintEventArgs e)
		{
			// Example of border problem.
			//Rectangle rect = new Rectangle(10, 10, 110, 110);
			//Pen pen = new Pen(Color.Red, 1);
			//Brush brush = Brushes.LightBlue;
			//e.Graphics.DrawRectangle(pen, rect);
			//e.Graphics.FillRectangle(brush, rect);

			
			Rectangle rect = new Rectangle(10, 10, 110, 110);
			Pen pen = new Pen(Color.White, 11);
			Pen penOutline = new Pen(Color.Black, 1);
			penOutline.Alignment = PenAlignment.Inset;
			pen.Alignment = PenAlignment.Center;
			e.Graphics.DrawString("11-Pixel Centered Pen", SystemFonts.DefaultFont, Brushes.Black, rect.Location);
			rect.Offset(0, 25);
			e.Graphics.FillRectangle(Brushes.LightBlue, rect);
			e.Graphics.DrawRectangle(pen, rect);
			e.Graphics.DrawRectangle(penOutline, rect);
			
			rect.Offset(150, -25);
			e.Graphics.DrawString("11-Pixel Inset Pen", SystemFonts.DefaultFont, Brushes.Black, rect.Location);
			rect.Offset(0, 25);
			pen.Alignment = PenAlignment.Inset;
			e.Graphics.FillRectangle(Brushes.LightBlue, rect);
			e.Graphics.DrawRectangle(pen, rect);
			e.Graphics.DrawRectangle(penOutline, rect);
			
			
			pen.Dispose();
		}
        protected void PaintTransparentBackground(Graphics g, Rectangle clipRect) {
            // check if we have a parent
            if (this.Parent != null) {
                // convert the clipRects coordinates from ours to our parents
                clipRect.Offset(this.Location);

                PaintEventArgs e = new PaintEventArgs(g, clipRect);
                GraphicsState state = g.Save();

                try {
                    // move the graphics object so that we are drawing in
                    // the correct place
                    g.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);

                    // draw the parents background and foreground
                    this.InvokePaintBackground(this.Parent, e);
                    this.InvokePaint(this.Parent, e);

                    return;
                } finally {
                    // reset everything back to where they were before
                    g.Restore(state);
                    clipRect.Offset(-this.Location.X, -this.Location.Y);
                }
            }

            // we don't have a parent, so fill the rect with
            // the default control color
            g.FillRectangle(SystemBrushes.Control, clipRect);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            float factor1 = isHover ? 0.40f : 0.20f;
            float factor2 = isHover ? 0.85f : 0.65f;

            Brush brush1 = new SolidBrush(ColorMagic.GetIntermediateColor(ColorBack, ColorFore, factor1));
            Brush brush2 = new SolidBrush(ColorMagic.GetIntermediateColor(ColorBack, ColorFore, factor2));

            var outside = new Rectangle(1, 3, 14, 3);
            var inside = new Rectangle(2, 4, 12, 1);
            var offset = new Point(0, 4);

            g.FillRectangle(brush1, outside);
            g.FillRectangle(brush2, inside);

            outside.Offset(offset);
            inside.Offset(offset);

            g.FillRectangle(brush1, outside);
            g.FillRectangle(brush2, inside);

            outside.Offset(offset);
            inside.Offset(offset);

            g.FillRectangle(brush1, outside);
            g.FillRectangle(brush2, inside);
        }
 private void pictureBox1_Paint(object sender, PaintEventArgs e)
 {
     Color[] cols = null;
     try
     {
         if (pal != null)
             cols = pal.getPal(checkBox1.Checked, checkBox2.Checked, checkBox3.Checked);
         e.Graphics.FillRectangle(new SolidBrush(Color.Black), e.ClipRectangle);
         int minrect = e.ClipRectangle.Width / 16;
         if (e.ClipRectangle.Height / 16 < minrect)
             minrect = e.ClipRectangle.Height / 16;
         Rectangle rct = new Rectangle(0, 0, minrect, minrect);
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 Color c = pal == null ? Color.Black : cols[i * 16 + j];
                 e.Graphics.FillRectangle(new SolidBrush(c), rct);
                 rct.Offset(minrect, 0);
             }
             rct.Offset(-rct.X, minrect);
         }
     }
     catch (Exception ex)
     {
         MainForm.clearResource(ex);
     }
 }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            Bitmap image = new Bitmap("apple.jpg");                 //加载图像
            ImageProcessing.GreyImage(image);                       //生成灰度图像
            Rectangle rectImage = new Rectangle(new Point(), image.Size);
            G.DrawImage(image, rectImage);

            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.ExtractEdge(image);                     //提取边缘
            G.DrawImage(image, rectImage);

            rectImage.Offset(-rectImage.Width, rectImage.Height);
            Bitmap image2 = image.Clone() as Bitmap;
            ImageProcessing.BinaryImage(image2, 0, 20, 255);        //在灰度20到255的范围提取边界
            G.DrawImage(image2, rectImage);

            image2.Dispose();

            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.BinaryImage(image, 0, 40, 255);         //在灰度40到255的范围提取边界
            G.DrawImage(image, rectImage);

            image.Dispose();
        }
Example #6
0
        public void Render(Graphics gfx)
        {
            gfx.Clear(Form1.DefaultBackColor);

            Pen myPen = new Pen(Color.RoyalBlue, 2);
            Rectangle rect = new Rectangle(0, 0, 50, 50);
            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    gfx.DrawRectangle(myPen, rect);
                    rect.Offset(0, 50);
                }

                rect.Offset(50, 0);
            }

            Point cp;
            foreach (ConsumerHolder ch in m_consumers)
            {
                cp = ch.GetPosition();
                cp.X *= 50;
                cp.Y *= 50;

                // Offset to match the center of the grid spot.
                cp.Offset(-25, -25);

                // Factor in the size of the object.
                cp.Offset(-1 * (ch.Strength / 2), -1 * (ch.Strength / 2));

                Pen pen = new Pen(Color.DarkRed, 2);
                Rectangle cr = new Rectangle(cp, new Size(ch.Strength, ch.Strength));
                gfx.DrawEllipse(pen, cr);
            }

            Point rp;
            foreach (IResource res in m_resources)
            {
                rp = res.Position();
                rp.X *= 50;
                rp.Y *= 50;

                // Offset to match the center of the grid spot.
                rp.Offset(-25, -25);

                Pen pen = null;
                if (res.IsConsumed())
                {
                    pen = new Pen(Color.Gray, 2);
                }
                else
                {
                    pen = new Pen(Color.Tomato, 2);
                }
                Rectangle cr = new Rectangle(rp, new Size(5, 5));
                gfx.DrawRectangle(pen, cr);
            }
        }
        public bool Contains(Point p)
        {
            Rectangle draw_rect = new Rectangle(Position.Location, new Size(4, 4));
            draw_rect.Offset(-2, -2);

            return draw_rect.Contains(p);
        }
Example #8
0
        private MultiScreenInfo()
        {
            allScreen = Rectangle.Empty;
            foreach (var scr in Screen.AllScreens)
            {
                allScreen = Rectangle.Union(allScreen, scr.Bounds);
            }

            allScreenOffset = new Point(-allScreen.Left, -allScreen.Top);

            allScreenOffsetted = allScreen;
            allScreenOffsetted.Offset(allScreenOffset);

            List<SingleScreenInfo> lstScrs = new List<SingleScreenInfo>();
            foreach (var scr in Screen.AllScreens)
            {
                lstScrs.Add(new SingleScreenInfo(scr, allScreenOffset));
            }
            scrs = lstScrs.ToArray();

            var toStr = this.ToString();
            var s = Settings.Instance;
            if (toStr != s.ScreensRects)
            {
                s.ScreensRects = toStr;

                IsChanged = true;
            }
            else
            {
                IsChanged = false;
            }
        }
        public Image DoStitch()
        {
            Image1 = Image.FromFile(_imageFile1.FullName);
            Image2 = Image.FromFile(_imageFile2.FullName);

            var outputWidth = OutputWidth();
            var outputHeight = OutputHeight();

            OutputImage = new Bitmap(outputWidth, outputHeight, PixelFormat.Format24bppRgb);
            OutputImage.SetResolution(Image1.HorizontalResolution, Image1.VerticalResolution);

            var graphics = Graphics.FromImage(OutputImage);

            var positionImage1 = new Rectangle(0, 0, Image1.Width, Image1.Height);
            var positionImage2 = new Rectangle(Image1.Width, 0, Image2.Width, Image2.Height);

            if (!Border.Inside)
            {
                positionImage1.Offset(Border.ThicknessLeft, Border.ThicknessTop);
                positionImage2.Offset(2 * Border.ThicknessLeft, Border.ThicknessTop);
            }

            graphics.DrawImage(Image1, positionImage1);
            graphics.DrawImage(Image2, positionImage2);

            Border.Draw(graphics, positionImage1);
            Border.Draw(graphics, positionImage2);

            return OutputImage;
        }
Example #10
0
        public void CenterRectangleRelativeTo(Rectangle destRectangle, ref Rectangle srcRectangle)
        {
            int x = destRectangle.X + (destRectangle.Width - srcRectangle.Width) / 2;
            int y = destRectangle.Y + (destRectangle.Height - srcRectangle.Height) / 2;

            srcRectangle.Offset(x, y);
        }
Example #11
0
      public Form1()
      {
         // initialize it to null
         this.streamWriter = null;
         this.latestFileName = "";

         InitializeComponent();

         // initialize flags
         editingText = false;
         pathSelected = false;
         writeToFile = false;

         // set location of the connectionStatusRectangle
         this.connectionStatusRectangle = new Rectangle(this.connectionStatusLabel.Location, new Size(10, 10));
         connectionStatusRectangle.Offset(45, 0);

         // set color of connectionStatusPen to be Red since by default disconnected
         this.connectionStatusPen = new Pen(Color.Red, 10);
         
         // populate port selection box
         foreach (var port in SerialPort.GetPortNames())
         {
            portComboBox.Items.Add(port);
         }

         // setup bluetooth connection
         bluetooth = new SerialPort("COM", 115200, Parity.None, 8, StopBits.One);
         
         this.DrawConnectionStatus();
      }
 /// <summary>
 ///     Перегружаемый метод прорисовки
 /// </summary>
 protected override void DrawItemCore(ControlGraphicsInfoArgs info, BaseListBoxViewInfo.ItemInfo itemInfo, ListBoxDrawItemEventArgs e)
 {
     base.DrawItemCore(info, itemInfo, e);
     var customInfo = itemInfo as CustomCheckedListBoxViewInfo.CustomCheckedItemInfo;
     if (customInfo == null)
     {
         return;
     }
     var rec = new Rectangle(itemInfo.Bounds.Location, new Size(itemInfo.Bounds.Width, LineWidth));
     var lineColor = ((CustomCheckedListBoxViewInfo) info.ViewInfo).DragDropLineColor;
     if (itemInfo.Index == 0)
     {
         var font = new Font(itemInfo.PaintAppearance.Font.FontFamily, itemInfo.PaintAppearance.Font.Size, FontStyle.Bold);
         info.Graphics.FillRectangle(Brushes.Lavender, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
         e.Graphics.DrawString(itemInfo.Text, font, Brushes.Black, e.Bounds.X, e.Bounds.Y + 2);
     }
     if (customInfo.IsOverLine)
     {
         if (customInfo.Index == 0)
         {
             rec.Height++;
         }
         info.Graphics.FillRectangle(info.Cache.GetSolidBrush(lineColor), rec);
     }
     if (!customInfo.IsUnderLine)
     {
         return;
     }
     rec.Offset(0, itemInfo.Bounds.Height - LineWidth);
     if (customInfo.Index == ((CustomCheckedListBoxViewInfo) info.ViewInfo).ItemCountAccessMethod() - 1)
     {
         rec.Height++;
     }
     info.Graphics.FillRectangle(info.Cache.GetSolidBrush(lineColor), rec);
 }
Example #13
0
        private void lbxNotes_DrawItem(object sender, DrawItemEventArgs e)
        {
            Note currNote;
            if (e.Index >= 0)
            {
                e.DrawBackground();

                Rectangle timeRectangle = new Rectangle(e.Bounds.Location, new Size(lbxNotes.Width, 16));
                timeRectangle.Offset(0, 2);
                Rectangle messageRectangle = new Rectangle(timeRectangle.Location, timeRectangle.Size);
                messageRectangle.Offset(0, 10);
                messageRectangle.Height = 34;

                currNote = (Note)lbxNotes.Items[e.Index];

                Font timeFont = new Font("Serif", (float)8.0);
                e.Graphics.DrawString(currNote.StartTime.ToLongTimeString(), timeFont, Brushes.DimGray,
                    timeRectangle, StringFormat.GenericDefault);

                Font messageFont = new Font("Serif", (float)16.0);
                e.Graphics.DrawString(currNote.Message.ToString(), messageFont,
                    (currNote.Status == Note.NoteStatus.Completed) ? Brushes.Green : Brushes.Black,
                    messageRectangle, StringFormat.GenericDefault);

                e.DrawFocusRectangle();
            }
        }
Example #14
0
 protected virtual void DrawButton(Graphics g, Rectangle buttonRect)
 {
     this.BuildGraphicsPath(buttonRect);
     PathGradientBrush brush = new PathGradientBrush(this.bpath);
     brush.SurroundColors = new Color[] { this.buttonColor };
     buttonRect.Offset(this.buttonPressOffset, this.buttonPressOffset);
     if (this.bevelHeight > 0)
     {
         buttonRect.Inflate(1, 1);
         brush.CenterPoint = new PointF((float) ((buttonRect.X + (buttonRect.Width / 8)) + this.buttonPressOffset), (float) ((buttonRect.Y + (buttonRect.Height / 8)) + this.buttonPressOffset));
         brush.CenterColor = this.cColor;
         this.FillShape(g, brush, buttonRect);
         this.ShrinkShape(ref g, ref buttonRect, this.bevelHeight);
     }
     if (this.bevelDepth > 0)
     {
         this.DrawInnerBevel(g, buttonRect, this.bevelDepth, this.buttonColor);
         this.ShrinkShape(ref g, ref buttonRect, this.bevelDepth);
     }
     brush.CenterColor = this.buttonColor;
     if (this.dome)
     {
         brush.CenterColor = this.cColor;
         brush.CenterPoint = new PointF((float) ((buttonRect.X + (buttonRect.Width / 8)) + this.buttonPressOffset), (float) ((buttonRect.Y + (buttonRect.Height / 8)) + this.buttonPressOffset));
     }
     this.FillShape(g, brush, buttonRect);
     if (this.gotFocus)
     {
         this.DrawFocus(g, buttonRect);
     }
 }
Example #15
0
        public void TestBGModel()
        {
            int width = 300;
             int height = 400;
             Image<Bgr, Byte> bg = new Image<Bgr, byte>(width, height);
             bg.SetRandNormal(new MCvScalar(), new MCvScalar(100, 100, 100));

             Size size = new Size(width / 10, height / 10);
             Point topLeft = new Point((width >> 1) - (size.Width >> 1), (height >> 1) - (size.Height >> 1));

             Rectangle rect = new Rectangle(topLeft, size);

             Image<Bgr, Byte> img1 = bg.Copy();
             img1.Draw(rect, new Bgr(Color.Red), -1);

             Image<Bgr, Byte> img2 = bg.Copy();
             rect.Offset(10, 0);
             img2.Draw(rect, new Bgr(Color.Red), -1);

             BGStatModel<Bgr> model1 = new BGStatModel<Bgr>(img1, Emgu.CV.CvEnum.BG_STAT_TYPE.GAUSSIAN_BG_MODEL);
             model1.Update(img2);

             BGStatModel<Bgr> model2 = new BGStatModel<Bgr>(img1, Emgu.CV.CvEnum.BG_STAT_TYPE.FGD_STAT_MODEL);
             model2.Update(img2);

             //ImageViewer.Show(model2.Foreground);
             //ImageViewer.Show(model1.Background);
        }
Example #16
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index < 0 || e.Index >= Items.Count) return;

            var item = (Item)this.Items[e.Index];

            var image = item.Title;

            var drawWidth = (int)(image.Width * scalingFactor);
            var drawHeight = (int)(image.Height * scalingFactor);

            var destRect = new Rectangle(e.Bounds.Location,
                new Size(drawWidth, drawHeight));

            // we need to manually add xMargin to the offset again, as it's
            // already subtracted from the actual list width in GetListWidth
            destRect.Offset((GetListWidth() - drawWidth + xMargin) / 2, yMargin);

            // background
            e.Graphics.FillRectangle(Brushes.Black, e.Bounds);

            // separator
            if (e.Index > 0)
            {
                e.Graphics.DrawLine(Pens.DimGray,
                    e.Bounds.Left + 5, e.Bounds.Top + 1,
                    e.Bounds.Right - 5, e.Bounds.Top + 1);

                destRect.Offset(0, 3);
            }

            // title
            e.Graphics.DrawImage(image, destRect,
                new Rectangle(new Point(), image.Size), GraphicsUnit.Pixel);
        }
Example #17
0
		private static void DrawContent(Graphics g, Rectangle rect, string title, string body)
		{
			if (!string.IsNullOrEmpty(title))
			{
				using (Font titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, FontStyle.Bold))
				{
					g.DrawString(title, titleFont, Brushes.Black, rect);

					//Update the rect to position the body text.
					SizeF titleSize = g.MeasureString(title, titleFont, rect.Width);
					int titleHeight = (int)titleSize.Height + 1;
					rect.Offset(0, titleHeight);
					rect.Height -= titleHeight;
				}
			}

			if (!string.IsNullOrEmpty(body))
			{
				using (Font bodyFont = new Font(FontFamily.GenericSerif, 12.0f, FontStyle.Regular))
				{
					rect.Inflate(-2, 0);
					g.DrawString(body, bodyFont, Brushes.Black, rect);
				}
			}
		}
Example #18
0
		private void DrawContent(Graphics graphics, Rectangle rect)
		{
			using (LinearGradientBrush brush = new LinearGradientBrush(new Point(0, 0),
				new Point(rect.Width, rect.Height), Color.White, Color.LightGreen))
			{
				graphics.FillRectangle(brush, rect);
			}

			if (!string.IsNullOrEmpty(_title))
			{
				using (Font titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, FontStyle.Bold))
				{
					graphics.DrawString(_title, titleFont, Brushes.Black, rect);

					// Update the rect to position the body text
					SizeF titleSize = graphics.MeasureString(_title, titleFont, rect.Width);
					int titleHeight = (int)titleSize.Height + 1;
					rect.Offset(0, titleHeight);
					rect.Height -= titleHeight;
				}
			}

			if (!string.IsNullOrEmpty(_description))
			{
				using (Font bodyFont = new Font(FontFamily.GenericSerif, 12.0f, FontStyle.Regular))
				{
					rect.Inflate(-2, 0);
					graphics.DrawString(_description, bodyFont, Brushes.Black, rect);
				}
			}
		}
 protected override void OnRenderGrip(ToolStripGripRenderEventArgs e)
 {
     if (renderer is ToolStripProfessionalRenderer)
     {
         if (e.GripStyle == ToolStripGripStyle.Hidden) return;
         using (Brush lightBrush = new SolidBrush(this.colorTable.GripLight))
         {
             Rectangle r = new Rectangle(e.GripBounds.Left, e.GripBounds.Top + 6, 2, 2);
             for (Int32 i = 0; i < e.GripBounds.Height - 11; i += 4)
             {
                 e.Graphics.FillRectangle(lightBrush, r);
                 r.Offset(0, 4);
             }
         }
         using (Brush darkBrush = new SolidBrush(this.colorTable.GripDark))
         {
             Rectangle r = new Rectangle(e.GripBounds.Left - 1, e.GripBounds.Top + 5, 2, 2);
             for (Int32 i = 0; i < e.GripBounds.Height - 11; i += 4)
             {
                 e.Graphics.FillRectangle(darkBrush, r);
                 r.Offset(0, 4);
             }
         }
     }
     else renderer.DrawGrip(e);
 }
Example #20
0
        public override void Draw(Graphics g)
        {
            System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
             rect.Offset(Offset.X, Offset.Y);

             using(GraphicsPath objGP = new GraphicsPath())
             {
            objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
            objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);

            objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
            objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
            objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
            objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
            objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner

            objGP.CloseFigure();

            g.FillPath(Fill, objGP);
            g.DrawPath(Stroke, objGP);
             }

            #if !PocketPC
             g.DrawString(Marker.ToolTipText, Font, Brushes.Navy, rect, Format);
            #else
             g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
            #endif
        }
Example #21
0
        public ScreenRegionForm(Rectangle regionRectangle, bool activateWindow = true)
        {
            InitializeComponent();

            this.activateWindow = activateWindow;

            borderRectangle = regionRectangle.Offset(1);
            borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);

            Location = borderRectangle.Location;
            int windowWidth = Math.Max(borderRectangle.Width, pInfo.Width);
            Size = new Size(windowWidth, borderRectangle.Height + pInfo.Height + 1);
            pInfo.Location = new Point(0, borderRectangle.Height + 1);

            Region region = new Region(ClientRectangle);
            region.Exclude(borderRectangle0Based.Offset(-1));
            region.Exclude(new Rectangle(0, borderRectangle.Height, windowWidth, 1));
            if (borderRectangle.Width < pInfo.Width)
            {
                region.Exclude(new Rectangle(borderRectangle.Width, 0, pInfo.Width - borderRectangle.Width, borderRectangle.Height));
            }
            else if (borderRectangle.Width > pInfo.Width)
            {
                region.Exclude(new Rectangle(pInfo.Width, borderRectangle.Height + 1, borderRectangle.Width - pInfo.Width, pInfo.Height));
            }
            Region = region;

            Timer = new Stopwatch();
        }
Example #22
0
		protected internal override void DrawDocumentStripButton(Graphics graphics, Rectangle bounds, SandDockButtonType buttonType, DrawItemState state)
		{
			vmethod_0(graphics, bounds, state);
			if ((state & DrawItemState.Selected) == DrawItemState.Selected)
			{
				bounds.Offset(1, 1);
			}
			switch (buttonType)
			{
			case SandDockButtonType.Close:
				using (var pen = new Pen(color_6))
				{
					ButtonRenderHelper.DrawDocumentStripCloseButton(graphics, bounds, pen);
					return;
				}
			    case SandDockButtonType.Pin:
			case SandDockButtonType.WindowPosition:
				return;
			case SandDockButtonType.ScrollLeft:
				break;
			case SandDockButtonType.ScrollRight:
				ButtonRenderHelper.DrawScrollRightDockButton(graphics, bounds, color_6, (state & DrawItemState.Disabled) != DrawItemState.Disabled);
				return;
			case SandDockButtonType.ActiveFiles:
				ButtonRenderHelper.DrawPositionDockButton(graphics, bounds, SystemPens.ControlText);
				return;
			default:
				return;
			}
			ButtonRenderHelper.DrawScrollLeftDockButton(graphics, bounds, color_6, (state & DrawItemState.Disabled) != DrawItemState.Disabled);
		}
Example #23
0
        //********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        /// <created>UPh,27.12.2007</created>
        /// <changed>UPh,27.12.2007</changed>
        //********************************************************************************
        internal static void MakeVisible(Form form)
        {
            Rectangle rcBounds;

            if (form.Parent != null)
            {
                rcBounds = form.Parent.ClientRectangle;
            }
            else
            {
                Screen screen = Screen.FromControl(form);
                if (screen == null)
                    screen = Screen.PrimaryScreen;
                if (screen == null)
                    return;

                rcBounds = screen.Bounds;
            }

            Rectangle rcNewWnd = new Rectangle(form.Left, form.Top, form.Width, form.Height);

            if (rcNewWnd.Right > rcBounds.Right)
                rcNewWnd.Offset(rcBounds.Right - rcNewWnd.Right, 0);
            if (rcNewWnd.Bottom > rcBounds.Bottom)
                rcNewWnd.Offset(0, rcBounds.Bottom - rcNewWnd.Bottom);
            if (rcNewWnd.Left < rcBounds.Left)
                rcNewWnd.Offset(rcBounds.Left - rcNewWnd.Left, 0);
            if (rcNewWnd.Top < rcBounds.Top)
                rcNewWnd.Offset(0, rcBounds.Top - rcNewWnd.Top);

            form.SetDesktopBounds(rcNewWnd.Left, rcNewWnd.Top, rcNewWnd.Width, rcNewWnd.Height);
        }
        protected unsafe override object[] OnDecode(byte* pIn, byte* pOut, Size sizeIn, Size sizeOut, params object[] state)
        {
            if (ticks++ % 100 == 0)
            {
                //特征区域
                rectFeature = new Rectangle(0, 0, sizeIn.Width, sizeIn.Height);
                rectFeature.Inflate(-50, -50);
                rectFeature.Offset(-50, -50);
                //提取全局随机正态分布特征点
                pointFeatures = DataManager.GetRandomPoint(rectFeature, 10000);
                //提取全局特征直方图
                rectFeature.Offset(50, 50);
                mouldFeature = DataManager.GetFeatureHistogram(rectFeature, pIn, sizeIn, pointFeatures);
                offSet = new Size();
            }
            else if (pointFeatures != null && mouldFeature != null)
            {
                Point pointMaxFeature = rectFeature.Location;
                //获取原始区域特征值
                byte[] particleMaxFeature = DataManager.GetFeatureHistogram(rectFeature, pIn, sizeIn, pointFeatures);
                //获取原始区域与模板的相似度
                double maxFeature = DataManager.GetSimilarFeature(mouldFeature, particleMaxFeature);

                //获取粒子
                pointParticles = DataManager.GetRandomPoint(new Rectangle(0, 0, 100, 100), 100);
                foreach (var particle in pointParticles)
                {
                    //获取粒子特征
                    byte[] particleFeature = DataManager.GetFeatureHistogram(
                        new Rectangle(particle, rectFeature.Size), pIn, sizeIn, pointFeatures);
                    //获取粒子特征与模板特征的相似度
                    double feature = DataManager.GetSimilarFeature(mouldFeature, particleFeature);
                    if (feature > maxFeature)
                    {
                        maxFeature = feature;
                        pointMaxFeature = particle;
                        particleMaxFeature = particleFeature;
                    }
                }
                pointMaxFeature.Offset(-50,-50);
                offSet = new Size(pointMaxFeature.X, pointMaxFeature.Y);
            }

            DataManager.OffSetImage(pIn, pOut, sizeIn, sizeOut, offSet.Width, offSet.Height);

            return new object[0];
        }
        public void Draw(PaintEventArgs e)
        {
            using( Brush VertexBrush = new SolidBrush(Color.Black) )
            {
                Rectangle draw_rect = new Rectangle( Position.Location, new Size(4, 4));
                draw_rect.Offset(-2, -2);

                e.Graphics.FillRectangle(VertexBrush, draw_rect);
            }
        }
Example #26
0
		protected override void CalculateLayout(RendererBase renderer, Rectangle bounds, bool floating, out Rectangle titlebarBounds, out Rectangle tabstripBounds, out Rectangle clientBounds, out Rectangle joinCatchmentBounds)
		{
			titlebarBounds = Rectangle.Empty;
			tabstripBounds = bounds;
			tabstripBounds.Height = renderer.DocumentTabStripSize;
			bounds.Offset(0, renderer.DocumentTabStripSize);
			bounds.Height -= renderer.DocumentTabStripSize;
			clientBounds = bounds;
			joinCatchmentBounds = tabstripBounds;
		}
Example #27
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            Rectangle rect = new Rectangle(0, 0, pictureBox1.Width - 1, pictureBox1.Height - 1);

            RibbonControl.FillRoundRectangle(e.Graphics, new LinearGradientBrush(e.ClipRectangle, this.startcolor, this.endcolor, LinearGradientMode.Horizontal), rect, 3f);

            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            e.Graphics.DrawString(Math.Round(this.value, 3).ToString(), this.label1.Font, new SolidBrush(Color.FromArgb(218, 226, 226)), rect, sf);

            if (this.hover)
            {
                float x = this.np ? (float)((this.value + 1.0) / 2.0) * rect.Width : (float)this.value * rect.Width;
                e.Graphics.DrawLine(new Pen(new LinearGradientBrush(e.ClipRectangle, Color.FromArgb(255, 255, 247), Color.FromArgb(210, 192, 141), LinearGradientMode.Vertical), 3f), x, 0, x, rect.Height);
            }
            else
            {
                float x = this.np ? (float)((this.value + 1.0) / 2.0) * rect.Width : (float)this.value * rect.Width;
                e.Graphics.DrawLine(new Pen(new LinearGradientBrush(e.ClipRectangle, Color.FromArgb(223, 183, 136), Color.FromArgb(171, 161, 140), LinearGradientMode.Vertical), 3f), x, 0, x, rect.Height);
            }

            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(172, 172, 172)), rect, 3f);

            rect.Offset(1, 1);
            rect.Width -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(96, 0, 0, 0)), rect, 3f);
            rect.Offset(1, 1);
            rect.Width -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(64, 0, 0, 0)), rect, 3f);
            rect.Offset(1, 1);
            rect.Width -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(32, 0, 0, 0)), rect, 3f);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            Bitmap image = new Bitmap("fruit.jpg");                 //加载图像
            Rectangle rectImage = new Rectangle(new Point(), image.Size);
            ImageProcessing.GreyImage(image);                       //将图像转换成灰度图像
            G.DrawImage(image, rectImage);
            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.BinaryImage(image, 0, 0, 250);          //将目标从背景中提取出来
            G.DrawImage(image, rectImage);
            rectImage.Offset(-rectImage.Width, rectImage.Height);
            ImageProcessing.MedianFilter(image);                    //利用中值滤波消除噪点
            G.DrawImage(image, rectImage);
            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.ConnectRegion(image);                   //对目标进行区域标记
            G.DrawImage(image, rectImage);
            image.Dispose();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;
            Bitmap image = new Bitmap("lena.jpg");                 //加载图像
            Rectangle rectImage = new Rectangle(new Point(), image.Size);
            G.DrawImage(image, rectImage);                          //绘制原始图像
            rectImage.Offset(rectImage.Width, 0);
            ImageProcessing.Dilation(image, 0.5f, 0.5f);            //对图像进行缩小处理
            G.DrawImage(image, rectImage);
            rectImage.Offset(-rectImage.Width, rectImage.Height);
            ImageProcessing.Translation(image, image.Width / 4, image.Height / 4);//将图像平移居中
            G.DrawImage(image, rectImage);
            rectImage.Offset(rectImage.Width, 0);
            //将图像围绕中心点逆时针旋转45度
            ImageProcessing.Rotation(image, 45, new Point(image.Width / 2, image.Height / 2));
            G.DrawImage(image, rectImage);
            image.Dispose();
        }
Example #30
0
        public override void Draw(Graphics g)
        {
            Rectangle rect = new Rectangle((int)Rectangle.X, (int)Rectangle.Y, (int)Rectangle.Width - 1, (int)Rectangle.Height - 1);

            switch (Shape)
            {
                case NodeShape.Square:
                    g.DrawRectangle(Pens.White, rect.Offset(-1));
                    g.DrawRectangle(Pens.Black, rect);
                    break;
                case NodeShape.Circle:
                    g.DrawEllipse(Pens.White, rect.Offset(-1));
                    g.DrawEllipse(Pens.Black, rect);
                    break;
                case NodeShape.Diamond:
                    g.DrawDiamond(Pens.White, rect.Offset(-1));
                    g.DrawDiamond(Pens.Black, rect);
                    break;
            }
        }